feat(YouTube/Navigation bar components): add Enable translucent navigation bar settings https://github.com/inotia00/ReVanced_Extended/issues/2177

This commit is contained in:
inotia00
2024-06-23 14:18:48 +09:00
parent 8186e9c8b2
commit 26479a205c
4 changed files with 41 additions and 8 deletions

View File

@ -8,12 +8,14 @@ import app.revanced.patches.youtube.general.navigation.fingerprints.AutoMotiveFi
import app.revanced.patches.youtube.general.navigation.fingerprints.PivotBarChangedFingerprint import app.revanced.patches.youtube.general.navigation.fingerprints.PivotBarChangedFingerprint
import app.revanced.patches.youtube.general.navigation.fingerprints.PivotBarSetTextFingerprint import app.revanced.patches.youtube.general.navigation.fingerprints.PivotBarSetTextFingerprint
import app.revanced.patches.youtube.general.navigation.fingerprints.PivotBarStyleFingerprint import app.revanced.patches.youtube.general.navigation.fingerprints.PivotBarStyleFingerprint
import app.revanced.patches.youtube.general.navigation.fingerprints.TranslucentNavigationBarFingerprint
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.navigation.NavigationBarHookPatch import app.revanced.patches.youtube.utils.navigation.NavigationBarHookPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.getStringInstructionIndex import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
import app.revanced.util.literalInstructionBooleanHook
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@ -32,11 +34,30 @@ object NavigationBarComponentsPatch : BaseBytecodePatch(
AutoMotiveFingerprint, AutoMotiveFingerprint,
PivotBarChangedFingerprint, PivotBarChangedFingerprint,
PivotBarSetTextFingerprint, PivotBarSetTextFingerprint,
PivotBarStyleFingerprint PivotBarStyleFingerprint,
TranslucentNavigationBarFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
var settingArray = arrayOf(
"PREFERENCE_SCREEN: GENERAL",
"SETTINGS: HIDE_NAVIGATION_COMPONENTS"
)
// region patch for enable translucent navigation bar
if (SettingsPatch.upward1923) {
TranslucentNavigationBarFingerprint.literalInstructionBooleanHook(
45630927,
"$GENERAL_CLASS_DESCRIPTOR->enableTranslucentNavigationBar()Z"
)
settingArray += "SETTINGS: TRANSLUCENT_NAVIGATION_BAR"
}
// endregion
// region patch for enable narrow navigation buttons // region patch for enable narrow navigation buttons
arrayOf( arrayOf(
@ -101,12 +122,7 @@ object NavigationBarComponentsPatch : BaseBytecodePatch(
/** /**
* Add settings * Add settings
*/ */
SettingsPatch.addPreference( SettingsPatch.addPreference(settingArray)
arrayOf(
"PREFERENCE_SCREEN: GENERAL",
"SETTINGS: HIDE_NAVIGATION_COMPONENTS"
)
)
SettingsPatch.updatePatchStatus(this) SettingsPatch.updatePatchStatus(this)
} }

View File

@ -0,0 +1,7 @@
package app.revanced.patches.youtube.general.navigation.fingerprints
import app.revanced.util.fingerprint.LiteralValueFingerprint
internal object TranslucentNavigationBarFingerprint : LiteralValueFingerprint(
literalSupplier = { 45630927 }
)

View File

@ -428,6 +428,10 @@ Some components may not be hidden."</string>
• Disabling this setting loads more ads from the server side. • Disabling this setting loads more ads from the server side.
• You should disable this setting to make video ads visible."</string> • You should disable this setting to make video ads visible."</string>
<string name="revanced_enable_translucent_navigation_bar_title">Enable translucent navigation bar</string>
<string name="revanced_enable_translucent_navigation_bar_summary_on">Navigation bar is translucent.</string>
<string name="revanced_enable_translucent_navigation_bar_summary_off">Navigation bar is opaque.</string>
<!-- PreferenceScreen: General, PreferenceCategory: General, PreferenceScreen: Settings menu --> <!-- PreferenceScreen: General, PreferenceCategory: General, PreferenceScreen: Settings menu -->
<string name="revanced_preference_screen_settings_menu_title">Settings menu</string> <string name="revanced_preference_screen_settings_menu_title">Settings menu</string>
<string name="revanced_preference_screen_settings_menu_summary">Hide elements of the YouTube settings menu.</string> <string name="revanced_preference_screen_settings_menu_summary">Hide elements of the YouTube settings menu.</string>

View File

@ -143,7 +143,13 @@
<SwitchPreference android:title="@string/revanced_hide_navigation_shorts_button_title" android:key="revanced_hide_navigation_shorts_button" android:summaryOn="@string/revanced_hide_navigation_shorts_button_summary_on" android:summaryOff="@string/revanced_hide_navigation_shorts_button_summary_off" /> <SwitchPreference android:title="@string/revanced_hide_navigation_shorts_button_title" android:key="revanced_hide_navigation_shorts_button" android:summaryOn="@string/revanced_hide_navigation_shorts_button_summary_on" android:summaryOff="@string/revanced_hide_navigation_shorts_button_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_navigation_subscriptions_button_title" android:key="revanced_hide_navigation_subscriptions_button" android:summaryOn="@string/revanced_hide_navigation_subscriptions_button_summary_on" android:summaryOff="@string/revanced_hide_navigation_subscriptions_button_summary_off" /> <SwitchPreference android:title="@string/revanced_hide_navigation_subscriptions_button_title" android:key="revanced_hide_navigation_subscriptions_button" android:summaryOn="@string/revanced_hide_navigation_subscriptions_button_summary_on" android:summaryOff="@string/revanced_hide_navigation_subscriptions_button_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_navigation_label_title" android:key="revanced_hide_navigation_label" android:summaryOn="@string/revanced_hide_navigation_label_summary_on" android:summaryOff="@string/revanced_hide_navigation_label_summary_off" /> <SwitchPreference android:title="@string/revanced_hide_navigation_label_title" android:key="revanced_hide_navigation_label" android:summaryOn="@string/revanced_hide_navigation_label_summary_on" android:summaryOff="@string/revanced_hide_navigation_label_summary_off" />
<SwitchPreference android:title="@string/revanced_switch_create_with_notifications_button_title" android:key="revanced_switch_create_with_notifications_button" android:summary="@string/revanced_switch_create_with_notifications_button_summary" /> <SwitchPreference android:title="@string/revanced_switch_create_with_notifications_button_title" android:key="revanced_switch_create_with_notifications_button" android:summary="@string/revanced_switch_create_with_notifications_button_summary" />SETTINGS: HIDE_NAVIGATION_COMPONENTS -->
<!-- SETTINGS: TRANSLUCENT_NAVIGATION_BAR
<PreferenceCategory android:title="@string/revanced_preference_category_experimental_flag" android:layout="@layout/revanced_settings_preferences_category"/>
<SwitchPreference android:title="@string/revanced_enable_translucent_navigation_bar_title" android:key="revanced_enable_translucent_navigation_bar" android:summaryOn="@string/revanced_enable_translucent_navigation_bar_summary_on" android:summaryOff="@string/revanced_enable_translucent_navigation_bar_summary_off" />SETTINGS: TRANSLUCENT_NAVIGATION_BAR -->
<!-- SETTINGS: HIDE_NAVIGATION_COMPONENTS
</PreferenceScreen>SETTINGS: HIDE_NAVIGATION_COMPONENTS --> </PreferenceScreen>SETTINGS: HIDE_NAVIGATION_COMPONENTS -->
<!-- SETTINGS: HIDE_LAYOUT_COMPONENTS <!-- SETTINGS: HIDE_LAYOUT_COMPONENTS