Fix issue on dark themes, after alert popup dismiss
This commit is contained in:
parent
905fa7dd86
commit
29fd4c4bd2
@ -23,6 +23,7 @@ Bugfix 🐛:
|
|||||||
- Fix status bar icon contrast on API in [21,23[
|
- Fix status bar icon contrast on API in [21,23[
|
||||||
- Wrong /query request (#1444)
|
- Wrong /query request (#1444)
|
||||||
- Make Credentials.homeServer optional because it is deprecated (#1443)
|
- Make Credentials.homeServer optional because it is deprecated (#1443)
|
||||||
|
- Fix issue on dark themes, after alert popup dismiss
|
||||||
|
|
||||||
Translations 🗣:
|
Translations 🗣:
|
||||||
-
|
-
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package im.vector.riotx.features.popup
|
package im.vector.riotx.features.popup
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
@ -26,6 +27,7 @@ import com.tapadoo.alerter.OnHideAlertListener
|
|||||||
import dagger.Lazy
|
import dagger.Lazy
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import im.vector.riotx.features.home.AvatarRenderer
|
import im.vector.riotx.features.home.AvatarRenderer
|
||||||
|
import im.vector.riotx.features.themes.ThemeUtils
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -139,20 +141,28 @@ class PopupAlertManager @Inject constructor(private val avatarRenderer: Lazy<Ava
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("InlinedApi")
|
||||||
private fun clearLightStatusBar() {
|
private fun clearLightStatusBar() {
|
||||||
val view = weakCurrentActivity?.get()?.window?.decorView
|
weakCurrentActivity?.get()
|
||||||
|
?.takeIf { Build.VERSION.SDK_INT >= Build.VERSION_CODES.M }
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && view != null) {
|
// Do not change anything on Dark themes
|
||||||
|
?.takeIf { ThemeUtils.isLightTheme(it) }
|
||||||
|
?.let { it.window?.decorView }
|
||||||
|
?.let { view ->
|
||||||
var flags = view.systemUiVisibility
|
var flags = view.systemUiVisibility
|
||||||
flags = flags and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv()
|
flags = flags and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv()
|
||||||
view.systemUiVisibility = flags
|
view.systemUiVisibility = flags
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("InlinedApi")
|
||||||
private fun setLightStatusBar() {
|
private fun setLightStatusBar() {
|
||||||
val view = weakCurrentActivity?.get()?.window?.decorView
|
weakCurrentActivity?.get()
|
||||||
|
?.takeIf { Build.VERSION.SDK_INT >= Build.VERSION_CODES.M }
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && view != null) {
|
// Do not change anything on Dark themes
|
||||||
|
?.takeIf { ThemeUtils.isLightTheme(it) }
|
||||||
|
?.let { it.window?.decorView }
|
||||||
|
?.let { view ->
|
||||||
var flags = view.systemUiVisibility
|
var flags = view.systemUiVisibility
|
||||||
flags = flags or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
flags = flags or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
||||||
view.systemUiVisibility = flags
|
view.systemUiVisibility = flags
|
||||||
|
@ -44,6 +44,17 @@ object ThemeUtils {
|
|||||||
|
|
||||||
private val mColorByAttr = HashMap<Int, Int>()
|
private val mColorByAttr = HashMap<Int, Int>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if current theme is Light or Status
|
||||||
|
*/
|
||||||
|
fun isLightTheme(context: Context): Boolean {
|
||||||
|
return when (getApplicationTheme(context)) {
|
||||||
|
THEME_LIGHT_VALUE,
|
||||||
|
THEME_STATUS_VALUE -> true
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the selected application theme
|
* Provides the selected application theme
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user