mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2026-01-11 13:46:17 +00:00
fix(YouTube Music - Hide category bar): Correctly hide the category bar in newer app targets (#6175)
This commit is contained in:
@@ -19,6 +19,6 @@ public class HideCastButtonPatch {
|
|||||||
* Injection point
|
* Injection point
|
||||||
*/
|
*/
|
||||||
public static void hideCastButton(View view) {
|
public static void hideCastButton(View view) {
|
||||||
hideViewBy0dpUnderCondition(Settings.HIDE_CAST_BUTTON.get(), view);
|
hideViewBy0dpUnderCondition(Settings.HIDE_CAST_BUTTON, view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package app.revanced.extension.music.patches;
|
package app.revanced.extension.music.patches;
|
||||||
|
|
||||||
|
import static app.revanced.extension.shared.Utils.hideViewBy0dpUnderCondition;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
import app.revanced.extension.music.settings.Settings;
|
import app.revanced.extension.music.settings.Settings;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@@ -8,7 +11,7 @@ public class HideCategoryBarPatch {
|
|||||||
/**
|
/**
|
||||||
* Injection point
|
* Injection point
|
||||||
*/
|
*/
|
||||||
public static boolean hideCategoryBar() {
|
public static void hideCategoryBar(View view) {
|
||||||
return Settings.HIDE_CATEGORY_BAR.get();
|
hideViewBy0dpUnderCondition(Settings.HIDE_CATEGORY_BAR, view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,16 @@
|
|||||||
package app.revanced.patches.music.layout.compactheader
|
package app.revanced.patches.music.layout.compactheader
|
||||||
|
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
|
||||||
import app.revanced.patcher.fingerprint
|
import app.revanced.patcher.fingerprint
|
||||||
|
import app.revanced.util.literal
|
||||||
|
|
||||||
internal val constructCategoryBarFingerprint = fingerprint {
|
internal val chipCloudFingerprint = fingerprint {
|
||||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
|
|
||||||
returns("V")
|
returns("V")
|
||||||
parameters("Landroid/content/Context;", "L", "L", "L")
|
|
||||||
opcodes(
|
opcodes(
|
||||||
Opcode.IPUT_OBJECT,
|
|
||||||
Opcode.CONST,
|
Opcode.CONST,
|
||||||
Opcode.INVOKE_VIRTUAL,
|
Opcode.CONST_4,
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
Opcode.INVOKE_STATIC,
|
||||||
Opcode.IPUT_OBJECT,
|
Opcode.MOVE_RESULT_OBJECT
|
||||||
Opcode.CONST,
|
|
||||||
Opcode.INVOKE_VIRTUAL
|
|
||||||
)
|
)
|
||||||
|
literal { chipCloud }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package app.revanced.patches.music.layout.compactheader
|
package app.revanced.patches.music.layout.compactheader
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.patch.bytecodePatch
|
import app.revanced.patcher.patch.bytecodePatch
|
||||||
import app.revanced.patches.all.misc.resources.addResources
|
import app.revanced.patches.all.misc.resources.addResources
|
||||||
@@ -8,10 +8,14 @@ import app.revanced.patches.all.misc.resources.addResourcesPatch
|
|||||||
import app.revanced.patches.music.misc.extension.sharedExtensionPatch
|
import app.revanced.patches.music.misc.extension.sharedExtensionPatch
|
||||||
import app.revanced.patches.music.misc.settings.PreferenceScreen
|
import app.revanced.patches.music.misc.settings.PreferenceScreen
|
||||||
import app.revanced.patches.music.misc.settings.settingsPatch
|
import app.revanced.patches.music.misc.settings.settingsPatch
|
||||||
|
import app.revanced.patches.shared.misc.mapping.get
|
||||||
|
import app.revanced.patches.shared.misc.mapping.resourceMappings
|
||||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||||
import app.revanced.util.findFreeRegister
|
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
|
internal var chipCloud = -1L
|
||||||
|
private set
|
||||||
|
|
||||||
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/music/patches/HideCategoryBarPatch;"
|
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/music/patches/HideCategoryBarPatch;"
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
@@ -33,28 +37,21 @@ val hideCategoryBar = bytecodePatch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
execute {
|
execute {
|
||||||
|
chipCloud = resourceMappings["layout", "chip_cloud"]
|
||||||
|
|
||||||
addResources("music", "layout.compactheader.hideCategoryBar")
|
addResources("music", "layout.compactheader.hideCategoryBar")
|
||||||
|
|
||||||
PreferenceScreen.GENERAL.addPreferences(
|
PreferenceScreen.GENERAL.addPreferences(
|
||||||
SwitchPreference("revanced_music_hide_category_bar"),
|
SwitchPreference("revanced_music_hide_category_bar"),
|
||||||
)
|
)
|
||||||
|
|
||||||
constructCategoryBarFingerprint.method.apply {
|
chipCloudFingerprint.method.apply {
|
||||||
val insertIndex = constructCategoryBarFingerprint.patternMatch!!.startIndex
|
val targetIndex = chipCloudFingerprint.patternMatch!!.endIndex
|
||||||
val register = getInstruction<OneRegisterInstruction>(insertIndex - 1).registerA
|
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||||
val freeRegister = findFreeRegister(insertIndex, register)
|
|
||||||
|
|
||||||
addInstructionsWithLabels(
|
addInstruction(
|
||||||
insertIndex,
|
targetIndex + 1,
|
||||||
"""
|
"invoke-static { v$targetRegister }, $EXTENSION_CLASS_DESCRIPTOR->hideCategoryBar(Landroid/view/View;)V"
|
||||||
invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->hideCategoryBar()Z
|
|
||||||
move-result v$freeRegister
|
|
||||||
if-eqz v$freeRegister, :show
|
|
||||||
const/16 v$freeRegister, 0x8
|
|
||||||
invoke-virtual { v$register, v$freeRegister }, Landroid/view/View;->setVisibility(I)V
|
|
||||||
:show
|
|
||||||
nop
|
|
||||||
"""
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user