mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-06-12 05:07:46 +02:00
feat: features overlay
- rename debug section to settings
This commit is contained in:
@ -93,4 +93,8 @@ interface BridgeInterface {
|
||||
oneway void passGroupsAndFriends(in List<String> groups, in List<String> friends);
|
||||
|
||||
IScripting getScriptingInterface();
|
||||
|
||||
void openSettingsOverlay();
|
||||
|
||||
void closeSettingsOverlay();
|
||||
}
|
@ -25,7 +25,7 @@
|
||||
"downloads": "Downloads",
|
||||
"features": "Features",
|
||||
"home": "Home",
|
||||
"home_debug": "Debug",
|
||||
"home_settings": "Settings",
|
||||
"home_logs": "Logs",
|
||||
"social": "Social",
|
||||
"scripts": "Scripts"
|
||||
|
@ -16,12 +16,20 @@ import me.rhunk.snapenhance.core.messaging.MessagingFriendInfo
|
||||
import me.rhunk.snapenhance.core.messaging.MessagingGroupInfo
|
||||
import me.rhunk.snapenhance.core.util.ktx.getApplicationInfoCompat
|
||||
import me.rhunk.snapenhance.data.SnapClassCache
|
||||
import me.rhunk.snapenhance.hook.HookAdapter
|
||||
import me.rhunk.snapenhance.hook.HookStage
|
||||
import me.rhunk.snapenhance.hook.Hooker
|
||||
import me.rhunk.snapenhance.hook.hook
|
||||
import kotlin.time.ExperimentalTime
|
||||
import kotlin.time.measureTime
|
||||
|
||||
private fun useMainActivity(hookAdapter: HookAdapter, block: Activity.() -> Unit) {
|
||||
val activity = hookAdapter.thisObject() as Activity
|
||||
if (!activity.packageName.equals(Constants.SNAPCHAT_PACKAGE_NAME)) return
|
||||
block(activity)
|
||||
}
|
||||
|
||||
|
||||
class SnapEnhance {
|
||||
companion object {
|
||||
lateinit var classLoader: ClassLoader
|
||||
@ -68,12 +76,18 @@ class SnapEnhance {
|
||||
}
|
||||
|
||||
Activity::class.java.hook( "onCreate", HookStage.AFTER, { isBridgeInitialized }) {
|
||||
val activity = it.thisObject() as Activity
|
||||
if (!activity.packageName.equals(Constants.SNAPCHAT_PACKAGE_NAME)) return@hook
|
||||
val isMainActivityNotNull = appContext.mainActivity != null
|
||||
appContext.mainActivity = activity
|
||||
if (isMainActivityNotNull || !appContext.mappings.isMappingsLoaded()) return@hook
|
||||
onActivityCreate()
|
||||
useMainActivity(it) {
|
||||
val isMainActivityNotNull = appContext.mainActivity != null
|
||||
appContext.mainActivity = this
|
||||
if (isMainActivityNotNull || !appContext.mappings.isMappingsLoaded()) return@useMainActivity
|
||||
onActivityCreate()
|
||||
}
|
||||
}
|
||||
|
||||
Activity::class.java.hook( "onPause", HookStage.AFTER, { isBridgeInitialized }) {
|
||||
useMainActivity(it) {
|
||||
appContext.bridgeClient.closeSettingsOverlay()
|
||||
}
|
||||
}
|
||||
|
||||
var activityWasResumed = false
|
||||
@ -81,17 +95,16 @@ class SnapEnhance {
|
||||
//we need to reload the config when the app is resumed
|
||||
//FIXME: called twice at first launch
|
||||
Activity::class.java.hook("onResume", HookStage.AFTER, { isBridgeInitialized }) {
|
||||
val activity = it.thisObject() as Activity
|
||||
if (!activity.packageName.equals(Constants.SNAPCHAT_PACKAGE_NAME)) return@hook
|
||||
useMainActivity(it) {
|
||||
if (!activityWasResumed) {
|
||||
activityWasResumed = true
|
||||
return@useMainActivity
|
||||
}
|
||||
|
||||
if (!activityWasResumed) {
|
||||
activityWasResumed = true
|
||||
return@hook
|
||||
appContext.actionManager.onNewIntent(this.intent)
|
||||
appContext.reloadConfig()
|
||||
syncRemote()
|
||||
}
|
||||
|
||||
appContext.actionManager.onNewIntent(activity.intent)
|
||||
appContext.reloadConfig()
|
||||
syncRemote()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,4 +140,7 @@ class BridgeClient(
|
||||
= service.setRule(targetUuid, type.key, state)
|
||||
|
||||
fun getScriptingInterface(): IScripting = service.getScriptingInterface()
|
||||
|
||||
fun openSettingsOverlay() = service.openSettingsOverlay()
|
||||
fun closeSettingsOverlay() = service.closeSettingsOverlay()
|
||||
}
|
||||
|
@ -45,11 +45,12 @@ class SettingsGearInjector : AbstractMenu() {
|
||||
isClickable = true
|
||||
|
||||
setOnClickListener {
|
||||
val intent = Intent().apply {
|
||||
/* val intent = Intent().apply {
|
||||
setClassName(BuildConfig.APPLICATION_ID, "me.rhunk.snapenhance.ui.manager.MainActivity")
|
||||
putExtra("route", "features")
|
||||
}
|
||||
context.startActivity(intent)
|
||||
context.startActivity(intent)*/
|
||||
this@SettingsGearInjector.context.bridgeClient.openSettingsOverlay()
|
||||
}
|
||||
|
||||
parent.setOnTouchListener { _, event ->
|
||||
|
Reference in New Issue
Block a user