Skip to content

Commit 03b8d69

Browse files
committed
do not recreate activity when screen rotates
1 parent 0a08eca commit 03b8d69

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/LicenseActivityHook.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.annotation.SuppressLint;
66
import android.app.Activity;
77
import android.content.Context;
8+
import android.content.res.Configuration;
89
import android.preference.PreferenceFragment;
910
import android.view.ViewGroup;
1011
import android.widget.TextView;

patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,24 @@ private val settingsResourcePatch = resourcePatch {
136136
}
137137
}
138138

139-
// Modify the manifest and add a data intent filter to the LicenseActivity.
140-
// Some devices freak out if undeclared data is passed to an intent,
141-
// and this change appears to fix the issue.
139+
// Modify the manifest to enhance LicenseActivity behavior:
140+
// 1. Add a data intent filter with MIME type "text/plain".
141+
// Some devices crash if undeclared data is passed to an intent,
142+
// and this change appears to fix the issue.
143+
// 2. Add android:configChanges="orientation|screenSize|keyboardHidden".
144+
// This prevents the activity from being recreated on configuration changes
145+
// (e.g., screen rotation), preserving its current state and fragment.
142146
document("AndroidManifest.xml").use { document ->
143147
val licenseElement = document.childNodes.findElementByAttributeValueOrThrow(
144148
"android:name",
145149
"com.google.android.libraries.social.licenses.LicenseActivity",
146150
)
147151

152+
licenseElement.setAttribute(
153+
"android:configChanges",
154+
"orientation|screenSize|keyboardHidden"
155+
)
156+
148157
val mimeType = document.createElement("data")
149158
mimeType.setAttribute("android:mimeType", "text/plain")
150159

0 commit comments

Comments
 (0)