Skip to content

Commit

Permalink
添加 长按发送卡片消息
Browse files Browse the repository at this point in the history
  • Loading branch information
Hicores committed May 7, 2022
1 parent 26d8aea commit cd9592f
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 12 deletions.
1 change: 1 addition & 0 deletions QTool/src/main/java/cc/hicore/Utils/HttpUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public static boolean DownloadToFile(String url, String local) {
while ((read = ins.read(buffer)) != -1) {
fOut.write(buffer, 0, read);
}
fOut.flush();
fOut.close();
ins.close();
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package cc.hicore.qtool.ChatHook.LongClickSendCard;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

import java.lang.reflect.Method;

import cc.hicore.HookItem;
import cc.hicore.ReflectUtils.MField;
import cc.hicore.ReflectUtils.XPBridge;
import cc.hicore.UIItem;
import cc.hicore.qtool.HookEnv;
import cc.hicore.qtool.QQMessage.QQMessageUtils;
import cc.hicore.qtool.QQMessage.QQMsgBuilder;
import cc.hicore.qtool.QQMessage.QQMsgSendUtils;
import cc.hicore.qtool.QQMessage.QQMsgSender;
import cc.hicore.qtool.QQMessage.QQSessionUtils;
import cc.hicore.qtool.XPWork.QQProxy.BaseChatPie;
import cc.hicore.qtool.XposedInit.ItemLoader.BaseHookItem;
import cc.hicore.qtool.XposedInit.ItemLoader.BaseUiItem;
import cc.hicore.qtool.XposedInit.ItemLoader.HookLoader;

@HookItem(isDelayInit = false,isRunInAllProc = false)
@UIItem(name = "长按发送卡片消息",groupName = "聊天辅助",targetID = 1,type = 1,id = "LongClickSendCard")
public class SendBtnHooker extends BaseHookItem implements BaseUiItem {
boolean IsEnable;
@Override
public boolean startHook() throws Throwable {
XPBridge.HookAfter(getMethod(),param -> {
if (IsEnable){
ViewGroup vg = MField.GetFirstField(param.thisObject,ViewGroup.class);
if (vg == null)return;
Context ctx = vg.getContext();
int fun_btn = ctx.getResources().getIdentifier("fun_btn", "id", ctx.getPackageName());
View sendBtn = vg.findViewById(fun_btn);
int ed_id = ctx.getResources().getIdentifier("input", "id", ctx.getPackageName());
EditText ed = vg.findViewById(ed_id);
sendBtn.setOnLongClickListener(v->{
String input = ed.getText().toString();
if (input.startsWith("{")){
QQMsgSender.sendArkApp(HookEnv.SessionInfo, QQMsgBuilder.build_arkapp(input));
ed.setText("");
return true;
}else if (input.startsWith("<")){
QQMsgSender.sendStruct(HookEnv.SessionInfo, QQMsgBuilder.build_struct(input));
ed.setText("");
return true;
}
return false;
});
}

});
return true;
}

@Override
public boolean isEnable() {
return IsEnable;
}

@Override
public boolean check() {
return getMethod() != null;
}

@Override
public void SwitchChange(boolean IsCheck) {
IsEnable = IsCheck;
if (IsCheck) HookLoader.CallHookStart(SendBtnHooker.class.getName());
}

@Override
public void ListItemClick(Context context) {

}
public Method getMethod(){
return BaseChatPie.getMethod();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import cc.hicore.qtool.QQMessage.QQMsgBuilder;
import cc.hicore.qtool.QQMessage.QQMsgSender;
import cc.hicore.qtool.R;
import de.robv.android.xposed.XposedBridge;


public class EmoPanelView extends BottomPopupView {
Expand Down Expand Up @@ -108,17 +109,12 @@ protected void onCreate() {
try {
String RootPath = HookEnv.ExtraDataPath + "Pic/" + Name + "/";
AtomicInteger mLock = new AtomicInteger();
for (EmoPanel.EmoInfo info : data) {
for (int i = data.size()-1;i>-1;i--){
EmoPanel.EmoInfo info = data.get(i);
HttpUtils.DownloadToFile(info.URL,RootPath + info.MD5);
new File(RootPath + info.MD5).setLastModified(System.currentTimeMillis());
mLock.getAndIncrement();
EmoOnlineLoader.submit2(info, () -> {
mLock.getAndDecrement();
new Handler(Looper.getMainLooper()).post(() -> mDialog.setMessage("正在保存图片[" + (data.size() - mLock.get()) + "/" + data.size() + "]"));
FileUtils.copy(info.Path, RootPath + info.MD5);
});
}
for (int iaa = 0; iaa < 60; iaa++) {
if (mLock.get() == 0) break;
Thread.sleep(1000);
new Handler(Looper.getMainLooper()).post(() -> mDialog.setMessage("正在保存图片[" + mLock.get()+ "/" + data.size() + "]"));
}
Utils.ShowToastL("保存完成");
} catch (Exception e) {
Expand All @@ -144,8 +140,7 @@ protected void onCreate() {
view.requestLayout();
titleBarList.add(view);

view.setOnClickListener(v -> {
CacheScrollTop = 0;
view.setOnClickListener(v -> { CacheScrollTop = 0;
updateShowPath(name);
for (View otherItem : titleBarList) {
otherItem.setBackgroundColor(getResources().getColor(R.color.bg_plugin, null));
Expand Down

0 comments on commit cd9592f

Please sign in to comment.