add hide-navigation-label patch

This commit is contained in:
inotia00 2023-05-03 23:58:27 +09:00
parent 373c1d7b7e
commit 3bc99a4a97
4 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,23 @@
package app.revanced.patches.youtube.layout.navigation.label.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object PivotBarSetTextFingerprint : MethodFingerprint(
returnType = "V",
access = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
parameters = listOf("L", "L", "L"),
opcodes = listOf(
Opcode.IPUT_OBJECT,
Opcode.INVOKE_DIRECT,
Opcode.INVOKE_VIRTUAL,
Opcode.IPUT_OBJECT,
Opcode.MOVE_OBJECT,
Opcode.CHECK_CAST,
Opcode.INVOKE_VIRTUAL,
Opcode.RETURN_VOID
),
customFingerprint = { it.name == "<init>" }
)

View File

@ -0,0 +1,63 @@
package app.revanced.patches.youtube.layout.navigation.label.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.navigation.label.fingerprints.PivotBarSetTextFingerprint
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.NAVIGATION
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
@Patch
@Name("hide-navigation-label")
@Description("Hide navigation bar labels.")
@DependsOn([SettingsPatch::class])
@YouTubeCompatibility
@Version("0.0.1")
class NavigationLabelPatch : BytecodePatch(
listOf(
PivotBarSetTextFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
PivotBarSetTextFingerprint.result?.let {
with (it.mutableMethod) {
val targetIndex = it.scanResult.patternScanResult!!.endIndex - 2
val targetReference = (instruction(targetIndex) as ReferenceInstruction).reference.toString()
if (targetReference != "Landroid/widget/TextView;")
return PivotBarSetTextFingerprint.toErrorResult()
val targetRegister = (instruction(targetIndex) as OneRegisterInstruction).registerA
addInstruction(
targetIndex + 1,
"invoke-static {v$targetRegister}, $NAVIGATION->hideNavigationLabel(Landroid/widget/TextView;)V"
)
}
} ?: return PivotBarSetTextFingerprint.toErrorResult()
/**
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: NAVIGATION_SETTINGS",
"SETTINGS: HIDE_NAVIGATION_LABEL"
)
)
SettingsPatch.updatePatchStatus("hide-navigation-label")
return PatchResultSuccess()
}
}

View File

@ -310,6 +310,9 @@ Please do not report any issues you encounter while using this feature."</string
<string name="revanced_hide_latest_posts_summary_off">Latest posts are shown</string> <string name="revanced_hide_latest_posts_summary_off">Latest posts are shown</string>
<string name="revanced_hide_latest_posts_summary_on">Latest posts are hidden</string> <string name="revanced_hide_latest_posts_summary_on">Latest posts are hidden</string>
<string name="revanced_hide_latest_posts_title">Hide latest posts</string> <string name="revanced_hide_latest_posts_title">Hide latest posts</string>
<string name="revanced_hide_navigation_label_summary_off">Navigation label is shown</string>
<string name="revanced_hide_navigation_label_summary_on">Navigation label is hidden</string>
<string name="revanced_hide_navigation_label_title">Hide navigation label</string>
<string name="revanced_hide_medical_panel_summary_off">Medical panels are shown</string> <string name="revanced_hide_medical_panel_summary_off">Medical panels are shown</string>
<string name="revanced_hide_medical_panel_summary_on">Medical panels are hidden</string> <string name="revanced_hide_medical_panel_summary_on">Medical panels are hidden</string>
<string name="revanced_hide_medical_panel_title">Hide medical panels</string> <string name="revanced_hide_medical_panel_title">Hide medical panels</string>

View File

@ -330,6 +330,9 @@
<SwitchPreference android:title="@string/revanced_hide_shorts_button_title" android:key="revanced_hide_shorts_button" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_button_summary_on" android:summaryOff="@string/revanced_hide_shorts_button_summary_off" /> <SwitchPreference android:title="@string/revanced_hide_shorts_button_title" android:key="revanced_hide_shorts_button" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_button_summary_on" android:summaryOff="@string/revanced_hide_shorts_button_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_subscriptions_button_title" android:key="revanced_hide_subscriptions_button" android:defaultValue="false" android:summaryOn="@string/revanced_hide_subscriptions_button_summary_on" android:summaryOff="@string/revanced_hide_subscriptions_button_summary_off" />SETTINGS: HIDE_NAVIGATION_BUTTONS --> <SwitchPreference android:title="@string/revanced_hide_subscriptions_button_title" android:key="revanced_hide_subscriptions_button" android:defaultValue="false" android:summaryOn="@string/revanced_hide_subscriptions_button_summary_on" android:summaryOff="@string/revanced_hide_subscriptions_button_summary_off" />SETTINGS: HIDE_NAVIGATION_BUTTONS -->
<!-- SETTINGS: HIDE_NAVIGATION_LABEL
<SwitchPreference android:title="@string/revanced_hide_navigation_label_title" android:key="revanced_hide_navigation_label" android:defaultValue="false" android:summaryOn="@string/revanced_hide_navigation_label_summary_on" android:summaryOff="@string/revanced_hide_navigation_label_summary_off" />SETTINGS: HIDE_NAVIGATION_LABEL -->
<!-- SETTINGS: HIDE_SHORTS_NAVIGATION_BAR <!-- SETTINGS: HIDE_SHORTS_NAVIGATION_BAR
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_experimental_flag" /> <Preference android:title=" " android:selectable="false" android:summary="@string/revanced_experimental_flag" />
<SwitchPreference android:title="@string/revanced_hide_shorts_navigation_bar_title" android:key="revanced_hide_shorts_navigation_bar" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_navigation_bar_summary_on" android:summaryOff="@string/revanced_hide_shorts_navigation_bar_summary_off" />SETTINGS: HIDE_SHORTS_NAVIGATION_BAR --> <SwitchPreference android:title="@string/revanced_hide_shorts_navigation_bar_title" android:key="revanced_hide_shorts_navigation_bar" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_navigation_bar_summary_on" android:summaryOff="@string/revanced_hide_shorts_navigation_bar_summary_off" />SETTINGS: HIDE_SHORTS_NAVIGATION_BAR -->
@ -514,6 +517,7 @@
<Preference android:title="change-homepage" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="change-homepage" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="enable-tablet-navigation-bar" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="enable-tablet-navigation-bar" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="hide-navigation-buttons" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="hide-navigation-buttons" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="hide-navigation-label" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="hide-shorts-navbar" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="hide-shorts-navbar" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_seekbar" /> <Preference android:title=" " android:selectable="false" android:summary="@string/revanced_seekbar" />