mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 15:50:16 +02:00
Fix installing font
This commit is contained in:
parent
1e657706a6
commit
5ff7c1ffa9
2 changed files with 12 additions and 6 deletions
|
|
@ -73,6 +73,9 @@ class MainActivity : AppCompatActivity() {
|
|||
@OptIn(ExperimentalTvMaterial3Api::class)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
if (savedInstanceState == null) {
|
||||
appUpgradeHandler.copySubfont(false)
|
||||
}
|
||||
Timber.i("MainActivity.onCreate")
|
||||
setContent {
|
||||
CoilConfig(okHttpClient, false)
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class AppUpgradeHandler
|
|||
putLong(VERSION_CODE_CURRENT_KEY, newVersionCode)
|
||||
}
|
||||
try {
|
||||
copySubfont()
|
||||
copySubfont(true)
|
||||
upgradeApp(
|
||||
context,
|
||||
Version.fromString(previousVersion ?: "0.0.0"),
|
||||
|
|
@ -60,15 +60,18 @@ class AppUpgradeHandler
|
|||
}
|
||||
}
|
||||
|
||||
private fun copySubfont() {
|
||||
fun copySubfont(overwrite: Boolean) {
|
||||
try {
|
||||
val fontFileName = "subfont.tff"
|
||||
val fontFileName = "subfont.ttf"
|
||||
val outputFile = File(context.filesDir, fontFileName)
|
||||
if (!outputFile.exists() || overwrite) {
|
||||
context.assets.open(fontFileName).use { input ->
|
||||
outputFile.outputStream().use { output ->
|
||||
input.copyTo(output)
|
||||
}
|
||||
}
|
||||
Timber.i("Wrote %s to local", fontFileName)
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
Timber.e(ex, "Exception copying subfont.tff")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue