mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-23 18:37:14 +02:00
feat(YouTube Music - Hide action bar components): Limit the available versions of the Override Download action button
setting to 7.16.53
This commit is contained in:
parent
8e02716d95
commit
f894327f0d
@ -7,10 +7,7 @@ import android.view.View;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import app.revanced.extension.music.settings.Settings;
|
import app.revanced.extension.music.settings.Settings;
|
||||||
import app.revanced.extension.music.utils.VideoUtils;
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class ActionBarPatch {
|
public class ActionBarPatch {
|
||||||
@ -42,41 +39,6 @@ public class ActionBarPatch {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String senderView = "com.google.android.libraries.youtube.rendering.elements.sender_view";
|
|
||||||
|
|
||||||
public static boolean inAppDownloadButtonOnClick(Map mMap) {
|
|
||||||
if (!Settings.EXTERNAL_DOWNLOADER_ACTION_BUTTON.get()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (mMap == null || mMap.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!mMap.containsKey(senderView)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!(getLithoViewFromMap(mMap, senderView, View.class) instanceof View view)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
VideoUtils.launchExternalDownloader();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rest of the implementation added by patch.
|
|
||||||
*/
|
|
||||||
private static Object getLithoViewFromMap(Map mMap, Object mObject, Class<?> mClass) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void inAppDownloadButtonOnClick(View view) {
|
|
||||||
if (!Settings.EXTERNAL_DOWNLOADER_ACTION_BUTTON.get()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buttonType.equals(ActionButton.DOWNLOAD.name))
|
|
||||||
view.setOnClickListener(imageView -> VideoUtils.launchExternalDownloader());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setButtonType(@NonNull Object obj) {
|
public static void setButtonType(@NonNull Object obj) {
|
||||||
final String buttonType = obj.toString();
|
final String buttonType = obj.toString();
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package app.revanced.patches.music.actionbar.components
|
package app.revanced.patches.music.actionbar.components
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
||||||
@ -24,7 +23,6 @@ import app.revanced.patches.music.utils.settings.settingsPatch
|
|||||||
import app.revanced.patches.music.video.information.videoInformationPatch
|
import app.revanced.patches.music.video.information.videoInformationPatch
|
||||||
import app.revanced.patches.shared.litho.addLithoFilter
|
import app.revanced.patches.shared.litho.addLithoFilter
|
||||||
import app.revanced.patches.shared.litho.lithoFilterPatch
|
import app.revanced.patches.shared.litho.lithoFilterPatch
|
||||||
import app.revanced.util.findMethodOrThrow
|
|
||||||
import app.revanced.util.fingerprint.matchOrThrow
|
import app.revanced.util.fingerprint.matchOrThrow
|
||||||
import app.revanced.util.fingerprint.methodOrThrow
|
import app.revanced.util.fingerprint.methodOrThrow
|
||||||
import app.revanced.util.getReference
|
import app.revanced.util.getReference
|
||||||
@ -58,32 +56,6 @@ val actionBarComponentsPatch = bytecodePatch(
|
|||||||
|
|
||||||
execute {
|
execute {
|
||||||
if (is_7_17_or_greater) {
|
if (is_7_17_or_greater) {
|
||||||
browseSectionListReloadEndpointFingerprint.methodOrThrow().apply {
|
|
||||||
val targetIndex = indexOfGetLithoViewFromMapInstruction(this)
|
|
||||||
val targetReference = getInstruction<ReferenceInstruction>(targetIndex).reference
|
|
||||||
|
|
||||||
findMethodOrThrow(ACTIONBAR_CLASS_DESCRIPTOR) {
|
|
||||||
name == "getLithoViewFromMap"
|
|
||||||
}.addInstructions(
|
|
||||||
0, """
|
|
||||||
invoke-static {p0, p1, p2}, $targetReference
|
|
||||||
move-result-object p1
|
|
||||||
return-object p1
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
offlineVideoEndpointFingerprint.methodOrThrow().apply {
|
|
||||||
addInstructionsWithLabels(
|
|
||||||
0, """
|
|
||||||
invoke-static {p2}, $ACTIONBAR_CLASS_DESCRIPTOR->inAppDownloadButtonOnClick(Ljava/util/Map;)Z
|
|
||||||
move-result v0
|
|
||||||
if-eqz v0, :ignore
|
|
||||||
return-void
|
|
||||||
""", ExternalLabel("ignore", getInstruction(0))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
addLithoFilter(FILTER_CLASS_DESCRIPTOR)
|
addLithoFilter(FILTER_CLASS_DESCRIPTOR)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,17 +195,17 @@ val actionBarComponentsPatch = bytecodePatch(
|
|||||||
"revanced_hide_action_button_label",
|
"revanced_hide_action_button_label",
|
||||||
"false"
|
"false"
|
||||||
)
|
)
|
||||||
|
addSwitchPreference(
|
||||||
|
CategoryType.ACTION_BAR,
|
||||||
|
"revanced_external_downloader_action",
|
||||||
|
"false"
|
||||||
|
)
|
||||||
|
addPreferenceWithIntent(
|
||||||
|
CategoryType.ACTION_BAR,
|
||||||
|
"revanced_external_downloader_package_name",
|
||||||
|
"revanced_external_downloader_action"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
addSwitchPreference(
|
|
||||||
CategoryType.ACTION_BAR,
|
|
||||||
"revanced_external_downloader_action",
|
|
||||||
"false"
|
|
||||||
)
|
|
||||||
addPreferenceWithIntent(
|
|
||||||
CategoryType.ACTION_BAR,
|
|
||||||
"revanced_external_downloader_package_name",
|
|
||||||
"revanced_external_downloader_action"
|
|
||||||
)
|
|
||||||
|
|
||||||
updatePatchStatus(HIDE_ACTION_BAR_COMPONENTS)
|
updatePatchStatus(HIDE_ACTION_BAR_COMPONENTS)
|
||||||
|
|
||||||
|
@ -2,13 +2,9 @@ package app.revanced.patches.music.actionbar.components
|
|||||||
|
|
||||||
import app.revanced.patches.music.utils.resourceid.likeDislikeContainer
|
import app.revanced.patches.music.utils.resourceid.likeDislikeContainer
|
||||||
import app.revanced.util.fingerprint.legacyFingerprint
|
import app.revanced.util.fingerprint.legacyFingerprint
|
||||||
import app.revanced.util.getReference
|
|
||||||
import app.revanced.util.indexOfFirstInstruction
|
|
||||||
import app.revanced.util.or
|
import app.revanced.util.or
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
import com.android.tools.smali.dexlib2.iface.Method
|
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
|
||||||
|
|
||||||
internal val actionBarComponentFingerprint = legacyFingerprint(
|
internal val actionBarComponentFingerprint = legacyFingerprint(
|
||||||
name = "actionBarComponentFingerprint",
|
name = "actionBarComponentFingerprint",
|
||||||
@ -26,40 +22,9 @@ internal val actionBarComponentFingerprint = legacyFingerprint(
|
|||||||
literals = listOf(99180L),
|
literals = listOf(99180L),
|
||||||
)
|
)
|
||||||
|
|
||||||
internal val browseSectionListReloadEndpointFingerprint = legacyFingerprint(
|
|
||||||
name = "browseSectionListReloadEndpointFingerprint",
|
|
||||||
returnType = "V",
|
|
||||||
parameters = listOf("L", "Ljava/util/Map;"),
|
|
||||||
strings = listOf("request_mutator"),
|
|
||||||
customFingerprint = { method, _ ->
|
|
||||||
indexOfGetLithoViewFromMapInstruction(method) >= 0
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
internal fun indexOfGetLithoViewFromMapInstruction(method: Method) =
|
|
||||||
method.indexOfFirstInstruction {
|
|
||||||
val reference = getReference<MethodReference>()
|
|
||||||
opcode == Opcode.INVOKE_STATIC &&
|
|
||||||
reference?.returnType == "Ljava/lang/Object;" &&
|
|
||||||
reference.parameterTypes ==
|
|
||||||
listOf(
|
|
||||||
"Ljava/util/Map;",
|
|
||||||
"Ljava/lang/Object;",
|
|
||||||
"Ljava/lang/Class;"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
internal val likeDislikeContainerFingerprint = legacyFingerprint(
|
internal val likeDislikeContainerFingerprint = legacyFingerprint(
|
||||||
name = "likeDislikeContainerFingerprint",
|
name = "likeDislikeContainerFingerprint",
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||||
literals = listOf(likeDislikeContainer)
|
literals = listOf(likeDislikeContainer)
|
||||||
)
|
)
|
||||||
|
|
||||||
internal val offlineVideoEndpointFingerprint = legacyFingerprint(
|
|
||||||
name = "offlineVideoEndpointFingerprint",
|
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
|
||||||
returnType = "V",
|
|
||||||
parameters = listOf("L", "Ljava/util/Map;"),
|
|
||||||
strings = listOf("Object is not an offlineable video: %s")
|
|
||||||
)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user