From 260bc8adb237fdde7f5e0e526a90324dce2e57cb Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Tue, 22 Jul 2025 15:16:28 +0200 Subject: [PATCH] adjust layouts and colors for Edge-to-Edge with transparent status bar as is default in Android 35+ --- .../GeneratePasswordActivity.cs | 8 +- src/keepass2android-app/PasswordActivity.cs | 78 +++++++++---------- src/keepass2android-app/QuickUnlock.cs | 5 +- .../Resources/layout/QuickUnlock.xml | 8 +- .../Resources/layout/generate_password.xml | 2 +- .../Resources/layout/password.xml | 22 +++--- .../Resources/values-night-v35/themes.xml | 22 ++++++ .../Resources/values-v35/themes.xml | 22 ++++++ .../Resources/values/dimens.xml | 2 +- .../Resources/values/themes.xml | 6 +- src/keepass2android-app/Utils/Util.cs | 68 ++++++++++++++++ .../settings/AppSettingsActivity.cs | 2 +- .../settings/DatabaseSettingsActivity.cs | 1 + 13 files changed, 183 insertions(+), 63 deletions(-) create mode 100644 src/keepass2android-app/Resources/values-night-v35/themes.xml create mode 100644 src/keepass2android-app/Resources/values-v35/themes.xml diff --git a/src/keepass2android-app/GeneratePasswordActivity.cs b/src/keepass2android-app/GeneratePasswordActivity.cs index e187a01e..46f3da0d 100644 --- a/src/keepass2android-app/GeneratePasswordActivity.cs +++ b/src/keepass2android-app/GeneratePasswordActivity.cs @@ -145,12 +145,14 @@ namespace keepass2android protected override void OnCreate(Bundle savedInstanceState) { _design.ApplyTheme(); base.OnCreate(savedInstanceState); - + SetContentView(Resource.Layout.generate_password); SetResult(KeePass.ExitNormal); - - var prefs = GetPreferences(FileCreationMode.Private); + new Util.InsetListener(FindViewById(Resource.Id.main_container)).Apply(); + + + var prefs = GetPreferences(FileCreationMode.Private); diff --git a/src/keepass2android-app/PasswordActivity.cs b/src/keepass2android-app/PasswordActivity.cs index 9cd6d54b..96c6bd1f 100644 --- a/src/keepass2android-app/PasswordActivity.cs +++ b/src/keepass2android-app/PasswordActivity.cs @@ -15,6 +15,36 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file along with Keepass2Android. If not, see . */ +using Android.App; +using Android.Content; +using Android.Content.PM; +using Android.Database; +using Android.Graphics; +using Android.Graphics.Drawables; +using Android.OS; +using Android.Preferences; +using Android.Runtime; +using Android.Text; +using Android.Views; +using Android.Views.InputMethods; +using Android.Widget; +using AndroidX.AppCompat.App; +using AndroidX.CoordinatorLayout.Widget; +using AndroidX.Core.Content; +using AndroidX.Core.View; +using AndroidX.DrawerLayout.Widget; +using Google.Android.Material.AppBar; +using Google.Android.Material.Dialog; +using Java.Lang; +using Java.Net; +using KeeChallenge; +using keepass2android; +using keepass2android.Io; +using keepass2android.Utils; +using Keepass2android.Pluginsdk; +using KeePassLib.Keys; +using KeePassLib.Serialization; +using OtpKeyProv; using System; using System.Collections.Generic; using System.IO; @@ -23,49 +53,17 @@ using System.Net; using System.Threading.Tasks; using System.Xml; using System.Xml.Serialization; -using keepass2android; -using Android.App; -using Android.Content; -using Android.Database; -using Android.Graphics.Drawables; -using Android.OS; -using Android.Runtime; -using Android.Views; -using Android.Views.InputMethods; -using Android.Widget; -using Java.Net; -using Android.Preferences; -using Android.Text; -using Android.Content.PM; -using Android.Graphics; -using AndroidX.AppCompat.App; -using AndroidX.CoordinatorLayout.Widget; -using AndroidX.Core.View; -using AndroidX.DrawerLayout.Widget; -using Google.Android.Material.AppBar; -using Google.Android.Material.Dialog; -using Java.Lang; -using KeePassLib.Keys; -using KeePassLib.Serialization; -using Keepass2android.Pluginsdk; -using OtpKeyProv; -using keepass2android.Io; -using keepass2android.Utils; - -using File = Java.IO.File; -using FileNotFoundException = Java.IO.FileNotFoundException; - -using Object = Java.Lang.Object; -using Process = Android.OS.Process; - -using KeeChallenge; +using static Android.Locations.GpsStatus; using AlertDialog = Android.App.AlertDialog; using ClipboardManager = Android.Content.ClipboardManager; using Enum = System.Enum; using Exception = System.Exception; +using File = Java.IO.File; +using FileNotFoundException = Java.IO.FileNotFoundException; +using Object = Java.Lang.Object; +using Process = Android.OS.Process; using String = System.String; using Toolbar = AndroidX.AppCompat.Widget.Toolbar; -using AndroidX.Core.Content; namespace keepass2android { @@ -651,7 +649,7 @@ namespace keepass2android _activityDesign.ApplyTheme(); base.OnCreate(savedInstanceState); - _intentReceiver = new PasswordActivityBroadcastReceiver(this); + _intentReceiver = new PasswordActivityBroadcastReceiver(this); IntentFilter filter = new IntentFilter(); filter.AddAction(Intent.ActionScreenOff); ContextCompat.RegisterReceiver(this, _intentReceiver, filter, (int)ReceiverFlags.Exported); @@ -1165,7 +1163,9 @@ namespace keepass2android changeDbButton.Click += (sender, args) => GoToFileSelectActivity(); Util.MoveBottomBarButtons(Resource.Id.change_db, Resource.Id.pass_ok, Resource.Id.bottom_bar, this); - } + Util.InsetListener.ForBottomElement(FindViewById(Resource.Id.bottom_bar)).Apply(); + Util.InsetListener.ForTopElement(FindViewById(Resource.Id.appbar)).Apply(); + } private void OnOk(bool usedFingerprintUnlock = false) { diff --git a/src/keepass2android-app/QuickUnlock.cs b/src/keepass2android-app/QuickUnlock.cs index 4a8b35fa..d57fd51f 100644 --- a/src/keepass2android-app/QuickUnlock.cs +++ b/src/keepass2android-app/QuickUnlock.cs @@ -81,8 +81,11 @@ namespace keepass2android SetContentView(Resource.Layout.QuickUnlock); + Util.InsetListener.ForBottomElement(FindViewById(Resource.Id.bottom_bar)).Apply(); + Util.InsetListener.ForTopElement(FindViewById(Resource.Id.appbar)).Apply(); - var collapsingToolbar = FindViewById(Resource.Id.collapsing_toolbar); + + var collapsingToolbar = FindViewById(Resource.Id.collapsing_toolbar); collapsingToolbar.SetTitle(GetString(Resource.String.QuickUnlock_prefs)); SetSupportActionBar(FindViewById(Resource.Id.toolbar)); diff --git a/src/keepass2android-app/Resources/layout/QuickUnlock.xml b/src/keepass2android-app/Resources/layout/QuickUnlock.xml index 0c4da5c4..70bd4b02 100644 --- a/src/keepass2android-app/Resources/layout/QuickUnlock.xml +++ b/src/keepass2android-app/Resources/layout/QuickUnlock.xml @@ -1,11 +1,11 @@ +android:fitsSystemWindows="false"> android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" - android:fitsSystemWindows="true"> + android:fitsSystemWindows="false"> android:layout_width="match_parent" android:layout_height="match_parent" app:layout_scrollFlags="scroll|exitUntilCollapsed" - android:fitsSystemWindows="true" + android:fitsSystemWindows="false" app:expandedTitleMarginStart="16dp" app:expandedTitleMarginEnd="24dp" app:expandedTitleMarginBottom="20sp"> diff --git a/src/keepass2android-app/Resources/layout/generate_password.xml b/src/keepass2android-app/Resources/layout/generate_password.xml index 6eca0d7f..351c7bd7 100644 --- a/src/keepass2android-app/Resources/layout/generate_password.xml +++ b/src/keepass2android-app/Resources/layout/generate_password.xml @@ -1,5 +1,6 @@ @@ -322,4 +323,3 @@ - diff --git a/src/keepass2android-app/Resources/layout/password.xml b/src/keepass2android-app/Resources/layout/password.xml index b21a343f..af9a3745 100644 --- a/src/keepass2android-app/Resources/layout/password.xml +++ b/src/keepass2android-app/Resources/layout/password.xml @@ -1,10 +1,10 @@ - +> + android:layout_weight="1"> @@ -446,4 +448,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/keepass2android-app/Resources/values-night-v35/themes.xml b/src/keepass2android-app/Resources/values-night-v35/themes.xml new file mode 100644 index 00000000..86a3ae7f --- /dev/null +++ b/src/keepass2android-app/Resources/values-night-v35/themes.xml @@ -0,0 +1,22 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/keepass2android-app/Resources/values-v35/themes.xml b/src/keepass2android-app/Resources/values-v35/themes.xml new file mode 100644 index 00000000..3bf426f4 --- /dev/null +++ b/src/keepass2android-app/Resources/values-v35/themes.xml @@ -0,0 +1,22 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/keepass2android-app/Resources/values/dimens.xml b/src/keepass2android-app/Resources/values/dimens.xml index dbc57788..982af1db 100644 --- a/src/keepass2android-app/Resources/values/dimens.xml +++ b/src/keepass2android-app/Resources/values/dimens.xml @@ -4,7 +4,7 @@ 16dp 16dp - 200dp + 250dp 16dp 79dp diff --git a/src/keepass2android-app/Resources/values/themes.xml b/src/keepass2android-app/Resources/values/themes.xml index 9635d989..d9b6d6fd 100644 --- a/src/keepass2android-app/Resources/values/themes.xml +++ b/src/keepass2android-app/Resources/values/themes.xml @@ -253,12 +253,12 @@ @color/statusbar_color_green - + +