mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-04-29 14:14:36 +02:00
fix(YouTube - Shorts components): Custom actions
do not override Shorts flyout menu in YouTube 19.05.36
This commit is contained in:
parent
aac38dc8af
commit
88d59d05b9
@ -155,6 +155,34 @@ public final class CustomActionsPatch {
|
||||
Logger.printInfo(() -> customAction.name() + bottomSheetMenuClass + bottomSheetMenuList + bottomSheetMenuObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
public static boolean onBottomSheetMenuItemClick(View view) {
|
||||
try {
|
||||
if (view instanceof ViewGroup viewGroup) {
|
||||
TextView textView = Utils.getChildView(viewGroup, v -> v instanceof TextView);
|
||||
if (textView != null) {
|
||||
String menuTitle = textView.getText().toString();
|
||||
for (CustomAction customAction : CustomAction.values()) {
|
||||
if (customAction.getLabel().equals(menuTitle)) {
|
||||
View.OnLongClickListener onLongClick = customAction.getOnLongClickListener();
|
||||
if (onLongClick != null) {
|
||||
view.setOnLongClickListener(onLongClick);
|
||||
}
|
||||
customAction.getOnClickAction().run();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Logger.printException(() -> "onBottomSheetMenuItemClick failed");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
@ -179,8 +207,9 @@ public final class CustomActionsPatch {
|
||||
if (recyclerView.getChildAt(childCount - i - 1) instanceof ViewGroup parentViewGroup) {
|
||||
childCount = recyclerView.getChildCount();
|
||||
if (childCount > 3 && parentViewGroup.getChildAt(1) instanceof TextView textView) {
|
||||
String menuTitle = textView.getText().toString();
|
||||
for (CustomAction customAction : CustomAction.values()) {
|
||||
if (customAction.getLabel().equals(textView.getText().toString())) {
|
||||
if (customAction.getLabel().equals(menuTitle)) {
|
||||
View.OnClickListener onClick = customAction.getOnClickListener();
|
||||
View.OnLongClickListener onLongClick = customAction.getOnLongClickListener();
|
||||
recyclerViewRef = new WeakReference<>(recyclerView);
|
||||
|
@ -24,6 +24,34 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
import kotlin.collections.listOf
|
||||
|
||||
internal val bottomSheetMenuDismissFingerprint = legacyFingerprint(
|
||||
name = "bottomSheetMenuDismissFingerprint",
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = emptyList(),
|
||||
customFingerprint = { method, _ ->
|
||||
indexOfDismissInstruction(method) >= 0
|
||||
}
|
||||
)
|
||||
|
||||
fun indexOfDismissInstruction(method: Method) =
|
||||
method.indexOfFirstInstruction {
|
||||
val reference = getReference<MethodReference>()
|
||||
reference?.name == "dismiss" &&
|
||||
reference.returnType == "V" &&
|
||||
reference.parameterTypes.isEmpty()
|
||||
}
|
||||
|
||||
internal val bottomSheetMenuItemClickFingerprint = legacyFingerprint(
|
||||
name = "bottomSheetMenuItemClickFingerprint",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
returnType = "V",
|
||||
parameters = listOf("Landroid/widget/AdapterView;", "Landroid/view/View;", "I", "J"),
|
||||
customFingerprint = { method, _ ->
|
||||
method.name == "onItemClick"
|
||||
}
|
||||
)
|
||||
|
||||
internal val bottomSheetMenuListBuilderFingerprint = legacyFingerprint(
|
||||
name = "bottomSheetMenuListBuilderFingerprint",
|
||||
returnType = "L",
|
||||
|
@ -35,6 +35,7 @@ import app.revanced.patches.youtube.utils.playservice.is_18_31_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.is_18_34_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.is_18_49_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.is_19_02_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.is_19_11_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.is_19_25_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.is_19_28_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.is_19_34_or_greater
|
||||
@ -74,7 +75,6 @@ import app.revanced.patches.youtube.video.videoid.hookPlayerResponseVideoId
|
||||
import app.revanced.patches.youtube.video.videoid.videoIdPatch
|
||||
import app.revanced.util.REGISTER_TEMPLATE_REPLACEMENT
|
||||
import app.revanced.util.ResourceGroup
|
||||
import app.revanced.util.addEntryValues
|
||||
import app.revanced.util.cloneMutable
|
||||
import app.revanced.util.copyResources
|
||||
import app.revanced.util.findMethodOrThrow
|
||||
@ -339,7 +339,30 @@ private val shortsCustomActionsPatch = bytecodePatch(
|
||||
}
|
||||
}
|
||||
|
||||
recyclerViewTreeObserverHook("$EXTENSION_CUSTOM_ACTIONS_CLASS_DESCRIPTOR->onFlyoutMenuCreate(Landroid/support/v7/widget/RecyclerView;)V")
|
||||
if (is_19_11_or_greater) {
|
||||
// The type of the Shorts flyout menu is RecyclerView.
|
||||
recyclerViewTreeObserverHook("$EXTENSION_CUSTOM_ACTIONS_CLASS_DESCRIPTOR->onFlyoutMenuCreate(Landroid/support/v7/widget/RecyclerView;)V")
|
||||
} else {
|
||||
// The type of the Shorts flyout menu is ListView.
|
||||
val dismissReference = with (bottomSheetMenuDismissFingerprint.methodOrThrow(bottomSheetMenuListBuilderFingerprint)) {
|
||||
val dismissIndex = indexOfDismissInstruction(this)
|
||||
getInstruction<ReferenceInstruction>(dismissIndex).reference
|
||||
}
|
||||
|
||||
bottomSheetMenuItemClickFingerprint
|
||||
.methodOrThrow(bottomSheetMenuListBuilderFingerprint)
|
||||
.addInstructionsWithLabels(
|
||||
0, """
|
||||
invoke-static/range {p2 .. p2}, $EXTENSION_CUSTOM_ACTIONS_CLASS_DESCRIPTOR->onBottomSheetMenuItemClick(Landroid/view/View;)Z
|
||||
move-result v0
|
||||
if-eqz v0, :ignore
|
||||
invoke-virtual {p0}, $dismissReference
|
||||
return-void
|
||||
:ignore
|
||||
nop
|
||||
""",
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
|
@ -25,6 +25,8 @@ var is_19_05_or_greater = false
|
||||
private set
|
||||
var is_19_09_or_greater = false
|
||||
private set
|
||||
var is_19_11_or_greater = false
|
||||
private set
|
||||
var is_19_15_or_greater = false
|
||||
private set
|
||||
var is_19_16_or_greater = false
|
||||
@ -100,6 +102,7 @@ val versionCheckPatch = resourcePatch(
|
||||
is_19_04_or_greater = 240502000 <= playStoreServicesVersion
|
||||
is_19_05_or_greater = 240602000 <= playStoreServicesVersion
|
||||
is_19_09_or_greater = 241002000 <= playStoreServicesVersion
|
||||
is_19_11_or_greater = 241199000 <= playStoreServicesVersion
|
||||
is_19_15_or_greater = 241602000 <= playStoreServicesVersion
|
||||
is_19_16_or_greater = 241702000 <= playStoreServicesVersion
|
||||
is_19_17_or_greater = 241802000 <= playStoreServicesVersion
|
||||
|
Loading…
x
Reference in New Issue
Block a user