Enabled edge-to-edge

pull/215/head
M66B 6 months ago
parent a25ab1367f
commit 1489dcb775

@ -46,9 +46,12 @@ import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window; import android.view.Window;
import android.view.WindowInsetsController;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.Toast; import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.activity.SystemBarStyle;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBar;
@ -56,6 +59,10 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.graphics.ColorUtils; 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.documentfile.provider.DocumentFile;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
@ -111,7 +118,40 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
FragmentDialogTheme.setBackground(this, container, this instanceof ActivityCompose); 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); 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 @Override
@ -132,6 +172,8 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
getSupportFragmentManager().registerFragmentLifecycleCallbacks(lifecycleCallbacks, true); getSupportFragmentManager().registerFragmentLifecycleCallbacks(lifecycleCallbacks, true);
int colorPrimaryDark = Helper.resolveColor(this, androidx.appcompat.R.attr.colorPrimaryDark);
this.contacts = hasPermission(Manifest.permission.READ_CONTACTS); this.contacts = hasPermission(Manifest.permission.READ_CONTACTS);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
@ -144,15 +186,9 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
themeId = FragmentDialogTheme.getTheme(this); themeId = FragmentDialogTheme.getTheme(this);
setTheme(themeId); setTheme(themeId);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { EdgeToEdge.enable(this);
boolean dark = Helper.isDarkTheme(this); WindowCompat.getInsetsController(getWindow(), getWindow().getDecorView())
Window window = getWindow(); .setAppearanceLightStatusBars(false);
View view = window.getDecorView();
int flags = view.getSystemUiVisibility();
if (dark)
flags &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
view.setSystemUiVisibility(flags);
}
} }
String requestKey = getRequestKey(); String requestKey = getRequestKey();
@ -181,8 +217,6 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
prefs.registerOnSharedPreferenceChangeListener(this); prefs.registerOnSharedPreferenceChangeListener(this);
int colorPrimaryDark = Helper.resolveColor(this, androidx.appcompat.R.attr.colorPrimaryDark);
try { try {
Drawable d = getDrawable(R.drawable.baseline_mail_24); Drawable d = getDrawable(R.drawable.baseline_mail_24);
Bitmap bm = Bitmap.createBitmap( Bitmap bm = Bitmap.createBitmap(
@ -212,13 +246,6 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
Log.e(ex); 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(); FragmentManager fm = getSupportFragmentManager();
Fragment bfragment = fm.findFragmentByTag("androidx.biometric.BiometricFragment"); Fragment bfragment = fm.findFragmentByTag("androidx.biometric.BiometricFragment");

@ -143,7 +143,7 @@ public class FragmentOptions extends FragmentBase {
"cards", "beige", "tabular_card_bg", "shadow_unread", "shadow_border", "shadow_highlight", "dividers", "tabular_unread_bg", "cards", "beige", "tabular_card_bg", "shadow_unread", "shadow_border", "shadow_highlight", "dividers", "tabular_unread_bg",
"portrait2", "portrait2c", "portrait_min_size", "landscape", "landscape_min_size", "portrait2", "portrait2c", "portrait_min_size", "landscape", "landscape_min_size",
"column_width", "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", "indentation", "date", "date_week", "date_fixed", "date_bold", "date_time", "threading", "threading_unread",
"show_filtered", "show_filtered",
"highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide", "highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide",

@ -100,7 +100,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swNavUnseenDrafts; private SwitchCompat swNavUnseenDrafts;
private SwitchCompat swNavPinnedCount; private SwitchCompat swNavPinnedCount;
private SwitchCompat swShowUnexposed; private SwitchCompat swShowUnexposed;
private SwitchCompat swNavBarColorize;
private SwitchCompat swThreading; private SwitchCompat swThreading;
private SwitchCompat swThreadingUnread; 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", "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", "cards", "beige", "tabular_card_bg", "shadow_unread", "shadow_border", "shadow_highlight", "dividers", "tabular_unread_bg",
"portrait2", "portrait2c", "landscape", "close_pane", "open_pane", "column_width", "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", "threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_swap", "actionbar_color",
"highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide", "highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide",
"avatars", "bimi", "gravatars", "libravatars", "favicons", "favicons_partial", "favicons_manifest", "generated_icons", "identicons", "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); swNavUnseenDrafts = view.findViewById(R.id.swNavUnseenDrafts);
swNavPinnedCount = view.findViewById(R.id.swNavPinnedCount); swNavPinnedCount = view.findViewById(R.id.swNavPinnedCount);
swShowUnexposed = view.findViewById(R.id.swShowUnexposed); swShowUnexposed = view.findViewById(R.id.swShowUnexposed);
swNavBarColorize = view.findViewById(R.id.swNavBarColorize);
swThreading = view.findViewById(R.id.swThreading); swThreading = view.findViewById(R.id.swThreading);
swThreadingUnread = view.findViewById(R.id.swThreadingUnread); 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() { swThreading.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { 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)); swNavUnseenDrafts.setChecked(prefs.getBoolean("nav_unseen_drafts", false));
swNavPinnedCount.setChecked(prefs.getBoolean("nav_count_pinned", false)); swNavPinnedCount.setChecked(prefs.getBoolean("nav_count_pinned", false));
swShowUnexposed.setChecked(prefs.getBoolean("show_unexposed", false)); swShowUnexposed.setChecked(prefs.getBoolean("show_unexposed", false));
swNavBarColorize.setChecked(prefs.getBoolean("navbar_colorize", false));
swThreading.setChecked(prefs.getBoolean("threading", true)); swThreading.setChecked(prefs.getBoolean("threading", true));
swThreadingUnread.setChecked(prefs.getBoolean("threading_unread", false)); swThreadingUnread.setChecked(prefs.getBoolean("threading_unread", false));

@ -913,25 +913,6 @@ public class Helper {
// View // 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 Integer actionBarHeight = null;
static int getActionBarHeight(Context context) { static int getActionBarHeight(Context context) {
@ -1175,15 +1156,13 @@ public class Helper {
reportNoViewer(context, uri, ex); reportNoViewer(context, uri, ex);
} }
} else { } else {
boolean navbar_colorize = prefs.getBoolean("navbar_colorize", false);
int colorPrimary = resolveColor(context, androidx.appcompat.R.attr.colorPrimary); int colorPrimary = resolveColor(context, androidx.appcompat.R.attr.colorPrimary);
int colorPrimaryDark = resolveColor(context, androidx.appcompat.R.attr.colorPrimaryDark); int colorPrimaryDark = resolveColor(context, androidx.appcompat.R.attr.colorPrimaryDark);
CustomTabColorSchemeParams.Builder schemes = new CustomTabColorSchemeParams.Builder() CustomTabColorSchemeParams.Builder schemes = new CustomTabColorSchemeParams.Builder()
.setToolbarColor(colorPrimary) .setToolbarColor(colorPrimary)
.setSecondaryToolbarColor(colorPrimaryDark); .setSecondaryToolbarColor(colorPrimaryDark)
if (navbar_colorize) .setNavigationBarColor(colorPrimaryDark);
schemes.setNavigationBarColor(colorPrimaryDark);
// https://developer.chrome.com/multidevice/android/customtabs // https://developer.chrome.com/multidevice/android/customtabs
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder() CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder()

@ -674,30 +674,6 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNavPinnedCount" app:layout_constraintTop_toBottomOf="@id/swNavPinnedCount"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNavBarColorize"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_navbar_colorize"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swShowUnexposed"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvNavBarColorizeHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_navbar_colorize_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNavBarColorize" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>

@ -678,7 +678,6 @@
<string name="title_advanced_actionbar_swap">Swap trash and archive button</string> <string name="title_advanced_actionbar_swap">Swap trash and archive button</string>
<string name="title_advanced_actionbar_color">Use account color as background color for conversation action bar</string> <string name="title_advanced_actionbar_color">Use account color as background color for conversation action bar</string>
<string name="title_advanced_category_header">Group by account category</string> <string name="title_advanced_category_header">Group by account category</string>
<string name="title_advanced_navbar_colorize">Colorize the Android navigation bar</string>
<string name="title_advanced_list_count">Show the number of messages or conversations in the top action bar</string> <string name="title_advanced_list_count">Show the number of messages or conversations in the top action bar</string>
<string name="title_advanced_bundled_fonts">Use bundled fonts</string> <string name="title_advanced_bundled_fonts">Use bundled fonts</string>
<string name="title_advanced_narrow_fonts">Use narrow fonts</string> <string name="title_advanced_narrow_fonts">Use narrow fonts</string>

@ -113,8 +113,6 @@
<item name="android:windowDisablePreview">true</item> <item name="android:windowDisablePreview">true</item>
<item name="android:windowAnimationStyle">@style/activityAnimationStyle</item> <item name="android:windowAnimationStyle">@style/activityAnimationStyle</item>
<item name="android:navigationBarColor">@color/black</item>
<item name="android:textColorPrimary">@color/abc_primary_text_material_dark</item> <item name="android:textColorPrimary">@color/abc_primary_text_material_dark</item>
<item name="android:textColorPrimaryInverse">@color/abc_primary_text_material_light</item> <item name="android:textColorPrimaryInverse">@color/abc_primary_text_material_light</item>
<item name="android:textColorPrimaryDisableOnly">@color/abc_primary_text_disable_only_material_dark</item> <item name="android:textColorPrimaryDisableOnly">@color/abc_primary_text_disable_only_material_dark</item>

Loading…
Cancel
Save