Skip to content

Commit 6354279

Browse files
committed
port original MikuBox UI resources
1 parent 115061a commit 6354279

79 files changed

Lines changed: 1397 additions & 290 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/build.gradle.kts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
22
import java.util.Properties
3+
import java.util.zip.ZipEntry
4+
import java.util.zip.ZipFile
5+
import java.util.zip.ZipOutputStream
36

47
plugins {
58
alias(libs.plugins.android.application)
@@ -65,6 +68,13 @@ android {
6568
}
6669

6770
packaging {
71+
resources {
72+
// Coroutine debug probes are useful only to a debugger and should
73+
// not be packaged in production or debug APKs.
74+
excludes += "DebugProbesKt.bin"
75+
excludes += "META-INF/**"
76+
excludes += "/META-INF/**"
77+
}
6878
jniLibs {
6979
useLegacyPackaging = true
7080
}
@@ -158,6 +168,57 @@ tasks.configureEach {
158168
}
159169
}
160170

171+
val stripDebugApkMetadata by tasks.registering {
172+
dependsOn("packageDebug")
173+
174+
doLast {
175+
val outputDir = layout.buildDirectory.dir("outputs/apk/debug").get().asFile
176+
val debugKeystore = file("${System.getProperty("user.home")}/.android/debug.keystore")
177+
check(debugKeystore.isFile) { "Debug keystore was not found: $debugKeystore" }
178+
179+
val buildToolsDir = android.sdkDirectory.resolve("build-tools/${android.buildToolsVersion}")
180+
val zipalign = buildToolsDir.resolve("zipalign.exe")
181+
val apksigner = buildToolsDir.resolve("apksigner.bat")
182+
check(zipalign.isFile && apksigner.isFile) { "Android build-tools are incomplete in $buildToolsDir" }
183+
184+
outputDir.listFiles { file -> file.extension == "apk" }?.forEach { apk ->
185+
val unaligned = apk.resolveSibling("${apk.nameWithoutExtension}-stripped-unaligned.apk")
186+
val aligned = apk.resolveSibling("${apk.nameWithoutExtension}-stripped-aligned.apk")
187+
ZipFile(apk).use { input ->
188+
ZipOutputStream(unaligned.outputStream().buffered()).use { output ->
189+
val entries = input.entries()
190+
while (entries.hasMoreElements()) {
191+
val entry = entries.nextElement()
192+
if (entry.name == "DebugProbesKt.bin" || entry.name.startsWith("META-INF/")) continue
193+
output.putNextEntry(ZipEntry(entry.name).apply { time = entry.time })
194+
if (!entry.isDirectory) input.getInputStream(entry).use { it.copyTo(output) }
195+
output.closeEntry()
196+
}
197+
}
198+
}
199+
exec { commandLine(zipalign.absolutePath, "-f", "4", unaligned.absolutePath, aligned.absolutePath) }
200+
exec {
201+
commandLine(
202+
apksigner.absolutePath,
203+
"sign",
204+
"--ks", debugKeystore.absolutePath,
205+
"--ks-pass", "pass:android",
206+
"--key-pass", "pass:android",
207+
"--v1-signing-enabled", "false",
208+
"--out", apk.absolutePath,
209+
aligned.absolutePath,
210+
)
211+
}
212+
unaligned.delete()
213+
aligned.delete()
214+
}
215+
}
216+
}
217+
218+
tasks.matching { it.name == "assembleDebug" }.configureEach {
219+
finalizedBy(stripDebugApkMetadata)
220+
}
221+
161222
kotlin {
162223
compilerOptions {
163224
jvmTarget.set(JvmTarget.JVM_21)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector
3+
xmlns:android="http://schemas.android.com/apk/res/android">
4+
<item
5+
android:color="?attr/colorSurface" />
6+
</selector>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector
3+
xmlns:android="http://schemas.android.com/apk/res/android">
4+
<item
5+
android:state_focused="true"
6+
android:color="?attr/colorPrimary" />
7+
<item
8+
android:color="?attr/colorOnSurface"
9+
android:alpha="0.87"
10+
android:state_hovered="true" />
11+
<item
12+
android:state_enabled="false"
13+
android:color="?attr/colorOnSurface"
14+
android:alpha="0.12" />
15+
<item
16+
android:color="?attr/colorOnSurface"
17+
android:alpha="0.38" />
18+
</selector>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector
3+
xmlns:android="http://schemas.android.com/apk/res/android">
4+
<item
5+
android:color="?attr/colorSurfaceVariant" />
6+
</selector>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector
3+
xmlns:android="http://schemas.android.com/apk/res/android">
4+
<item
5+
android:color="?attr/colorPrimary" />
6+
</selector>
239 KB
Loading
259 KB
Loading
77.1 KB
Loading
60.8 KB
Loading
73.7 KB
Loading

0 commit comments

Comments
 (0)