-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
57 additions
and
4 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
27 changes: 27 additions & 0 deletions
27
...src/main/kotlin/me/rhunk/snapenhance/core/features/impl/global/DisableMemoriesSnapFeed.kt
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,27 @@ | ||
package me.rhunk.snapenhance.core.features.impl.global | ||
|
||
import me.rhunk.snapenhance.core.features.Feature | ||
import me.rhunk.snapenhance.core.features.FeatureLoadParams | ||
import me.rhunk.snapenhance.core.util.hook.HookStage | ||
import me.rhunk.snapenhance.core.util.hook.hook | ||
import me.rhunk.snapenhance.mapper.impl.MemoriesPresenterMapper | ||
|
||
class DisableMemoriesSnapFeed : Feature("Disable Memories Snap Feed", loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC) { | ||
override fun onActivityCreate() { | ||
if (!context.config.global.disableMemoriesSnapFeed.get()) return | ||
|
||
context.mappings.useMapper(MemoriesPresenterMapper::class) { | ||
classReference.get()?.apply { | ||
val getNameMethod = getMethod("getName") ?: return@apply | ||
|
||
hook(onNavigationEventMethod.get()!!, HookStage.BEFORE) { param -> | ||
val instance = param.thisObject<Any>() | ||
|
||
if (getNameMethod.invoke(instance) == "MemoriesAsyncPresenterFragmentSubscriber") { | ||
param.setResult(null) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
mapper/src/main/kotlin/me/rhunk/snapenhance/mapper/impl/MemoriesPresenterMapper.kt
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,25 @@ | ||
package me.rhunk.snapenhance.mapper.impl | ||
|
||
import me.rhunk.snapenhance.mapper.AbstractClassMapper | ||
import me.rhunk.snapenhance.mapper.ext.findConstString | ||
import me.rhunk.snapenhance.mapper.ext.getClassName | ||
|
||
class MemoriesPresenterMapper : AbstractClassMapper("MemoriesPresenter") { | ||
val classReference = classReference("class") | ||
val onNavigationEventMethod = string("onNavigationEventMethod") | ||
|
||
init { | ||
mapper { | ||
for (clazz in classes) { | ||
if (clazz.interfaces.size != 1) continue | ||
val getNameMethod = clazz.methods.firstOrNull { it.name == "getName" } ?: continue | ||
if (getNameMethod.implementation?.findConstString("MemoriesAsyncPresenterFragmentSubscriber") != true) continue | ||
|
||
val onNavigationEvent = clazz.methods.firstOrNull { it.implementation?.findConstString("Memories") == true } ?: continue | ||
|
||
classReference.set(clazz.getClassName()) | ||
onNavigationEventMethod.set(onNavigationEvent.name) | ||
} | ||
} | ||
} | ||
} |