|
|
|
@ -2,6 +2,7 @@ package org.tasks.themes;
|
|
|
|
|
|
|
|
|
|
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastLollipop;
|
|
|
|
|
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastMarshmallow;
|
|
|
|
|
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastOreoMR1;
|
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
|
|
import android.annotation.TargetApi;
|
|
|
|
@ -9,6 +10,7 @@ import android.app.Activity;
|
|
|
|
|
import android.app.ActivityManager;
|
|
|
|
|
import android.content.res.Resources;
|
|
|
|
|
import android.os.Build;
|
|
|
|
|
import android.os.Build.VERSION_CODES;
|
|
|
|
|
import android.os.Parcel;
|
|
|
|
|
import androidx.drawerlayout.widget.DrawerLayout;
|
|
|
|
|
import androidx.appcompat.widget.Toolbar;
|
|
|
|
@ -140,7 +142,7 @@ public class ThemeColor implements ColorPickerDialog.Pickable {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressLint("NewApi")
|
|
|
|
|
public void applyToStatusBar(Activity activity) {
|
|
|
|
|
public void applyToSystemBars(Activity activity) {
|
|
|
|
|
setStatusBarColor(activity);
|
|
|
|
|
|
|
|
|
|
if (atLeastMarshmallow()) {
|
|
|
|
@ -148,6 +150,8 @@ public class ThemeColor implements ColorPickerDialog.Pickable {
|
|
|
|
|
int systemUiVisibility = applyLightStatusBarFlag(decorView.getSystemUiVisibility());
|
|
|
|
|
decorView.setSystemUiVisibility(systemUiVisibility);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
applyToNavigationBar(activity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressLint("NewApi")
|
|
|
|
@ -168,6 +172,16 @@ public class ThemeColor implements ColorPickerDialog.Pickable {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void applyToNavigationBar(Activity activity) {
|
|
|
|
|
if (atLeastOreoMR1()) {
|
|
|
|
|
activity.getWindow().setNavigationBarColor(getPrimaryColor());
|
|
|
|
|
|
|
|
|
|
View decorView = activity.getWindow().getDecorView();
|
|
|
|
|
int systemUiVisibility = applyLightNavigationBar(decorView.getSystemUiVisibility());
|
|
|
|
|
decorView.setSystemUiVisibility(systemUiVisibility);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@TargetApi(Build.VERSION_CODES.M)
|
|
|
|
|
private int applyLightStatusBarFlag(int flag) {
|
|
|
|
|
return isDark
|
|
|
|
@ -175,6 +189,13 @@ public class ThemeColor implements ColorPickerDialog.Pickable {
|
|
|
|
|
: flag & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@TargetApi(VERSION_CODES.O_MR1)
|
|
|
|
|
private int applyLightNavigationBar(int flag) {
|
|
|
|
|
return isDark
|
|
|
|
|
? flag | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
|
|
|
|
: flag & ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void applyStyle(Resources.Theme theme) {
|
|
|
|
|
theme.applyStyle(style, true);
|
|
|
|
|
}
|
|
|
|
|