android: fix transparent icon background on Android, closes #1462 (#1464)

This commit is contained in:
Huang Xin
2025-06-24 12:54:49 +08:00
committed by GitHub
parent 41e5f27d4d
commit fc0c42f7db
2 changed files with 9 additions and 32 deletions
@@ -9,10 +9,11 @@
<application
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
android:largeHeap="true"
android:label="@string/app_name"
android:theme="@style/Theme.readest"
android:hardwareAccelerated="true"
android:hardwareAccelerated="true"
android:usesCleartextTraffic="${usesCleartextTraffic}">
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
@@ -81,39 +81,15 @@ class MainActivity : TauriActivity(), KeyDownInterceptor {
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
updateTaskDescription()
}
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
updateTaskDescription()
}
override fun onResume() {
super.onResume()
updateTaskDescription()
}
private fun updateTaskDescription() {
val backgroundColor = if (isDarkTheme()) {
Color.parseColor("#2D2D2D")
} else {
Color.parseColor("#FFFFFF")
}
setTaskDescription(
ActivityManager.TaskDescription(
"Readest",
null,
backgroundColor
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setTaskDescription(
ActivityManager.TaskDescription(
getString(R.string.app_name),
null,
Color.TRANSPARENT
)
)
)
}
private fun isDarkTheme(): Boolean {
return when (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
Configuration.UI_MODE_NIGHT_YES -> true
else -> false
}
}
}