mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
feat: add Hide voice search button
patch
This commit is contained in:
@ -0,0 +1,17 @@
|
|||||||
|
package app.revanced.patches.music.general.voicesearch
|
||||||
|
|
||||||
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||||
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
|
import app.revanced.patches.shared.patch.voicesearch.AbstractVoiceSearchButtonPatch
|
||||||
|
|
||||||
|
@Patch(
|
||||||
|
name = "Hide voice search button",
|
||||||
|
description = "Hide voice search button in search bar.",
|
||||||
|
compatiblePackages = [CompatiblePackage("com.google.android.apps.youtube.music")],
|
||||||
|
use = false
|
||||||
|
)
|
||||||
|
@Suppress("unused")
|
||||||
|
object VoiceSearchButtonPatch : AbstractVoiceSearchButtonPatch(
|
||||||
|
arrayOf("search_toolbar_view.xml"),
|
||||||
|
arrayOf("height", "width")
|
||||||
|
)
|
@ -0,0 +1,41 @@
|
|||||||
|
package app.revanced.patches.shared.patch.voicesearch
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.ResourceContext
|
||||||
|
import app.revanced.patcher.patch.ResourcePatch
|
||||||
|
import org.w3c.dom.Element
|
||||||
|
import kotlin.io.path.exists
|
||||||
|
|
||||||
|
abstract class AbstractVoiceSearchButtonPatch(
|
||||||
|
private val paths: Array<String>,
|
||||||
|
private val replacements: Array<String>
|
||||||
|
) : ResourcePatch() {
|
||||||
|
private companion object {
|
||||||
|
const val IMAGE_VIEW_TAG = "android.support.v7.widget.AppCompatImageView"
|
||||||
|
const val VOICE_SEARCH_ID = "@id/voice_search"
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun execute(context: ResourceContext) {
|
||||||
|
val resDirectory = context["res"]
|
||||||
|
|
||||||
|
paths.forEach { path ->
|
||||||
|
val targetXmlPath = resDirectory.resolve("layout").resolve(path).toPath()
|
||||||
|
|
||||||
|
if (targetXmlPath.exists()) {
|
||||||
|
context.xmlEditor["res/layout/$path"].use { editor ->
|
||||||
|
val document = editor.file
|
||||||
|
val imageViewTags = document.getElementsByTagName(IMAGE_VIEW_TAG)
|
||||||
|
List(imageViewTags.length) { imageViewTags.item(it) as Element }
|
||||||
|
.filter { it.getAttribute("android:id").equals(VOICE_SEARCH_ID) }
|
||||||
|
.forEach { node ->
|
||||||
|
replacements.forEach replacement@{ replacement ->
|
||||||
|
node.getAttributeNode("android:layout_$replacement")?.let { attribute ->
|
||||||
|
attribute.textContent = "0.0dip"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
package app.revanced.patches.youtube.layout.voicesearch
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.ResourceContext
|
||||||
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||||
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
|
import app.revanced.patches.shared.patch.voicesearch.AbstractVoiceSearchButtonPatch
|
||||||
|
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||||
|
|
||||||
|
@Patch(
|
||||||
|
name = "Hide voice search button",
|
||||||
|
description = "Hide voice search button in search bar.",
|
||||||
|
dependencies = [SettingsPatch::class],
|
||||||
|
compatiblePackages = [
|
||||||
|
CompatiblePackage(
|
||||||
|
"com.google.android.youtube",
|
||||||
|
[
|
||||||
|
"18.25.40",
|
||||||
|
"18.27.36",
|
||||||
|
"18.29.38",
|
||||||
|
"18.30.37",
|
||||||
|
"18.31.40",
|
||||||
|
"18.32.39",
|
||||||
|
"18.33.40",
|
||||||
|
"18.34.38",
|
||||||
|
"18.35.36",
|
||||||
|
"18.36.39",
|
||||||
|
"18.37.36",
|
||||||
|
"18.38.44",
|
||||||
|
"18.39.41",
|
||||||
|
"18.40.34",
|
||||||
|
"18.41.39",
|
||||||
|
"18.42.41",
|
||||||
|
"18.43.45",
|
||||||
|
"18.44.41",
|
||||||
|
"18.45.43"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
],
|
||||||
|
use = false
|
||||||
|
)
|
||||||
|
@Suppress("unused")
|
||||||
|
object VoiceSearchButtonPatch : AbstractVoiceSearchButtonPatch(
|
||||||
|
arrayOf(
|
||||||
|
"action_bar_search_results_view_mic.xml",
|
||||||
|
"action_bar_search_view.xml",
|
||||||
|
"action_bar_search_view_grey.xml",
|
||||||
|
"action_bar_search_view_mic_out.xml"
|
||||||
|
),
|
||||||
|
arrayOf(
|
||||||
|
"height",
|
||||||
|
"marginEnd",
|
||||||
|
"width"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
override fun execute(context: ResourceContext) {
|
||||||
|
super.execute(context)
|
||||||
|
|
||||||
|
SettingsPatch.updatePatchStatus("Hide voice search button")
|
||||||
|
}
|
||||||
|
}
|
@ -479,6 +479,7 @@
|
|||||||
<Preference android:title="Hide animated button background" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
<Preference android:title="Hide animated button background" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
<Preference android:title="Hide double tap overlay filter" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
<Preference android:title="Hide double tap overlay filter" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
<Preference android:title="Hide tooltip content" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
<Preference android:title="Hide tooltip content" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
|
<Preference android:title="Hide voice search button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
<Preference android:title="Icon" android:summary="@string/revanced_icon_default" android:selectable="false"/>
|
<Preference android:title="Icon" android:summary="@string/revanced_icon_default" android:selectable="false"/>
|
||||||
<Preference android:title="Label" android:summary="@string/revanced_label_default" android:selectable="false"/>
|
<Preference android:title="Label" android:summary="@string/revanced_label_default" android:selectable="false"/>
|
||||||
<Preference android:title="MicroG support" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
<Preference android:title="MicroG support" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
|
Reference in New Issue
Block a user