feat(YouTube - Settings): Add option to use new Cairo settings menus (#4305)
Co-authored-by: MarcaDian <152095496+marcadian@users.noreply.github.com>
This commit is contained in:

committed by
GitHub

parent
ad478d390e
commit
7b8a2a2721
@ -1,5 +1,6 @@
|
||||
package app.revanced.patches.shared.misc.settings
|
||||
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.resourcePatch
|
||||
import app.revanced.patches.all.misc.resources.addResource
|
||||
import app.revanced.patches.all.misc.resources.addResources
|
||||
@ -12,15 +13,22 @@ import app.revanced.util.getNode
|
||||
import app.revanced.util.insertFirst
|
||||
import org.w3c.dom.Node
|
||||
|
||||
// TODO: Delete this on next major version bump.
|
||||
@Deprecated("Use non deprecated settings patch function")
|
||||
fun settingsPatch (
|
||||
rootPreference: Pair<IntentPreference, String>,
|
||||
preferences: Set<BasePreference>,
|
||||
) = settingsPatch(listOf(rootPreference), preferences)
|
||||
|
||||
/**
|
||||
* A resource patch that adds settings to a settings fragment.
|
||||
*
|
||||
* @param rootPreference A pair of an intent preference and the name of the fragment file to add it to.
|
||||
* If null, no preference will be added.
|
||||
* @param rootPreferences List of intent preferences and the name of the fragment file to add it to.
|
||||
* File names that do not exist are ignored and not processed.
|
||||
* @param preferences A set of preferences to add to the ReVanced fragment.
|
||||
*/
|
||||
fun settingsPatch(
|
||||
rootPreference: Pair<IntentPreference, String>? = null,
|
||||
fun settingsPatch (
|
||||
rootPreferences: List<Pair<BasePreference, String>>? = null,
|
||||
preferences: Set<BasePreference>,
|
||||
) = resourcePatch {
|
||||
dependsOn(addResourcesPatch)
|
||||
@ -46,10 +54,20 @@ fun settingsPatch(
|
||||
}
|
||||
|
||||
// Add the root preference to an existing fragment if needed.
|
||||
rootPreference?.let { (intentPreference, fragment) ->
|
||||
document("res/xml/$fragment.xml").use { document ->
|
||||
document.getNode("PreferenceScreen").addPreference(intentPreference, true)
|
||||
rootPreferences?.let {
|
||||
var modified = false
|
||||
|
||||
it.forEach { (intent, fileName) ->
|
||||
val preferenceFileName = "res/xml/$fileName.xml"
|
||||
if (get(preferenceFileName).exists()) {
|
||||
document(preferenceFileName).use { document ->
|
||||
document.getNode("PreferenceScreen").addPreference(intent, true)
|
||||
}
|
||||
modified = true
|
||||
}
|
||||
}
|
||||
|
||||
if (!modified) throw PatchException("No declared preference files exists: $rootPreferences")
|
||||
}
|
||||
|
||||
// Add all preferences to the ReVanced fragment.
|
||||
|
@ -9,6 +9,8 @@ import org.w3c.dom.Element
|
||||
*
|
||||
* @param key The key of the preference. If null, other parameters must be specified.
|
||||
* @param titleKey The key of the preference title.
|
||||
* @param icon The preference icon resource name.
|
||||
* @param layout Layout declaration.
|
||||
* @param summaryKey The key of the preference summary.
|
||||
* @param tag The tag or full class name of the preference.
|
||||
*/
|
||||
@ -17,6 +19,8 @@ abstract class BasePreference(
|
||||
val key: String? = null,
|
||||
val titleKey: String = "${key}_title",
|
||||
val summaryKey: String? = "${key}_summary",
|
||||
val icon: String? = null,
|
||||
val layout: String? = null,
|
||||
val tag: String
|
||||
) {
|
||||
/**
|
||||
@ -33,6 +37,11 @@ abstract class BasePreference(
|
||||
key?.let { setAttribute("android:key", it) }
|
||||
setAttribute("android:title", "@string/${titleKey}")
|
||||
summaryKey?.let { addSummary(it) }
|
||||
icon?.let {
|
||||
setAttribute("android:icon", it)
|
||||
setAttribute("app:iconSpaceReserved", "true")
|
||||
}
|
||||
layout?.let { setAttribute("android:layout", layout) }
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
|
@ -24,16 +24,20 @@ abstract class BasePreferenceScreen(
|
||||
key: String? = null,
|
||||
titleKey: String = "${key}_title",
|
||||
private val summaryKey: String? = "${key}_summary",
|
||||
icon: String? = null,
|
||||
layout: String? = null,
|
||||
preferences: MutableSet<BasePreference> = mutableSetOf(),
|
||||
val categories: MutableSet<Category> = mutableSetOf(),
|
||||
private val sorting: Sorting = Sorting.BY_TITLE,
|
||||
) : BasePreferenceCollection(key, titleKey, preferences) {
|
||||
) : BasePreferenceCollection(key, titleKey, icon, layout, preferences) {
|
||||
|
||||
override fun transform(): PreferenceScreenPreference {
|
||||
return PreferenceScreenPreference(
|
||||
key,
|
||||
titleKey,
|
||||
summaryKey,
|
||||
icon,
|
||||
layout,
|
||||
sorting,
|
||||
// Screens and preferences are sorted at runtime by extension code,
|
||||
// so title sorting uses the localized language in use.
|
||||
@ -56,12 +60,17 @@ abstract class BasePreferenceScreen(
|
||||
open inner class Category(
|
||||
key: String? = null,
|
||||
titleKey: String = "${key}_title",
|
||||
icon: String? = null,
|
||||
layout: String? = null,
|
||||
preferences: MutableSet<BasePreference> = mutableSetOf(),
|
||||
) : BasePreferenceCollection(key, titleKey, preferences) {
|
||||
) : BasePreferenceCollection(key, titleKey, icon, layout, preferences) {
|
||||
override fun transform(): PreferenceCategory {
|
||||
return PreferenceCategory(
|
||||
key,
|
||||
titleKey,
|
||||
icon,
|
||||
layout,
|
||||
sorting,
|
||||
preferences = preferences,
|
||||
)
|
||||
}
|
||||
@ -82,6 +91,8 @@ abstract class BasePreferenceScreen(
|
||||
abstract class BasePreferenceCollection(
|
||||
val key: String? = null,
|
||||
val titleKey: String = "${key}_title",
|
||||
val icon: String? = null,
|
||||
val layout: String? = null,
|
||||
val preferences: MutableSet<BasePreference> = mutableSetOf(),
|
||||
) {
|
||||
abstract fun transform(): BasePreference
|
||||
|
@ -9,6 +9,8 @@ import org.w3c.dom.Document
|
||||
* @param key Optional preference key.
|
||||
* @param titleKey The preference title key.
|
||||
* @param summaryKey The preference summary key.
|
||||
* @param icon The preference icon resource name.
|
||||
* @param layout Layout declaration.
|
||||
* @param tag The preference tag.
|
||||
* @param intent The intent to open.
|
||||
*/
|
||||
@ -16,9 +18,11 @@ class IntentPreference(
|
||||
key: String? = null,
|
||||
titleKey: String = "${key}_title",
|
||||
summaryKey: String? = "${key}_summary",
|
||||
icon: String? = null,
|
||||
layout: String? = null,
|
||||
tag: String = "Preference",
|
||||
val intent: Intent,
|
||||
) : BasePreference(key, titleKey, summaryKey, tag) {
|
||||
) : BasePreference(key, titleKey, summaryKey, icon, layout, tag) {
|
||||
|
||||
override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) =
|
||||
super.serialize(ownerDocument, resourceCallback).apply {
|
||||
|
@ -10,6 +10,8 @@ import org.w3c.dom.Document
|
||||
* @param key The preference key. If null, other parameters must be specified.
|
||||
* @param titleKey The preference title key.
|
||||
* @param summaryKey The preference summary key.
|
||||
* @param icon The preference icon resource name.
|
||||
* @param layout Layout declaration.
|
||||
* @param tag The preference tag.
|
||||
* @param entriesKey The entries array key.
|
||||
* @param entryValuesKey The entry values array key.
|
||||
@ -19,10 +21,12 @@ class ListPreference(
|
||||
key: String? = null,
|
||||
titleKey: String = "${key}_title",
|
||||
summaryKey: String? = "${key}_summary",
|
||||
icon: String? = null,
|
||||
layout: String? = null,
|
||||
tag: String = "ListPreference",
|
||||
val entriesKey: String? = "${key}_entries",
|
||||
val entryValuesKey: String? = "${key}_entry_values"
|
||||
) : BasePreference(key, titleKey, summaryKey, tag) {
|
||||
) : BasePreference(key, titleKey, summaryKey, icon, layout, tag) {
|
||||
var entries: ArrayResource? = null
|
||||
private set
|
||||
var entryValues: ArrayResource? = null
|
||||
|
@ -10,6 +10,8 @@ import org.w3c.dom.Document
|
||||
*
|
||||
* @param key The preference key.
|
||||
* @param summaryKey The preference summary key.
|
||||
* @param icon The preference icon resource name.
|
||||
* @param layout Layout declaration.
|
||||
* @param tag The tag or full class name of the preference.
|
||||
* @param selectable If the preference is selectable and responds to tap events.
|
||||
*/
|
||||
@ -18,9 +20,11 @@ class NonInteractivePreference(
|
||||
key: String,
|
||||
titleKey: String = "${key}_title",
|
||||
summaryKey: String? = "${key}_summary",
|
||||
icon: String? = null,
|
||||
layout: String? = null,
|
||||
tag: String = "Preference",
|
||||
val selectable: Boolean = false,
|
||||
) : BasePreference(key, titleKey, summaryKey, tag) {
|
||||
) : BasePreference(key, titleKey, summaryKey, icon, layout, tag) {
|
||||
override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) =
|
||||
super.serialize(ownerDocument, resourceCallback).apply {
|
||||
setAttribute("android:selectable", selectable.toString())
|
||||
|
@ -1,5 +1,6 @@
|
||||
package app.revanced.patches.shared.misc.settings.preference
|
||||
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference.Sorting
|
||||
import app.revanced.util.resource.BaseResource
|
||||
import org.w3c.dom.Document
|
||||
|
||||
@ -8,6 +9,8 @@ import org.w3c.dom.Document
|
||||
*
|
||||
* @param key The key of the preference. If null, other parameters must be specified.
|
||||
* @param titleKey The key of the preference title.
|
||||
* @param icon The preference icon resource name.
|
||||
* @param layout Layout declaration.
|
||||
* @param tag The tag or full class name of the preference.
|
||||
* @param preferences The preferences in this category.
|
||||
*/
|
||||
@ -15,9 +18,12 @@ import org.w3c.dom.Document
|
||||
open class PreferenceCategory(
|
||||
key: String? = null,
|
||||
titleKey: String = "${key}_title",
|
||||
icon: String? = null,
|
||||
layout: String? = null,
|
||||
sorting: Sorting = Sorting.BY_TITLE,
|
||||
tag: String = "PreferenceCategory",
|
||||
val preferences: Set<BasePreference>
|
||||
) : BasePreference(key, titleKey, null, tag) {
|
||||
) : BasePreference(sorting.appendSortType(key), titleKey, null, icon, layout, tag) {
|
||||
|
||||
override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) =
|
||||
super.serialize(ownerDocument, resourceCallback).apply {
|
||||
|
@ -9,6 +9,8 @@ import org.w3c.dom.Document
|
||||
* @param key The key of the preference. If null, other parameters must be specified.
|
||||
* @param titleKey The key of the preference title.
|
||||
* @param summaryKey The key of the preference summary.
|
||||
* @param icon The preference icon resource name.
|
||||
* @param layout Layout declaration.
|
||||
* @param sorting Sorting to use. If the sorting is not [Sorting.UNSORTED],
|
||||
* then the key parameter will be modified to include the sort type.
|
||||
* @param tag The tag or full class name of the preference.
|
||||
@ -19,6 +21,8 @@ open class PreferenceScreenPreference(
|
||||
key: String? = null,
|
||||
titleKey: String = "${key}_title",
|
||||
summaryKey: String? = "${key}_summary",
|
||||
icon: String? = null,
|
||||
layout: String? = null,
|
||||
sorting: Sorting = Sorting.BY_TITLE,
|
||||
tag: String = "PreferenceScreen",
|
||||
val preferences: Set<BasePreference>,
|
||||
@ -28,7 +32,7 @@ open class PreferenceScreenPreference(
|
||||
// or adding new attributes to the attrs.xml file.
|
||||
// Since the key value is not currently used by the extensions,
|
||||
// for now it's much simpler to modify the key to include the sort parameter.
|
||||
) : BasePreference(if (sorting == Sorting.UNSORTED) key else (key + sorting.keySuffix), titleKey, summaryKey, tag) {
|
||||
) : BasePreference(sorting.appendSortType(key), titleKey, summaryKey, icon, layout, tag) {
|
||||
override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) =
|
||||
super.serialize(ownerDocument, resourceCallback).apply {
|
||||
preferences.forEach {
|
||||
@ -53,6 +57,16 @@ open class PreferenceScreenPreference(
|
||||
/**
|
||||
* Unspecified sorting.
|
||||
*/
|
||||
UNSORTED("_sort_by_unsorted"),
|
||||
UNSORTED("_sort_by_unsorted");
|
||||
|
||||
/**
|
||||
* @return The key with this sort type appended to to the end,
|
||||
* or if key is null then null is returned.
|
||||
*/
|
||||
fun appendSortType(key: String?): String? {
|
||||
if (key == null) return null
|
||||
if (this == UNSORTED) return key
|
||||
return key + keySuffix
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ import org.w3c.dom.Document
|
||||
*
|
||||
* @param key The preference key. If null, other parameters must be specified.
|
||||
* @param titleKey The preference title key.
|
||||
* @param icon The preference icon resource name.
|
||||
* @param layout Layout declaration.
|
||||
* @param tag The preference tag.
|
||||
* @param summaryOnKey The preference summary-on key.
|
||||
* @param summaryOffKey The preference summary-off key.
|
||||
@ -17,9 +19,11 @@ class SwitchPreference(
|
||||
key: String? = null,
|
||||
titleKey: String = "${key}_title",
|
||||
tag: String = "SwitchPreference",
|
||||
icon: String? = null,
|
||||
layout: String? = null,
|
||||
val summaryOnKey: String = "${key}_summary_on",
|
||||
val summaryOffKey: String = "${key}_summary_off"
|
||||
) : BasePreference(key, titleKey, null, tag) {
|
||||
) : BasePreference(key, titleKey, null, icon, layout, tag) {
|
||||
override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) =
|
||||
super.serialize(ownerDocument, resourceCallback).apply {
|
||||
addSummary(summaryOnKey, SummaryType.ON)
|
||||
|
@ -9,6 +9,8 @@ import org.w3c.dom.Document
|
||||
* @param key The preference key. If null, other parameters must be specified.
|
||||
* @param titleKey The preference title key.
|
||||
* @param summaryKey The preference summary key.
|
||||
* @param icon The preference icon resource name.
|
||||
* @param layout Layout declaration.
|
||||
* @param tag The preference tag.
|
||||
* @param inputType The preference input type.
|
||||
*/
|
||||
@ -17,9 +19,11 @@ class TextPreference(
|
||||
key: String? = null,
|
||||
titleKey: String = "${key}_title",
|
||||
summaryKey: String? = "${key}_summary",
|
||||
icon: String? = null,
|
||||
layout: String? = null,
|
||||
tag: String = "app.revanced.extension.shared.settings.preference.ResettableEditTextPreference",
|
||||
val inputType: InputType = InputType.TEXT
|
||||
) : BasePreference(key, titleKey, summaryKey, tag) {
|
||||
) : BasePreference(key, titleKey, summaryKey, icon, layout, tag) {
|
||||
|
||||
override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) =
|
||||
super.serialize(ownerDocument, resourceCallback).apply {
|
||||
|
@ -65,9 +65,12 @@ val navigationButtonsPatch = bytecodePatch(
|
||||
)
|
||||
|
||||
if (is_19_25_or_greater) {
|
||||
preferences += SwitchPreference("revanced_disable_translucent_status_bar")
|
||||
preferences += SwitchPreference("revanced_disable_translucent_navigation_bar_light")
|
||||
preferences += SwitchPreference("revanced_disable_translucent_navigation_bar_dark")
|
||||
|
||||
PreferenceScreen.GENERAL_LAYOUT.addPreferences(
|
||||
SwitchPreference("revanced_disable_translucent_status_bar")
|
||||
)
|
||||
}
|
||||
|
||||
PreferenceScreen.GENERAL_LAYOUT.addPreferences(
|
||||
|
@ -1,47 +0,0 @@
|
||||
package app.revanced.patches.youtube.misc.fix.cairo
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.youtube.misc.backgroundplayback.backgroundPlaybackPatch
|
||||
import app.revanced.patches.youtube.misc.playservice.is_19_04_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.indexOfFirstLiteralInstructionOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
internal val disableCairoSettingsPatch = bytecodePatch(
|
||||
description = "Disables Cairo Fragment from being used.",
|
||||
) {
|
||||
dependsOn(versionCheckPatch)
|
||||
|
||||
execute {
|
||||
if (!is_19_04_or_greater) {
|
||||
return@execute
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Cairo Fragment was added since YouTube v19.04.38.
|
||||
*
|
||||
* Disable this for the following reasons:
|
||||
* 1. [backgroundPlaybackPatch] does not activate the Minimized playback setting of Cairo Fragment.
|
||||
* 2. Some patches do not yet support Cairo Fragments (ie: custom Seekbar color).
|
||||
* 3. Settings preferences added by ReVanced are missing.
|
||||
*
|
||||
* Screenshots of the Cairo Fragment:
|
||||
* <a href="https://github.com/qnblackcat/uYouPlus/issues/1468">uYouPlus#1468</a>.
|
||||
*/
|
||||
cairoFragmentConfigFingerprint.method.apply {
|
||||
val literalIndex = indexOfFirstLiteralInstructionOrThrow(CAIRO_CONFIG_LITERAL_VALUE)
|
||||
val resultIndex = indexOfFirstInstructionOrThrow(literalIndex, Opcode.MOVE_RESULT)
|
||||
val register = getInstruction<OneRegisterInstruction>(resultIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
resultIndex + 1,
|
||||
"const/16 v$register, 0x0",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package app.revanced.patches.youtube.misc.fix.cairo
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
import app.revanced.util.literal
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
/**
|
||||
* Added in YouTube v19.04.38.
|
||||
*
|
||||
* When this value is true, Cairo Fragment is used.
|
||||
* In this case, some of the patches may be broken, so set this value to FALSE.
|
||||
*/
|
||||
internal const val CAIRO_CONFIG_LITERAL_VALUE = 45532100L
|
||||
|
||||
internal val cairoFragmentConfigFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returns("Z")
|
||||
literal { CAIRO_CONFIG_LITERAL_VALUE }
|
||||
}
|
@ -21,3 +21,14 @@ internal val setThemeFingerprint = fingerprint {
|
||||
opcodes(Opcode.RETURN_OBJECT)
|
||||
literal { appearanceStringId }
|
||||
}
|
||||
|
||||
/**
|
||||
* Added in YouTube v19.04.38.
|
||||
*/
|
||||
internal const val CAIRO_CONFIG_LITERAL_VALUE = 45532100L
|
||||
|
||||
internal val cairoFragmentConfigFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returns("Z")
|
||||
literal { CAIRO_CONFIG_LITERAL_VALUE }
|
||||
}
|
||||
|
@ -18,8 +18,10 @@ import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPref
|
||||
import app.revanced.patches.shared.misc.settings.settingsPatch
|
||||
import app.revanced.patches.youtube.misc.check.checkEnvironmentPatch
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.fix.cairo.disableCairoSettingsPatch
|
||||
import app.revanced.patches.youtube.misc.fix.playbackspeed.fixPlaybackSpeedWhilePlayingPatch
|
||||
import app.revanced.patches.youtube.misc.playservice.is_19_04_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.is_19_34_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
|
||||
import app.revanced.util.*
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
@ -43,13 +45,28 @@ private val settingsResourcePatch = resourcePatch {
|
||||
dependsOn(
|
||||
resourceMappingPatch,
|
||||
settingsPatch(
|
||||
rootPreference = IntentPreference(
|
||||
titleKey = "revanced_settings_title",
|
||||
summaryKey = null,
|
||||
intent = newIntent("revanced_settings_intent"),
|
||||
) to "settings_fragment",
|
||||
preferences,
|
||||
),
|
||||
listOf(
|
||||
IntentPreference(
|
||||
titleKey = "revanced_settings_title",
|
||||
summaryKey = null,
|
||||
intent = newIntent("revanced_settings_intent"),
|
||||
) to "settings_fragment",
|
||||
PreferenceCategory(
|
||||
titleKey = "revanced_settings_title",
|
||||
layout = "@layout/preference_group_title",
|
||||
preferences = setOf(
|
||||
IntentPreference(
|
||||
titleKey = "revanced_settings_submenu_title",
|
||||
summaryKey = null,
|
||||
icon = "@drawable/revanced_settings_icon",
|
||||
layout = "@layout/preference_with_icon",
|
||||
intent = newIntent("revanced_settings_intent"),
|
||||
)
|
||||
)
|
||||
) to "settings_fragment_cairo",
|
||||
),
|
||||
preferences
|
||||
)
|
||||
)
|
||||
|
||||
execute {
|
||||
@ -57,6 +74,7 @@ private val settingsResourcePatch = resourcePatch {
|
||||
appearanceStringId = resourceMappings["string", "app_theme_appearance_dark"]
|
||||
|
||||
arrayOf(
|
||||
ResourceGroup("drawable", "revanced_settings_icon.xml"),
|
||||
ResourceGroup("layout", "revanced_settings_with_toolbar.xml"),
|
||||
).forEach { resourceGroup ->
|
||||
copyResources("settings", resourceGroup)
|
||||
@ -79,7 +97,6 @@ private val settingsResourcePatch = resourcePatch {
|
||||
// Remove horizontal divider from the settings Preferences
|
||||
// To better match the appearance of the stock YouTube settings.
|
||||
document("res/values/styles.xml").use { document ->
|
||||
|
||||
arrayOf(
|
||||
"Theme.YouTube.Settings",
|
||||
"Theme.YouTube.Settings.Dark",
|
||||
@ -99,7 +116,6 @@ private val settingsResourcePatch = resourcePatch {
|
||||
// Some devices freak out if undeclared data is passed to an intent,
|
||||
// and this change appears to fix the issue.
|
||||
document("AndroidManifest.xml").use { document ->
|
||||
|
||||
val licenseElement = document.childNodes.findElementByAttributeValueOrThrow(
|
||||
"android:name",
|
||||
"com.google.android.libraries.social.licenses.LicenseActivity",
|
||||
@ -123,7 +139,7 @@ val settingsPatch = bytecodePatch(
|
||||
sharedExtensionPatch,
|
||||
settingsResourcePatch,
|
||||
addResourcesPatch,
|
||||
disableCairoSettingsPatch,
|
||||
versionCheckPatch,
|
||||
fixPlaybackSpeedWhilePlayingPatch,
|
||||
// Currently there is no easy way to make a mandatory patch,
|
||||
// so for now this is a dependent of this patch.
|
||||
@ -147,6 +163,12 @@ val settingsPatch = bytecodePatch(
|
||||
selectable = true,
|
||||
)
|
||||
|
||||
if (is_19_34_or_greater) {
|
||||
PreferenceScreen.GENERAL_LAYOUT.addPreferences(
|
||||
SwitchPreference("revanced_restore_old_settings_menus")
|
||||
)
|
||||
}
|
||||
|
||||
PreferenceScreen.MISC.addPreferences(
|
||||
TextPreference(
|
||||
key = null,
|
||||
@ -224,6 +246,14 @@ val settingsPatch = bytecodePatch(
|
||||
methods.add(attachBaseContext)
|
||||
}
|
||||
|
||||
// Add setting to force cairo settings fragment on/off.
|
||||
if (is_19_04_or_greater) {
|
||||
cairoFragmentConfigFingerprint.method.insertFeatureFlagBooleanOverride(
|
||||
CAIRO_CONFIG_LITERAL_VALUE,
|
||||
"$activityHookClassDescriptor->useCairoSettingsFragment(Z)Z"
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
finalize {
|
||||
@ -259,17 +289,15 @@ object PreferenceScreen : BasePreferenceScreen() {
|
||||
key = "revanced_settings_screen_03_feed",
|
||||
summaryKey = null,
|
||||
)
|
||||
val PLAYER = Screen(
|
||||
key = "revanced_settings_screen_04_player",
|
||||
val GENERAL_LAYOUT = Screen(
|
||||
key = "revanced_settings_screen_04_general",
|
||||
summaryKey = null,
|
||||
)
|
||||
val GENERAL_LAYOUT = Screen(
|
||||
key = "revanced_settings_screen_05_general",
|
||||
val PLAYER = Screen(
|
||||
key = "revanced_settings_screen_05_player",
|
||||
summaryKey = null,
|
||||
)
|
||||
|
||||
// Don't sort, as related preferences are scattered apart.
|
||||
// Can use title sorting after PreferenceCategory support is added.
|
||||
val SHORTS = Screen(
|
||||
key = "revanced_settings_screen_06_shorts",
|
||||
summaryKey = null,
|
||||
|
Reference in New Issue
Block a user