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 Pick-to: 6.5 6.4 6.2 Change-Id: I38a31cfb0a3a1b912b86ed1b302c567e14a7ffcc Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
parent
c1fa5d602c
commit
eda4049a01
@ -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;
|
||||
@ -978,6 +981,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);
|
||||
|
Loading…
Reference in New Issue
Block a user