chore: merge branch dev to main (#1389)

This commit is contained in:
oSumAtrIX 2022-12-29 18:59:20 +01:00 committed by GitHub
commit 26473a3cc7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 540 additions and 28 deletions

View file

@ -1,3 +1,46 @@
# [2.148.0-dev.6](https://github.com/revanced/revanced-patches/compare/v2.148.0-dev.5...v2.148.0-dev.6) (2022-12-29)
### Features
* **youtube/theme:** add option to color the seekbar ([53b91fe](https://github.com/revanced/revanced-patches/commit/53b91fe2b5a41f1a63deec8d919f2a1bc1cae12a))
* **youtube/theme:** include the patch by default ([c363997](https://github.com/revanced/revanced-patches/commit/c3639975683fb0ca0e271e8fc3ef7fbf79f33414))
# [2.148.0-dev.5](https://github.com/revanced/revanced-patches/compare/v2.148.0-dev.4...v2.148.0-dev.5) (2022-12-29)
### Features
* **youtube:** `hide-breaking-news-shelf` patch ([#1381](https://github.com/revanced/revanced-patches/issues/1381)) ([38a9877](https://github.com/revanced/revanced-patches/commit/38a987744fbb49c2b7d5d0e69297e95f5ee405c4))
# [2.148.0-dev.4](https://github.com/revanced/revanced-patches/compare/v2.148.0-dev.3...v2.148.0-dev.4) (2022-12-29)
### Features
* **twitter:** `hide-views-stats` patch ([#1371](https://github.com/revanced/revanced-patches/issues/1371)) ([2f04a06](https://github.com/revanced/revanced-patches/commit/2f04a06e3b782931870d973fd0937f8731062f12))
# [2.148.0-dev.3](https://github.com/revanced/revanced-patches/compare/v2.148.0-dev.2...v2.148.0-dev.3) (2022-12-26)
### Bug Fixes
* **youtube/general-ads:** don't early return when not necessary ([#1353](https://github.com/revanced/revanced-patches/issues/1353)) ([003a400](https://github.com/revanced/revanced-patches/commit/003a400ce41ff543fb5484c576f5ec2df0a87273))
# [2.148.0-dev.2](https://github.com/revanced/revanced-patches/compare/v2.148.0-dev.1...v2.148.0-dev.2) (2022-12-26)
### Features
* **youtube/general-ads-patch:** hide guidelines for subscriber ([#1352](https://github.com/revanced/revanced-patches/issues/1352)) ([2d10932](https://github.com/revanced/revanced-patches/commit/2d1093251d5d50b476ca44f76acb9a8597b37aea))
# [2.148.0-dev.1](https://github.com/revanced/revanced-patches/compare/v2.147.0...v2.148.0-dev.1) (2022-12-21)
### Features
* **tasker:** `unlock-license` patch ([#1339](https://github.com/revanced/revanced-patches/issues/1339)) ([78a43b8](https://github.com/revanced/revanced-patches/commit/78a43b8abd972172eab99519dfa636ce77d9e64f))
# [2.147.0](https://github.com/revanced/revanced-patches/compare/v2.146.0...v2.147.0) (2022-12-21)

View file

@ -28,6 +28,7 @@ The official Patch bundle provided by ReVanced and the community.
| `hide-album-cards` | Hides the album cards below the artist description. | 17.49.37 |
| `hide-artist-card` | Hides the artist card below the searchbar. | 17.49.37 |
| `hide-autoplay-button` | Hides the autoplay button in the video player. | 17.49.37 |
| `hide-breaking-news-shelf` | Hides the breaking news shelf on the homepage tab. | 17.49.37 |
| `hide-captions-button` | Hides the captions button on video player. | 17.49.37 |
| `hide-cast-button` | Hides the cast button in the video player. | all |
| `hide-create-button` | Hides the create button in the navigation bar. | 17.49.37 |
@ -120,6 +121,17 @@ The official Patch bundle provided by ReVanced and the community.
| `show-deleted-messages` | Shows deleted chat messages behind a clickable spoiler. | all |
</details>
### [📦 `com.twitter.android`](https://play.google.com/store/apps/details?id=com.twitter.android)
<details>
| 💊 Patch | 📜 Description | 🏹 Target Version |
|:--------:|:--------------:|:-----------------:|
| `dynamic-color` | Replaces the default Twitter Blue with the users Material You palette. | all |
| `hide-views-stats` | Hides the view stats under tweets. | all |
| `monochrome-icon` | Adds a monochrome icon. | all |
| `timeline-ads` | Removes ads from the Twitter timeline. Might require clearing app data to remove already cached ads. | all |
</details>
### [📦 `com.spotify.music`](https://play.google.com/store/apps/details?id=com.spotify.music)
<details>
@ -130,16 +142,6 @@ The official Patch bundle provided by ReVanced and the community.
| `spotify-theme` | Applies a custom theme. | all |
</details>
### [📦 `com.twitter.android`](https://play.google.com/store/apps/details?id=com.twitter.android)
<details>
| 💊 Patch | 📜 Description | 🏹 Target Version |
|:--------:|:--------------:|:-----------------:|
| `dynamic-color` | Replaces the default Twitter Blue with the users Material You palette. | all |
| `monochrome-icon` | Adds a monochrome icon. | all |
| `timeline-ads` | Removes ads from the Twitter timeline. Might require clearing app data to remove already cached ads. | all |
</details>
### [📦 `com.reddit.frontpage`](https://play.google.com/store/apps/details?id=com.reddit.frontpage)
<details>
@ -197,6 +199,14 @@ The official Patch bundle provided by ReVanced and the community.
| `promo-code-unlock` | Disables the validation of promo code. Any code will work to unlock all features. | all |
</details>
### [📦 `net.dinglisch.android.taskerm`](https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm)
<details>
| 💊 Patch | 📜 Description | 🏹 Target Version |
|:--------:|:--------------:|:-----------------:|
| `unlock-license` | Unlocks the trial version. | all |
</details>
### [📦 `co.windyapp.android`](https://play.google.com/store/apps/details?id=co.windyapp.android)
<details>

View file

@ -1,2 +1,2 @@
kotlin.code.style = official
version = 2.147.0
version = 2.148.0-dev.6

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,9 @@
package app.revanced.patches.tasker.license.unlock.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("net.dinglisch.android.taskerm")])
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class UnlockLicenseCompatibility

View file

@ -0,0 +1,14 @@
package app.revanced.patches.tasker.license.unlock.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
object CheckLicenseFingerprint : MethodFingerprint(
strings = listOf("just(IsLicensedResult(true))"),
opcodes = listOf(
Opcode.GOTO,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_VIRTUAL
)
)

View file

@ -0,0 +1,46 @@
package app.revanced.patches.tasker.license.unlock.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.tasker.license.unlock.annotations.UnlockLicenseCompatibility
import app.revanced.patches.tasker.license.unlock.fingerprints.CheckLicenseFingerprint
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.reference.MethodReference
import org.jf.dexlib2.immutable.instruction.ImmutableInstruction35c
@Patch
@Name("unlock-license")
@Description("Unlocks the trial version.")
@UnlockLicenseCompatibility
@Version("0.0.1")
class UnlockLicensePatch : BytecodePatch(
listOf(
CheckLicenseFingerprint
)
) {
override fun execute(context: BytecodeContext) = CheckLicenseFingerprint.result?.let { result ->
val patchIndex = result.scanResult.patternScanResult!!.endIndex
with(result.mutableMethod.instruction(patchIndex) as FiveRegisterInstruction) {
ImmutableInstruction35c(
opcode,
registerCount,
registerC,
0, // registerE is 1, registerD is now 0 instead of 1 bypassing the license verification
registerE,
registerF,
registerG,
(this as ReferenceInstruction).reference as MethodReference
)
}
PatchResultSuccess()
} ?: CheckLicenseFingerprint.toErrorResult()
}

View file

@ -0,0 +1,9 @@
package app.revanced.patches.twitter.layout.hideviews.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.twitter.android")])
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class HideViewsCompatibility

View file

@ -0,0 +1,15 @@
package app.revanced.patches.twitter.layout.hideviews.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
object InlineActionTypesFingerprint : MethodFingerprint(
returnType = "Ljava/util/List",
access = AccessFlags.PUBLIC or AccessFlags.STATIC,
strings = listOf(
"getCurrentMemoizing()",
"android_animated_reply_icon_enabled",
"reply_voting_android_position_before_favorite_enabled"
)
)

View file

@ -0,0 +1,22 @@
package app.revanced.patches.twitter.layout.hideviews.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object TweetStatsContainerConstructorFingerprint : MethodFingerprint(
access = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
parameters = listOf("L"),
opcodes = listOf(
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT,
Opcode.CONST,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.CHECK_CAST,
Opcode.CONST_4,
Opcode.INVOKE_VIRTUAL,
Opcode.INVOKE_VIRTUAL
)
)

View file

@ -0,0 +1,22 @@
package app.revanced.patches.twitter.layout.hideviews.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object TweetStatsContainerWrapperConstructorFingerprint : MethodFingerprint(
access = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
parameters = listOf("L"),
opcodes = listOf(
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT,
Opcode.IGET_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IPUT_OBJECT
)
)

View file

@ -0,0 +1,26 @@
package app.revanced.patches.twitter.layout.hideviews.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object TweetStatsViewDelegateBinderFingerprint : MethodFingerprint(
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
opcodes = listOf(
Opcode.NEW_INSTANCE,
Opcode.CONST_16,
Opcode.INVOKE_DIRECT,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.IGET_OBJECT,
Opcode.NEW_INSTANCE,
Opcode.CONST_16,
Opcode.INVOKE_DIRECT,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.RETURN_OBJECT
)
)

View file

@ -0,0 +1,114 @@
package app.revanced.patches.twitter.layout.hideviews.patch
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.removeInstruction
import app.revanced.patcher.extensions.removeInstructions
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.twitter.layout.hideviews.fingerprints.InlineActionTypesFingerprint
import app.revanced.patches.twitter.layout.hideviews.fingerprints.TweetStatsContainerConstructorFingerprint
import app.revanced.patches.twitter.layout.hideviews.fingerprints.TweetStatsContainerWrapperConstructorFingerprint
import app.revanced.patches.twitter.layout.hideviews.fingerprints.TweetStatsViewDelegateBinderFingerprint
import org.jf.dexlib2.Opcode
class HideViewsBytecodePatch : BytecodePatch(
listOf(
InlineActionTypesFingerprint,
TweetStatsContainerWrapperConstructorFingerprint,
TweetStatsContainerConstructorFingerprint,
TweetStatsViewDelegateBinderFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
removeViewsFromTimeline(context)
removeTweetStatViewInitializer(context)
removeTweetStatViewWrapperInitializer(context)
removeViewDelegateBinderSubscription()
return PatchResultSuccess()
}
private fun removeViewsFromTimeline(context: BytecodeContext) {
val addViewsToActionBarMethodFingerprint = object : MethodFingerprint(
opcodes = listOf(
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT,
Opcode.IF_EQZ,
Opcode.SGET_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.IF_EQZ,
)
) {}
transformMethodAtPattern(
context,
InlineActionTypesFingerprint,
addViewsToActionBarMethodFingerprint
) { patternScanResult, method ->
method.removeInstruction(patternScanResult.endIndex - 1)
}
}
private fun removeTweetStatViewInitializer(context: BytecodeContext) {
val returnFingerprint = object : MethodFingerprint(
opcodes = listOf(Opcode.RETURN_VOID)
) {}
transformMethodAtPattern(
context,
TweetStatsContainerConstructorFingerprint,
returnFingerprint
) { patternScanResult, method ->
method.removeInstructions(patternScanResult.endIndex - 3, 2)
}
}
private fun removeTweetStatViewWrapperInitializer(context: BytecodeContext) {
val wrapperReturnFingerprint = object : MethodFingerprint(
opcodes = listOf(
Opcode.IGET_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.RETURN_VOID,
)
) {}
transformMethodAtPattern(
context,
TweetStatsContainerWrapperConstructorFingerprint,
wrapperReturnFingerprint
) { patternScanResult, method ->
method.removeInstructions(patternScanResult.startIndex - 4, 3)
}
}
private fun removeViewDelegateBinderSubscription() {
transformMethod(TweetStatsViewDelegateBinderFingerprint) { result, method ->
method.removeInstructions(result.scanResult.patternScanResult!!.startIndex - 4, 9)
}
}
private fun transformMethodAtPattern(
context: BytecodeContext, methodFingerprint: MethodFingerprint,
patternFingerprint: MethodFingerprint, transformer: TransformerAtPattern
) {
transformMethod(methodFingerprint) { result, method ->
val patternResult = patternFingerprint.also {
it.resolve(context, method, result.classDef)
}.result!!
transformer(patternResult.scanResult.patternScanResult!!, method)
}
}
private fun transformMethod(methodFingerprint: MethodFingerprint, transformer: Transformer) {
val result = methodFingerprint.result!!
val method = result.mutableMethod
transformer(result, method)
}
}
private typealias Transformer = (MethodFingerprintResult, MutableMethod) -> Unit
private typealias TransformerAtPattern = (MethodFingerprintResult.MethodFingerprintScanResult.PatternScanResult, MutableMethod) -> Unit

View file

@ -0,0 +1,34 @@
package app.revanced.patches.twitter.layout.hideviews.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.*
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.twitter.layout.hideviews.annotations.HideViewsCompatibility
import org.w3c.dom.Element
@Patch
@DependsOn([HideViewsBytecodePatch::class])
@Name("hide-views-stats")
@Description("Hides the view stats under tweets.")
@HideViewsCompatibility
@Version("0.0.1")
class HideViewsResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
arrayOf(
"res/layout/condensed_tweet_stats.xml",
"res/layout/focal_tweet_stats.xml"
).forEach { file ->
context.xmlEditor[file].use { editor ->
val tags = editor.file.getElementsByTagName("com.twitter.ui.tweet.TweetStatView")
List(tags.length) { tags.item(it) as Element }
.filter { it.getAttribute("android:id").contains("views_stat") }
.forEach { it.parentNode.removeChild(it) }
}
}
return PatchResultSuccess()
}
}

View file

@ -102,6 +102,13 @@ class GeneralAdsResourcePatch : ResourcePatch {
"Community guidelines are shown"
)
),
SwitchPreference(
"revanced_adremover_subscribers_community_guidelines_removal",
StringResource("revanced_adremover_subscribers_community_guidelines_enabled_title", "Hide subscribers community guidelines"),
true,
StringResource("revanced_adremover_subscribers_community_guidelines_enabled_summary_on", "Subscribers community guidelines are hidden"),
StringResource("revanced_adremover_subscribers_community_guidelines_enabled_summary_off", "Subscribers community guidelines are shown")
),
SwitchPreference(
"revanced_adremover_emergency_box_removal",
StringResource("revanced_adremover_emergency_box_enabled_title", "Hide emergency boxes"),

View file

@ -0,0 +1,13 @@
package app.revanced.patches.youtube.layout.homepage.breakingnews.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility(
[Package(
"com.google.android.youtube", arrayOf("17.49.37")
)]
)
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class BreakingNewsCompatibility

View file

@ -0,0 +1,23 @@
package app.revanced.patches.youtube.layout.homepage.breakingnews.bytecode.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.layout.homepage.breakingnews.resource.patch.BreakingNewsResourcePatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
object BreakingNewsFingerprint : MethodFingerprint(
opcodes = listOf(
Opcode.CONST,
Opcode.CONST_4,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.CHECK_CAST,
Opcode.IPUT_OBJECT,
),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any { instruction ->
instruction.opcode.ordinal == Opcode.CONST.ordinal &&
(instruction as? WideLiteralInstruction)?.wideLiteral == BreakingNewsResourcePatch.horizontalCardListId
} == true
}
)

View file

@ -0,0 +1,46 @@
package app.revanced.patches.youtube.layout.homepage.breakingnews.bytecode.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.layout.homepage.breakingnews.annotations.BreakingNewsCompatibility
import app.revanced.patches.youtube.layout.homepage.breakingnews.bytecode.fingerprints.BreakingNewsFingerprint
import app.revanced.patches.youtube.layout.homepage.breakingnews.resource.patch.BreakingNewsResourcePatch
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Patch
@DependsOn([IntegrationsPatch::class, BreakingNewsResourcePatch::class])
@Name("hide-breaking-news-shelf")
@Description("Hides the breaking news shelf on the homepage tab.")
@BreakingNewsCompatibility
@Version("0.0.1")
class BreakingNewsPatch : BytecodePatch(
listOf(
BreakingNewsFingerprint,
)
) {
override fun execute(context: BytecodeContext): PatchResult {
val breakingNewsResult = BreakingNewsFingerprint.result!!
val breakingNewsMethod = breakingNewsResult.mutableMethod
val moveResultObjectIndex =
breakingNewsResult.scanResult.patternScanResult!!.endIndex - 2
breakingNewsMethod.addInstruction(
moveResultObjectIndex + 1, """
invoke-static {v${(breakingNewsMethod.instruction(moveResultObjectIndex) as OneRegisterInstruction).registerA}}, Lapp/revanced/integrations/patches/HideBreakingNewsPatch;->hideBreakingNews(Landroid/view/View;)V
"""
)
return PatchResultSuccess()
}
}

View file

@ -0,0 +1,40 @@
package app.revanced.patches.youtube.layout.homepage.breakingnews.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.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@Name("breaking-news-shelf-resource-patch")
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
@Version("0.0.1")
class BreakingNewsResourcePatch : ResourcePatch {
companion object {
internal var horizontalCardListId: Long = -1
}
override fun execute(context: ResourceContext): PatchResult {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_hide_breaking_news",
StringResource("revanced_hide_breaking_news_title", "Hide breaking news"),
true,
StringResource("revanced_hide_breaking_news_summary_on", "Breaking news are hidden"),
StringResource("revanced_hide_breaking_news_summary_off", "Breaking news are shown")
)
)
horizontalCardListId = ResourceMappingPatch.resourceMappings.single {
it.type == "layout" && it.name == "horizontal_card_list"
}.id
return PatchResultSuccess()
}
}

View file

@ -13,7 +13,7 @@ import app.revanced.util.resources.ResourceUtils
import app.revanced.util.resources.ResourceUtils.copyResources
import org.w3c.dom.Element
@Patch(include = false)
@Patch
@DependsOn([LithoThemePatch::class, FixLocaleConfigErrorPatch::class])
@Name("theme")
@Description("Applies a custom theme.")
@ -23,6 +23,7 @@ class ThemePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
val darkThemeBackgroundColor = darkThemeBackgroundColor!!
val lightThemeBackgroundColor = lightThemeBackgroundColor!!
val darkThemeSeekbarColor = darkThemeSeekbarColor!!
context.xmlEditor["res/values/colors.xml"].use { editor ->
val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element
@ -31,20 +32,20 @@ class ThemePatch : ResourcePatch {
val node = resourcesNode.childNodes.item(i) as? Element ?: continue
node.textContent = when (node.getAttribute("name")) {
"yt_black0", "yt_black1", "yt_black1_opacity95", "yt_black1_opacity98", "yt_black2", "yt_black3",
"yt_black4", "yt_status_bar_background_dark", "material_grey_850" -> darkThemeBackgroundColor
"yt_black0", "yt_black1", "yt_black1_opacity95", "yt_black1_opacity98", "yt_black2", "yt_black3", "yt_black4", "yt_status_bar_background_dark", "material_grey_850" -> darkThemeBackgroundColor
"yt_white1", "yt_white1_opacity95", "yt_white1_opacity98", "yt_white2", "yt_white3", "yt_white4",
-> lightThemeBackgroundColor
-> lightThemeBackgroundColor
"inline_time_bar_colorized_bar_played_color_dark" -> darkThemeSeekbarColor
else -> continue
}
}
}
// copies the resource file to change the splash screen color
context.copyResources("theme",
ResourceUtils.ResourceGroup("values-night-v31", "styles.xml")
context.copyResources(
"theme", ResourceUtils.ResourceGroup("values-night-v31", "styles.xml")
)
return PatchResultSuccess()
@ -68,5 +69,14 @@ class ThemePatch : ResourcePatch {
description = "The background color of the light theme. Can be a hex color or a resource reference.",
)
)
var darkThemeSeekbarColor: String? by option(
PatchOption.StringOption(
key = "darkThemeSeekbarColor",
default = "#ffff0000",
title = "Dark theme seekbar color",
description = "The background color of the seekbar of the dark theme. Leave empty for default color.",
)
)
}
}

View file

@ -7,6 +7,9 @@ import org.jf.dexlib2.Opcode
object CanScrollVerticallyFingerprint : MethodFingerprint(
"Z",
parameters = emptyList(),
opcodes = listOf(Opcode.INSTANCE_OF),
opcodes = listOf(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT,
),
customFingerprint = { methodDef -> methodDef.definingClass.endsWith("SwipeRefreshLayout;") }
)
)

View file

@ -4,12 +4,14 @@ import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.youtube.misc.fix.verticalscroll.annotations.VerticalScrollCompatibility
import app.revanced.patches.youtube.misc.fix.verticalscroll.fingerprints.CanScrollVerticallyFingerprint
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Description("Fixes issues with scrolling on the home screen when the first component is of type EmptyComponent.")
@VerticalScrollCompatibility
@ -20,13 +22,17 @@ class VerticalScrollPatch : BytecodePatch(
override fun execute(context: BytecodeContext): PatchResult {
val result = CanScrollVerticallyFingerprint.result ?: return CanScrollVerticallyFingerprint.toErrorResult()
result.mutableMethod.addInstructions(
0,
"""
const/4 v0, 0x0
return v0
"""
)
with(result) {
val method = mutableMethod
val moveResultIndex = scanResult.patternScanResult!!.endIndex
val moveResultRegister = (method.instruction(moveResultIndex) as OneRegisterInstruction).registerA
method.addInstruction(
moveResultIndex + 1,
"const/4 v$moveResultRegister, 0x0"
)
}
return PatchResultSuccess()
}