refactor(wide-searchbar): add some left margin

This commit is contained in:
inotia00 2023-04-02 18:49:00 +09:00
parent 18e1eedd34
commit 5ffed2d934
2 changed files with 38 additions and 1 deletions

View File

@ -16,6 +16,7 @@ import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints.* import app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints.*
import app.revanced.patches.youtube.layout.general.widesearchbar.resource.patch.WideSearchbarResourcePatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.GENERAL import app.revanced.util.integrations.Constants.GENERAL
@ -24,7 +25,8 @@ import app.revanced.util.integrations.Constants.GENERAL
@Description("Replaces the search icon with a wide search bar. This will hide the YouTube logo when active.") @Description("Replaces the search icon with a wide search bar. This will hide the YouTube logo when active.")
@DependsOn( @DependsOn(
[ [
SettingsPatch::class SettingsPatch::class,
WideSearchbarResourcePatch::class
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility

View File

@ -0,0 +1,35 @@
package app.revanced.patches.youtube.layout.general.widesearchbar.resource.patch
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patches.shared.annotation.YouTubeCompatibility
@Name("enable-wide-searchbar-resource-patch")
@YouTubeCompatibility
@Version("0.0.1")
class WideSearchbarResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
context.xmlEditor["res/layout/action_bar_ringo_background.xml"].use { editor ->
val document = editor.file
with(document.getElementsByTagName("RelativeLayout").item(0)) {
if (attributes.getNamedItem(FLAG) != null) return@with
document.createAttribute(FLAG)
.apply { value = "8.0dip" }
.let(attributes::setNamedItem)
}
}
return PatchResultSuccess()
}
private companion object {
const val FLAG = "android:paddingStart"
}
}