chore: lint code

This commit is contained in:
inotia00 2024-05-23 02:57:57 +09:00
parent 04e61d8c4a
commit 904f1d6357
5 changed files with 41 additions and 53 deletions

View File

@ -1,15 +1,15 @@
package app.revanced.patches.youtube.layout.animated package app.revanced.patches.youtube.layout.animated
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
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.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.copyResources
import app.revanced.util.ResourceGroup import app.revanced.util.ResourceGroup
import app.revanced.util.copyResources
import app.revanced.util.patch.BaseResourcePatch
@Suppress("unused") @Suppress("unused")
object ForceAnimatedButtonBackgroundPatch : ResourcePatch( object AnimatedButtonBackgroundPatch : BaseResourcePatch(
name = "Force hide animated button background", name = "Hide animated button background",
description = "Hides the background of the pause and play animated buttons in the Shorts player at compile time.", description = "Hides the background of the pause and play animated buttons in the Shorts player at compile time.",
dependencies = setOf(SettingsPatch::class), dependencies = setOf(SettingsPatch::class),
compatiblePackages = COMPATIBLE_PACKAGE, compatiblePackages = COMPATIBLE_PACKAGE,
@ -28,6 +28,6 @@ object ForceAnimatedButtonBackgroundPatch : ResourcePatch(
) )
) )
SettingsPatch.updatePatchStatus("Hide animated button background") SettingsPatch.updatePatchStatus(this)
} }
} }

View File

@ -1,16 +1,16 @@
package app.revanced.patches.youtube.layout.animated package app.revanced.patches.youtube.layout.animated
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
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.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.ResourceGroup import app.revanced.util.ResourceGroup
import app.revanced.util.copyResources import app.revanced.util.copyResources
import app.revanced.util.patch.BaseResourcePatch
@Suppress("unused") @Suppress("unused")
object ForceAnimatedLikePatch : ResourcePatch( object AnimatedLikePatch : BaseResourcePatch(
name = "Force hide double tap to like animations", name = "Hide double tap to like animations",
description = "Hide the like animations when double tap the screen in the Shorts player at compile time.", description = "Hide the like animations when double tap the screen in the Shorts player at compile time.",
dependencies = setOf(SettingsPatch::class), dependencies = setOf(SettingsPatch::class),
compatiblePackages = COMPATIBLE_PACKAGE, compatiblePackages = COMPATIBLE_PACKAGE,
@ -28,6 +28,6 @@ object ForceAnimatedLikePatch : ResourcePatch(
) )
) )
SettingsPatch.updatePatchStatus("Hide double tap to like animations") SettingsPatch.updatePatchStatus(this)
} }
} }

View File

@ -0,0 +1,30 @@
package app.revanced.patches.youtube.layout.dimming
import app.revanced.patcher.data.ResourceContext
import app.revanced.patches.shared.overlaybackground.OverlayBackgroundUtils.removeOverlayBackground
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.patch.BaseResourcePatch
@Suppress("unused")
object ShortsDimmingPatch : BaseResourcePatch(
name = "Hide shorts dimming",
description = "Hide the dimming effect on the top and bottom of Shorts video at compile time.",
dependencies = setOf(SettingsPatch::class),
compatiblePackages = COMPATIBLE_PACKAGE,
use = false
) {
override fun execute(context: ResourceContext) {
context.removeOverlayBackground(
arrayOf("reel_player_overlay_scrims.xml"),
arrayOf("reel_player_overlay_v2_scrims_vertical")
)
context.removeOverlayBackground(
arrayOf("reel_watch_fragment.xml"),
arrayOf("reel_scrim_shorts_while_top")
)
SettingsPatch.updatePatchStatus(this)
}
}

View File

@ -1,43 +0,0 @@
package app.revanced.patches.youtube.shorts.dimming
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.doRecursively
import org.w3c.dom.Element
@Suppress("Deprecation", "unused")
object ForceDisableShortsDimPatch : ResourcePatch(
name = "Force disable Shorts dim",
description = "Hide the dimming effect on the top and bottom of Shorts video at compile time.",
dependencies = setOf(SettingsPatch::class),
compatiblePackages = COMPATIBLE_PACKAGE,
use = false
) {
override fun execute(context: ResourceContext) {
val hide = "0.0dip"
fun hideLayoutAttributes(layoutFile: String, targetId: String) {
context.xmlEditor[layoutFile].use { editor ->
editor.file.doRecursively { node ->
if (node !is Element) return@doRecursively
when (node.getAttributeNode("android:id")?.textContent) {
targetId -> {
node.apply {
setAttribute("android:layout_height", hide)
setAttribute("android:layout_width", hide)
}
}
}
}
}
}
hideLayoutAttributes("res/layout/reel_player_overlay_scrims.xml", "@id/reel_player_overlay_v2_scrims_vertical")
hideLayoutAttributes("res/layout/reel_watch_fragment.xml", "@id/reel_scrim_shorts_while_top")
SettingsPatch.updatePatchStatus("Force disable Shorts dim")
}
}

View File

@ -644,10 +644,11 @@
<PreferenceCategory android:title="@string/revanced_preference_category_others" android:layout="@layout/revanced_settings_preferences_category"> <PreferenceCategory android:title="@string/revanced_preference_category_others" android:layout="@layout/revanced_settings_preferences_category">
<Preference android:title="Custom double tap length" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="Custom double tap length" 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="GmsCore support" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="GmsCore support" 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 double tap to like animations" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="Hide double tap to like animations" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="Hide shorts dimming" 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="Return YouTube Dislike" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="Return YouTube Dislike" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>