Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Commit

Permalink
Show dialog on first start
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-TSNG committed Mar 18, 2022
1 parent baefc40 commit f2bed80
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-keep class icu.nullptr.twifucker.HookEntry
-keep class icu.nullptr.twifucker.hook.HookEntry
2 changes: 1 addition & 1 deletion app/src/main/assets/xposed_init
Original file line number Diff line number Diff line change
@@ -1 +1 @@
icu.nullptr.twifucker.HookEntry
icu.nullptr.twifucker.hook.HookEntry
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package icu.nullptr.twifucker
package icu.nullptr.twifucker.hook

import android.app.Application
import android.content.Context
Expand All @@ -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"

Expand All @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package icu.nullptr.twifucker
package icu.nullptr.twifucker.hook

import android.content.ClipData
import android.content.Intent
Expand Down Expand Up @@ -45,4 +45,4 @@ fun urlHook() {
Log.i("Handle Url")
param.args[1] = clearExtraParams(text)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package icu.nullptr.twifucker
package icu.nullptr.twifucker.hook

import android.content.Context
import android.content.SharedPreferences
Expand Down
24 changes: 24 additions & 0 deletions app/src/main/java/icu/nullptr/twifucker/hook/activity/Main.kt
Original file line number Diff line number Diff line change
@@ -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}")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package icu.nullptr.twifucker
package icu.nullptr.twifucker.hook.activity

import android.app.Activity
import com.github.kyuubiran.ezxhelper.utils.findMethod
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 ->
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
<string name="save_restart">save and restart</string>

<string name="settings_dismiss">dismiss</string>
<string name="settings_general">General</string>
<string name="settings_main">Main</string>
<string name="settings_extra">Extra</string>

<string name="show_toast_title">Show Toast on Start</string>
<string name="disable_promoted_content_title">Disable Promoted Content</string>
<string name="disable_promoted_user_title">Disable Promoted User</string>
<string name="disable_promoted_trends_title">Disable Promoted Trends</string>
<string name="disable_sensitive_media_warning_title">Disable Sensitive Media Warning</string>
<string name="disable_who_to_follow_title">Disable Who to Follow</string>
<string name="disable_topics_to_follow_title">Disable Topics to Follow</string>

<string name="show_toast_summary">You can find this page through settings/additional/version</string>
<string name="disable_promoted_content_summary">home/profile/search timeline</string>
<string name="disable_promoted_user_summary">home/profile/search timeline</string>
<string name="disable_promoted_trends_summary">search</string>
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/xml/settings_dialog.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/settings_general">
<SwitchPreference
android:defaultValue="true"
android:key="show_toast"
android:summary="@string/show_toast_summary"
android:title="@string/show_toast_title" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/settings_main">
<SwitchPreference
android:defaultValue="true"
Expand Down

0 comments on commit f2bed80

Please sign in to comment.