Skip to content

Commit

Permalink
add hook item SortTroopSettingAppListView (#702)
Browse files Browse the repository at this point in the history
* add: Turn off friend interaction logo

* add : sort troop setting view GroupAppInfoListView(GroupFileView) to top
  • Loading branch information
suzhelan authored Dec 2, 2023
1 parent 54a7fe8 commit e3ca40b
Show file tree
Hide file tree
Showing 10 changed files with 367 additions and 35 deletions.
10 changes: 9 additions & 1 deletion app/src/main/java/io/github/qauxv/dsl/FunctionEntryRouter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -120,6 +124,7 @@ object FunctionEntryRouter {
category("auxiliary-friend", "好友")
category("auxiliary-profile", "资料卡")
}
fragment("auxiliary-group", "群聊")
fragment("auxiliary-notification", "通知设置")
fragment("auxiliary-experimental", "实验性功能")
fragment("entertainment-function", "娱乐功能")
Expand Down Expand Up @@ -253,6 +258,9 @@ object FunctionEntryRouter {
@JvmField
val FRIEND_CATEGORY: Array<String> = arrayOf(ANY_CAST_PREFIX, "auxiliary-friend")

@JvmField
val GROUP_CATEGORY: Array<String> = arrayOf(ANY_CAST_PREFIX, "auxiliary-group")

@JvmField
val PROFILE_CATEGORY: Array<String> = arrayOf(ANY_CAST_PREFIX, "auxiliary-profile")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
119 changes: 119 additions & 0 deletions app/src/main/java/top/linl/hook/SortTroopSettingAppListView.java
Original file line number Diff line number Diff line change
@@ -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
* <https://www.gnu.org/licenses/>
* <https://github.com/cinit/QAuxiliary/blob/master/LICENSE.md>.
*/

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 "将群应用卡片(群文件)移动到正常位置";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 0 additions & 27 deletions app/src/main/java/top/linl/util/ReflectException.java

This file was deleted.

117 changes: 117 additions & 0 deletions app/src/main/java/top/linl/util/ScreenParamUtils.java
Original file line number Diff line number Diff line change
@@ -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);
}


}
Original file line number Diff line number Diff line change
@@ -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
* <https://www.gnu.org/licenses/>
* <https://github.com/cinit/QAuxiliary/blob/master/LICENSE.md>.
*/

package top.linl.util.reflect;

public class CheckClassType {

Expand Down
Original file line number Diff line number Diff line change
@@ -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
* <https://www.gnu.org/licenses/>
* <https://github.com/cinit/QAuxiliary/blob/master/LICENSE.md>.
*/

package top.linl.util.reflect;


import java.lang.reflect.Field;
Expand Down
Loading

0 comments on commit e3ca40b

Please sign in to comment.