feat: inject setting button
Some checks failed
Android CI / build (push) Failing after 14m58s

This commit is contained in:
MoonLeeeaf 2024-08-03 10:04:48 +08:00
parent 525f842bea
commit 0d6e388ea8
4 changed files with 85 additions and 26 deletions

View File

@ -1,32 +1,32 @@
{
"allFiles": [
{
"file": "/storage/emulated/0/MoonLeaf/Projects/FuckMaoNemo/app/src/main/res/xml/config.xml",
"selection": {
"end": {
"column": 83,
"index": 3436,
"line": 97
},
"start": {
"column": 83,
"index": 3436,
"line": 97
}
}
},
{
"file": "/storage/emulated/0/MoonLeaf/Projects/FuckMaoNemo/app/src/main/java/io/github/moonleeeaf/fuckmaonemo/Hook.java",
"selection": {
"end": {
"column": 58,
"index": 8459,
"line": 207
"column": 30,
"index": 4201,
"line": 112
},
"start": {
"column": 58,
"index": 8459,
"line": 207
"column": 30,
"index": 4201,
"line": 112
}
}
},
{
"file": "/storage/emulated/0/MoonLeaf/Projects/FuckMaoNemo/app/src/main/res/xml/config.xml",
"selection": {
"end": {
"column": 27,
"index": 461,
"line": 13
},
"start": {
"column": 27,
"index": 461,
"line": 13
}
}
},

View File

@ -12,8 +12,8 @@ android {
applicationId "io.github.moonleeeaf.fuckmaonemo"
minSdk 21
targetSdk 33
versionCode 15000
versionName "1.5.0"
versionCode 16000
versionName "1.6.0"
vectorDrawables {
useSupportLibrary true

View File

@ -1,6 +1,8 @@
package io.github.moonleeeaf.fuckmaonemo;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Application;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.res.AssetManager;
@ -9,7 +11,10 @@ import android.os.Bundle;
import android.text.InputFilter;
import android.text.Spanned;
import android.util.Pair;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.PopupMenu;
import android.widget.Toast;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
@ -98,6 +103,46 @@ public class Hook implements IXposedHookLoadPackage {
XposedBridge.log("[FuckMaoNemo] 注入中...");
// 劫持设置按钮的点击事件
load("inject_settings_button", () -> {
XposedBridge.log("[FuckMaoNemo] Hook_注入设置菜单");
XposedBridge.hookMethod(
getMethod(
XposedHelpers.findClass("com.codemao.nemo.fragment.MineFragment", classLoader),
"onClick",
View.class
),
new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam mp) throws Throwable {
View v = (View) mp.args[0];
if (v.getId() == 2131297099)
v.setId(11451419);
}
@Override
protected void afterHookedMethod(MethodHookParam mp) throws Throwable {
View v = (View) mp.args[0];
Context c = v.getContext();
if (v.getId() == 11451419) {
PopupMenu pop = new PopupMenu(c, v);
Menu m = pop.getMenu();
m.add("Nemo设置").setOnMenuItemClickListener((mm) -> {
c.startActivity(new Intent(c, XposedHelpers.findClass("com.codemao.nemo.activity.SettingActivity", classLoader)));
return false;
});
m.add("模块设置").setOnMenuItemClickListener((mm) -> {
c.startActivity(new Intent().setComponent(new ComponentName("io.github.moonleeeaf.fuckmaonemo", ConfigActivity.class.getName())));
return false;
});
pop.show();
mp.setResult(null);
}
}
}
);
}, true);
// 拦截40x码
load("fuck_40x", () -> {
XposedBridge.log("[FuckMaoNemo] Hook_拦截40x码");
@ -420,7 +465,11 @@ public class Hook implements IXposedHookLoadPackage {
}
public void load(String pref, Callback cb) {
if (xsp.getBoolean(pref, false)) {
load(pref, cb ,false);
}
public void load(String pref, Callback cb, boolean def) {
if (xsp.getBoolean(pref, def)) {
try {
cb.onCallback();
nohengheng++;

View File

@ -8,13 +8,23 @@
<Preference
android:title="作者"
android:summary="编程猫 @满月叶\nGitHub @MoonLeeeaf\n喵呜~" />
android:summary="编程猫 @满月叶\nGitHub @MoonLeeeaf\nBiliBili @静之彼端\n喵呜~" />
<Preference
android:title="提示"
android:summary="目前只支持 LSPosed\n其他暂未测试\n更改功能后重启生效" />
<SwitchPreference
android:key="force_enable"
android:title="强制启用"
android:title="非官方客户端"
android:summary="如果你正在使用基于官方 Nemo 修改的客户端,那么可以打开此选项(记得配置模块作用域哦)" />
<SwitchPreference
android:key="inject_settings_button"
android:title="注入设置菜单"
android:summary="字面意思"
android:defaultValue="true" />
</PreferenceCategory>
<PreferenceCategory android:title="网络">