diff --git a/app/src/main/java/eu/faircode/email/ActivityBase.java b/app/src/main/java/eu/faircode/email/ActivityBase.java index 4d340e754d..6fba83d89b 100644 --- a/app/src/main/java/eu/faircode/email/ActivityBase.java +++ b/app/src/main/java/eu/faircode/email/ActivityBase.java @@ -46,9 +46,12 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.Window; +import android.view.WindowInsetsController; import android.view.WindowManager; import android.widget.Toast; +import androidx.activity.EdgeToEdge; +import androidx.activity.SystemBarStyle; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; @@ -56,6 +59,10 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.core.graphics.ColorUtils; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowCompat; +import androidx.core.view.WindowInsetsCompat; import androidx.documentfile.provider.DocumentFile; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -111,7 +118,40 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc FragmentDialogTheme.setBackground(this, container, this instanceof ActivityCompose); + ViewCompat.setOnApplyWindowInsetsListener(container, (v, windowInsets) -> { + Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + + ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams(); + mlp.leftMargin = insets.left; + mlp.topMargin = insets.top; + mlp.rightMargin = insets.right; + mlp.bottomMargin = insets.bottom; + v.setLayoutParams(mlp); + + if (ActivityBase.this instanceof ActivityCompose) { + int bottom = windowInsets.getInsets(WindowInsetsCompat.Type.ime()).bottom; + ViewCompat.onApplyWindowInsets(v, new WindowInsetsCompat + .Builder() + .setInsets( + WindowInsetsCompat.Type.systemBars(), + Insets.of(0, 0, 0, bottom - insets.bottom) + ) + .build()); + } + + return WindowInsetsCompat.CONSUMED; + }); + + super.setContentView(container); + + int colorPrimaryDark = Helper.resolveColor(this, androidx.appcompat.R.attr.colorPrimaryDark); + view.post(new RunnableEx("setBackgroundColor") { + @Override + public void delegate() { + getWindow().getDecorView().setBackgroundColor(colorPrimaryDark); + } + }); } @Override @@ -132,6 +172,8 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc getSupportFragmentManager().registerFragmentLifecycleCallbacks(lifecycleCallbacks, true); + int colorPrimaryDark = Helper.resolveColor(this, androidx.appcompat.R.attr.colorPrimaryDark); + this.contacts = hasPermission(Manifest.permission.READ_CONTACTS); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); @@ -144,15 +186,9 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc themeId = FragmentDialogTheme.getTheme(this); setTheme(themeId); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - boolean dark = Helper.isDarkTheme(this); - Window window = getWindow(); - View view = window.getDecorView(); - int flags = view.getSystemUiVisibility(); - if (dark) - flags &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; - view.setSystemUiVisibility(flags); - } + EdgeToEdge.enable(this); + WindowCompat.getInsetsController(getWindow(), getWindow().getDecorView()) + .setAppearanceLightStatusBars(false); } String requestKey = getRequestKey(); @@ -181,8 +217,6 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc prefs.registerOnSharedPreferenceChangeListener(this); - int colorPrimaryDark = Helper.resolveColor(this, androidx.appcompat.R.attr.colorPrimaryDark); - try { Drawable d = getDrawable(R.drawable.baseline_mail_24); Bitmap bm = Bitmap.createBitmap( @@ -212,13 +246,6 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc Log.e(ex); } - boolean navbar_colorize = prefs.getBoolean("navbar_colorize", false); - if (navbar_colorize) { - Window window = getWindow(); - if (window != null) - window.setNavigationBarColor(colorPrimaryDark); - } - FragmentManager fm = getSupportFragmentManager(); Fragment bfragment = fm.findFragmentByTag("androidx.biometric.BiometricFragment"); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index 30d561ea76..13053ca46a 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -143,7 +143,7 @@ public class FragmentOptions extends FragmentBase { "cards", "beige", "tabular_card_bg", "shadow_unread", "shadow_border", "shadow_highlight", "dividers", "tabular_unread_bg", "portrait2", "portrait2c", "portrait_min_size", "landscape", "landscape_min_size", "column_width", - "hide_toolbar", "nav_categories", "nav_last_sync", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "show_unexposed", "navbar_colorize", + "hide_toolbar", "nav_categories", "nav_last_sync", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "show_unexposed", "indentation", "date", "date_week", "date_fixed", "date_bold", "date_time", "threading", "threading_unread", "show_filtered", "highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide", diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java index 00c24ba04a..526028b10f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java @@ -100,7 +100,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer private SwitchCompat swNavUnseenDrafts; private SwitchCompat swNavPinnedCount; private SwitchCompat swShowUnexposed; - private SwitchCompat swNavBarColorize; private SwitchCompat swThreading; private SwitchCompat swThreadingUnread; @@ -214,7 +213,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer "date", "date_week", "date_fixed", "date_bold", "date_time", "group_category", "cards", "beige", "tabular_card_bg", "shadow_unread", "shadow_border", "shadow_highlight", "dividers", "tabular_unread_bg", "portrait2", "portrait2c", "landscape", "close_pane", "open_pane", "column_width", - "hide_toolbar", "nav_options", "nav_categories", "nav_last_sync", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "show_unexposed", "navbar_colorize", + "hide_toolbar", "nav_options", "nav_categories", "nav_last_sync", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "show_unexposed", "threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_swap", "actionbar_color", "highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide", "avatars", "bimi", "gravatars", "libravatars", "favicons", "favicons_partial", "favicons_manifest", "generated_icons", "identicons", @@ -279,7 +278,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer swNavUnseenDrafts = view.findViewById(R.id.swNavUnseenDrafts); swNavPinnedCount = view.findViewById(R.id.swNavPinnedCount); swShowUnexposed = view.findViewById(R.id.swShowUnexposed); - swNavBarColorize = view.findViewById(R.id.swNavBarColorize); swThreading = view.findViewById(R.id.swThreading); swThreadingUnread = view.findViewById(R.id.swThreadingUnread); @@ -695,15 +693,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer } }); - swNavBarColorize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { - prefs.edit().putBoolean("navbar_colorize", checked).apply(); - setNavigationBarColor( - checked ? Helper.resolveColor(getContext(), androidx.appcompat.R.attr.colorPrimaryDark) : Color.BLACK); - } - }); - swThreading.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -1583,7 +1572,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer swNavUnseenDrafts.setChecked(prefs.getBoolean("nav_unseen_drafts", false)); swNavPinnedCount.setChecked(prefs.getBoolean("nav_count_pinned", false)); swShowUnexposed.setChecked(prefs.getBoolean("show_unexposed", false)); - swNavBarColorize.setChecked(prefs.getBoolean("navbar_colorize", false)); swThreading.setChecked(prefs.getBoolean("threading", true)); swThreadingUnread.setChecked(prefs.getBoolean("threading_unread", false)); diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 738ec1ecd1..c352711b9d 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -913,25 +913,6 @@ public class Helper { // View - static void setStatusBarColor(Activity activity, Integer color) { - if (!BuildConfig.DEBUG) - return; - if (activity == null) - return; - Window window = activity.getWindow(); - if (window == null) - return; - - if (color == null) { - //window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - window.setStatusBarColor(Helper.resolveColor(window.getContext(), androidx.appcompat.R.attr.colorPrimaryDark)); - } else { - //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - //window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - window.setStatusBarColor(color); - } - } - static Integer actionBarHeight = null; static int getActionBarHeight(Context context) { @@ -1175,15 +1156,13 @@ public class Helper { reportNoViewer(context, uri, ex); } } else { - boolean navbar_colorize = prefs.getBoolean("navbar_colorize", false); int colorPrimary = resolveColor(context, androidx.appcompat.R.attr.colorPrimary); int colorPrimaryDark = resolveColor(context, androidx.appcompat.R.attr.colorPrimaryDark); CustomTabColorSchemeParams.Builder schemes = new CustomTabColorSchemeParams.Builder() .setToolbarColor(colorPrimary) - .setSecondaryToolbarColor(colorPrimaryDark); - if (navbar_colorize) - schemes.setNavigationBarColor(colorPrimaryDark); + .setSecondaryToolbarColor(colorPrimaryDark) + .setNavigationBarColor(colorPrimaryDark); // https://developer.chrome.com/multidevice/android/customtabs CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder() diff --git a/app/src/main/res/layout/fragment_options_display.xml b/app/src/main/res/layout/fragment_options_display.xml index f2b12446d2..35bafe0676 100644 --- a/app/src/main/res/layout/fragment_options_display.xml +++ b/app/src/main/res/layout/fragment_options_display.xml @@ -674,30 +674,6 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swNavPinnedCount" app:switchPadding="12dp" /> - - - - - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cb9ec294f7..96d28f27ee 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -678,7 +678,6 @@ Swap trash and archive button Use account color as background color for conversation action bar Group by account category - Colorize the Android navigation bar Show the number of messages or conversations in the top action bar Use bundled fonts Use narrow fonts diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 520d88f752..8904658971 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -113,8 +113,6 @@ true @style/activityAnimationStyle - @color/black - @color/abc_primary_text_material_dark @color/abc_primary_text_material_light @color/abc_primary_text_disable_only_material_dark