fix(YouTube - Settings): Leaving RVX settings crashed the app
Close https://github.com/anddea/revanced-patches/issues/1239
This commit is contained in:
parent
f7ebfba41c
commit
52f912dfe9
3 changed files with 11 additions and 2 deletions
|
|
@ -148,6 +148,6 @@ public class YouTubeActivityHook extends BaseActivityHook {
|
|||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public static boolean handleBackPress() {
|
||||
return YouTubeSearchViewController.handleBackPress(searchViewController);
|
||||
return YouTubeSearchViewController.handleFinish(searchViewController);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue