mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
Android: Allow modifying the status/navigation bar colours
ComponentPeer::setAppStyle() will now update the status and navigation bar foreground colours, with some caveats: - Status and nav bar backgrounds are now always completely transparent. - The navigation bar foreground colour can only be changed on Android API 26 or higher. - For platforms using gesture controls instead of button controls, the system automatically determines the colour of the gesture bar. On those systems, setAppStyle() will only affect the status bar colour.
This commit is contained in:
parent
5bb20e8e04
commit
640574eaba
3 changed files with 895 additions and 852 deletions
|
|
@ -34,6 +34,9 @@
|
|||
|
||||
package com.rmsl.juce;
|
||||
|
||||
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_CAPTION_BARS;
|
||||
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
|
||||
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
|
||||
import static android.view.WindowInsetsController.BEHAVIOR_DEFAULT;
|
||||
import static android.view.WindowInsetsController.BEHAVIOR_SHOW_BARS_BY_SWIPE;
|
||||
import static android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
|
||||
|
|
@ -804,7 +807,7 @@ public final class ComponentPeerView extends ViewGroup
|
|||
{
|
||||
}
|
||||
|
||||
public void setSystemUiVisibilityCompat (Window window, boolean visible)
|
||||
public void setSystemUiVisibilityCompat (Window window, boolean visible, boolean isLight)
|
||||
{
|
||||
if (30 <= Build.VERSION.SDK_INT)
|
||||
{
|
||||
|
|
@ -812,6 +815,11 @@ public final class ComponentPeerView extends ViewGroup
|
|||
|
||||
if (controller != null)
|
||||
{
|
||||
final int mask = (35 <= Build.VERSION.SDK_INT ? APPEARANCE_LIGHT_CAPTION_BARS : 0)
|
||||
| APPEARANCE_LIGHT_NAVIGATION_BARS
|
||||
| APPEARANCE_LIGHT_STATUS_BARS;
|
||||
controller.setSystemBarsAppearance (isLight ? mask : 0, mask);
|
||||
|
||||
if (visible)
|
||||
{
|
||||
controller.show (WindowInsets.Type.systemBars());
|
||||
|
|
@ -843,14 +851,18 @@ public final class ComponentPeerView extends ViewGroup
|
|||
|
||||
for (View view : views)
|
||||
{
|
||||
final int lightStyle = (26 <= Build.VERSION.SDK_INT ? SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR : 0)
|
||||
| SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
|
||||
final int prevFlags = view.getSystemUiVisibility();
|
||||
final int fullScreenFlags = SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
| SYSTEM_UI_FLAG_FULLSCREEN
|
||||
| SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
||||
final int newFlags = visible ? (prevFlags & ~fullScreenFlags)
|
||||
: (prevFlags | fullScreenFlags);
|
||||
final int withVisibility = visible ? (prevFlags & ~fullScreenFlags)
|
||||
: (prevFlags | fullScreenFlags);
|
||||
final int withColour = isLight ? (withVisibility | lightStyle)
|
||||
: (withVisibility & ~lightStyle);
|
||||
|
||||
view.setSystemUiVisibility (newFlags);
|
||||
view.setSystemUiVisibility (withColour);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,13 +60,21 @@ public class JuceActivity extends Activity
|
|||
? ( SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
| SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
|
||||
: SYSTEM_UI_FLAG_LAYOUT_STABLE;
|
||||
: 0;
|
||||
|
||||
decorView.setSystemUiVisibility (decorView.getSystemUiVisibility() | flags);
|
||||
}
|
||||
|
||||
if (30 <= Build.VERSION.SDK_INT)
|
||||
getWindow().setDecorFitsSystemWindows (false);
|
||||
|
||||
if (29 <= Build.VERSION.SDK_INT)
|
||||
{
|
||||
if (Build.VERSION.SDK_INT < 35)
|
||||
getWindow().setStatusBarContrastEnforced (false);
|
||||
|
||||
getWindow().setNavigationBarContrastEnforced (false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue