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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Gluon
* Copyright (c) 2020, 2025, Gluon
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -29,8 +29,10 @@

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

Expand All @@ -45,7 +47,7 @@ public DalvikStatusBarService(Activity activity) {
}

private void setColor(final int color) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // < 21
Log.e(TAG, "StatusBar service is not supported for the current Android version");
return;
}
Expand All @@ -62,9 +64,27 @@ private void setColor(final int color) {
@Override
public void run() {
Window window = activity.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(color);
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { // <= 34
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
// make status bar transparent
window.setStatusBarColor(0x00000000);
// paint window
window.setBackgroundDrawable(new ColorDrawable(color));
} else { // >= 35
View decorView = window.getDecorView();

// Get insets, before applying the color, as it will reset them
int top = decorView.getPaddingTop();
int right = decorView.getPaddingRight();
int bottom = decorView.getPaddingBottom();
int left = decorView.getPaddingLeft();

// Apply color
decorView.setBackground(new ColorDrawable(color));

// Restore insets
decorView.setPadding(left, top, right, bottom);
}
}
});
}
Expand Down