mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-04-30 06:34:37 +02:00
fix(YouTube - Custom branding icon): Restore old splash animation
does not apply to dark theme
This commit is contained in:
parent
7a209bf28c
commit
81f262ef62
@ -147,7 +147,7 @@ class ActionButtonRequest private constructor(
|
|||||||
} catch (ex: IOException) {
|
} catch (ex: IOException) {
|
||||||
handleConnectionError("Network error", ex)
|
handleConnectionError("Network error", ex)
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
Logger.printException({ "sendApplicationRequest failed" }, ex)
|
Logger.printException({ "sendRequest failed" }, ex)
|
||||||
} finally {
|
} finally {
|
||||||
Logger.printDebug { "video: " + videoId + " took: " + (System.currentTimeMillis() - startTime) + "ms" }
|
Logger.printDebug { "video: " + videoId + " took: " + (System.currentTimeMillis() - startTime) + "ms" }
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package app.revanced.extension.youtube.patches.utils;
|
package app.revanced.extension.youtube.patches.utils;
|
||||||
|
|
||||||
|
import app.revanced.extension.shared.utils.Utils;
|
||||||
|
|
||||||
public class PatchStatus {
|
public class PatchStatus {
|
||||||
|
|
||||||
public static boolean ImageSearchButton() {
|
public static boolean ImageSearchButton() {
|
||||||
@ -7,6 +9,11 @@ public class PatchStatus {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean OldSplashAnimation() {
|
||||||
|
// Replace this with true if the Restore old splash animation (Custom branding icon) succeeds
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean PlayerButtons() {
|
public static boolean PlayerButtons() {
|
||||||
// Replace this with true if the Hide player buttons patch succeeds
|
// Replace this with true if the Hide player buttons patch succeeds
|
||||||
return false;
|
return false;
|
||||||
@ -22,6 +29,12 @@ public class PatchStatus {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean SplashAnimation() {
|
||||||
|
// If 'Restore old splash animation' is included and device is running Android 12+,
|
||||||
|
// YouTube TV splash animations will be disabled by default.
|
||||||
|
return OldSplashAnimation() && Utils.isSDKAbove(31);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean SponsorBlock() {
|
public static boolean SponsorBlock() {
|
||||||
// Replace this with true if the SponsorBlock patch succeeds
|
// Replace this with true if the SponsorBlock patch succeeds
|
||||||
return false;
|
return false;
|
||||||
|
@ -147,7 +147,7 @@ public class Settings extends BaseSettings {
|
|||||||
public static final BooleanSetting CHANGE_START_PAGE_TYPE = new BooleanSetting("revanced_change_start_page_type", FALSE, true,
|
public static final BooleanSetting CHANGE_START_PAGE_TYPE = new BooleanSetting("revanced_change_start_page_type", FALSE, true,
|
||||||
new ChangeStartPagePatch.ChangeStartPageTypeAvailability());
|
new ChangeStartPagePatch.ChangeStartPageTypeAvailability());
|
||||||
public static final BooleanSetting DISABLE_AUTO_AUDIO_TRACKS = new BooleanSetting("revanced_disable_auto_audio_tracks", FALSE);
|
public static final BooleanSetting DISABLE_AUTO_AUDIO_TRACKS = new BooleanSetting("revanced_disable_auto_audio_tracks", FALSE);
|
||||||
public static final BooleanSetting DISABLE_SPLASH_ANIMATION = new BooleanSetting("revanced_disable_splash_animation", FALSE, true);
|
public static final BooleanSetting DISABLE_SPLASH_ANIMATION = new BooleanSetting("revanced_disable_splash_animation", PatchStatus.SplashAnimation(), true);
|
||||||
public static final BooleanSetting DISABLE_TRANSLUCENT_STATUS_BAR = new BooleanSetting("revanced_disable_translucent_status_bar", TRUE, true);
|
public static final BooleanSetting DISABLE_TRANSLUCENT_STATUS_BAR = new BooleanSetting("revanced_disable_translucent_status_bar", TRUE, true);
|
||||||
public static final BooleanSetting ENABLE_GRADIENT_LOADING_SCREEN = new BooleanSetting("revanced_enable_gradient_loading_screen", FALSE, true);
|
public static final BooleanSetting ENABLE_GRADIENT_LOADING_SCREEN = new BooleanSetting("revanced_enable_gradient_loading_screen", FALSE, true);
|
||||||
public static final BooleanSetting HIDE_FLOATING_MICROPHONE = new BooleanSetting("revanced_hide_floating_microphone", TRUE, true);
|
public static final BooleanSetting HIDE_FLOATING_MICROPHONE = new BooleanSetting("revanced_hide_floating_microphone", TRUE, true);
|
||||||
|
@ -4,12 +4,14 @@ import app.revanced.patcher.patch.booleanOption
|
|||||||
import app.revanced.patcher.patch.resourcePatch
|
import app.revanced.patcher.patch.resourcePatch
|
||||||
import app.revanced.patcher.patch.stringOption
|
import app.revanced.patcher.patch.stringOption
|
||||||
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.extension.Constants.PATCH_STATUS_CLASS_DESCRIPTOR
|
||||||
import app.revanced.patches.youtube.utils.patch.PatchList.CUSTOM_BRANDING_ICON_FOR_YOUTUBE
|
import app.revanced.patches.youtube.utils.patch.PatchList.CUSTOM_BRANDING_ICON_FOR_YOUTUBE
|
||||||
import app.revanced.patches.youtube.utils.playservice.is_19_17_or_greater
|
import app.revanced.patches.youtube.utils.playservice.is_19_17_or_greater
|
||||||
import app.revanced.patches.youtube.utils.playservice.is_19_32_or_greater
|
import app.revanced.patches.youtube.utils.playservice.is_19_32_or_greater
|
||||||
import app.revanced.patches.youtube.utils.playservice.is_19_34_or_greater
|
import app.revanced.patches.youtube.utils.playservice.is_19_34_or_greater
|
||||||
import app.revanced.patches.youtube.utils.playservice.versionCheckPatch
|
import app.revanced.patches.youtube.utils.playservice.versionCheckPatch
|
||||||
import app.revanced.patches.youtube.utils.settings.ResourceUtils.updatePatchStatusIcon
|
import app.revanced.patches.youtube.utils.settings.ResourceUtils.updatePatchStatusIcon
|
||||||
|
import app.revanced.patches.youtube.utils.settings.getBytecodeContext
|
||||||
import app.revanced.patches.youtube.utils.settings.settingsPatch
|
import app.revanced.patches.youtube.utils.settings.settingsPatch
|
||||||
import app.revanced.util.ResourceGroup
|
import app.revanced.util.ResourceGroup
|
||||||
import app.revanced.util.Utils.printWarn
|
import app.revanced.util.Utils.printWarn
|
||||||
@ -19,6 +21,7 @@ import app.revanced.util.copyFile
|
|||||||
import app.revanced.util.copyResources
|
import app.revanced.util.copyResources
|
||||||
import app.revanced.util.getResourceGroup
|
import app.revanced.util.getResourceGroup
|
||||||
import app.revanced.util.underBarOrThrow
|
import app.revanced.util.underBarOrThrow
|
||||||
|
import app.revanced.util.updatePatchStatus
|
||||||
import app.revanced.util.valueOrThrow
|
import app.revanced.util.valueOrThrow
|
||||||
import org.w3c.dom.Element
|
import org.w3c.dom.Element
|
||||||
|
|
||||||
@ -247,11 +250,17 @@ val customBrandingIconPatch = resourcePatch(
|
|||||||
resourcesNode.appendChild(style)
|
resourcesNode.appendChild(style)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getBytecodeContext().apply {
|
||||||
|
updatePatchStatus(PATCH_STATUS_CLASS_DESCRIPTOR, "OldSplashAnimation")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePatchStatusIcon(appIcon)
|
updatePatchStatusIcon(appIcon)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CUSTOM_BRANDING_ICON_FOR_YOUTUBE.included = true
|
||||||
|
|
||||||
// region fix app icon
|
// region fix app icon
|
||||||
|
|
||||||
if (!is_19_34_or_greater) {
|
if (!is_19_34_or_greater) {
|
||||||
|
@ -123,7 +123,7 @@ val seekbarComponentsPatch = bytecodePatch(
|
|||||||
execute {
|
execute {
|
||||||
|
|
||||||
val restoreOldSplashAnimationIncluded = CUSTOM_BRANDING_ICON_FOR_YOUTUBE.included == true &&
|
val restoreOldSplashAnimationIncluded = CUSTOM_BRANDING_ICON_FOR_YOUTUBE.included == true &&
|
||||||
customBrandingIconPatch.getBooleanOptionValue("restoreOldSplashAnimationOption").value == true
|
customBrandingIconPatch.getBooleanOptionValue("restoreOldSplashAnimation").value == true
|
||||||
|
|
||||||
var settingArray = arrayOf(
|
var settingArray = arrayOf(
|
||||||
"PREFERENCE_SCREEN: PLAYER",
|
"PREFERENCE_SCREEN: PLAYER",
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package app.revanced.patches.youtube.utils.fix.splash
|
package app.revanced.patches.youtube.utils.fix.splash
|
||||||
|
|
||||||
import app.revanced.patcher.patch.resourcePatch
|
import app.revanced.patcher.patch.resourcePatch
|
||||||
|
import app.revanced.patches.youtube.layout.branding.icon.customBrandingIconPatch
|
||||||
|
import app.revanced.patches.youtube.utils.patch.PatchList.CUSTOM_BRANDING_ICON_FOR_YOUTUBE
|
||||||
import app.revanced.patches.youtube.utils.playservice.is_19_32_or_greater
|
import app.revanced.patches.youtube.utils.playservice.is_19_32_or_greater
|
||||||
import app.revanced.patches.youtube.utils.playservice.versionCheckPatch
|
import app.revanced.patches.youtube.utils.playservice.versionCheckPatch
|
||||||
|
import app.revanced.util.getBooleanOptionValue
|
||||||
import org.w3c.dom.Element
|
import org.w3c.dom.Element
|
||||||
|
|
||||||
val darkModeSplashScreenPatch = resourcePatch(
|
val darkModeSplashScreenPatch = resourcePatch(
|
||||||
@ -10,10 +13,10 @@ val darkModeSplashScreenPatch = resourcePatch(
|
|||||||
) {
|
) {
|
||||||
dependsOn(versionCheckPatch)
|
dependsOn(versionCheckPatch)
|
||||||
|
|
||||||
execute {
|
finalize {
|
||||||
if (!is_19_32_or_greater) {
|
val restoreOldSplashAnimationIncluded = is_19_32_or_greater &&
|
||||||
return@execute
|
CUSTOM_BRANDING_ICON_FOR_YOUTUBE.included == true &&
|
||||||
}
|
customBrandingIconPatch.getBooleanOptionValue("restoreOldSplashAnimation").value == true
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fix the splash screen dark mode background color.
|
* Fix the splash screen dark mode background color.
|
||||||
@ -24,30 +27,57 @@ val darkModeSplashScreenPatch = resourcePatch(
|
|||||||
* This is a bug in unpatched YouTube.
|
* This is a bug in unpatched YouTube.
|
||||||
* Should always be applied even if the `Theme` patch is excluded.
|
* Should always be applied even if the `Theme` patch is excluded.
|
||||||
*/
|
*/
|
||||||
document("res/values-night-v27/styles.xml").use { document ->
|
if (restoreOldSplashAnimationIncluded) {
|
||||||
// Create a night mode specific override for the splash screen background.
|
document("res/values-night/styles.xml").use { document ->
|
||||||
val style = document.createElement("style")
|
val resourcesNode = document.getElementsByTagName("resources").item(0) as Element
|
||||||
style.setAttribute("name", "Theme.YouTube.Home")
|
val childNodes = resourcesNode.childNodes
|
||||||
style.setAttribute("parent", "@style/Base.V27.Theme.YouTube.Home")
|
|
||||||
|
|
||||||
// Fix status and navigation bar showing white on some Android devices,
|
for (i in 0 until childNodes.length) {
|
||||||
// such as SDK 28 Android 10 medium tablet.
|
val node = childNodes.item(i) as? Element ?: continue
|
||||||
val colorSplashBackgroundColor = "@color/yt_black1"
|
val nodeAttributeName = node.getAttribute("name")
|
||||||
arrayOf(
|
if (nodeAttributeName.startsWith("Theme.YouTube.Launcher")) {
|
||||||
"android:navigationBarColor" to colorSplashBackgroundColor,
|
val nodeAttributeParent = node.getAttribute("parent")
|
||||||
"android:windowBackground" to colorSplashBackgroundColor,
|
|
||||||
"android:colorBackground" to colorSplashBackgroundColor,
|
val style = document.createElement("style")
|
||||||
"colorPrimaryDark" to colorSplashBackgroundColor,
|
style.setAttribute("name", "Theme.YouTube.Home")
|
||||||
"android:windowLightStatusBar" to "false",
|
style.setAttribute("parent", nodeAttributeParent)
|
||||||
).forEach { (name, value) ->
|
|
||||||
val styleItem = document.createElement("item")
|
val windowItem = document.createElement("item")
|
||||||
styleItem.setAttribute("name", name)
|
windowItem.setAttribute("name", "android:windowBackground")
|
||||||
styleItem.textContent = value
|
windowItem.textContent = "@color/yt_black1"
|
||||||
style.appendChild(styleItem)
|
style.appendChild(windowItem)
|
||||||
|
|
||||||
|
resourcesNode.removeChild(node)
|
||||||
|
resourcesNode.appendChild(style)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
document("res/values-night-v27/styles.xml").use { document ->
|
||||||
|
// Create a night mode specific override for the splash screen background.
|
||||||
|
val style = document.createElement("style")
|
||||||
|
style.setAttribute("name", "Theme.YouTube.Home")
|
||||||
|
style.setAttribute("parent", "@style/Base.V27.Theme.YouTube.Home")
|
||||||
|
|
||||||
val resourcesNode = document.getElementsByTagName("resources").item(0) as Element
|
// Fix status and navigation bar showing white on some Android devices,
|
||||||
resourcesNode.appendChild(style)
|
// such as SDK 28 Android 10 medium tablet.
|
||||||
|
val colorSplashBackgroundColor = "@color/yt_black1"
|
||||||
|
arrayOf(
|
||||||
|
"android:navigationBarColor" to colorSplashBackgroundColor,
|
||||||
|
"android:windowBackground" to colorSplashBackgroundColor,
|
||||||
|
"android:colorBackground" to colorSplashBackgroundColor,
|
||||||
|
"colorPrimaryDark" to colorSplashBackgroundColor,
|
||||||
|
"android:windowLightStatusBar" to "false",
|
||||||
|
).forEach { (name, value) ->
|
||||||
|
val styleItem = document.createElement("item")
|
||||||
|
styleItem.setAttribute("name", name)
|
||||||
|
styleItem.textContent = value
|
||||||
|
style.appendChild(styleItem)
|
||||||
|
}
|
||||||
|
|
||||||
|
val resourcesNode = document.getElementsByTagName("resources").item(0) as Element
|
||||||
|
resourcesNode.appendChild(style)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package app.revanced.patches.youtube.utils.settings
|
package app.revanced.patches.youtube.utils.settings
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
|
import app.revanced.patcher.patch.BytecodePatchContext
|
||||||
import app.revanced.patcher.patch.bytecodePatch
|
import app.revanced.patcher.patch.bytecodePatch
|
||||||
import app.revanced.patcher.patch.resourcePatch
|
import app.revanced.patcher.patch.resourcePatch
|
||||||
import app.revanced.patcher.patch.stringOption
|
import app.revanced.patcher.patch.stringOption
|
||||||
@ -39,6 +40,10 @@ private const val EXTENSION_INITIALIZATION_CLASS_DESCRIPTOR =
|
|||||||
private const val EXTENSION_THEME_METHOD_DESCRIPTOR =
|
private const val EXTENSION_THEME_METHOD_DESCRIPTOR =
|
||||||
"$EXTENSION_UTILS_PATH/BaseThemeUtils;->setTheme(Ljava/lang/Enum;)V"
|
"$EXTENSION_UTILS_PATH/BaseThemeUtils;->setTheme(Ljava/lang/Enum;)V"
|
||||||
|
|
||||||
|
private lateinit var bytecodeContext: BytecodePatchContext
|
||||||
|
|
||||||
|
internal fun getBytecodeContext() = bytecodeContext
|
||||||
|
|
||||||
private val settingsBytecodePatch = bytecodePatch(
|
private val settingsBytecodePatch = bytecodePatch(
|
||||||
description = "settingsBytecodePatch"
|
description = "settingsBytecodePatch"
|
||||||
) {
|
) {
|
||||||
@ -50,6 +55,7 @@ private val settingsBytecodePatch = bytecodePatch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
execute {
|
execute {
|
||||||
|
bytecodeContext = this
|
||||||
|
|
||||||
// apply the current theme of the settings page
|
// apply the current theme of the settings page
|
||||||
themeSetterSystemFingerprint.methodOrThrow().apply {
|
themeSetterSystemFingerprint.methodOrThrow().apply {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user