mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-09 11:04:36 +02:00
feat(YouTube Music/Hide flyout panel): add Hide 3-column component
settings
This commit is contained in:
parent
388df97449
commit
bfda7b4a3e
@ -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"
|
||||
)
|
||||
if (!SettingsPatch.upward0636) {
|
||||
SettingsPatch.addMusicPreferenceWithoutSummary(
|
||||
CategoryType.FLYOUT,
|
||||
"revanced_hide_flyout_panel_play_next",
|
||||
"false"
|
||||
)
|
||||
}
|
||||
SettingsPatch.addMusicPreferenceWithoutSummary(
|
||||
CategoryType.FLYOUT,
|
||||
"revanced_hide_flyout_panel_quality",
|
||||
@ -188,6 +203,7 @@ object FlyoutPanelPatch : BytecodePatch(
|
||||
"revanced_hide_flyout_panel_save_to_library",
|
||||
"false"
|
||||
)
|
||||
if (!SettingsPatch.upward0636) {
|
||||
SettingsPatch.addMusicPreferenceWithoutSummary(
|
||||
CategoryType.FLYOUT,
|
||||
"revanced_hide_flyout_panel_save_to_playlist",
|
||||
@ -198,6 +214,7 @@ object FlyoutPanelPatch : BytecodePatch(
|
||||
"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;"
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -121,6 +121,8 @@ Some features may not work properly in the old player layout."</string>
|
||||
<string name="revanced_hide_emoji_picker_title">Hide emoji picker and time stamp</string>
|
||||
<string name="revanced_hide_explore_button_summary">Hides the explore button.</string>
|
||||
<string name="revanced_hide_explore_button_title">Hide explore button</string>
|
||||
<string name="revanced_hide_flyout_panel_3_column_component_summary">Hide play next, save to playlist, share menus.</string>
|
||||
<string name="revanced_hide_flyout_panel_3_column_component_title">Hide 3-column component</string>
|
||||
<string name="revanced_hide_flyout_panel_add_to_queue_title">Hide add to queue menu</string>
|
||||
<string name="revanced_hide_flyout_panel_captions_title">Hide captions menu</string>
|
||||
<string name="revanced_hide_flyout_panel_delete_playlist_title">Hide delete playlist menu</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user