diff options
author | Bartlomiej Moskal <bartlomiej.moskal@qt.io> | 2022-12-14 11:17:46 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-12-20 12:42:52 +0000 |
commit | d6c932e0011f6d2ba5a792e09d0fa9f9f19d66b2 (patch) | |
tree | 58b6bd919ebf8111c5393e44dc8159d21c59e359 /src | |
parent | 25b9567f0e4deee4def26f4900d623b927712598 (diff) | |
download | qtbase-d6c932e0011f6d2ba5a792e09d0fa9f9f19d66b2.tar.gz |
Android: Fix for low contrast status bar
After we start to use THEME: Theme_DeviceDefault_DayNight, status bar
icons have low contrasts on some devices.
That is why we need to set APPEARANCE_LIGHT_STATUS_BARS[0] in case when
Status bar color is too bright.
[0]https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_LIGHT_STATUS_BARS
Fixes: QTBUG-108365
Change-Id: I38a31cfb0a3a1b912b86ed1b302c567e14a7ffcc
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit eda4049a0142029c192e1690bafffbb98ee4ff99)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java index ec890d1d61..7a0af367a3 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java @@ -14,6 +14,7 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.AssetManager; import android.content.res.Configuration; +import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.graphics.Rect; @@ -43,6 +44,8 @@ import android.view.Surface; import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowInsetsController; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; import android.view.ViewTreeObserver; @@ -973,6 +976,19 @@ public class QtActivityDelegate private void handleUiModeChange(int uiMode) { + // QTBUG-108365 + if (Build.VERSION.SDK_INT >= 29) { + // Since 29 version we are using Theme_DeviceDefault_DayNight + Window window = m_activity.getWindow(); + WindowInsetsController controller = window.getInsetsController(); + if (controller != null) { + // set APPEARANCE_LIGHT_STATUS_BARS if needed + int appearanceLight = Color.luminance(window.getStatusBarColor()) > 0.5 ? + WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS : 0; + controller.setSystemBarsAppearance(appearanceLight, + WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS); + } + } switch (uiMode) { case Configuration.UI_MODE_NIGHT_NO: ExtractStyle.runIfNeeded(m_activity, false); |