mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Merge pull request #2775 from vector-im/feature/bma/fix_crash_1015
Fix crash on API < 30 and light theme (#2774)
This commit is contained in:
commit
2d5f57591f
2 changed files with 29 additions and 20 deletions
|
@ -8,7 +8,7 @@ Improvements 🙌:
|
|||
-
|
||||
|
||||
Bugfix 🐛:
|
||||
-
|
||||
- Fix crash on API < 30 and light theme (#2774)
|
||||
|
||||
Translations 🗣:
|
||||
-
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
package im.vector.app.features.popup
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
|
@ -158,28 +157,38 @@ class PopupAlertManager @Inject constructor(private val avatarRenderer: Lazy<Ava
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressLint("InlinedApi")
|
||||
private fun clearLightStatusBar() {
|
||||
weakCurrentActivity?.get()
|
||||
?.takeIf { Build.VERSION.SDK_INT >= Build.VERSION_CODES.M }
|
||||
// Do not change anything on Dark themes
|
||||
?.takeIf { ThemeUtils.isLightTheme(it) }
|
||||
?.let { it.window?.decorView }
|
||||
?.let { view ->
|
||||
view.windowInsetsController?.setSystemBarsAppearance(0, APPEARANCE_LIGHT_STATUS_BARS)
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
weakCurrentActivity?.get()
|
||||
// Do not change anything on Dark themes
|
||||
?.takeIf { ThemeUtils.isLightTheme(it) }
|
||||
?.window?.decorView
|
||||
?.let { view ->
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
view.windowInsetsController?.setSystemBarsAppearance(0, APPEARANCE_LIGHT_STATUS_BARS)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
view.systemUiVisibility = view.systemUiVisibility and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("InlinedApi")
|
||||
private fun setLightStatusBar() {
|
||||
weakCurrentActivity?.get()
|
||||
?.takeIf { Build.VERSION.SDK_INT >= Build.VERSION_CODES.M }
|
||||
// Do not change anything on Dark themes
|
||||
?.takeIf { ThemeUtils.isLightTheme(it) }
|
||||
?.let { it.window?.decorView }
|
||||
?.let { view ->
|
||||
view.windowInsetsController?.setSystemBarsAppearance(APPEARANCE_LIGHT_STATUS_BARS, APPEARANCE_LIGHT_STATUS_BARS)
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
weakCurrentActivity?.get()
|
||||
// Do not change anything on Dark themes
|
||||
?.takeIf { ThemeUtils.isLightTheme(it) }
|
||||
?.window?.decorView
|
||||
?.let { view ->
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
view.windowInsetsController?.setSystemBarsAppearance(APPEARANCE_LIGHT_STATUS_BARS, APPEARANCE_LIGHT_STATUS_BARS)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
view.systemUiVisibility = view.systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showAlert(alert: VectorAlert, activity: Activity, animate: Boolean = true) {
|
||||
|
|
Loading…
Reference in a new issue