Skip to content

Commit

Permalink
fix: optimize SaveToPanelDialog style
Browse files Browse the repository at this point in the history
  • Loading branch information
klxiaoniu committed Jul 8, 2023
1 parent c6a1751 commit 1330f16
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,18 @@
import cc.ioctl.util.HookUtils;
import cc.ioctl.util.Reflex;
import com.tencent.qqnt.kernel.nativeinterface.IKernelMsgService;
import com.tencent.qqnt.kernel.nativeinterface.IMsgOperateCallback;
import com.tencent.qqnt.kernel.nativeinterface.MsgElement;
import com.tencent.qqnt.kernel.nativeinterface.MsgRecord;
import com.tencent.qqnt.kernel.nativeinterface.PicElement;
import com.xiaoniu.util.ContextUtils;
import de.robv.android.xposed.XposedBridge;
import io.github.qauxv.R;
import io.github.qauxv.base.annotation.FunctionHookEntry;
import io.github.qauxv.base.annotation.UiItemAgentEntry;
import io.github.qauxv.bridge.AppRuntimeHelper;
import io.github.qauxv.bridge.ntapi.MsgServiceHelper;
import io.github.qauxv.dsl.FunctionEntryRouter;
import io.github.qauxv.hook.CommonSwitchFunctionHook;
import io.github.qauxv.ui.CommonContextWrapper;
import io.github.qauxv.util.CustomMenu;
import io.github.qauxv.util.Initiator;
import io.github.qauxv.util.SyncUtils;
Expand Down Expand Up @@ -170,9 +169,9 @@ protected boolean initOnce() throws Exception {
}
if (!md5s.isEmpty()){
if (md5s.size() > 1){
PanelUtils.PreSaveMultiPicList(urls,md5s, ContextUtils.getCurrentActivity());
PanelUtils.PreSaveMultiPicList(urls,md5s, CommonContextWrapper.createAppCompatContext(ContextUtils.getCurrentActivity()));
}else {
PanelUtils.PreSavePicToList(urls.get(0),md5s.get(0), ContextUtils.getCurrentActivity());
PanelUtils.PreSavePicToList(urls.get(0),md5s.get(0), CommonContextWrapper.createAppCompatContext(ContextUtils.getCurrentActivity()));
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/cc/hicore/hook/stickerPanel/ICreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import com.lxj.xpopup.util.XPopupUtils;
import io.github.qauxv.R;
import io.github.qauxv.lifecycle.Parasitics;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -114,7 +112,7 @@ private void initDefItemsBefore() {

private void initDefItemsLast() {

ViewGroup inputView = (ViewGroup) createPicImage(R.drawable.input, "导入图片", v -> {
ViewGroup inputView = (ViewGroup) createPicImage(R.drawable.input, "导入表情", v -> {
listView.setSelection(IdOfInputPic);
listView.smoothScrollToPositionFromTop(IdOfInputPic, -5);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ public View getView(ViewGroup parent) {
} else {
EditText ed = new EditText(parent.getContext());
new AlertDialog.Builder(CommonContextWrapper.createAppCompatContext(parent.getContext()))
.setTitle("输入表情包名称")
.setTitle("输入分组名称")
.setView(ed)
.setNegativeButton("确定导入", (dialog, which) -> {
.setPositiveButton("确定导入", (dialog, which) -> {
inputWorker(parent.getContext(), path, ed.getText().toString());
}).show();
}).setNeutralButton("取消", null)
.show();
}

});
Expand Down
25 changes: 11 additions & 14 deletions app/src/main/java/cc/hicore/hook/stickerPanel/PanelUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.widget.Button;
Expand All @@ -19,7 +17,6 @@
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 @@ -77,13 +74,13 @@ 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(CommonContextWrapper.createAppCompatContext(context))
.setTitle("创建新目录")
new AlertDialog.Builder(context)
.setTitle("创建分组")
.setView(edNew)
.setPositiveButton("确定创建", (dialog, which) -> {
String newName = edNew.getText().toString();
if (TextUtils.isEmpty(newName)) {
Toasts.info(v.getContext(),"名字不能为空");
Toasts.info(v.getContext(),"名称不能为空");
return;
}
LocalDataHelper.LocalPath path = new LocalDataHelper.LocalPath();
Expand All @@ -107,17 +104,19 @@ public static void PreSavePicToList(String URL, String MD5, Context context) {
group.addView(button);
}
})
.setNeutralButton("取消", null)
.show();

});

new AlertDialog.Builder(CommonContextWrapper.createAppCompatContext(context))
new AlertDialog.Builder(context)
.setTitle("选择保存分组")
.setView(mRoot)
.setPositiveButton("保存", (dialog, which) -> {
if (choicePath == null) {
Toasts.info(context,"没有选择任何的保存列表");
Toasts.info(context,"没有选择分组");
} else if (TextUtils.isEmpty(NewInfo.Path)) {
Toasts.info(context,"图片尚未加载完毕,保存失败");
Toasts.info(context,"图片尚未加载完毕保存失败");
} else {
FileUtils.copy(NewInfo.Path, Env.app_save_path + "本地表情包/" + choicePath.storePath + "/" + MD5);
LocalDataHelper.LocalPicItems item = new LocalDataHelper.LocalPicItems();
Expand All @@ -128,19 +127,17 @@ public static void PreSavePicToList(String URL, String MD5, Context context) {
LocalDataHelper.addPicItem(choicePath.storePath, item);


Toasts.info(context,"已保存到:" + Env.app_save_path + "本地表情包/" + choicePath.storePath + "/" + MD5);
Toasts.info(context,"已保存到" + Env.app_save_path + "本地表情包/" + choicePath.storePath + "/" + MD5);
}
}).setNeutralButton("取消", (dialog, which) -> {

})
}).setNeutralButton("取消", null)
.setOnDismissListener(dialog -> {
Glide.with(HostInfo.getApplication()).clear(preView);
}).show();
}

//如果要保存的是多张图片则弹出MD5选择,选择后才弹出确认图片保存框
public static void PreSaveMultiPicList(ArrayList<String> url, ArrayList<String> MD5, Context context) {
new AlertDialog.Builder(CommonContextWrapper.createAppCompatContext(context))
new AlertDialog.Builder(context)
.setTitle("选择需要保存的图片")
.setItems(MD5.toArray(new String[0]), (dialog, which) -> {
PreSavePicToList(url.get(which), MD5.get(which), context);
Expand Down
13 changes: 3 additions & 10 deletions app/src/main/res/layout/sticker_pre_save.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,15 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:background="@color/bg_plugin"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="是否保存如下图片"
android:textColor="@color/font_plugin"
android:gravity="center_horizontal"
android:textSize="20sp"/>

<ImageView
android:id="@+id/emo_pre_container"
android:layout_width="160dp"
android:layout_height="160dp"/>

<ScrollView
android:layout_width="160dp"
android:layout_height="200dp">
Expand All @@ -31,7 +25,6 @@
android:id="@+id/createNew"
android:layout_width="160dp"
android:layout_height="40dp"
android:text="新建项目"/>

android:text="创建分组"/>

</LinearLayout>

0 comments on commit 1330f16

Please sign in to comment.