mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2024-11-10 01:01:56 +01:00
feat(YouTube - Navigation buttons): Add option to hide navigation button labels (#3189)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
8ab9e8f89d
commit
f9dc705051
3 changed files with 50 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
package app.revanced.patches.youtube.layout.buttons.navigation
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
|
@ -12,11 +13,16 @@ import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen.Sor
|
|||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.layout.buttons.navigation.fingerprints.ANDROID_AUTOMOTIVE_STRING
|
||||
import app.revanced.patches.youtube.layout.buttons.navigation.fingerprints.AddCreateButtonViewFingerprint
|
||||
import app.revanced.patches.youtube.layout.buttons.navigation.fingerprints.CreatePivotBarFingerprint
|
||||
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.navigation.NavigationBarHookPatch
|
||||
import app.revanced.patches.youtube.misc.settings.SettingsPatch
|
||||
import app.revanced.util.exception
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
|
||||
@Patch(
|
||||
name = "Navigation buttons",
|
||||
|
@ -49,14 +55,17 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
|||
"19.08.36",
|
||||
"19.09.38",
|
||||
"19.10.39",
|
||||
"19.11.43"
|
||||
"19.11.43",
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
@Suppress("unused")
|
||||
object NavigationButtonsPatch : BytecodePatch(
|
||||
setOf(AddCreateButtonViewFingerprint),
|
||||
setOf(
|
||||
AddCreateButtonViewFingerprint,
|
||||
CreatePivotBarFingerprint,
|
||||
),
|
||||
) {
|
||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||
"Lapp/revanced/integrations/youtube/patches/NavigationButtonsPatch;"
|
||||
|
@ -74,6 +83,7 @@ object NavigationButtonsPatch : BytecodePatch(
|
|||
SwitchPreference("revanced_hide_create_button"),
|
||||
SwitchPreference("revanced_hide_subscriptions_button"),
|
||||
SwitchPreference("revanced_switch_create_with_notifications_button"),
|
||||
SwitchPreference("revanced_hide_navigation_labels"),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
@ -99,6 +109,21 @@ object NavigationButtonsPatch : BytecodePatch(
|
|||
}
|
||||
} ?: throw AddCreateButtonViewFingerprint.exception
|
||||
|
||||
// Hide navigation button labels.
|
||||
CreatePivotBarFingerprint.result?.mutableMethod?.apply {
|
||||
val setTextIndex = indexOfFirstInstruction {
|
||||
getReference<MethodReference>()?.name == "setText"
|
||||
}
|
||||
|
||||
val targetRegister = getInstruction<FiveRegisterInstruction>(setTextIndex).registerC
|
||||
|
||||
addInstruction(
|
||||
setTextIndex,
|
||||
"invoke-static { v$targetRegister }, " +
|
||||
"$INTEGRATIONS_CLASS_DESCRIPTOR->hideNavigationButtonLabels(Landroid/widget/TextView;)V",
|
||||
)
|
||||
} ?: throw CreatePivotBarFingerprint.exception
|
||||
|
||||
// Hook navigation button created, in order to hide them.
|
||||
NavigationBarHookPatch.hookNavigationButtonCreated(INTEGRATIONS_CLASS_DESCRIPTOR)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package app.revanced.patches.youtube.layout.buttons.navigation.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal object CreatePivotBarFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||
parameters = listOf(
|
||||
"Lcom/google/android/libraries/youtube/rendering/ui/pivotbar/PivotBar;",
|
||||
"Landroid/widget/TextView;",
|
||||
"Ljava/lang/CharSequence;",
|
||||
),
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.RETURN_VOID,
|
||||
),
|
||||
)
|
|
@ -437,6 +437,9 @@
|
|||
<string name="revanced_switch_create_with_notifications_button_title">Switch Create with Notifications</string>
|
||||
<string name="revanced_switch_create_with_notifications_button_summary_on">Create button is switched with Notifications button\n\nNote: Enabling this also forcibly hides video ads</string>
|
||||
<string name="revanced_switch_create_with_notifications_button_summary_off">Create button is not switched with Notifications button</string>
|
||||
<string name="revanced_hide_navigation_button_labels_title">Hide navigation button labels</string>
|
||||
<string name="revanced_hide_navigation_button_labels_summary_on">Labels are hidden</string>
|
||||
<string name="revanced_hide_navigation_button_labels_summary_off">Labels are shown</string>
|
||||
</patch>
|
||||
<patch id="layout.hide.player.flyoutmenupanel.HidePlayerFlyoutMenuPatch">
|
||||
<string name="revanced_hide_player_flyout_title">Flyout menu</string>
|
||||
|
|
Loading…
Reference in a new issue