@@ -39,6 +39,23 @@ fun newIntent(settingsName: String) = IntentPreference.Intent(
3939
4040@Suppress(" UNREACHABLE_CODE" )
4141fun YoutubeHook.SettingsHook () {
42+ val inflate = getDexMethod(" PreferenceInflater#inflate" ) {
43+ findMethod {
44+ matcher {
45+ returnType = " androidx.preference.Preference"
46+ paramTypes(
47+ " org.xmlpull.v1.XmlPullParser" ,
48+ " androidx.preference.PreferenceGroup" ,
49+ " android.content.Context" ,
50+ " java.lang.Object[]" ,
51+ null ,
52+ " java.lang.String[]"
53+ )
54+ usingEqStrings(" : No start tag found!" , " : " )
55+ }
56+ }.single()
57+ }
58+
4259 getDexMethod(" PreferenceFragmentCompat#addPreferencesFromResource" ) {
4360 findClass {
4461 matcher {
@@ -48,20 +65,20 @@ fun YoutubeHook.SettingsHook() {
4865 " androidx.preference.PreferenceFragmentCompat.PREFERENCE_ROOT"
4966 )
5067 }
51- }.findMethod {
52- matcher {
53- returnType = " void"
54- paramTypes(" int" )
55- }
56- }.single().also { method ->
57- getDexMethod(" PreferenceInflater#inflate" ) {
58- method.invokes.single {
59- it.paramTypes.getOrNull(0 )?.name == " org.xmlpull.v1.XmlPullParser"
68+ }.single().let { preferenceFragmentCompat ->
69+ preferenceFragmentCompat.findMethod {
70+ matcher {
71+ returnType = " void"
72+ paramTypes(" int" )
6073 }
61- }
74+ }.singleOrNull() ? : preferenceFragmentCompat.findMethod {
75+ matcher {
76+ name = " addPreferencesFromResource"
77+ }
78+ }.single()
6279 }
6380 }.hookMethod(
64- ScopedHook (getDexMethod( " PreferenceInflater# inflate" ) .toMethod()) {
81+ ScopedHook (inflate.toMethod()) {
6582 var handleWebView = false
6683 after {
6784 val preferencesName = app.resources.getResourceName(outerParam.args[0 ] as Int )
@@ -108,8 +125,7 @@ fun YoutubeHook.SettingsHook() {
108125 try {
109126 LicenseActivityHook .initialize(activity)
110127 } catch (_: Resources .NotFoundException ) {
111- AlertDialog .Builder (activity)
112- .setTitle(" Restart needed" )
128+ AlertDialog .Builder (activity).setTitle(" Restart needed" )
113129 .setMessage(" ReVanced Xposed has been updated" )
114130 .setPositiveButton(" Restart now" ) { _, _ ->
115131 restartApplication(activity)
0 commit comments