mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-28 12:30:12 +02:00
feat: app appearance & disable spotlight
This commit is contained in:
parent
7aa75b6fc8
commit
cbf2d41d7a
@ -59,7 +59,9 @@
|
||||
"longitude_value": "Longitude",
|
||||
"hide_ui_elements": "Hide UI Elements",
|
||||
"auto_updater": "Auto Updater",
|
||||
"infinite_story_boost": "Infinite Story Boost"
|
||||
"infinite_story_boost": "Infinite Story Boost",
|
||||
"enable_app_appearance": "Enable App Appearance Settings",
|
||||
"disable_spotlight": "Disable Spotlight"
|
||||
},
|
||||
|
||||
"option": {
|
||||
|
@ -80,17 +80,10 @@ class ModContext {
|
||||
}
|
||||
}
|
||||
|
||||
fun restartApp() {
|
||||
androidContext.packageManager.getLaunchIntentForPackage(
|
||||
Constants.SNAPCHAT_PACKAGE_NAME
|
||||
)?.let {
|
||||
val intent = Intent.makeRestartActivityTask(it.component)
|
||||
androidContext.startActivity(intent)
|
||||
Runtime.getRuntime().exit(0)
|
||||
fun softRestartApp(saveSettings: Boolean = false) {
|
||||
if (saveSettings) {
|
||||
config.writeConfig()
|
||||
}
|
||||
}
|
||||
|
||||
fun softRestartApp() {
|
||||
val intent: Intent? = androidContext.packageManager.getLaunchIntentForPackage(
|
||||
Constants.SNAPCHAT_PACKAGE_NAME
|
||||
)
|
||||
|
@ -35,7 +35,7 @@ class SnapEnhance {
|
||||
start { bridgeResult ->
|
||||
if (!bridgeResult) {
|
||||
Logger.xposedLog("Cannot connect to bridge service")
|
||||
appContext.restartApp()
|
||||
appContext.softRestartApp()
|
||||
return@start
|
||||
}
|
||||
runCatching {
|
||||
|
@ -258,6 +258,19 @@ enum class ConfigProperty(
|
||||
ConfigCategory.UI_TWEAKS,
|
||||
ConfigIntegerValue(20)
|
||||
),
|
||||
DISABLE_SPOTLIGHT(
|
||||
"property.disable_spotlight",
|
||||
"description.disable_spotlight",
|
||||
ConfigCategory.UI_TWEAKS,
|
||||
ConfigStateValue(false)
|
||||
),
|
||||
ENABLE_APP_APPEARANCE(
|
||||
"property.enable_app_appearance",
|
||||
"description.enable_app_appearance",
|
||||
ConfigCategory.UI_TWEAKS,
|
||||
ConfigStateValue(false)
|
||||
),
|
||||
|
||||
|
||||
// UPDATES
|
||||
AUTO_UPDATER(
|
||||
|
@ -1,8 +1,11 @@
|
||||
package me.rhunk.snapenhance.features.impl
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import me.rhunk.snapenhance.config.ConfigProperty
|
||||
import me.rhunk.snapenhance.features.Feature
|
||||
import me.rhunk.snapenhance.features.FeatureLoadParams
|
||||
import me.rhunk.snapenhance.hook.HookStage
|
||||
import me.rhunk.snapenhance.hook.hook
|
||||
import me.rhunk.snapenhance.util.setObjectField
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.Modifier
|
||||
@ -33,6 +36,7 @@ class ConfigEnumKeys : Feature("Config enum keys", loadParams = FeatureLoadParam
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("PrivateApi")
|
||||
override fun onActivityCreate() {
|
||||
if (context.config.bool(ConfigProperty.NEW_MAP_UI)) {
|
||||
hookAllEnums(context.mappings.getMappedClass("enums", "PLUS")) { key, set ->
|
||||
@ -62,5 +66,18 @@ class ConfigEnumKeys : Feature("Config enum keys", loadParams = FeatureLoadParam
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConfigProperty.ENABLE_APP_APPEARANCE.valueContainer.addPropertyChangeListener {
|
||||
context.softRestartApp(true)
|
||||
}
|
||||
|
||||
val sharedPreferencesImpl = context.androidContext.classLoader.loadClass("android.app.SharedPreferencesImpl")
|
||||
|
||||
sharedPreferencesImpl.methods.first { it.name == "getBoolean" }.hook(HookStage.BEFORE) { param ->
|
||||
when (param.arg<String>(0)) {
|
||||
"SIG_APP_APPEARANCE_SETTING" -> if (context.config.bool(ConfigProperty.ENABLE_APP_APPEARANCE)) param.setResult(true)
|
||||
"SPOTLIGHT_5TH_TAB_ENABLED" -> if (context.config.bool(ConfigProperty.DISABLE_SPOTLIGHT)) param.setResult(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user