New Patch: Cover Everywhere - WIP

This commit is contained in:
2026-05-25 20:27:03 +10:00
parent 045bbbab9a
commit 942742e86e
11 changed files with 1517 additions and 13 deletions
@@ -92,18 +92,25 @@ class SmaliPatchStep(
container.log("Recorded rl-locals bump: $smaliPath method≈\"$methodSubstring\" >= $newValue")
}
val targetLine = lines.firstOrNull { it.startsWith("--- a/") }
?: throw Error("Patch $patchFile is missing a '--- a/...' header")
val fullClassName = targetLine
.removePrefix("--- a/")
.removeSuffix(".smali")
.trim()
val patch = LoadedPatch(
fullClassName = fullClassName,
patch = UnifiedDiffUtils.parseUnifiedDiff(lines),
)
patches.add(patch)
container.log("Loaded patch file $patchFile for class ${patch.fullClassName}")
// Split into per-target sections — a single .patch may contain multiple
// `--- a/...` blocks targeting different classes.
val sections = splitMultiTargetPatch(lines)
if (sections.isEmpty()) {
throw Error("Patch $patchFile is missing a '--- a/...' header")
}
for (section in sections) {
val targetLine = section.first { it.startsWith("--- a/") }
val fullClassName = targetLine
.removePrefix("--- a/")
.removeSuffix(".smali")
.trim()
val patch = LoadedPatch(
fullClassName = fullClassName,
patch = UnifiedDiffUtils.parseUnifiedDiff(section),
)
patches.add(patch)
container.log("Loaded patch file $patchFile for class ${patch.fullClassName}")
}
} catch (t: Throwable) {
throw Error("Failed to parse patch file $patchFile", t)
}
@@ -314,6 +321,28 @@ class SmaliPatchStep(
private companion object {
val LOCALS_DIRECTIVE = Regex("""^#\s*rl-locals:\s+(\S+)\s+(\S+)\s+(\d+)\s*$""")
}
/**
* Splits a unified diff into per-target sections. A single `.patch` file may bundle
* multiple file diffs (each starting with `--- a/...`); each section becomes its own
* patch with its own target class. The header lines before the first `--- a/` (and
* any `# rl-locals:` directives) are preserved by being copied into every section so
* that `UnifiedDiffUtils.parseUnifiedDiff` can still parse the section in isolation.
*/
private fun splitMultiTargetPatch(lines: List<String>): List<List<String>> {
val headerEnd = lines.indexOfFirst { it.startsWith("--- a/") }
if (headerEnd < 0) return emptyList()
val header = lines.subList(0, headerEnd)
val sectionStarts = lines.withIndex()
.filter { (_, line) -> line.startsWith("--- a/") }
.map { it.index }
return sectionStarts.mapIndexed { i, start ->
val end = sectionStarts.getOrNull(i + 1) ?: lines.size
header + lines.subList(start, end)
}
}
}
private data class LoadedPatch(
@@ -63,6 +63,16 @@ enum class KnownPatch(
titleRes = R.string.patch_player_backdrop_title,
descRes = R.string.patch_player_backdrop_desc,
),
CoverEverywhere(
order = 35,
fileNames = listOf(
"home-backdrop.patch",
"collection-backdrop.patch",
"cover-capture.patch",
),
titleRes = R.string.patch_cover_everywhere_title,
descRes = R.string.patch_cover_everywhere_desc,
),
DebugMenuUnlock(
order = 100,
fileNames = listOf("debug-menu-unlock.patch"),
@@ -93,6 +103,7 @@ enum class KnownPatch(
LyricsKeepControlsVisible,
PlayerBackdrop,
LyricsProgressPill,
CoverEverywhere,
),
);
@@ -269,6 +269,8 @@
>Inverts the auto-hide behavior on the lyrics screen, playback controls stay visible by default and only hide when you tap them off.</string>
<string name="patch_player_backdrop_title">Player Backdrop</string>
<string name="patch_player_backdrop_desc">Restores the legacy translucent backdrop blur behind the player.</string>
<string name="patch_cover_everywhere_title">Cover Everywhere - WIP</string>
<string name="patch_cover_everywhere_desc">Applies the blurred backdrop to every Compose based page (Home &amp; Collection)</string>
<string name="patch_lyrics_replace_share_button_title">Replace Share Button</string>
<string
name="patch_lyrics_replace_share_button_desc"