fix(YouTube - Settings): Leaving RVX settings crashed the app

Close https://github.com/anddea/revanced-patches/issues/1239
This commit is contained in:
Aaron Veil 2025-09-27 22:04:20 +03:00
parent f7ebfba41c
commit 52f912dfe9
3 changed files with 11 additions and 2 deletions

View file

@ -148,6 +148,6 @@ public class YouTubeActivityHook extends BaseActivityHook {
*/
@SuppressWarnings("unused")
public static boolean handleBackPress() {
return YouTubeSearchViewController.handleBackPress(searchViewController);
return YouTubeSearchViewController.handleFinish(searchViewController);
}
}

View file

@ -49,6 +49,15 @@ public class YouTubeSearchViewController extends BaseSearchViewController {
return true;
}
// Static method for Activity finish.
public static boolean handleFinish(YouTubeSearchViewController searchViewController) {
if (searchViewController != null && searchViewController.isSearchActive()) {
searchViewController.closeSearch();
return true;
}
return false;
}
// Adapter to wrap YouTubePreferenceFragment to BasePreferenceFragment interface.
private record PreferenceFragmentAdapter(YouTubePreferenceFragment fragment) implements BasePreferenceFragment {
@Override

View file

@ -214,7 +214,7 @@ private val settingsBytecodePatch = bytecodePatch(
).toMutable().apply {
addInstructions(
"""
invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->handleFinish()Z
invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->handleBackPress()Z
move-result v0
if-nez v0, :search_handled
invoke-super { p0 }, Landroid/app/Activity;->finish()V