add switch-create-notification patch

This commit is contained in:
inotia00
2023-03-04 02:37:57 +09:00
parent 808e2f31f9
commit cec926569f
4 changed files with 84 additions and 0 deletions

View File

@ -0,0 +1,14 @@
package app.revanced.patches.youtube.layout.general.pivotbar.switchbutton.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
object AutoMotiveFingerprint : MethodFingerprint(
opcodes = listOf(
Opcode.GOTO,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT,
Opcode.IF_EQZ
),
strings = listOf("Android Automotive")
)

View File

@ -0,0 +1,60 @@
package app.revanced.patches.youtube.layout.general.pivotbar.switchbutton.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.addInstructions
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.general.pivotbar.switchbutton.fingerprints.AutoMotiveFingerprint
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Patch
@Name("switch-create-notification")
@Description("Switching the create button and notification button.")
@DependsOn([SettingsPatch::class])
@YouTubeCompatibility
@Version("0.0.1")
class SwitchCreateButtonPatch : BytecodePatch(
listOf(AutoMotiveFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
AutoMotiveFingerprint.result?.let {
with (it.mutableMethod) {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
val register = (instruction(insertIndex) as OneRegisterInstruction).registerA
addInstructions(
insertIndex, """
invoke-static {v$register}, $GENERAL_LAYOUT->switchCreateNotification(Z)Z
move-result v$register
"""
)
}
} ?: return AutoMotiveFingerprint.toErrorResult()
/*
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"SETTINGS: SWITCH_CREATE_NOTIFICATION"
)
)
SettingsPatch.updatePatchStatus("switch-create-notification")
return PatchResultSuccess()
}
}

View File

@ -489,6 +489,8 @@ In the app settings, the YouTube version may be marked as v17.28.35"</string>
If you enable this setting, the following features are available: If you enable this setting, the following features are available:
- Community Posts - Community Posts
- Hide Mix playlist"</string> - Hide Mix playlist"</string>
<string name="revanced_reboot_warning_switch">"If you enable this setting, the following features are not available:
- Ambient mode"</string>
<string name="revanced_reboot_warning_tablet">"Tricks the dpi to change some layouts to tablet layouts. <string name="revanced_reboot_warning_tablet">"Tricks the dpi to change some layouts to tablet layouts.
If you enable this setting, the following features are not available: If you enable this setting, the following features are not available:
@ -527,6 +529,9 @@ Since these setting is quite outdated, it may not be valid"</string>
<string name="revanced_swipe_overlay_text_size_title">Swipe overlay text size</string> <string name="revanced_swipe_overlay_text_size_title">Swipe overlay text size</string>
<string name="revanced_swipe_overlay_timeout_summary">The amount of milliseconds the overlay is visible</string> <string name="revanced_swipe_overlay_timeout_summary">The amount of milliseconds the overlay is visible</string>
<string name="revanced_swipe_overlay_timeout_title">Swipe overlay timeout</string> <string name="revanced_swipe_overlay_timeout_title">Swipe overlay timeout</string>
<string name="revanced_switching_create_notification_summary_off">Create button and notification button not switching</string>
<string name="revanced_switching_create_notification_summary_on">Create button and notification button are switched</string>
<string name="revanced_switching_create_notification_title">Switching the create button and notification button</string>
<string name="revanced_tool_used">Tool used</string> <string name="revanced_tool_used">Tool used</string>
<string name="revanced_video_ads_removal_summary_off">Video ads are shown</string> <string name="revanced_video_ads_removal_summary_off">Video ads are shown</string>
<string name="revanced_video_ads_removal_summary_on">Video ads are hidden</string> <string name="revanced_video_ads_removal_summary_on">Video ads are hidden</string>

View File

@ -145,6 +145,10 @@
<!-- SETTINGS: HEADER_SWITCH <!-- SETTINGS: HEADER_SWITCH
<SwitchPreference android:title="@string/revanced_override_premium_header_title" android:key="revanced_override_premium_header" android:defaultValue="false" android:summaryOn="@string/revanced_override_premium_header_summary_on" android:summaryOff="@string/revanced_override_premium_header_summary_off" />SETTINGS: HEADER_SWITCH --> <SwitchPreference android:title="@string/revanced_override_premium_header_title" android:key="revanced_override_premium_header" android:defaultValue="false" android:summaryOn="@string/revanced_override_premium_header_summary_on" android:summaryOff="@string/revanced_override_premium_header_summary_off" />SETTINGS: HEADER_SWITCH -->
<!-- SETTINGS: SWITCH_CREATE_NOTIFICATION
<Preference android:title=" " android:selectable="false" android:key="revanced_experimental_flag" android:summary="@string/revanced_experimental_flag" />
<SwitchPreference android:title="@string/revanced_switching_create_notification_title" android:key="revanced_switching_create_notification" android:defaultValue="false" android:summaryOn="@string/revanced_switching_create_notification_summary_on" android:summaryOff="@string/revanced_switching_create_notification_summary_off" />SETTINGS: SWITCH_CREATE_NOTIFICATION -->
<!-- PREFERENCE: GENERAL_LAYOUT_SETTINGS <!-- PREFERENCE: GENERAL_LAYOUT_SETTINGS
</PreferenceScreen>PREFERENCE: GENERAL_LAYOUT_SETTINGS --> </PreferenceScreen>PREFERENCE: GENERAL_LAYOUT_SETTINGS -->
@ -395,6 +399,7 @@
<Preference android:title="hide-snackbar" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="hide-snackbar" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="hide-floating-microphone" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="hide-floating-microphone" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="header-switch" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="header-switch" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="switch-create-notification" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_layout_settings_player" /> <Preference android:title=" " android:selectable="false" android:summary="@string/revanced_layout_settings_player" />
<Preference android:title="hide-cast-button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="hide-cast-button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>