Fix task description color crash (#2475)

This commit is contained in:
Rafał Borcz 2024-03-11 11:44:59 +01:00 committed by GitHub
parent c72cc39920
commit 38c00ddab5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 4 deletions

1
.gitignore vendored
View File

@ -69,6 +69,7 @@ captures/
.idea/androidTestResultsUserPreferences.xml
.idea/copilot
.idea/deploymentTargetDropDown.xml
.idea/deploymentTargetSelector.xml
.idea/kotlinc.xml
# Keystore files

View File

@ -1,6 +1,7 @@
package io.github.wulkanowy.ui.base
import android.app.ActivityManager
import android.os.Build
import android.os.Bundle
import android.view.View
import android.widget.Toast
@ -45,11 +46,19 @@ abstract class BaseActivity<T : BasePresenter<out BaseView>, VB : ViewBinding> :
themeManager.applyActivityTheme(this)
super.onCreate(savedInstanceState)
supportFragmentManager.registerFragmentLifecycleCallbacks(fragmentLifecycleLogger, true)
applyCustomTaskDescription()
}
@Suppress("DEPRECATION")
setTaskDescription(
ActivityManager.TaskDescription(null, null, getThemeAttrColor(R.attr.colorSurface))
)
private fun applyCustomTaskDescription() {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) return
try {
val newColor = getThemeAttrColor(R.attr.colorSurface)
val taskDescription = ActivityManager.TaskDescription(null, null, newColor)
setTaskDescription(taskDescription)
} catch (e: Exception) {
Timber.e(e)
}
}
override fun showError(text: String, error: Throwable) {