mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +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)
|
@OptIn(ExperimentalTvMaterial3Api::class)
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
if (savedInstanceState == null) {
|
||||||
|
appUpgradeHandler.copySubfont(false)
|
||||||
|
}
|
||||||
Timber.i("MainActivity.onCreate")
|
Timber.i("MainActivity.onCreate")
|
||||||
setContent {
|
setContent {
|
||||||
CoilConfig(okHttpClient, false)
|
CoilConfig(okHttpClient, false)
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class AppUpgradeHandler
|
||||||
putLong(VERSION_CODE_CURRENT_KEY, newVersionCode)
|
putLong(VERSION_CODE_CURRENT_KEY, newVersionCode)
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
copySubfont()
|
copySubfont(true)
|
||||||
upgradeApp(
|
upgradeApp(
|
||||||
context,
|
context,
|
||||||
Version.fromString(previousVersion ?: "0.0.0"),
|
Version.fromString(previousVersion ?: "0.0.0"),
|
||||||
|
|
@ -60,15 +60,18 @@ class AppUpgradeHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun copySubfont() {
|
fun copySubfont(overwrite: Boolean) {
|
||||||
try {
|
try {
|
||||||
val fontFileName = "subfont.tff"
|
val fontFileName = "subfont.ttf"
|
||||||
val outputFile = File(context.filesDir, fontFileName)
|
val outputFile = File(context.filesDir, fontFileName)
|
||||||
|
if (!outputFile.exists() || overwrite) {
|
||||||
context.assets.open(fontFileName).use { input ->
|
context.assets.open(fontFileName).use { input ->
|
||||||
outputFile.outputStream().use { output ->
|
outputFile.outputStream().use { output ->
|
||||||
input.copyTo(output)
|
input.copyTo(output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Timber.i("Wrote %s to local", fontFileName)
|
||||||
|
}
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
Timber.e(ex, "Exception copying subfont.tff")
|
Timber.e(ex, "Exception copying subfont.tff")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue