mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-29 21:30:19 +02:00
chore: lint code
This commit is contained in:
parent
4adce1465c
commit
a4c50493f7
@ -29,6 +29,7 @@ object SettingsPatch : BaseResourcePatch(
|
||||
description = "The name of the RVX settings menu.",
|
||||
required = true
|
||||
)
|
||||
|
||||
override fun execute(context: ResourceContext) {
|
||||
/**
|
||||
* Replace settings icon and label
|
||||
|
@ -85,7 +85,8 @@ abstract class BaseAdsPatch(
|
||||
internal fun MethodFingerprintResult.hookLithoFullscreenAds(context: BytecodeContext) {
|
||||
mutableMethod.apply {
|
||||
val dialogCodeIndex = scanResult.patternScanResult!!.endIndex
|
||||
val dialogCodeField = getInstruction<ReferenceInstruction>(dialogCodeIndex).reference as FieldReference
|
||||
val dialogCodeField =
|
||||
getInstruction<ReferenceInstruction>(dialogCodeIndex).reference as FieldReference
|
||||
if (dialogCodeField.type != "I")
|
||||
throw PatchException("Invalid dialogCodeField: $dialogCodeField")
|
||||
|
||||
@ -119,7 +120,8 @@ abstract class BaseAdsPatch(
|
||||
method.parameters == listOf("I")
|
||||
&& method.returnType == "Landroid/widget/Button;"
|
||||
}
|
||||
val getButtonCall = dialogDefiningClass + "->" + getButtonMethod.name + "(I)Landroid/widget/Button;"
|
||||
val getButtonCall =
|
||||
dialogDefiningClass + "->" + getButtonMethod.name + "(I)Landroid/widget/Button;"
|
||||
val dialogRegister = getInstruction<FiveRegisterInstruction>(dialogIndex).registerC
|
||||
val freeIndex = getTargetIndex(dialogIndex, Opcode.IF_EQZ)
|
||||
val freeRegister = getInstruction<OneRegisterInstruction>(freeIndex).registerA
|
||||
|
@ -38,12 +38,13 @@ object TranslationsUtils {
|
||||
// Exception is thrown if an invalid path is used in the patch option.
|
||||
throw PatchException("Invalid custom translations path: $customLang")
|
||||
}
|
||||
}?: run {
|
||||
} ?: run {
|
||||
// Process selected translations if no custom translation is set.
|
||||
val selectedTranslationsArray =
|
||||
selectedTranslations?.split(",")?.map { it.trim() }?.toTypedArray()
|
||||
?: throw PatchException("Invalid selected languages.")
|
||||
val filteredLanguages = translationsArray.filter { it in selectedTranslationsArray }.toTypedArray()
|
||||
val filteredLanguages =
|
||||
translationsArray.filter { it in selectedTranslationsArray }.toTypedArray()
|
||||
copyXml(sourceDirectory, filteredLanguages)
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,11 @@ object MiniplayerPatch : BaseBytecodePatch(
|
||||
MiniplayerDimensionsCalculatorParentFingerprint.resultOrThrow().classDef
|
||||
)
|
||||
MiniplayerOverrideNoContextFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
findReturnIndicesReversed().forEach { index -> insertLegacyTabletMiniplayerOverride(index) }
|
||||
findReturnIndicesReversed().forEach { index ->
|
||||
insertLegacyTabletMiniplayerOverride(
|
||||
index
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
@ -110,7 +114,11 @@ object MiniplayerPatch : BaseBytecodePatch(
|
||||
val walkerMethod = getWalkerMethod(context, appNameStringIndex)
|
||||
|
||||
walkerMethod.apply {
|
||||
findReturnIndicesReversed().forEach { index -> insertLegacyTabletMiniplayerOverride(index) }
|
||||
findReturnIndicesReversed().forEach { index ->
|
||||
insertLegacyTabletMiniplayerOverride(
|
||||
index
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -143,7 +151,11 @@ object MiniplayerPatch : BaseBytecodePatch(
|
||||
|
||||
insertModernMiniplayerTypeOverride(iPutIndex)
|
||||
} else {
|
||||
findReturnIndicesReversed().forEach { index -> insertModernMiniplayerOverride(index) }
|
||||
findReturnIndicesReversed().forEach { index ->
|
||||
insertModernMiniplayerOverride(
|
||||
index
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -165,7 +177,8 @@ object MiniplayerPatch : BaseBytecodePatch(
|
||||
YtOutlineXWhite to YtOutlinePictureInPictureWhite,
|
||||
).forEach { (originalResource, replacementResource) ->
|
||||
val imageResourceIndex = indexOfWideLiteralInstructionOrThrow(originalResource)
|
||||
val register = getInstruction<OneRegisterInstruction>(imageResourceIndex).registerA
|
||||
val register =
|
||||
getInstruction<OneRegisterInstruction>(imageResourceIndex).registerA
|
||||
|
||||
replaceInstruction(imageResourceIndex, "const v$register, $replacementResource")
|
||||
}
|
||||
@ -178,10 +191,26 @@ object MiniplayerPatch : BaseBytecodePatch(
|
||||
// region Add hooks to hide tablet modern miniplayer buttons.
|
||||
|
||||
listOf(
|
||||
Triple(MiniplayerModernExpandButtonFingerprint, ModernMiniPlayerExpand,"hideMiniplayerExpandClose"),
|
||||
Triple(MiniplayerModernCloseButtonFingerprint, ModernMiniPlayerClose, "hideMiniplayerExpandClose"),
|
||||
Triple(MiniplayerModernRewindButtonFingerprint, ModernMiniPlayerRewindButton, "hideMiniplayerRewindForward"),
|
||||
Triple(MiniplayerModernForwardButtonFingerprint, ModernMiniPlayerForwardButton, "hideMiniplayerRewindForward"),
|
||||
Triple(
|
||||
MiniplayerModernExpandButtonFingerprint,
|
||||
ModernMiniPlayerExpand,
|
||||
"hideMiniplayerExpandClose"
|
||||
),
|
||||
Triple(
|
||||
MiniplayerModernCloseButtonFingerprint,
|
||||
ModernMiniPlayerClose,
|
||||
"hideMiniplayerExpandClose"
|
||||
),
|
||||
Triple(
|
||||
MiniplayerModernRewindButtonFingerprint,
|
||||
ModernMiniPlayerRewindButton,
|
||||
"hideMiniplayerRewindForward"
|
||||
),
|
||||
Triple(
|
||||
MiniplayerModernForwardButtonFingerprint,
|
||||
ModernMiniPlayerForwardButton,
|
||||
"hideMiniplayerRewindForward"
|
||||
),
|
||||
Triple(MiniplayerModernOverlayViewFingerprint, ScrimOverlay, "adjustMiniplayerOpacity")
|
||||
).forEach { (fingerprint, literalValue, methodName) ->
|
||||
fingerprint.resolve(
|
||||
@ -221,7 +250,11 @@ object MiniplayerPatch : BaseBytecodePatch(
|
||||
listOf(
|
||||
ImmutableMethodParameter("Landroid/view/View;", annotations, null),
|
||||
ImmutableMethodParameter("I", annotations, null),
|
||||
ImmutableMethodParameter("Landroid/view/ViewGroup\$LayoutParams;", annotations, null),
|
||||
ImmutableMethodParameter(
|
||||
"Landroid/view/ViewGroup\$LayoutParams;",
|
||||
annotations,
|
||||
null
|
||||
),
|
||||
),
|
||||
"V",
|
||||
AccessFlags.PUBLIC.value,
|
||||
|
@ -79,11 +79,14 @@ object CustomBrandingIconPatch : BaseResourcePatch(
|
||||
)
|
||||
}
|
||||
|
||||
private val launcherIconResourceGroups = mipmapDirectories.getResourceGroup(launcherIconResourceFileNames)
|
||||
private val launcherIconResourceGroups =
|
||||
mipmapDirectories.getResourceGroup(launcherIconResourceFileNames)
|
||||
|
||||
private val splashIconResourceGroups = drawableDirectories.getResourceGroup(splashIconResourceFileNames)
|
||||
private val splashIconResourceGroups =
|
||||
drawableDirectories.getResourceGroup(splashIconResourceFileNames)
|
||||
|
||||
private val oldSplashAnimationResourceGroups = listOf("drawable").getResourceGroup(oldSplashAnimationResourceFileNames)
|
||||
private val oldSplashAnimationResourceGroups =
|
||||
listOf("drawable").getResourceGroup(oldSplashAnimationResourceFileNames)
|
||||
|
||||
// region patch option
|
||||
|
||||
@ -178,7 +181,11 @@ object CustomBrandingIconPatch : BaseResourcePatch(
|
||||
}
|
||||
}
|
||||
|
||||
context.copyXmlNode("$stockResourcePath/splash", "values-v31/styles.xml", "resources")
|
||||
context.copyXmlNode(
|
||||
"$stockResourcePath/splash",
|
||||
"values-v31/styles.xml",
|
||||
"resources"
|
||||
)
|
||||
}
|
||||
|
||||
context.updatePatchStatusIcon(appIcon)
|
||||
|
@ -50,8 +50,10 @@ object ChangeHeaderPatch : BaseResourcePatch(
|
||||
premiumHeaderResourceDirectoryNames.keys.map { directory ->
|
||||
ResourceGroup(
|
||||
directory,
|
||||
*variants.map { variant -> "${GENERIC_HEADER_FILE_NAME}_$variant.png" }.toTypedArray(),
|
||||
*variants.map { variant -> "${PREMIUM_HEADER_FILE_NAME}_$variant.png" }.toTypedArray(),
|
||||
*variants.map { variant -> "${GENERIC_HEADER_FILE_NAME}_$variant.png" }
|
||||
.toTypedArray(),
|
||||
*variants.map { variant -> "${PREMIUM_HEADER_FILE_NAME}_$variant.png" }
|
||||
.toTypedArray(),
|
||||
)
|
||||
}
|
||||
|
||||
@ -82,14 +84,20 @@ object ChangeHeaderPatch : BaseResourcePatch(
|
||||
|
||||
The image dimensions must be as follows:
|
||||
|
||||
${genericHeaderResourceDirectoryNames.map { (dpi, dim) -> "- $dpi: $dim" }.joinToString("\n")}
|
||||
${
|
||||
genericHeaderResourceDirectoryNames.map { (dpi, dim) -> "- $dpi: $dim" }
|
||||
.joinToString("\n")
|
||||
}
|
||||
|
||||
[Premium header]
|
||||
|
||||
${variants.joinToString("\n") { variant -> "- ${PREMIUM_HEADER_FILE_NAME}_$variant.png" }}
|
||||
|
||||
The image dimensions must be as follows:
|
||||
${premiumHeaderResourceDirectoryNames.map { (dpi, dim) -> "- $dpi: $dim" }.joinToString("\n")}
|
||||
${
|
||||
premiumHeaderResourceDirectoryNames.map { (dpi, dim) -> "- $dpi: $dim" }
|
||||
.joinToString("\n")
|
||||
}
|
||||
""".trimIndentMultiline(),
|
||||
required = true,
|
||||
)
|
||||
|
@ -1,7 +1,6 @@
|
||||
package app.revanced.patches.youtube.layout.visual
|
||||
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption
|
||||
import app.revanced.patches.youtube.layout.branding.icon.CustomBrandingIconPatch
|
||||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
|
@ -1,7 +1,7 @@
|
||||
package app.revanced.patches.youtube.misc.codecs
|
||||
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.MISC_PATH
|
||||
import app.revanced.patches.shared.opus.BaseOpusCodecsPatch
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.MISC_PATH
|
||||
|
||||
object OpusCodecBytecodePatch : BaseOpusCodecsPatch(
|
||||
"$MISC_PATH/OpusCodecPatch;->enableOpusCodec()Z"
|
||||
|
@ -300,8 +300,10 @@ object SpoofClientPatch : BaseBytecodePatch(
|
||||
|
||||
it.mutableMethod.apply {
|
||||
// Find the conditional check if the playback speed menu item is not created.
|
||||
val shouldCreateMenuIndex = indexOfFirstInstructionOrThrow(scanResult.endIndex) { opcode == Opcode.IF_EQZ }
|
||||
val shouldCreateMenuRegister = getInstruction<OneRegisterInstruction>(shouldCreateMenuIndex).registerA
|
||||
val shouldCreateMenuIndex =
|
||||
indexOfFirstInstructionOrThrow(scanResult.endIndex) { opcode == Opcode.IF_EQZ }
|
||||
val shouldCreateMenuRegister =
|
||||
getInstruction<OneRegisterInstruction>(shouldCreateMenuIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
shouldCreateMenuIndex,
|
||||
|
@ -1,8 +1,8 @@
|
||||
package app.revanced.patches.youtube.utils.fix.client.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.annotation.FuzzyPatternScanMethod
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import app.revanced.patcher.fingerprint.annotation.FuzzyPatternScanMethod
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstruction
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
@ -239,7 +239,10 @@ fun Method.indexOfFirstInstruction(startIndex: Int = 0, predicate: Instruction.(
|
||||
* @throws PatchException
|
||||
* @see indexOfFirstInstruction
|
||||
*/
|
||||
fun Method.indexOfFirstInstructionOrThrow(startIndex: Int = 0, predicate: Instruction.() -> Boolean): Int {
|
||||
fun Method.indexOfFirstInstructionOrThrow(
|
||||
startIndex: Int = 0,
|
||||
predicate: Instruction.() -> Boolean
|
||||
): Int {
|
||||
val index = indexOfFirstInstruction(startIndex, predicate)
|
||||
if (index < 0) {
|
||||
throw PatchException("Could not find instruction index")
|
||||
|
@ -106,7 +106,10 @@ fun ResourceContext.copyResources(
|
||||
resourceGroup.resources.forEach { resource ->
|
||||
val resourceFile = "${resourceGroup.resourceDirectoryName}/$resource"
|
||||
|
||||
inputStreamFromBundledResource(sourceResourceDirectory, resourceFile)?.let { inputStream ->
|
||||
inputStreamFromBundledResource(
|
||||
sourceResourceDirectory,
|
||||
resourceFile
|
||||
)?.let { inputStream ->
|
||||
Files.copy(
|
||||
inputStream,
|
||||
targetResourceDirectory.resolve(resourceFile).toPath(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user