mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-01 17:26:12 +00:00
Enabled edge-to-edge
This commit is contained in:
parent
a25ab1367f
commit
1489dcb775
7 changed files with 49 additions and 82 deletions
|
@ -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");
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -674,30 +674,6 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swNavPinnedCount"
|
||||
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.cardview.widget.CardView>
|
||||
|
||||
|
|
|
@ -678,7 +678,6 @@
|
|||
<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_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_bundled_fonts">Use bundled 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: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:textColorPrimaryInverse">@color/abc_primary_text_material_light</item>
|
||||
<item name="android:textColorPrimaryDisableOnly">@color/abc_primary_text_disable_only_material_dark</item>
|
||||
|
|
Loading…
Reference in a new issue