mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-12-07 01:51:27 +01:00
fix(YouTube - Settings): Handle on screen back swipe gesture (#6002)
This commit is contained in:
committed by
GitHub
parent
1e023fa1f3
commit
6f92b6c50b
@@ -152,7 +152,7 @@ public class YouTubeActivityHook extends BaseActivityHook {
|
||||
* @return if the original activity finish method should be allowed to run.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public static boolean handleFinish() {
|
||||
public static boolean handleBackPress() {
|
||||
return YouTubeSearchViewController.handleFinish(searchViewController);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,8 @@ val settingsPatch = bytecodePatch(
|
||||
modifyActivityForSettingsInjection(
|
||||
googleApiActivityFingerprint.classDef,
|
||||
googleApiActivityFingerprint.method,
|
||||
GOOGLE_API_ACTIVITY_HOOK_CLASS_DESCRIPTOR
|
||||
GOOGLE_API_ACTIVITY_HOOK_CLASS_DESCRIPTOR,
|
||||
true
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -218,7 +218,8 @@ val settingsPatch = bytecodePatch(
|
||||
modifyActivityForSettingsInjection(
|
||||
licenseActivityOnCreateFingerprint.classDef,
|
||||
licenseActivityOnCreateFingerprint.method,
|
||||
YOUTUBE_ACTIVITY_HOOK_CLASS_DESCRIPTOR
|
||||
YOUTUBE_ACTIVITY_HOOK_CLASS_DESCRIPTOR,
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
@@ -233,7 +234,8 @@ val settingsPatch = bytecodePatch(
|
||||
internal fun modifyActivityForSettingsInjection(
|
||||
activityOnCreateClass: MutableClass,
|
||||
activityOnCreateMethod: MutableMethod,
|
||||
extensionClassType: String
|
||||
extensionClassType: String,
|
||||
isYouTubeMusic: Boolean
|
||||
) {
|
||||
// Modify Activity and remove all existing layout code.
|
||||
// Must modify an existing activity and cannot add a new activity to the manifest,
|
||||
@@ -275,7 +277,7 @@ internal fun modifyActivityForSettingsInjection(
|
||||
// Override finish() to intercept back gesture.
|
||||
ImmutableMethod(
|
||||
activityOnCreateClass.type,
|
||||
"finish",
|
||||
if (isYouTubeMusic) "finish" else "onBackPressed",
|
||||
emptyList(),
|
||||
"V",
|
||||
AccessFlags.PUBLIC.value,
|
||||
@@ -283,13 +285,16 @@ internal fun modifyActivityForSettingsInjection(
|
||||
null,
|
||||
MutableMethodImplementation(3),
|
||||
).toMutable().apply {
|
||||
// Slightly different hooks are needed, otherwise the back button can behave wrong.
|
||||
val extensionMethodName = if (isYouTubeMusic) "handleFinish" else "handleBackPress"
|
||||
val invokeFinishOpcode = if (isYouTubeMusic) "invoke-super" else "invoke-virtual"
|
||||
|
||||
addInstructions(
|
||||
"""
|
||||
invoke-static {}, $extensionClassType->handleFinish()Z
|
||||
invoke-static {}, $extensionClassType->$extensionMethodName()Z
|
||||
move-result v0
|
||||
if-nez v0, :search_handled
|
||||
invoke-super { p0 }, Landroid/app/Activity;->finish()V
|
||||
return-void
|
||||
$invokeFinishOpcode { p0 }, Landroid/app/Activity;->finish()V
|
||||
:search_handled
|
||||
return-void
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user