-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add : sort troop setting view GroupAppInfoListView(GroupFileView) to top
- Loading branch information
suzhelan
committed
Dec 1, 2023
1 parent
43c5e36
commit 953419e
Showing
10 changed files
with
367 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
app/src/main/java/top/linl/hook/SortTroopSettingAppListView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "将群应用卡片(群文件)移动到正常位置"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
|
||
} |
24 changes: 23 additions & 1 deletion
24
...in/java/top/linl/util/CheckClassType.java → ...top/linl/util/reflect/CheckClassType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 23 additions & 1 deletion
24
...c/main/java/top/linl/util/FieIdUtils.java → ...ava/top/linl/util/reflect/FieIdUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.