Skip to content

Commit

Permalink
chore: optimize Panel layout
Browse files Browse the repository at this point in the history
  • Loading branch information
klxiaoniu committed Jun 20, 2023
1 parent ea52f21 commit 9a5d564
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 60 deletions.
3 changes: 2 additions & 1 deletion app/src/main/java/cc/hicore/Utils/HttpUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.widget.TextView;
import cc.hicore.Env;
import de.robv.android.xposed.XposedBridge;
import io.github.qauxv.ui.CommonContextWrapper;
import io.github.qauxv.util.Toasts;
import java.io.File;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -133,7 +134,7 @@ public static String Post(String u,byte[] buffer){
}
}
public static void ProgressDownload(String url, String filepath, Runnable callback, Context context) {
AlertDialog al = new AlertDialog.Builder(context, 3).create();
AlertDialog al = new AlertDialog.Builder(CommonContextWrapper.createAppCompatContext(context)).create();
al.setTitle("下载中...");
LinearLayout layout = new LinearLayout(context);
layout.setOrientation(LinearLayout.VERTICAL);
Expand Down
9 changes: 4 additions & 5 deletions app/src/main/java/cc/hicore/hook/stickerPanel/ICreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.os.Handler;
import android.os.Looper;
import android.view.Gravity;
Expand Down Expand Up @@ -153,7 +152,7 @@ private View createPicImage(String imgPath, String title, OnClickListener clickL

TextView titleView = new TextView(getContext());
titleView.setText(title);
titleView.setTextColor(Color.BLACK);
titleView.setTextColor(0xff888888);
titleView.setGravity(Gravity.CENTER_HORIZONTAL);
titleView.setTextSize(10);
titleView.setSingleLine();
Expand All @@ -177,7 +176,7 @@ private View createPicImage(String imgPath, String title, OnClickListener clickL
panel.setLayoutParams(panel_param);

View greenTip = new View(getContext());
greenTip.setBackgroundColor(Color.GREEN);
greenTip.setBackgroundColor(0xff339933);
panel_param = new LinearLayout.LayoutParams(LayoutHelper.dip2px(getContext(), 30), 50);
panel_param.leftMargin = LayoutHelper.dip2px(getContext(), 5);
panel_param.rightMargin = LayoutHelper.dip2px(getContext(), 5);
Expand Down Expand Up @@ -211,7 +210,7 @@ private View createPicImage(int resID, String title, OnClickListener clickListen
TextView titleView = new TextView(getContext());
titleView.setText(title);
titleView.setGravity(Gravity.CENTER_HORIZONTAL);
titleView.setTextColor(Color.BLACK);
titleView.setTextColor(0xff888888);
titleView.setTextSize(10);
titleView.setSingleLine();
panel.addView(titleView);
Expand All @@ -224,7 +223,7 @@ private View createPicImage(int resID, String title, OnClickListener clickListen
panel.setLayoutParams(panel_param);

View greenTip = new View(getContext());
greenTip.setBackgroundColor(Color.GREEN);
greenTip.setBackgroundColor(0xff339933);
panel_param = new LinearLayout.LayoutParams(LayoutHelper.dip2px(getContext(), 30), 50);
panel_param.leftMargin = LayoutHelper.dip2px(getContext(), 5);
panel_param.rightMargin = LayoutHelper.dip2px(getContext(), 5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,63 +15,55 @@
import cc.hicore.hook.stickerPanel.ICreator;
import cc.hicore.hook.stickerPanel.LocalDataHelper;
import cc.hicore.hook.stickerPanel.MainPanelAdapter;
import cc.ioctl.util.ui.FaultyDialog;
import io.github.qauxv.R;
import io.github.qauxv.ui.CommonContextWrapper;
import io.github.qauxv.util.SyncUtils;
import java.io.File;
import java.util.List;

public class InputFromLocalImpl implements MainPanelAdapter.IMainPanelItem{
public class InputFromLocalImpl implements MainPanelAdapter.IMainPanelItem {

@Override
public View getView(ViewGroup parent) {
ViewGroup vgInput = (ViewGroup) View.inflate(parent.getContext(), R.layout.sticker_panel_impl_input_from_local, null);
EditText edPath = vgInput.findViewById(R.id.input_path);
Button btnPath = vgInput.findViewById(R.id.btn_confirm_input);
btnPath.setOnClickListener(v->{
btnPath.setOnClickListener(v -> {
String path = edPath.getText().toString();
File[] f = new File(path).listFiles();
if (f == null){
new AlertDialog.Builder(parent.getContext(),3)
.setTitle("错误")
.setMessage("路径无效")
.setPositiveButton("确定", null)
.show();
}else {
if (f == null) {
FaultyDialog.show(parent.getContext(), "错误", "路径无效");
} else {
EditText ed = new EditText(parent.getContext());
new AlertDialog.Builder(parent.getContext(),3)
.setTitle("输入显示的名字")
new AlertDialog.Builder(CommonContextWrapper.createAppCompatContext(parent.getContext()))
.setTitle("输入表情包名称")
.setView(ed)
.setNegativeButton("确定导入", (dialog, which) -> {
inputWorker(parent.getContext(), path,ed.getText().toString());
inputWorker(parent.getContext(), path, ed.getText().toString());
}).show();
}

});
return vgInput;
}
private static void inputWorker(Context context,String path,String name){
if (TextUtils.isEmpty(name)){
new AlertDialog.Builder(context,3)
.setTitle("错误")
.setMessage("名字不能为空")
.setPositiveButton("确定", null)
.show();

private static void inputWorker(Context context, String path, String name) {
if (TextUtils.isEmpty(name)) {
FaultyDialog.show(context, "错误", "名称不能为空");
return;
}
ProgressDialog progressDialog = new ProgressDialog(context,3);
ProgressDialog progressDialog = new ProgressDialog(CommonContextWrapper.createAppCompatContext(context));
progressDialog.setTitle("正在导入...");
progressDialog.setCancelable(false);
progressDialog.show();

SyncUtils.async(()->{
SyncUtils.async(() -> {
File[] f = new File(path).listFiles();
if (f == null){
SyncUtils.runOnUiThread(()->{
if (f == null) {
SyncUtils.runOnUiThread(() -> {
progressDialog.dismiss();
new AlertDialog.Builder(context,3)
.setTitle("错误")
.setMessage("路径无效")
.setPositiveButton("确定", null)
.show();
FaultyDialog.show(context, "错误", "路径无效");
});
return;
}
Expand All @@ -86,11 +78,11 @@ private static void inputWorker(Context context,String path,String name){
int finish = 0;
int available = 0;
for (File file : f) {
if (file.isFile()){
if (file.isFile()) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(file.getAbsolutePath(),options);
if (options.outWidth > 0 && options.outHeight > 0){
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
if (options.outWidth > 0 && options.outHeight > 0) {
LocalDataHelper.LocalPicItems localItem = new LocalDataHelper.LocalPicItems();
localItem.url = "";
localItem.type = 1;
Expand All @@ -99,37 +91,32 @@ private static void inputWorker(Context context,String path,String name){
localItem.fileName = localItem.MD5;
localItem.thumbUrl = "";

FileUtils.copy(file.getAbsolutePath(), LocalDataHelper.getLocalItemPath(newPath, localItem));

FileUtils.copy(file.getAbsolutePath(),LocalDataHelper.getLocalItemPath(newPath,localItem));

LocalDataHelper.addPicItem(ID,localItem);
LocalDataHelper.addPicItem(ID, localItem);
available++;
}
}
finish++;
int finalFinish = finish;
int finalAvailable = available;
SyncUtils.runOnUiThread(()->{
progressDialog.setMessage("已完成"+ finalFinish +"/"+size+"个文件,有效文件"+ finalAvailable +"个");
SyncUtils.runOnUiThread(() -> {
progressDialog.setMessage("已完成" + finalFinish + "/" + size + "个文件有效文件" + finalAvailable + "个");
});
}

List<LocalDataHelper.LocalPicItems> list = LocalDataHelper.getPicItems(ID);
if (list.size() > 0){
LocalDataHelper.setPathCover(newPath,list.get(0));
List<LocalDataHelper.LocalPicItems> list = LocalDataHelper.getPicItems(ID);
if (list.size() > 0) {
LocalDataHelper.setPathCover(newPath, list.get(0));
}
SyncUtils.runOnUiThread(()->{
SyncUtils.runOnUiThread(() -> {
progressDialog.dismiss();
new AlertDialog.Builder(context,3)
.setTitle("导入完成")
.setMessage("导入完成")
.setPositiveButton("确定", null)
.show();

FaultyDialog.show(context, "导入完成", "导入完成");
ICreator.dismissAll();
});
});
}

private static boolean isImageFile(String filePath) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import de.robv.android.xposed.XposedBridge;
import io.github.qauxv.R;
import io.github.qauxv.ui.CommonContextWrapper;
import io.github.qauxv.util.SyncUtils;
import io.github.qauxv.util.Toasts;
import java.io.File;
Expand Down Expand Up @@ -81,12 +82,12 @@ public LocalStickerImpl(LocalDataHelper.LocalPath pathInfo, List<LocalDataHelper
}

private void onSetButtonClick() {
new AlertDialog.Builder(mContext, 3)
new AlertDialog.Builder(CommonContextWrapper.createAppCompatContext(mContext))
.setTitle("选择你的操作").setItems(new String[]{
"删除该表情包", "表情包本地化"
}, (dialog, which) -> {
if (which == 0) {
new AlertDialog.Builder(mContext, 3)
new AlertDialog.Builder(CommonContextWrapper.createAppCompatContext(mContext))
.setTitle("提示")
.setMessage("是否删除该表情包(" + tv_title.getText() + "),该表情包内的本地表情将被删除并不可恢复")
.setNeutralButton("确定删除", (dialog1, which1) -> {
Expand All @@ -103,7 +104,7 @@ private void onSetButtonClick() {
}

private void updateAllResToLocal() {
ProgressDialog progressDialog = new ProgressDialog(mContext, 3);
ProgressDialog progressDialog = new ProgressDialog(CommonContextWrapper.createAppCompatContext(mContext));
progressDialog.setTitle("正在更新表情包");
progressDialog.setMessage("正在更新表情包,请稍等...");
progressDialog.setCancelable(false);
Expand Down Expand Up @@ -209,7 +210,7 @@ private View getItemContainer(Context context, String coverView, int count, Loca
} else {
Glide.with(HostInfo.getApplication()).load(coverView).fitCenter().diskCacheStrategy(DiskCacheStrategy.RESOURCE).override(LayoutHelper.getScreenWidth(v.getContext()) / 2, LayoutHelper.getScreenWidth(v.getContext()) / 2).into(preView);
}
new AlertDialog.Builder(mContext, 3)
new AlertDialog.Builder(CommonContextWrapper.createAppCompatContext(mContext))
.setTitle("选择你对该表情的操作")
.setView(preView)
.setOnDismissListener(dialog -> {
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/cc/hicore/hook/stickerPanel/PanelUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.bumptech.glide.Glide;
import io.github.qauxv.R;
import io.github.qauxv.lifecycle.Parasitics;
import io.github.qauxv.ui.CommonContextWrapper;
import io.github.qauxv.util.Toasts;
import java.io.File;
import java.util.ArrayList;
Expand Down Expand Up @@ -75,7 +76,7 @@ public static void PreSavePicToList(String URL, String MD5, Context context) {
Button btnCreate = mRoot.findViewById(R.id.createNew);
btnCreate.setOnClickListener(v -> {
EditText edNew = new EditText(context);
new AlertDialog.Builder(context, AlertDialog.THEME_HOLO_LIGHT)
new AlertDialog.Builder(CommonContextWrapper.createAppCompatContext(context))
.setTitle("创建新目录")
.setView(edNew)
.setNeutralButton("确定创建", (dialog, which) -> {
Expand Down Expand Up @@ -109,7 +110,7 @@ public static void PreSavePicToList(String URL, String MD5, Context context) {

});

new AlertDialog.Builder(context, AlertDialog.THEME_HOLO_LIGHT)
new AlertDialog.Builder(CommonContextWrapper.createAppCompatContext(context))
.setTitle("是否保存")
.setView(mRoot)
.setNeutralButton("保存", (dialog, which) -> {
Expand All @@ -136,7 +137,7 @@ public static void PreSavePicToList(String URL, String MD5, Context context) {

//如果要保存的是多张图片则弹出MD5选择,选择后才弹出确认图片保存框
public static void PreSaveMultiPicList(ArrayList<String> url, ArrayList<String> MD5, Context context) {
new AlertDialog.Builder(context, AlertDialog.THEME_HOLO_LIGHT)
new AlertDialog.Builder(CommonContextWrapper.createAppCompatContext(context))
.setTitle("选择需要保存的图片")
.setItems(MD5.toArray(new String[0]), (dialog, which) -> {
PreSavePicToList(url.get(which), MD5.get(which), context);
Expand Down
Binary file modified app/src/main/res/drawable/input.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion app/src/main/res/layout/sticker_panel_plus_main.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/bg_plugin"
android:theme="@style/AppTheme.Def"
android:layout_width="match_parent"
android:layout_height="match_parent">
<HorizontalScrollView
Expand All @@ -15,7 +16,7 @@
android:orientation="horizontal" />
</HorizontalScrollView>
<ListView
android:background="#22000000"
android:background="#11000000"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/Sticker_Pack_Select_Bar_Container"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
<color name="defaultThemeBackgroundColor">#FF303030</color>
<color name="defaultThemeBackgroundColorAlpha80">#CC303030</color>

<color name="bg_plugin">#FF3C3C3C</color>
</resources>

0 comments on commit 9a5d564

Please sign in to comment.