Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 34 additions & 22 deletions app/android/src/uk/co/lutraconsulting/MMActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
import android.net.Uri;
import android.content.ActivityNotFoundException;
import java.io.File;
Expand Down Expand Up @@ -78,38 +79,49 @@ public String homePath()
return getFilesDir().getAbsolutePath();
}

void setCustomStatusAndNavBar()
@Override
public void onConfigurationChanged(Configuration newConfig)
{
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
Log.d( TAG, "Unsupported Android version for painting behind system bars." );
return;
}
else {
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
super.onConfigurationChanged(newConfig);

Window window = getWindow();
setCustomStatusAndNavBar();
}

// on Android 15+ all apps are edge-to-edge
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
// draw app edge-to-edge
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
@SuppressWarnings("deprecation")
void setCustomStatusAndNavBar()
{
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);

// make the status bar background color transparent
window.setStatusBarColor(Color.TRANSPARENT);
Window window = getWindow();

// make the navigation button background color transparent
window.setNavigationBarColor(Color.TRANSPARENT);
}
// on Android 15+ all apps are edge-to-edge
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
// draw app edge-to-edge
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

// make the status bar background color transparent
window.setStatusBarColor(Color.TRANSPARENT);

// make the navigation button background color transparent
window.setNavigationBarColor(Color.TRANSPARENT);
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// do not show background dim for the navigation buttons
window.setNavigationBarContrastEnforced(false);
window.setNavigationBarContrastEnforced(false);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {

// change the status bar text color to black
WindowInsetsController insetsController = window.getDecorView().getWindowInsetsController();

if (insetsController != null) {
insetsController.setSystemBarsAppearance(WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS, WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS);
}

if (insetsController != null) {
insetsController.setSystemBarsAppearance(WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS, WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS);
}
} else {
// Force the navigation bar icons back to light so they stay visible against the green background.
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility( decorView.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR );
}
}

Expand Down
Loading