mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2026-01-11 13:46:17 +00: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.
|
* @return if the original activity finish method should be allowed to run.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static boolean handleFinish() {
|
public static boolean handleBackPress() {
|
||||||
return YouTubeSearchViewController.handleFinish(searchViewController);
|
return YouTubeSearchViewController.handleFinish(searchViewController);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,8 @@ val settingsPatch = bytecodePatch(
|
|||||||
modifyActivityForSettingsInjection(
|
modifyActivityForSettingsInjection(
|
||||||
googleApiActivityFingerprint.classDef,
|
googleApiActivityFingerprint.classDef,
|
||||||
googleApiActivityFingerprint.method,
|
googleApiActivityFingerprint.method,
|
||||||
GOOGLE_API_ACTIVITY_HOOK_CLASS_DESCRIPTOR
|
GOOGLE_API_ACTIVITY_HOOK_CLASS_DESCRIPTOR,
|
||||||
|
true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -218,7 +218,8 @@ val settingsPatch = bytecodePatch(
|
|||||||
modifyActivityForSettingsInjection(
|
modifyActivityForSettingsInjection(
|
||||||
licenseActivityOnCreateFingerprint.classDef,
|
licenseActivityOnCreateFingerprint.classDef,
|
||||||
licenseActivityOnCreateFingerprint.method,
|
licenseActivityOnCreateFingerprint.method,
|
||||||
YOUTUBE_ACTIVITY_HOOK_CLASS_DESCRIPTOR
|
YOUTUBE_ACTIVITY_HOOK_CLASS_DESCRIPTOR,
|
||||||
|
false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,7 +234,8 @@ val settingsPatch = bytecodePatch(
|
|||||||
internal fun modifyActivityForSettingsInjection(
|
internal fun modifyActivityForSettingsInjection(
|
||||||
activityOnCreateClass: MutableClass,
|
activityOnCreateClass: MutableClass,
|
||||||
activityOnCreateMethod: MutableMethod,
|
activityOnCreateMethod: MutableMethod,
|
||||||
extensionClassType: String
|
extensionClassType: String,
|
||||||
|
isYouTubeMusic: Boolean
|
||||||
) {
|
) {
|
||||||
// Modify Activity and remove all existing layout code.
|
// Modify Activity and remove all existing layout code.
|
||||||
// Must modify an existing activity and cannot add a new activity to the manifest,
|
// 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.
|
// Override finish() to intercept back gesture.
|
||||||
ImmutableMethod(
|
ImmutableMethod(
|
||||||
activityOnCreateClass.type,
|
activityOnCreateClass.type,
|
||||||
"finish",
|
if (isYouTubeMusic) "finish" else "onBackPressed",
|
||||||
emptyList(),
|
emptyList(),
|
||||||
"V",
|
"V",
|
||||||
AccessFlags.PUBLIC.value,
|
AccessFlags.PUBLIC.value,
|
||||||
@@ -283,13 +285,16 @@ internal fun modifyActivityForSettingsInjection(
|
|||||||
null,
|
null,
|
||||||
MutableMethodImplementation(3),
|
MutableMethodImplementation(3),
|
||||||
).toMutable().apply {
|
).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(
|
addInstructions(
|
||||||
"""
|
"""
|
||||||
invoke-static {}, $extensionClassType->handleFinish()Z
|
invoke-static {}, $extensionClassType->$extensionMethodName()Z
|
||||||
move-result v0
|
move-result v0
|
||||||
if-nez v0, :search_handled
|
if-nez v0, :search_handled
|
||||||
invoke-super { p0 }, Landroid/app/Activity;->finish()V
|
$invokeFinishOpcode { p0 }, Landroid/app/Activity;->finish()V
|
||||||
return-void
|
|
||||||
:search_handled
|
:search_handled
|
||||||
return-void
|
return-void
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user