Skip to content

Commit

Permalink
feat: stickerPanel support QQGuild and refactor some code
Browse files Browse the repository at this point in the history
Signed-off-by: Hicores <me@hicore.cc>
  • Loading branch information
Hicores committed Jul 20, 2023
1 parent bcc95ba commit 3bb2300
Show file tree
Hide file tree
Showing 17 changed files with 144 additions and 331 deletions.
3 changes: 3 additions & 0 deletions app/src/main/java/cc/hicore/Utils/XLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class XLog {
public static void e(String TAG,Throwable msg){
Log.e("[QAuxv]"+"("+TAG+")"+Log.getStackTraceString(msg));
}
public static void e(String TAG,String TAG2,Throwable msg){
e(TAG+"."+TAG2,msg);
}
public static void e(String TAG,String msg){
Log.e("[QAuxv]"+"("+TAG+")"+msg);
}
Expand Down
23 changes: 0 additions & 23 deletions app/src/main/java/cc/hicore/hook/stickerPanel/EmoOnlineLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import java.util.concurrent.Executors;

public class EmoOnlineLoader {
static ExecutorService savePool = Executors.newFixedThreadPool(16);
static ExecutorService savePoolSingle = Executors.newSingleThreadExecutor();
public static ExecutorService syncThread = Executors.newFixedThreadPool(16);

public static void submit(EmoPanel.EmoInfo info, Runnable run) {
Expand All @@ -34,25 +32,4 @@ public static void submit(EmoPanel.EmoInfo info, Runnable run) {

});
}

public static void submit2(EmoPanel.EmoInfo info, Runnable run) {
savePool.submit(() -> {
try {
String CacheDir = Env.app_save_path+ "/Cache/img_" + info.MD5;
if (info.MD5.equals(DataUtils.getFileMD5(new File(CacheDir)))) {
info.Path = CacheDir;
new Handler(Looper.getMainLooper()).post(run);
return;
}
new File(CacheDir).delete();

HttpUtils.DownloadToFile(info.URL, CacheDir);
info.Path = CacheDir;
new Handler(Looper.getMainLooper()).post(run);
} catch (Throwable th) {
new Handler(Looper.getMainLooper()).post(run);
}

});
}
}
2 changes: 0 additions & 2 deletions app/src/main/java/cc/hicore/hook/stickerPanel/EmoPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
public class EmoPanel {
public static class EmoInfo {
public String Path;
public String OCR;
public int type;
public String MD5;
public String URL;
public String thumb;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package cc.hicore.hook.stickerPanel.Hooker;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import androidx.annotation.NonNull;
Expand Down Expand Up @@ -56,6 +57,7 @@
import io.github.qauxv.util.dexkit.ChatPanel_InitPanel_QQNT;
import io.github.qauxv.util.dexkit.DexKit;
import io.github.qauxv.util.dexkit.DexKitTarget;
import io.github.qauxv.util.dexkit.Guild_Emo_Btn_Create_QQNT;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
Expand All @@ -70,7 +72,8 @@ public class StickerPanelEntryHooker extends CommonSwitchFunctionHook implements
private StickerPanelEntryHooker() {
super(new DexKitTarget[]{
ChatPanel_InitPanel_QQNT.INSTANCE,
AbstractQQCustomMenuItem.INSTANCE
AbstractQQCustomMenuItem.INSTANCE,
Guild_Emo_Btn_Create_QQNT.INSTANCE
});
}

Expand Down Expand Up @@ -103,6 +106,19 @@ protected boolean initOnce() throws Exception {
}
});

HookUtils.hookAfterIfEnabled(this,DexKit.loadMethodFromCache(Guild_Emo_Btn_Create_QQNT.INSTANCE),param -> {
ViewGroup vg = (ViewGroup) param.getResult();
for (int i = 0; i < vg.getChildCount(); i++) {
View v = vg.getChildAt(i);
if (v instanceof ImageView) {
v.setOnLongClickListener(v1 -> {
ICreator.createPanel(v1.getContext());
return true;
});
}
}
});

HookUtils.hookAfterIfEnabled(this, MMethod.FindMethod(Initiator.loadClass("com.tencent.qqnt.aio.shortcutbar.PanelIconLinearLayout"),
null,
ImageView.class,
Expand Down
15 changes: 0 additions & 15 deletions app/src/main/java/cc/hicore/hook/stickerPanel/ICreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@
public class ICreator extends BottomPopupView implements AbsListView.OnScrollListener {
private static BasePopupView popupView;
MainPanelAdapter adapter = new MainPanelAdapter();
int IdOfShareGroup;
LinearLayout topSelectBar;
int myLovePos = 0;
int recentUsePos = 0;
int IdOfConvertFromTg;

int IdOfInputPic;
private final List<ViewGroup> newTabView = new ArrayList<>();
Expand Down Expand Up @@ -89,18 +86,6 @@ private void initStickerPacks() {
}

private void initDefItemsBefore() {
/*
ViewGroup likeTab = (ViewGroup) createPicImage(R.drawable.sticker_like,"收藏表情", v->{
listView.setSelection(myLovePos);
listView.smoothScrollToPositionFromTop(myLovePos,-5);
});
myLovePos = adapter.addItemData(new MyLoveStickerImpl());
likeTab.setTag(myLovePos);
topSelectBar.addView(likeTab);
*/


ViewGroup recentUse = (ViewGroup) createPicImage(R.drawable.sticker_recent, "最近使用", v -> {
listView.setSelection(recentUsePos);
listView.smoothScrollToPositionFromTop(recentUsePos, -5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ public static List<LocalPath> readPaths() {
localPath.Name = path.getString("Name");
localPath.storePath = path.getString("storePath");
paths.add(localPath);
} catch (Exception e) {

}
} catch (Exception ignored) { }
}
return paths;
} catch (Exception e) {
Expand Down Expand Up @@ -54,9 +52,7 @@ public synchronized static List<LocalPicItems> getPicItems(String pathName) {
localPath.thumbUrl = path.optString("thumbUrl");
localPath.ocr = path.optString("ocr");
items.add(localPath);
} catch (Exception e) {

}
} catch (Exception ignored) { }

}
return items;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
package cc.hicore.hook.stickerPanel.MainItemImpl;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.BitmapFactory;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import cc.hicore.Utils.ContextUtils;
import cc.hicore.Utils.DataUtils;
import cc.hicore.Utils.FileUtils;
import cc.hicore.Utils.RandomUtils;
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 com.lxj.xpopup.XPopup;
import com.lxj.xpopup.impl.LoadingPopupView;
import io.github.qauxv.R;
import io.github.qauxv.ui.CommonContextWrapper;
import io.github.qauxv.util.SyncUtils;
Expand All @@ -39,9 +41,8 @@ public View getView(ViewGroup parent) {
new AlertDialog.Builder(CommonContextWrapper.createAppCompatContext(parent.getContext()))
.setTitle("输入分组名称")
.setView(ed)
.setPositiveButton("确定导入", (dialog, which) -> {
inputWorker(parent.getContext(), path, ed.getText().toString());
}).setNeutralButton("取消", null)
.setPositiveButton("确定导入", (dialog, which) -> inputWorker(parent.getContext(), path, ed.getText().toString()))
.setNeutralButton("取消", null)
.show();
}

Expand All @@ -54,16 +55,18 @@ private static void inputWorker(Context context, String path, String name) {
FaultyDialog.show(context, "错误", "名称不能为空");
return;
}
ProgressDialog progressDialog = new ProgressDialog(CommonContextWrapper.createAppCompatContext(context));
progressDialog.setTitle("正在导入...");
progressDialog.setCancelable(false);
progressDialog.show();
LoadingPopupView progress = new XPopup.Builder(ContextUtils.getFixContext(CommonContextWrapper.createAppCompatContext(context)))
.dismissOnBackPressed(false)
.dismissOnTouchOutside(false)
.asLoading("正在导入...");

progress.show();

SyncUtils.async(() -> {
File[] f = new File(path).listFiles();
if (f == null) {
SyncUtils.runOnUiThread(() -> {
progressDialog.dismiss();
progress.dismiss();
FaultyDialog.show(context, "错误", "路径无效");
});
return;
Expand Down Expand Up @@ -101,30 +104,21 @@ private static void inputWorker(Context context, String path, String name) {
finish++;
int finalFinish = finish;
int finalAvailable = available;
SyncUtils.runOnUiThread(() -> {
progressDialog.setMessage("已完成" + finalFinish + "/" + size + "个文件,有效文件" + finalAvailable + "个");
});
SyncUtils.runOnUiThread(() -> progress.setTitle("已完成" + finalFinish + "/" + size + "个文件,有效文件" + finalAvailable + "个"));
}

List<LocalDataHelper.LocalPicItems> list = LocalDataHelper.getPicItems(ID);
if (list.size() > 0) {
LocalDataHelper.setPathCover(newPath, list.get(0));
}
SyncUtils.runOnUiThread(() -> {
progressDialog.dismiss();
progress.dismiss();
FaultyDialog.show(context, "导入完成", "导入完成");
ICreator.dismissAll();
});
});
}

private static boolean isImageFile(String filePath) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(filePath, options);
return options.outWidth != -1;
}

@Override
public void onViewDestroy(ViewGroup parent) {

Expand Down
Loading

0 comments on commit 3bb2300

Please sign in to comment.