diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 208b5d5..91aa417 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1 +1 @@ --keep class icu.nullptr.twifucker.HookEntry +-keep class icu.nullptr.twifucker.hook.HookEntry diff --git a/app/src/main/assets/xposed_init b/app/src/main/assets/xposed_init index b9f889e..8ac922b 100644 --- a/app/src/main/assets/xposed_init +++ b/app/src/main/assets/xposed_init @@ -1 +1 @@ -icu.nullptr.twifucker.HookEntry +icu.nullptr.twifucker.hook.HookEntry diff --git a/app/src/main/java/icu/nullptr/twifucker/HookEntry.kt b/app/src/main/java/icu/nullptr/twifucker/hook/HookEntry.kt similarity index 86% rename from app/src/main/java/icu/nullptr/twifucker/HookEntry.kt rename to app/src/main/java/icu/nullptr/twifucker/hook/HookEntry.kt index f3e3750..31d2216 100644 --- a/app/src/main/java/icu/nullptr/twifucker/HookEntry.kt +++ b/app/src/main/java/icu/nullptr/twifucker/hook/HookEntry.kt @@ -1,4 +1,4 @@ -package icu.nullptr.twifucker +package icu.nullptr.twifucker.hook import android.app.Application import android.content.Context @@ -10,6 +10,8 @@ import com.github.kyuubiran.ezxhelper.utils.hookAfter import de.robv.android.xposed.IXposedHookLoadPackage import de.robv.android.xposed.IXposedHookZygoteInit import de.robv.android.xposed.callbacks.XC_LoadPackage +import icu.nullptr.twifucker.hook.activity.settingsActivityHook +import icu.nullptr.twifucker.hook.activity.mainActivityHook private const val TAG = "TwiFucker" @@ -33,9 +35,9 @@ class HookEntry : IXposedHookZygoteInit, IXposedHookLoadPackage { EzXHelperInit.initAppContext(param.args[0] as Context) EzXHelperInit.setEzClassLoader(appContext.classLoader) Log.d("AttachContext") - if (BuildConfig.DEBUG) Log.toast("TwiFucker version ${BuildConfig.VERSION_NAME}") - settingsHook() + mainActivityHook() + settingsActivityHook() jsonHook() urlHook() } diff --git a/app/src/main/java/icu/nullptr/twifucker/JsonHook.kt b/app/src/main/java/icu/nullptr/twifucker/hook/JsonHook.kt similarity index 99% rename from app/src/main/java/icu/nullptr/twifucker/JsonHook.kt rename to app/src/main/java/icu/nullptr/twifucker/hook/JsonHook.kt index 7acf460..35d1a63 100644 --- a/app/src/main/java/icu/nullptr/twifucker/JsonHook.kt +++ b/app/src/main/java/icu/nullptr/twifucker/hook/JsonHook.kt @@ -1,4 +1,4 @@ -package icu.nullptr.twifucker +package icu.nullptr.twifucker.hook import com.github.kyuubiran.ezxhelper.utils.* import de.robv.android.xposed.XC_MethodHook diff --git a/app/src/main/java/icu/nullptr/twifucker/UrlHook.kt b/app/src/main/java/icu/nullptr/twifucker/hook/UrlHook.kt similarity index 97% rename from app/src/main/java/icu/nullptr/twifucker/UrlHook.kt rename to app/src/main/java/icu/nullptr/twifucker/hook/UrlHook.kt index d1d74c9..7d8ff82 100644 --- a/app/src/main/java/icu/nullptr/twifucker/UrlHook.kt +++ b/app/src/main/java/icu/nullptr/twifucker/hook/UrlHook.kt @@ -1,4 +1,4 @@ -package icu.nullptr.twifucker +package icu.nullptr.twifucker.hook import android.content.ClipData import android.content.Intent @@ -45,4 +45,4 @@ fun urlHook() { Log.i("Handle Url") param.args[1] = clearExtraParams(text) } -} \ No newline at end of file +} diff --git a/app/src/main/java/icu/nullptr/twifucker/Utils.kt b/app/src/main/java/icu/nullptr/twifucker/hook/Utils.kt similarity index 91% rename from app/src/main/java/icu/nullptr/twifucker/Utils.kt rename to app/src/main/java/icu/nullptr/twifucker/hook/Utils.kt index 363dfb9..92497c3 100644 --- a/app/src/main/java/icu/nullptr/twifucker/Utils.kt +++ b/app/src/main/java/icu/nullptr/twifucker/hook/Utils.kt @@ -1,4 +1,4 @@ -package icu.nullptr.twifucker +package icu.nullptr.twifucker.hook import android.content.Context import android.content.SharedPreferences diff --git a/app/src/main/java/icu/nullptr/twifucker/hook/activity/Main.kt b/app/src/main/java/icu/nullptr/twifucker/hook/activity/Main.kt new file mode 100644 index 0000000..5eb419a --- /dev/null +++ b/app/src/main/java/icu/nullptr/twifucker/hook/activity/Main.kt @@ -0,0 +1,24 @@ +package icu.nullptr.twifucker.hook.activity + +import android.app.Activity +import com.github.kyuubiran.ezxhelper.utils.Log +import com.github.kyuubiran.ezxhelper.utils.findMethod +import com.github.kyuubiran.ezxhelper.utils.hookAfter +import icu.nullptr.twifucker.BuildConfig +import icu.nullptr.twifucker.hook.modulePrefs +import icu.nullptr.twifucker.ui.SettingsDialog + +fun mainActivityHook() { + findMethod("com.twitter.app.main.MainActivity") { + name == "onResume" + }.hookAfter { param -> + Log.d("MainActivity onResume") + if (modulePrefs.getBoolean("first_run", true)) { + SettingsDialog(param.thisObject as Activity) + modulePrefs.edit().putBoolean("first_run", false).apply() + } + if (modulePrefs.getBoolean("show_toast", true)) { + Log.toast("TwiFucker version ${BuildConfig.VERSION_NAME}") + } + } +} diff --git a/app/src/main/java/icu/nullptr/twifucker/SettingsHook.kt b/app/src/main/java/icu/nullptr/twifucker/hook/activity/Settings.kt similarity index 87% rename from app/src/main/java/icu/nullptr/twifucker/SettingsHook.kt rename to app/src/main/java/icu/nullptr/twifucker/hook/activity/Settings.kt index 45e21d1..8274be8 100644 --- a/app/src/main/java/icu/nullptr/twifucker/SettingsHook.kt +++ b/app/src/main/java/icu/nullptr/twifucker/hook/activity/Settings.kt @@ -1,4 +1,4 @@ -package icu.nullptr.twifucker +package icu.nullptr.twifucker.hook.activity import android.app.Activity import com.github.kyuubiran.ezxhelper.utils.findMethod @@ -6,7 +6,7 @@ import com.github.kyuubiran.ezxhelper.utils.hookReplace import com.github.kyuubiran.ezxhelper.utils.loadClass import icu.nullptr.twifucker.ui.SettingsDialog -fun settingsHook() { +fun settingsActivityHook() { findMethod("com.twitter.app.settings.AboutActivity") { parameterTypes.size == 1 && parameterTypes[0] == loadClass("android.preference.Preference") }.hookReplace { param -> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c63c67e..dec53df 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -4,9 +4,11 @@ save and restart dismiss + General Main Extra + Show Toast on Start Disable Promoted Content Disable Promoted User Disable Promoted Trends @@ -14,6 +16,7 @@ Disable Who to Follow Disable Topics to Follow + You can find this page through settings/additional/version home/profile/search timeline home/profile/search timeline search diff --git a/app/src/main/res/xml/settings_dialog.xml b/app/src/main/res/xml/settings_dialog.xml index e157cf9..1943da8 100644 --- a/app/src/main/res/xml/settings_dialog.xml +++ b/app/src/main/res/xml/settings_dialog.xml @@ -1,5 +1,12 @@ + + +