diff --git a/src/main/kotlin/app/revanced/patches/music/flyoutpanel/component/FlyoutPanelPatch.kt b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/component/FlyoutPanelPatch.kt
index 798b97df8..ca062bb33 100644
--- a/src/main/kotlin/app/revanced/patches/music/flyoutpanel/component/FlyoutPanelPatch.kt
+++ b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/component/FlyoutPanelPatch.kt
@@ -12,7 +12,9 @@ import app.revanced.patches.music.flyoutpanel.component.fingerprints.SleepTimerF
import app.revanced.patches.music.flyoutpanel.utils.EnumUtils.getEnumIndex
import app.revanced.patches.music.utils.fingerprints.MenuItemFingerprint
import app.revanced.patches.music.utils.flyoutbutton.FlyoutButtonContainerPatch
+import app.revanced.patches.music.utils.integrations.Constants.COMPONENTS_PATH
import app.revanced.patches.music.utils.integrations.Constants.FLYOUT
+import app.revanced.patches.music.utils.litho.LithoFilterPatch
import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
@@ -26,6 +28,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
description = "Adds options to hide flyout panel components.",
dependencies = [
FlyoutButtonContainerPatch::class,
+ LithoFilterPatch::class,
SettingsPatch::class
],
compatiblePackages = [
@@ -93,6 +96,16 @@ object FlyoutPanelPatch : BytecodePatch(
}
}
+ if (SettingsPatch.upward0636) {
+ LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
+
+ SettingsPatch.addMusicPreference(
+ CategoryType.FLYOUT,
+ "revanced_hide_flyout_panel_3_column_component",
+ "false"
+ )
+ }
+
SettingsPatch.addMusicPreferenceWithoutSummary(
CategoryType.FLYOUT,
"revanced_hide_flyout_panel_add_to_queue",
@@ -153,11 +166,13 @@ object FlyoutPanelPatch : BytecodePatch(
"revanced_hide_flyout_panel_like_dislike",
"false"
)
- SettingsPatch.addMusicPreferenceWithoutSummary(
- CategoryType.FLYOUT,
- "revanced_hide_flyout_panel_play_next",
- "false"
- )
+ if (!SettingsPatch.upward0636) {
+ SettingsPatch.addMusicPreferenceWithoutSummary(
+ CategoryType.FLYOUT,
+ "revanced_hide_flyout_panel_play_next",
+ "false"
+ )
+ }
SettingsPatch.addMusicPreferenceWithoutSummary(
CategoryType.FLYOUT,
"revanced_hide_flyout_panel_quality",
@@ -188,16 +203,18 @@ object FlyoutPanelPatch : BytecodePatch(
"revanced_hide_flyout_panel_save_to_library",
"false"
)
- SettingsPatch.addMusicPreferenceWithoutSummary(
- CategoryType.FLYOUT,
- "revanced_hide_flyout_panel_save_to_playlist",
- "false"
- )
- SettingsPatch.addMusicPreferenceWithoutSummary(
- CategoryType.FLYOUT,
- "revanced_hide_flyout_panel_share",
- "false"
- )
+ if (!SettingsPatch.upward0636) {
+ SettingsPatch.addMusicPreferenceWithoutSummary(
+ CategoryType.FLYOUT,
+ "revanced_hide_flyout_panel_save_to_playlist",
+ "false"
+ )
+ SettingsPatch.addMusicPreferenceWithoutSummary(
+ CategoryType.FLYOUT,
+ "revanced_hide_flyout_panel_share",
+ "false"
+ )
+ }
SettingsPatch.addMusicPreferenceWithoutSummary(
CategoryType.FLYOUT,
"revanced_hide_flyout_panel_shuffle_play",
@@ -228,6 +245,8 @@ object FlyoutPanelPatch : BytecodePatch(
"revanced_hide_flyout_panel_view_song_credit",
"false"
)
-
}
+
+ private const val FILTER_CLASS_DESCRIPTOR =
+ "$COMPONENTS_PATH/PlayerFlyoutPanelsFilter;"
}
diff --git a/src/main/kotlin/app/revanced/patches/music/utils/settings/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/settings/SettingsPatch.kt
index 0638ca627..b1a65d4ed 100644
--- a/src/main/kotlin/app/revanced/patches/music/utils/settings/SettingsPatch.kt
+++ b/src/main/kotlin/app/revanced/patches/music/utils/settings/SettingsPatch.kt
@@ -16,6 +16,8 @@ import app.revanced.util.copyResources
import app.revanced.util.copyXmlNode
import org.w3c.dom.Element
import java.io.Closeable
+import java.util.concurrent.Executors
+import java.util.concurrent.TimeUnit
@Patch(
name = "Settings",
@@ -46,6 +48,41 @@ object SettingsPatch : AbstractSettingsResourcePatch(
override fun execute(context: ResourceContext) {
contexts = context
+ val resourceXmlFile = context["res/values/integers.xml"].readBytes()
+
+ for (threadIndex in 0 until THREAD_COUNT) {
+ threadPoolExecutor.execute thread@{
+ context.xmlEditor[resourceXmlFile.inputStream()].use { editor ->
+ val resources = editor.file.documentElement.childNodes
+ val resourcesLength = resources.length
+ val jobSize = resourcesLength / THREAD_COUNT
+
+ val batchStart = jobSize * threadIndex
+ val batchEnd = jobSize * (threadIndex + 1)
+ element@ for (i in batchStart until batchEnd) {
+ if (i >= resourcesLength) return@thread
+
+ val node = resources.item(i)
+ if (node !is Element) continue
+
+ if (node.nodeName != "integer" || !node.getAttribute("name")
+ .startsWith("google_play_services_version")
+ ) continue
+
+ val playServicesVersion = node.textContent.toInt()
+
+ upward0636 = 240399000 <= playServicesVersion
+
+ break
+ }
+ }
+ }
+ }
+
+ threadPoolExecutor
+ .also { it.shutdown() }
+ .awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS)
+
/**
* create directory for the untranslated language resources
*/
@@ -100,7 +137,11 @@ object SettingsPatch : AbstractSettingsResourcePatch(
}
+ private val THREAD_COUNT = Runtime.getRuntime().availableProcessors()
+ private val threadPoolExecutor = Executors.newFixedThreadPool(THREAD_COUNT)
+
lateinit var contexts: ResourceContext
+ internal var upward0636: Boolean = false
internal fun addMusicPreference(
category: CategoryType,
diff --git a/src/main/resources/music/settings/host/values/strings.xml b/src/main/resources/music/settings/host/values/strings.xml
index 99a2d8409..599275824 100644
--- a/src/main/resources/music/settings/host/values/strings.xml
+++ b/src/main/resources/music/settings/host/values/strings.xml
@@ -121,6 +121,8 @@ Some features may not work properly in the old player layout."
Hide emoji picker and time stamp
Hides the explore button.
Hide explore button
+ Hide play next, save to playlist, share menus.
+ Hide 3-column component
Hide add to queue menu
Hide captions menu
Hide delete playlist menu