Skip to content

Commit 2ae8ed6

Browse files
committed
1.1.12
1 parent 772b23e commit 2ae8ed6

File tree

14 files changed

+185
-11
lines changed

14 files changed

+185
-11
lines changed

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ android {
1212
applicationId 'io.github.chsbuffer.miuihelper'
1313
minSdk 27
1414
targetSdk sdk
15-
versionCode 13
16-
versionName '1.1.11'
15+
versionCode 14
16+
versionName '1.1.12'
1717
ndk {
1818
abiFilters 'arm64-v8a'
1919
}
@@ -58,5 +58,5 @@ dependencies {
5858
compileOnly project(path: ':miuistub')
5959
implementation("dev.rikka.tools.refine:runtime:$refine")
6060
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
61-
implementation 'org.luckypray:DexKit:1.1.3'
61+
implementation 'org.luckypray:DexKit:1.1.4'
6262
}

app/src/main/java/io/github/chsbuffer/miuihelper/MainHook.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import de.robv.android.xposed.IXposedHookLoadPackage
55
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam
66
import io.github.chsbuffer.miuihelper.hooks.aiasst.SupportAiSubtitles
77
import io.github.chsbuffer.miuihelper.hooks.home.RestoreCnBuildGoogleApp
8+
import io.github.chsbuffer.miuihelper.hooks.home.RestoreGoogleFeed
9+
import io.github.chsbuffer.miuihelper.hooks.home.RestoreGoogleSearch
810
import io.github.chsbuffer.miuihelper.hooks.screenrecorder.ForceSupportPlaybackCapture
911
import io.github.chsbuffer.miuihelper.hooks.screenrecorder.SaveToMovies
1012
import io.github.chsbuffer.miuihelper.hooks.screenshot.SaveToPictures
@@ -38,7 +40,9 @@ class MainHook : IXposedHookLoadPackage {
3840
)
3941
"com.miui.home" -> hooks(
4042
lpparam,
41-
RestoreCnBuildGoogleApp
43+
RestoreCnBuildGoogleApp,
44+
RestoreGoogleFeed,
45+
RestoreGoogleSearch
4246
)
4347
"com.xiaomi.aiasst.vision" -> hooks(
4448
lpparam,
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package io.github.chsbuffer.miuihelper.hooks.home
2+
3+
import android.content.Intent
4+
import de.robv.android.xposed.XC_MethodHook
5+
import de.robv.android.xposed.XposedHelpers
6+
import io.github.chsbuffer.miuihelper.model.BooleanDuringMethod
7+
import io.github.chsbuffer.miuihelper.model.Hook
8+
import miui.os.Build
9+
10+
11+
object RestoreGoogleFeed : Hook() {
12+
override fun init(classLoader: ClassLoader) {
13+
if (!xPrefs.getBoolean("restore_google_feed", true) || Build.IS_INTERNATIONAL_BUILD) return
14+
15+
// 启用可以切换负一屏(即“智能助理”或“Google”)
16+
val LauncherAssistantCompatClass =
17+
classLoader.loadClass("com.miui.home.launcher.LauncherAssistantCompat")
18+
XposedHelpers.setStaticBooleanField(
19+
LauncherAssistantCompatClass, "CAN_SWITCH_MINUS_SCREEN", true
20+
)
21+
22+
// isUseGoogleMinusScreen, instead of LauncherAssistantCompatMIUI
23+
val mUtilities = classLoader.loadClass("com.miui.home.launcher.common.Utilities")
24+
XposedHelpers.findAndHookMethod("com.miui.home.launcher.LauncherAssistantCompat",
25+
classLoader,
26+
"newInstance",
27+
"com.miui.home.launcher.Launcher",
28+
object : BooleanDuringMethod(
29+
XposedHelpers.findClass(
30+
"miui.os.Build", classLoader
31+
), "IS_INTERNATIONAL_BUILD", true
32+
) {
33+
override fun beforeHookedMethod(param: MethodHookParam) {
34+
super.value =
35+
XposedHelpers.callStaticMethod(mUtilities, "getCurrentPersonalAssistant")
36+
.equals("personal_assistant_google")
37+
super.beforeHookedMethod(param)
38+
}
39+
})
40+
41+
// 使用含 AssistantSwitchObserver 的 LauncherCallbacksGlobal, 而不是 LauncherCallbacksChinese (只观察负一屏是否开启)
42+
XposedHelpers.findAndHookConstructor(
43+
"com.miui.home.launcher.Launcher", classLoader, BooleanDuringMethod(
44+
XposedHelpers.findClass(
45+
"miui.os.Build", classLoader
46+
), "IS_INTERNATIONAL_BUILD", true
47+
)
48+
)
49+
50+
// 恢复“切换负一屏”设置
51+
XposedHelpers.findAndHookMethod("com.miui.home.settings.MiuiHomeSettings",
52+
classLoader,
53+
"onCreatePreferences",
54+
android.os.Bundle::class.java,
55+
java.lang.String::class.java,
56+
object : XC_MethodHook() {
57+
override fun afterHookedMethod(param: MethodHookParam) {
58+
val mSwitchPersonalAssistant =
59+
XposedHelpers.getObjectField(param.thisObject, "mSwitchPersonalAssistant")
60+
XposedHelpers.callMethod(
61+
mSwitchPersonalAssistant,
62+
"setIntent",
63+
Intent("com.miui.home.action.LAUNCHER_PERSONAL_ASSISTANT_SETTING")
64+
)
65+
XposedHelpers.callMethod(
66+
mSwitchPersonalAssistant, "setOnPreferenceChangeListener", param.thisObject
67+
)
68+
val mPreferenceScreen =
69+
XposedHelpers.callMethod(param.thisObject, "getPreferenceScreen")
70+
XposedHelpers.callMethod(
71+
mPreferenceScreen, "addPreference", mSwitchPersonalAssistant
72+
)
73+
}
74+
})
75+
76+
XposedHelpers.findAndHookMethod("com.miui.home.settings.MiuiHomeSettings",
77+
classLoader,
78+
"onResume",
79+
object : XC_MethodHook() {
80+
override fun afterHookedMethod(param: MethodHookParam) {
81+
val mSwitchPersonalAssistant =
82+
XposedHelpers.getObjectField(param.thisObject, "mSwitchPersonalAssistant")
83+
XposedHelpers.callMethod(
84+
mSwitchPersonalAssistant, "setVisible", true
85+
)
86+
87+
}
88+
})
89+
90+
}
91+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package io.github.chsbuffer.miuihelper.hooks.home
2+
3+
import android.content.Context
4+
import android.content.Intent
5+
import de.robv.android.xposed.XC_MethodReplacement
6+
import de.robv.android.xposed.XposedBridge
7+
import de.robv.android.xposed.XposedHelpers
8+
import io.github.chsbuffer.miuihelper.model.Hook
9+
10+
11+
object RestoreGoogleSearch : Hook() {
12+
override fun init(classLoader: ClassLoader) {
13+
if (!xPrefs.getBoolean("restore_google_search", false))
14+
return
15+
16+
XposedHelpers.findAndHookMethod(
17+
"com.miui.home.launcher.SearchBarDesktopLayout",
18+
classLoader,
19+
"launchGlobalSearch",
20+
java.lang.String::class.java,
21+
java.lang.String::class.java,
22+
object : XC_MethodReplacement() {
23+
override fun replaceHookedMethod(param: MethodHookParam) {
24+
val context =
25+
XposedHelpers.getObjectField(param.thisObject, "mLauncher") as Context
26+
try {
27+
context.startActivity(
28+
Intent("android.search.action.GLOBAL_SEARCH").addFlags(
29+
Intent.FLAG_ACTIVITY_NEW_TASK
30+
// and Intent.FLAG_ACTIVITY_CLEAR_TASK
31+
and Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
32+
).setPackage("com.google.android.googlequicksearchbox")
33+
)
34+
} catch (e: Exception) {
35+
// fallback doesn't work, still keep the code here because i don't care
36+
XposedBridge.invokeOriginalMethod(
37+
param.method,
38+
param.thisObject,
39+
param.args
40+
)
41+
}
42+
}
43+
}
44+
)
45+
}
46+
47+
}

app/src/main/java/io/github/chsbuffer/miuihelper/model/BooleanDuringMethod.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package io.github.chsbuffer.miuihelper.model
33
import de.robv.android.xposed.XC_MethodHook
44
import de.robv.android.xposed.XposedHelpers
55

6-
class BooleanDuringMethod : XC_MethodHook {
6+
open class BooleanDuringMethod : XC_MethodHook {
77
enum class Type {
88
ThisObj, Obj, Class, Func
99
}
@@ -14,7 +14,7 @@ class BooleanDuringMethod : XC_MethodHook {
1414
private var func: ((MethodHookParam) -> Any)? = null
1515

1616
private val fieldName: String
17-
private val value: Boolean
17+
protected var value: Boolean
1818

1919
constructor(fieldName: String, value: Boolean) : super() {
2020
type = Type.ThisObj

app/src/main/res/values-zh-rCN/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,7 @@
5050
<string name="force_support_playbackcapture_title">强制启用原生录音支持</string>
5151
<string name="notification_channel_setting_title">打开通知频道设置</string>
5252
<string name="notification_channel_setting_summary">打开通知菜单的设置会导航至频道设置而不是应用通用通知设置</string>
53+
<string name="restore_google_feed_title">替换负一屏为 Google Feed</string>
54+
<string name="restore_google_search_title">替换搜索为 Google 搜索</string>
55+
<string name="restore_google_feed_summary">如果无法滑动到负一屏,请强行停止 Google</string>
5356
</resources>

app/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,7 @@
5050
<string name="force_support_playbackcapture_title">Force enable Native Audio Recorder</string>
5151
<string name="notification_channel_setting_title" >Open channel settings</string>
5252
<string name="notification_channel_setting_summary">Opening settings from notification menu leads to channel settings instead of app\'s common notification settings</string>
53+
<string name="restore_google_search_title">Search bar opens Google Search</string>
54+
<string name="restore_google_feed_title">Replace App Vault into Google Feed</string>
55+
<string name="restore_google_feed_summary">Force stop Google App if you can\'t swipe to -1 screen</string>
5356
</resources>

app/src/main/res/xml/root_preferences.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@
4747
android:key="restore_google_icon"
4848
android:singleLineTitle="false"
4949
android:title="@string/restore_google_icon_title" />
50+
<SwitchPreference
51+
android:defaultValue="true"
52+
android:key="restore_google_feed"
53+
android:singleLineTitle="false"
54+
android:title="@string/restore_google_feed_title"
55+
android:summary="@string/restore_google_feed_summary" />
56+
<SwitchPreference
57+
android:defaultValue="false"
58+
android:key="restore_google_search"
59+
android:singleLineTitle="false"
60+
android:title="@string/restore_google_search_title" />
5061
</PreferenceCategory>
5162
<PreferenceCategory android:title="@string/system_ui_app_name">
5263
<Preference

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
buildscript {
3-
ext.kotlin_version = '1.8.10'
3+
ext.kotlin_version = '1.8.20'
44
ext.refine = '4.3.0'
55
ext.buildToolsVersion = '33.0.2'
66
ext.sdk = 33

gradle/wrapper/gradle-wrapper.jar

468 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)