From cdd861fbc138d859bed65202373c5ce11f656473 Mon Sep 17 00:00:00 2001 From: suzhelan Date: Fri, 24 Nov 2023 20:53:34 +0800 Subject: [PATCH 1/5] add: Turn off friend interaction logo --- .../hook/OffRelationshipIdentification.java | 6 ++ .../TurnOffFriendInteractionLogoView.java | 66 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 app/src/main/java/top/linl/hook/TurnOffFriendInteractionLogoView.java diff --git a/app/src/main/java/top/linl/hook/OffRelationshipIdentification.java b/app/src/main/java/top/linl/hook/OffRelationshipIdentification.java index 48b798fb6c..fcb133d730 100644 --- a/app/src/main/java/top/linl/hook/OffRelationshipIdentification.java +++ b/app/src/main/java/top/linl/hook/OffRelationshipIdentification.java @@ -52,12 +52,18 @@ protected boolean initOnce() throws Exception { } + /** + * @return item 位置 + */ @NonNull @Override public String[] getUiItemLocation() { return FunctionEntryRouter.Locations.Simplify.UI_PROFILE; } + /** + * @return item name + */ @NonNull @Override public String getName() { diff --git a/app/src/main/java/top/linl/hook/TurnOffFriendInteractionLogoView.java b/app/src/main/java/top/linl/hook/TurnOffFriendInteractionLogoView.java new file mode 100644 index 0000000000..35660514a5 --- /dev/null +++ b/app/src/main/java/top/linl/hook/TurnOffFriendInteractionLogoView.java @@ -0,0 +1,66 @@ +/* + * QAuxiliary - An Xposed module for QQ/TIM + * Copyright (C) 2019-2023 QAuxiliary developers + * https://github.com/cinit/QAuxiliary + * + * This software is non-free but opensource software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation; either + * version 3 of the License, or any later version and our eula as published + * by QAuxiliary contributors. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * and eula along with this software. If not, see + * + * . + */ + +package top.linl.hook; + +import androidx.annotation.NonNull; +import cc.ioctl.util.HookUtils; +import io.github.qauxv.base.annotation.FunctionHookEntry; +import io.github.qauxv.base.annotation.UiItemAgentEntry; +import io.github.qauxv.dsl.FunctionEntryRouter; +import io.github.qauxv.hook.CommonSwitchFunctionHook; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import top.linl.util.FieIdUtils; +import top.linl.util.MethodTool; + +@FunctionHookEntry +@UiItemAgentEntry +public class TurnOffFriendInteractionLogoView extends CommonSwitchFunctionHook { + + public static final TurnOffFriendInteractionLogoView INSTANCE = new TurnOffFriendInteractionLogoView(); + + @NonNull + @Override + public String[] getUiItemLocation() { + return FunctionEntryRouter.Locations.Simplify.UI_PROFILE; + } + + @Override + protected boolean initOnce() throws Exception { + Method initViewMethod = MethodTool.find("com.tencent.mobileqq.profilecard.component.ProfileIntimateComponent") + .name("initComponentViewContainer") + .returnType(void.class) + .get(); + HookUtils.hookBeforeIfEnabled(this, initViewMethod, param -> { + Field mViewContainerField = FieIdUtils.findUnknownTypeField(param.thisObject.getClass(), "mViewContainer"); + mViewContainerField.set(param.thisObject, 1); + }); + return true; + } + + @NonNull + @Override + public String getName() { + return "关闭好友互动标识"; + } +} From 8dd6320e9ee3a4723a5d228074872e00832b2c68 Mon Sep 17 00:00:00 2001 From: suzhelan Date: Fri, 24 Nov 2023 21:42:24 +0800 Subject: [PATCH 2/5] add: Turn off friend interaction logo --- .../java/top/linl/hook/TurnOffFriendInteractionLogoView.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/top/linl/hook/TurnOffFriendInteractionLogoView.java b/app/src/main/java/top/linl/hook/TurnOffFriendInteractionLogoView.java index 35660514a5..5a59a6b28f 100644 --- a/app/src/main/java/top/linl/hook/TurnOffFriendInteractionLogoView.java +++ b/app/src/main/java/top/linl/hook/TurnOffFriendInteractionLogoView.java @@ -54,6 +54,7 @@ protected boolean initOnce() throws Exception { HookUtils.hookBeforeIfEnabled(this, initViewMethod, param -> { Field mViewContainerField = FieIdUtils.findUnknownTypeField(param.thisObject.getClass(), "mViewContainer"); mViewContainerField.set(param.thisObject, 1); + param.setResult(null); }); return true; } From 953419e50050bd16765bf8c0c6e5e128d4b49e9a Mon Sep 17 00:00:00 2001 From: suzhelan Date: Sat, 2 Dec 2023 06:53:48 +0800 Subject: [PATCH 3/5] add : sort troop setting view GroupAppInfoListView(GroupFileView) to top --- .../github/qauxv/dsl/FunctionEntryRouter.kt | 10 +- .../hook/OffRelationshipIdentification.java | 4 +- .../hook/SortTroopSettingAppListView.java | 119 ++++++++++++++++++ .../TurnOffFriendInteractionLogoView.java | 4 +- .../java/top/linl/util/ReflectException.java | 27 ---- .../java/top/linl/util/ScreenParamUtils.java | 117 +++++++++++++++++ .../util/{ => reflect}/CheckClassType.java | 24 +++- .../linl/util/{ => reflect}/FieIdUtils.java | 24 +++- .../linl/util/{ => reflect}/MethodTool.java | 24 +++- .../linl/util/reflect/ReflectException.java | 49 ++++++++ 10 files changed, 367 insertions(+), 35 deletions(-) create mode 100644 app/src/main/java/top/linl/hook/SortTroopSettingAppListView.java delete mode 100644 app/src/main/java/top/linl/util/ReflectException.java create mode 100644 app/src/main/java/top/linl/util/ScreenParamUtils.java rename app/src/main/java/top/linl/util/{ => reflect}/CheckClassType.java (57%) rename app/src/main/java/top/linl/util/{ => reflect}/FieIdUtils.java (89%) rename app/src/main/java/top/linl/util/{ => reflect}/MethodTool.java (82%) create mode 100644 app/src/main/java/top/linl/util/reflect/ReflectException.java diff --git a/app/src/main/java/io/github/qauxv/dsl/FunctionEntryRouter.kt b/app/src/main/java/io/github/qauxv/dsl/FunctionEntryRouter.kt index ee23d6d5dd..a5c0b3d5a1 100644 --- a/app/src/main/java/io/github/qauxv/dsl/FunctionEntryRouter.kt +++ b/app/src/main/java/io/github/qauxv/dsl/FunctionEntryRouter.kt @@ -23,7 +23,11 @@ package io.github.qauxv.dsl import io.github.qauxv.base.IUiItemAgentProvider -import io.github.qauxv.dsl.func.* +import io.github.qauxv.dsl.func.FragmentDescription +import io.github.qauxv.dsl.func.IDslItemNode +import io.github.qauxv.dsl.func.IDslParentNode +import io.github.qauxv.dsl.func.RootFragmentDescription +import io.github.qauxv.dsl.func.UiItemAgentDescription import io.github.qauxv.fragment.AboutFragment import io.github.qauxv.fragment.BackupRestoreConfigFragment import io.github.qauxv.fragment.PendingFunctionFragment @@ -120,6 +124,7 @@ object FunctionEntryRouter { category("auxiliary-friend", "好友") category("auxiliary-profile", "资料卡") } + fragment("auxiliary-group", "群聊") fragment("auxiliary-notification", "通知设置") fragment("auxiliary-experimental", "实验性功能") fragment("entertainment-function", "娱乐功能") @@ -253,6 +258,9 @@ object FunctionEntryRouter { @JvmField val FRIEND_CATEGORY: Array = arrayOf(ANY_CAST_PREFIX, "auxiliary-friend") + @JvmField + val GROUP_CATEGORY: Array = arrayOf(ANY_CAST_PREFIX, "auxiliary-group") + @JvmField val PROFILE_CATEGORY: Array = arrayOf(ANY_CAST_PREFIX, "auxiliary-profile") diff --git a/app/src/main/java/top/linl/hook/OffRelationshipIdentification.java b/app/src/main/java/top/linl/hook/OffRelationshipIdentification.java index fcb133d730..550e3e8ba5 100644 --- a/app/src/main/java/top/linl/hook/OffRelationshipIdentification.java +++ b/app/src/main/java/top/linl/hook/OffRelationshipIdentification.java @@ -11,8 +11,8 @@ import io.github.qauxv.hook.CommonSwitchFunctionHook; import io.github.qauxv.util.Initiator; import java.lang.reflect.Method; -import top.linl.util.FieIdUtils; -import top.linl.util.MethodTool; +import top.linl.util.reflect.FieIdUtils; +import top.linl.util.reflect.MethodTool; @FunctionHookEntry diff --git a/app/src/main/java/top/linl/hook/SortTroopSettingAppListView.java b/app/src/main/java/top/linl/hook/SortTroopSettingAppListView.java new file mode 100644 index 0000000000..aa9f9f7d1e --- /dev/null +++ b/app/src/main/java/top/linl/hook/SortTroopSettingAppListView.java @@ -0,0 +1,119 @@ +/* + * QAuxiliary - An Xposed module for QQ/TIM + * Copyright (C) 2019-2023 QAuxiliary developers + * https://github.com/cinit/QAuxiliary + * + * This software is non-free but opensource software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation; either + * version 3 of the License, or any later version and our eula as published + * by QAuxiliary contributors. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * and eula along with this software. If not, see + * + * . + */ + +package top.linl.hook; + +import android.os.Bundle; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import cc.ioctl.util.HookUtils; +import de.robv.android.xposed.XC_MethodHook; +import io.github.qauxv.base.annotation.FunctionHookEntry; +import io.github.qauxv.base.annotation.UiItemAgentEntry; +import io.github.qauxv.dsl.FunctionEntryRouter; +import io.github.qauxv.hook.CommonSwitchFunctionHook; +import java.lang.reflect.Method; +import top.linl.util.ScreenParamUtils; +import top.linl.util.reflect.FieIdUtils; +import top.linl.util.reflect.MethodTool; + +@FunctionHookEntry +@UiItemAgentEntry +public class SortTroopSettingAppListView extends CommonSwitchFunctionHook { + + public static final SortTroopSettingAppListView INSTANCE = new SortTroopSettingAppListView(); + + @NonNull + @Override + public String[] getUiItemLocation() { + return FunctionEntryRouter.Locations.Auxiliary.GROUP_CATEGORY; + } + + @Nullable + @Override + public CharSequence getDescription() { + return "让群设置的群文件在上面而不是在下面"; + } + + @Override + protected boolean initOnce() throws Exception { + Method doOnCreateMethod = MethodTool.find("com.tencent.mobileqq.troop.troopsetting.activity.TroopSettingActivity") + .returnType(boolean.class) + .params(Bundle.class) + .name("doOnCreate") + .get(); + HookUtils.hookAfterIfEnabled(this, doOnCreateMethod, new HookUtils.AfterHookedMethod() { + @Override + public void afterHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable { + LinearLayout rootView = FieIdUtils.getFirstField(param.thisObject, LinearLayout.class); + int troopInfoTextIndex = 0; + View troopAppListView = null; +// View[] views = FieIdUtils.getFirstField(param.thisObject, View[].class);//过于复杂 不如不用 + + for (int i = 0; i < rootView.getChildCount(); i++) { + View child = rootView.getChildAt(i); + if (child instanceof TextView) { + TextView textView = (TextView) child; + String text = textView.getText().toString(); + if (text.equals("群聊信息")) { + troopInfoTextIndex = i; + } + } + if (child instanceof LinearLayout) { + LinearLayout simpleFormItem = (LinearLayout) child; + if (simpleFormItem.getChildAt(0) instanceof RelativeLayout) { + RelativeLayout itemTitle = (RelativeLayout) simpleFormItem.getChildAt(0); + if (itemTitle.getChildAt(0) instanceof TextView) { + TextView titleTextView = (TextView) itemTitle.getChildAt(0); + String titleText = titleTextView.getText().toString(); + if (titleText.equals("群应用")) { + troopAppListView = child; + break; + } + } + } + } + } + if (troopAppListView != null && troopInfoTextIndex != 0) { + rootView.removeView(troopAppListView); + //顶部偏移 不然会和群聊成员卡片贴一起 (贴贴 + LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT); + layoutParams.topMargin += ScreenParamUtils.dpToPx(rootView.getContext(), 16); + rootView.addView(troopAppListView, troopInfoTextIndex, layoutParams); + } + } + }); + return true; + } + + @NonNull + @Override + public String getName() { + return "将群应用卡片(群文件)移动到正常位置"; + } +} diff --git a/app/src/main/java/top/linl/hook/TurnOffFriendInteractionLogoView.java b/app/src/main/java/top/linl/hook/TurnOffFriendInteractionLogoView.java index 5a59a6b28f..ba53ee0ece 100644 --- a/app/src/main/java/top/linl/hook/TurnOffFriendInteractionLogoView.java +++ b/app/src/main/java/top/linl/hook/TurnOffFriendInteractionLogoView.java @@ -30,8 +30,8 @@ import io.github.qauxv.hook.CommonSwitchFunctionHook; import java.lang.reflect.Field; import java.lang.reflect.Method; -import top.linl.util.FieIdUtils; -import top.linl.util.MethodTool; +import top.linl.util.reflect.FieIdUtils; +import top.linl.util.reflect.MethodTool; @FunctionHookEntry @UiItemAgentEntry diff --git a/app/src/main/java/top/linl/util/ReflectException.java b/app/src/main/java/top/linl/util/ReflectException.java deleted file mode 100644 index 9771a1ebe2..0000000000 --- a/app/src/main/java/top/linl/util/ReflectException.java +++ /dev/null @@ -1,27 +0,0 @@ -package top.linl.util; - -public class ReflectException extends RuntimeException { - - private Exception otherExceptions; - - public ReflectException() { - super(); - } - - public ReflectException(String content) { - super(content); - } - - public ReflectException(String content, Exception e) { - super(content); - this.otherExceptions = e; - } - - public boolean hasOtherExceptions() { - return otherExceptions != null; - } - - public Exception getOtherExceptions() { - return this.otherExceptions; - } -} diff --git a/app/src/main/java/top/linl/util/ScreenParamUtils.java b/app/src/main/java/top/linl/util/ScreenParamUtils.java new file mode 100644 index 0000000000..6fca7de341 --- /dev/null +++ b/app/src/main/java/top/linl/util/ScreenParamUtils.java @@ -0,0 +1,117 @@ +package top.linl.util; + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Color; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; + +public class ScreenParamUtils { + + + /** + * sp转px + */ + public static int spToPx(Context context, float spValue) { + final float fontScale = context.getResources().getDisplayMetrics().scaledDensity; + return (int) (spValue * fontScale + 0.5f); + } + + /** + * 获取手机像素宽度 + * + * @return 宽度px + */ + public static int getScreenWidth(Context context) { + return context.getResources().getDisplayMetrics().widthPixels; + } + + /** + * 获取手机像素高度(不包含虚拟导航栏和状态栏) + * + * @return 高度px + */ + public static int getScreenHeight(Context context) { + return context.getResources().getDisplayMetrics().heightPixels; + } + + + /** + * 获取导航栏高度 + * + * @return px + */ + public static int getNavigationBarHeight(Context context) { + int navigationBarHeight = -1; + Resources resources = context.getResources(); + @SuppressLint({"DiscouragedApi", "InternalInsetResource"}) int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); + if (resourceId > 0) { + navigationBarHeight = resources.getDimensionPixelSize(resourceId); + } + return navigationBarHeight; + } + + /** + * 获取状态栏高度 + * + * @return px + */ + public static int getStatusBarHeight(Context context) { + int height = 0; + @SuppressLint({"InternalInsetResource", "DiscouragedApi"}) + int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); + if (resourceId > 0) { + height = context.getResources().getDimensionPixelSize(resourceId); + } + return height; + } + + /** + * 根据手机的分辨率从 dp(相对大小) 的单位 转成为 px(像素) + */ + public static int dpToPx(Context context, float dpValue) { + // 获取屏幕密度 + final float scale = context.getResources().getDisplayMetrics().density; + // 结果+0.5是为了int取整时更接近 + return (int) (dpValue * scale + 0.5f); + } + + + /** + * 根据手机的分辨率从 px(像素) 的单位 转成为 dp(相对大小) + */ + public static int pxToDp(Context context, float pxValue) { + final float scale = context.getResources().getDisplayMetrics().density; + return (int) (pxValue / scale + 0.5f); + } + + /** + * px转sp + */ + public static int pxToSp(Context context, float pxValue) { + final float fontScale = context.getResources().getDisplayMetrics().scaledDensity; + return (int) (pxValue / fontScale + 0.5f); + } + + /** + * 将当前活动设置为透明的状态栏 + * + * @param activity 当前Activity + */ + protected void requestTranslucentStatusBar(Activity activity) { + Window window = activity.getWindow(); + window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS + | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); + window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); + window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + window.setStatusBarColor(Color.TRANSPARENT); + window.setNavigationBarColor(Color.TRANSPARENT); + } + + +} diff --git a/app/src/main/java/top/linl/util/CheckClassType.java b/app/src/main/java/top/linl/util/reflect/CheckClassType.java similarity index 57% rename from app/src/main/java/top/linl/util/CheckClassType.java rename to app/src/main/java/top/linl/util/reflect/CheckClassType.java index 5e2e4c4254..bf8ad76c36 100644 --- a/app/src/main/java/top/linl/util/CheckClassType.java +++ b/app/src/main/java/top/linl/util/reflect/CheckClassType.java @@ -1,4 +1,26 @@ -package top.linl.util; +/* + * QAuxiliary - An Xposed module for QQ/TIM + * Copyright (C) 2019-2023 QAuxiliary developers + * https://github.com/cinit/QAuxiliary + * + * This software is non-free but opensource software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation; either + * version 3 of the License, or any later version and our eula as published + * by QAuxiliary contributors. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * and eula along with this software. If not, see + * + * . + */ + +package top.linl.util.reflect; public class CheckClassType { diff --git a/app/src/main/java/top/linl/util/FieIdUtils.java b/app/src/main/java/top/linl/util/reflect/FieIdUtils.java similarity index 89% rename from app/src/main/java/top/linl/util/FieIdUtils.java rename to app/src/main/java/top/linl/util/reflect/FieIdUtils.java index c445a84907..3e5ab8d152 100644 --- a/app/src/main/java/top/linl/util/FieIdUtils.java +++ b/app/src/main/java/top/linl/util/reflect/FieIdUtils.java @@ -1,4 +1,26 @@ -package top.linl.util; +/* + * QAuxiliary - An Xposed module for QQ/TIM + * Copyright (C) 2019-2023 QAuxiliary developers + * https://github.com/cinit/QAuxiliary + * + * This software is non-free but opensource software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation; either + * version 3 of the License, or any later version and our eula as published + * by QAuxiliary contributors. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * and eula along with this software. If not, see + * + * . + */ + +package top.linl.util.reflect; import java.lang.reflect.Field; diff --git a/app/src/main/java/top/linl/util/MethodTool.java b/app/src/main/java/top/linl/util/reflect/MethodTool.java similarity index 82% rename from app/src/main/java/top/linl/util/MethodTool.java rename to app/src/main/java/top/linl/util/reflect/MethodTool.java index f11f098c82..5a1a1f6604 100644 --- a/app/src/main/java/top/linl/util/MethodTool.java +++ b/app/src/main/java/top/linl/util/reflect/MethodTool.java @@ -1,4 +1,26 @@ -package top.linl.util; +/* + * QAuxiliary - An Xposed module for QQ/TIM + * Copyright (C) 2019-2023 QAuxiliary developers + * https://github.com/cinit/QAuxiliary + * + * This software is non-free but opensource software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation; either + * version 3 of the License, or any later version and our eula as published + * by QAuxiliary contributors. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * and eula along with this software. If not, see + * + * . + */ + +package top.linl.util.reflect; import io.github.qauxv.util.Initiator; import java.lang.reflect.Method; diff --git a/app/src/main/java/top/linl/util/reflect/ReflectException.java b/app/src/main/java/top/linl/util/reflect/ReflectException.java new file mode 100644 index 0000000000..141ecbb0d3 --- /dev/null +++ b/app/src/main/java/top/linl/util/reflect/ReflectException.java @@ -0,0 +1,49 @@ +/* + * QAuxiliary - An Xposed module for QQ/TIM + * Copyright (C) 2019-2023 QAuxiliary developers + * https://github.com/cinit/QAuxiliary + * + * This software is non-free but opensource software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation; either + * version 3 of the License, or any later version and our eula as published + * by QAuxiliary contributors. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * and eula along with this software. If not, see + * + * . + */ + +package top.linl.util.reflect; + +public class ReflectException extends RuntimeException { + + private Exception otherExceptions; + + public ReflectException() { + super(); + } + + public ReflectException(String content) { + super(content); + } + + public ReflectException(String content, Exception e) { + super(content); + this.otherExceptions = e; + } + + public boolean hasOtherExceptions() { + return otherExceptions != null; + } + + public Exception getOtherExceptions() { + return this.otherExceptions; + } +} From a9cbdc28e8443385bbb6a2cdd69f1b1dc12e73a9 Mon Sep 17 00:00:00 2001 From: suzhelan Date: Sat, 2 Dec 2023 07:12:25 +0800 Subject: [PATCH 4/5] add : sort troop setting view GroupAppInfoListView(GroupFileView) to top Signed-off-by: suzhelan --- .../main/java/top/linl/hook/SortTroopSettingAppListView.java | 2 -- libs/LSPlant | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/src/main/java/top/linl/hook/SortTroopSettingAppListView.java b/app/src/main/java/top/linl/hook/SortTroopSettingAppListView.java index aa9f9f7d1e..721a45f54f 100644 --- a/app/src/main/java/top/linl/hook/SortTroopSettingAppListView.java +++ b/app/src/main/java/top/linl/hook/SortTroopSettingAppListView.java @@ -72,8 +72,6 @@ public void afterHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwa LinearLayout rootView = FieIdUtils.getFirstField(param.thisObject, LinearLayout.class); int troopInfoTextIndex = 0; View troopAppListView = null; -// View[] views = FieIdUtils.getFirstField(param.thisObject, View[].class);//过于复杂 不如不用 - for (int i = 0; i < rootView.getChildCount(); i++) { View child = rootView.getChildAt(i); if (child instanceof TextView) { diff --git a/libs/LSPlant b/libs/LSPlant index 9c33903c87..7854f34f75 160000 --- a/libs/LSPlant +++ b/libs/LSPlant @@ -1 +1 @@ -Subproject commit 9c33903c87a240ae38dbf7fdf49c0748addd073d +Subproject commit 7854f34f75c4dbf1fde62674aa3ba7c5cf40072c From 41599b84f5f21f1170b32515134aaba35638c452 Mon Sep 17 00:00:00 2001 From: suzhelan Date: Sat, 2 Dec 2023 08:18:26 +0800 Subject: [PATCH 5/5] Revert "add : sort troop setting view GroupAppInfoListView(GroupFileView) to top" This reverts commit 953419e5 Signed-off-by: suzhelan --- .../github/qauxv/dsl/FunctionEntryRouter.kt | 4 - .../hook/OffRelationshipIdentification.java | 4 +- .../hook/SortTroopSettingAppListView.java | 117 ------------------ .../TurnOffFriendInteractionLogoView.java | 4 +- .../util/{reflect => }/CheckClassType.java | 24 +--- .../linl/util/{reflect => }/FieIdUtils.java | 24 +--- .../linl/util/{reflect => }/MethodTool.java | 24 +--- .../java/top/linl/util/ReflectException.java | 27 ++++ .../java/top/linl/util/ScreenParamUtils.java | 117 ------------------ .../linl/util/reflect/ReflectException.java | 49 -------- 10 files changed, 34 insertions(+), 360 deletions(-) delete mode 100644 app/src/main/java/top/linl/hook/SortTroopSettingAppListView.java rename app/src/main/java/top/linl/util/{reflect => }/CheckClassType.java (57%) rename app/src/main/java/top/linl/util/{reflect => }/FieIdUtils.java (89%) rename app/src/main/java/top/linl/util/{reflect => }/MethodTool.java (82%) create mode 100644 app/src/main/java/top/linl/util/ReflectException.java delete mode 100644 app/src/main/java/top/linl/util/ScreenParamUtils.java delete mode 100644 app/src/main/java/top/linl/util/reflect/ReflectException.java diff --git a/app/src/main/java/io/github/qauxv/dsl/FunctionEntryRouter.kt b/app/src/main/java/io/github/qauxv/dsl/FunctionEntryRouter.kt index a5c0b3d5a1..4fe99c1ad1 100644 --- a/app/src/main/java/io/github/qauxv/dsl/FunctionEntryRouter.kt +++ b/app/src/main/java/io/github/qauxv/dsl/FunctionEntryRouter.kt @@ -124,7 +124,6 @@ object FunctionEntryRouter { category("auxiliary-friend", "好友") category("auxiliary-profile", "资料卡") } - fragment("auxiliary-group", "群聊") fragment("auxiliary-notification", "通知设置") fragment("auxiliary-experimental", "实验性功能") fragment("entertainment-function", "娱乐功能") @@ -258,9 +257,6 @@ object FunctionEntryRouter { @JvmField val FRIEND_CATEGORY: Array = arrayOf(ANY_CAST_PREFIX, "auxiliary-friend") - @JvmField - val GROUP_CATEGORY: Array = arrayOf(ANY_CAST_PREFIX, "auxiliary-group") - @JvmField val PROFILE_CATEGORY: Array = arrayOf(ANY_CAST_PREFIX, "auxiliary-profile") diff --git a/app/src/main/java/top/linl/hook/OffRelationshipIdentification.java b/app/src/main/java/top/linl/hook/OffRelationshipIdentification.java index 550e3e8ba5..fcb133d730 100644 --- a/app/src/main/java/top/linl/hook/OffRelationshipIdentification.java +++ b/app/src/main/java/top/linl/hook/OffRelationshipIdentification.java @@ -11,8 +11,8 @@ import io.github.qauxv.hook.CommonSwitchFunctionHook; import io.github.qauxv.util.Initiator; import java.lang.reflect.Method; -import top.linl.util.reflect.FieIdUtils; -import top.linl.util.reflect.MethodTool; +import top.linl.util.FieIdUtils; +import top.linl.util.MethodTool; @FunctionHookEntry diff --git a/app/src/main/java/top/linl/hook/SortTroopSettingAppListView.java b/app/src/main/java/top/linl/hook/SortTroopSettingAppListView.java deleted file mode 100644 index 721a45f54f..0000000000 --- a/app/src/main/java/top/linl/hook/SortTroopSettingAppListView.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * QAuxiliary - An Xposed module for QQ/TIM - * Copyright (C) 2019-2023 QAuxiliary developers - * https://github.com/cinit/QAuxiliary - * - * This software is non-free but opensource software: you can redistribute it - * and/or modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation; either - * version 3 of the License, or any later version and our eula as published - * by QAuxiliary contributors. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * and eula along with this software. If not, see - * - * . - */ - -package top.linl.hook; - -import android.os.Bundle; -import android.view.View; -import android.view.ViewGroup; -import android.widget.LinearLayout; -import android.widget.RelativeLayout; -import android.widget.TextView; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import cc.ioctl.util.HookUtils; -import de.robv.android.xposed.XC_MethodHook; -import io.github.qauxv.base.annotation.FunctionHookEntry; -import io.github.qauxv.base.annotation.UiItemAgentEntry; -import io.github.qauxv.dsl.FunctionEntryRouter; -import io.github.qauxv.hook.CommonSwitchFunctionHook; -import java.lang.reflect.Method; -import top.linl.util.ScreenParamUtils; -import top.linl.util.reflect.FieIdUtils; -import top.linl.util.reflect.MethodTool; - -@FunctionHookEntry -@UiItemAgentEntry -public class SortTroopSettingAppListView extends CommonSwitchFunctionHook { - - public static final SortTroopSettingAppListView INSTANCE = new SortTroopSettingAppListView(); - - @NonNull - @Override - public String[] getUiItemLocation() { - return FunctionEntryRouter.Locations.Auxiliary.GROUP_CATEGORY; - } - - @Nullable - @Override - public CharSequence getDescription() { - return "让群设置的群文件在上面而不是在下面"; - } - - @Override - protected boolean initOnce() throws Exception { - Method doOnCreateMethod = MethodTool.find("com.tencent.mobileqq.troop.troopsetting.activity.TroopSettingActivity") - .returnType(boolean.class) - .params(Bundle.class) - .name("doOnCreate") - .get(); - HookUtils.hookAfterIfEnabled(this, doOnCreateMethod, new HookUtils.AfterHookedMethod() { - @Override - public void afterHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable { - LinearLayout rootView = FieIdUtils.getFirstField(param.thisObject, LinearLayout.class); - int troopInfoTextIndex = 0; - View troopAppListView = null; - for (int i = 0; i < rootView.getChildCount(); i++) { - View child = rootView.getChildAt(i); - if (child instanceof TextView) { - TextView textView = (TextView) child; - String text = textView.getText().toString(); - if (text.equals("群聊信息")) { - troopInfoTextIndex = i; - } - } - if (child instanceof LinearLayout) { - LinearLayout simpleFormItem = (LinearLayout) child; - if (simpleFormItem.getChildAt(0) instanceof RelativeLayout) { - RelativeLayout itemTitle = (RelativeLayout) simpleFormItem.getChildAt(0); - if (itemTitle.getChildAt(0) instanceof TextView) { - TextView titleTextView = (TextView) itemTitle.getChildAt(0); - String titleText = titleTextView.getText().toString(); - if (titleText.equals("群应用")) { - troopAppListView = child; - break; - } - } - } - } - } - if (troopAppListView != null && troopInfoTextIndex != 0) { - rootView.removeView(troopAppListView); - //顶部偏移 不然会和群聊成员卡片贴一起 (贴贴 - LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT); - layoutParams.topMargin += ScreenParamUtils.dpToPx(rootView.getContext(), 16); - rootView.addView(troopAppListView, troopInfoTextIndex, layoutParams); - } - } - }); - return true; - } - - @NonNull - @Override - public String getName() { - return "将群应用卡片(群文件)移动到正常位置"; - } -} diff --git a/app/src/main/java/top/linl/hook/TurnOffFriendInteractionLogoView.java b/app/src/main/java/top/linl/hook/TurnOffFriendInteractionLogoView.java index ba53ee0ece..5a59a6b28f 100644 --- a/app/src/main/java/top/linl/hook/TurnOffFriendInteractionLogoView.java +++ b/app/src/main/java/top/linl/hook/TurnOffFriendInteractionLogoView.java @@ -30,8 +30,8 @@ import io.github.qauxv.hook.CommonSwitchFunctionHook; import java.lang.reflect.Field; import java.lang.reflect.Method; -import top.linl.util.reflect.FieIdUtils; -import top.linl.util.reflect.MethodTool; +import top.linl.util.FieIdUtils; +import top.linl.util.MethodTool; @FunctionHookEntry @UiItemAgentEntry diff --git a/app/src/main/java/top/linl/util/reflect/CheckClassType.java b/app/src/main/java/top/linl/util/CheckClassType.java similarity index 57% rename from app/src/main/java/top/linl/util/reflect/CheckClassType.java rename to app/src/main/java/top/linl/util/CheckClassType.java index bf8ad76c36..5e2e4c4254 100644 --- a/app/src/main/java/top/linl/util/reflect/CheckClassType.java +++ b/app/src/main/java/top/linl/util/CheckClassType.java @@ -1,26 +1,4 @@ -/* - * QAuxiliary - An Xposed module for QQ/TIM - * Copyright (C) 2019-2023 QAuxiliary developers - * https://github.com/cinit/QAuxiliary - * - * This software is non-free but opensource software: you can redistribute it - * and/or modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation; either - * version 3 of the License, or any later version and our eula as published - * by QAuxiliary contributors. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * and eula along with this software. If not, see - * - * . - */ - -package top.linl.util.reflect; +package top.linl.util; public class CheckClassType { diff --git a/app/src/main/java/top/linl/util/reflect/FieIdUtils.java b/app/src/main/java/top/linl/util/FieIdUtils.java similarity index 89% rename from app/src/main/java/top/linl/util/reflect/FieIdUtils.java rename to app/src/main/java/top/linl/util/FieIdUtils.java index 3e5ab8d152..c445a84907 100644 --- a/app/src/main/java/top/linl/util/reflect/FieIdUtils.java +++ b/app/src/main/java/top/linl/util/FieIdUtils.java @@ -1,26 +1,4 @@ -/* - * QAuxiliary - An Xposed module for QQ/TIM - * Copyright (C) 2019-2023 QAuxiliary developers - * https://github.com/cinit/QAuxiliary - * - * This software is non-free but opensource software: you can redistribute it - * and/or modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation; either - * version 3 of the License, or any later version and our eula as published - * by QAuxiliary contributors. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * and eula along with this software. If not, see - * - * . - */ - -package top.linl.util.reflect; +package top.linl.util; import java.lang.reflect.Field; diff --git a/app/src/main/java/top/linl/util/reflect/MethodTool.java b/app/src/main/java/top/linl/util/MethodTool.java similarity index 82% rename from app/src/main/java/top/linl/util/reflect/MethodTool.java rename to app/src/main/java/top/linl/util/MethodTool.java index 5a1a1f6604..f11f098c82 100644 --- a/app/src/main/java/top/linl/util/reflect/MethodTool.java +++ b/app/src/main/java/top/linl/util/MethodTool.java @@ -1,26 +1,4 @@ -/* - * QAuxiliary - An Xposed module for QQ/TIM - * Copyright (C) 2019-2023 QAuxiliary developers - * https://github.com/cinit/QAuxiliary - * - * This software is non-free but opensource software: you can redistribute it - * and/or modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation; either - * version 3 of the License, or any later version and our eula as published - * by QAuxiliary contributors. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * and eula along with this software. If not, see - * - * . - */ - -package top.linl.util.reflect; +package top.linl.util; import io.github.qauxv.util.Initiator; import java.lang.reflect.Method; diff --git a/app/src/main/java/top/linl/util/ReflectException.java b/app/src/main/java/top/linl/util/ReflectException.java new file mode 100644 index 0000000000..9771a1ebe2 --- /dev/null +++ b/app/src/main/java/top/linl/util/ReflectException.java @@ -0,0 +1,27 @@ +package top.linl.util; + +public class ReflectException extends RuntimeException { + + private Exception otherExceptions; + + public ReflectException() { + super(); + } + + public ReflectException(String content) { + super(content); + } + + public ReflectException(String content, Exception e) { + super(content); + this.otherExceptions = e; + } + + public boolean hasOtherExceptions() { + return otherExceptions != null; + } + + public Exception getOtherExceptions() { + return this.otherExceptions; + } +} diff --git a/app/src/main/java/top/linl/util/ScreenParamUtils.java b/app/src/main/java/top/linl/util/ScreenParamUtils.java deleted file mode 100644 index 6fca7de341..0000000000 --- a/app/src/main/java/top/linl/util/ScreenParamUtils.java +++ /dev/null @@ -1,117 +0,0 @@ -package top.linl.util; - -import android.annotation.SuppressLint; -import android.app.Activity; -import android.content.Context; -import android.content.res.Resources; -import android.graphics.Color; -import android.view.View; -import android.view.Window; -import android.view.WindowManager; - -public class ScreenParamUtils { - - - /** - * sp转px - */ - public static int spToPx(Context context, float spValue) { - final float fontScale = context.getResources().getDisplayMetrics().scaledDensity; - return (int) (spValue * fontScale + 0.5f); - } - - /** - * 获取手机像素宽度 - * - * @return 宽度px - */ - public static int getScreenWidth(Context context) { - return context.getResources().getDisplayMetrics().widthPixels; - } - - /** - * 获取手机像素高度(不包含虚拟导航栏和状态栏) - * - * @return 高度px - */ - public static int getScreenHeight(Context context) { - return context.getResources().getDisplayMetrics().heightPixels; - } - - - /** - * 获取导航栏高度 - * - * @return px - */ - public static int getNavigationBarHeight(Context context) { - int navigationBarHeight = -1; - Resources resources = context.getResources(); - @SuppressLint({"DiscouragedApi", "InternalInsetResource"}) int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); - if (resourceId > 0) { - navigationBarHeight = resources.getDimensionPixelSize(resourceId); - } - return navigationBarHeight; - } - - /** - * 获取状态栏高度 - * - * @return px - */ - public static int getStatusBarHeight(Context context) { - int height = 0; - @SuppressLint({"InternalInsetResource", "DiscouragedApi"}) - int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); - if (resourceId > 0) { - height = context.getResources().getDimensionPixelSize(resourceId); - } - return height; - } - - /** - * 根据手机的分辨率从 dp(相对大小) 的单位 转成为 px(像素) - */ - public static int dpToPx(Context context, float dpValue) { - // 获取屏幕密度 - final float scale = context.getResources().getDisplayMetrics().density; - // 结果+0.5是为了int取整时更接近 - return (int) (dpValue * scale + 0.5f); - } - - - /** - * 根据手机的分辨率从 px(像素) 的单位 转成为 dp(相对大小) - */ - public static int pxToDp(Context context, float pxValue) { - final float scale = context.getResources().getDisplayMetrics().density; - return (int) (pxValue / scale + 0.5f); - } - - /** - * px转sp - */ - public static int pxToSp(Context context, float pxValue) { - final float fontScale = context.getResources().getDisplayMetrics().scaledDensity; - return (int) (pxValue / fontScale + 0.5f); - } - - /** - * 将当前活动设置为透明的状态栏 - * - * @param activity 当前Activity - */ - protected void requestTranslucentStatusBar(Activity activity) { - Window window = activity.getWindow(); - window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS - | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); - window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); - window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - window.setStatusBarColor(Color.TRANSPARENT); - window.setNavigationBarColor(Color.TRANSPARENT); - } - - -} diff --git a/app/src/main/java/top/linl/util/reflect/ReflectException.java b/app/src/main/java/top/linl/util/reflect/ReflectException.java deleted file mode 100644 index 141ecbb0d3..0000000000 --- a/app/src/main/java/top/linl/util/reflect/ReflectException.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * QAuxiliary - An Xposed module for QQ/TIM - * Copyright (C) 2019-2023 QAuxiliary developers - * https://github.com/cinit/QAuxiliary - * - * This software is non-free but opensource software: you can redistribute it - * and/or modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation; either - * version 3 of the License, or any later version and our eula as published - * by QAuxiliary contributors. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * and eula along with this software. If not, see - * - * . - */ - -package top.linl.util.reflect; - -public class ReflectException extends RuntimeException { - - private Exception otherExceptions; - - public ReflectException() { - super(); - } - - public ReflectException(String content) { - super(content); - } - - public ReflectException(String content, Exception e) { - super(content); - this.otherExceptions = e; - } - - public boolean hasOtherExceptions() { - return otherExceptions != null; - } - - public Exception getOtherExceptions() { - return this.otherExceptions; - } -}