adjust layouts and colors for Edge-to-Edge with transparent status bar as is default in Android 35+
This commit is contained in:
@@ -149,6 +149,8 @@ namespace keepass2android
|
||||
SetContentView(Resource.Layout.generate_password);
|
||||
SetResult(KeePass.ExitNormal);
|
||||
|
||||
new Util.InsetListener(FindViewById(Resource.Id.main_container)).Apply();
|
||||
|
||||
|
||||
var prefs = GetPreferences(FileCreationMode.Private);
|
||||
|
||||
|
@@ -15,6 +15,36 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
along with Keepass2Android. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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
|
||||
{
|
||||
@@ -1165,6 +1163,8 @@ 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)
|
||||
|
@@ -81,6 +81,9 @@ 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<CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar);
|
||||
collapsingToolbar.SetTitle(GetString(Resource.String.QuickUnlock_prefs));
|
||||
|
@@ -5,7 +5,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
android:fitsSystemWindows="false">
|
||||
<keepass2android.MeasuringLinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
@@ -17,7 +17,7 @@ android:fitsSystemWindows="true">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:fitsSystemWindows="true">
|
||||
android:fitsSystemWindows="false">
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
android:layout_width="match_parent"
|
||||
@@ -28,7 +28,7 @@ android:fitsSystemWindows="true">
|
||||
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">
|
||||
|
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/main_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:background="?android:attr/colorBackground"
|
||||
android:layout_height="fill_parent">
|
||||
@@ -322,4 +323,3 @@
|
||||
</ScrollView>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<keepass2android.FixedDrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
>
|
||||
<!-- activity view -->
|
||||
<keepass2android.MeasuringLinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
@@ -17,14 +17,13 @@
|
||||
android:id="@+id/main_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:fitsSystemWindows="true">
|
||||
android:layout_weight="1">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/detail_backdrop_height"
|
||||
android:fitsSystemWindows="true"
|
||||
android:fitsSystemWindows="false"
|
||||
android:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
@@ -32,14 +31,17 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed"
|
||||
android:fitsSystemWindows="true"
|
||||
app:expandedTitleMarginStart="48dp"
|
||||
android:fitsSystemWindows="false"
|
||||
app:collapsedTitleGravity="center"
|
||||
app:expandedTitleGravity="bottom|left"
|
||||
|
||||
app:expandedTitleMarginStart="8dp"
|
||||
app:expandedTitleMarginEnd="24dp"
|
||||
app:expandedTitleMarginBottom="20sp">
|
||||
|
||||
<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:fitsSystemWindows="false"
|
||||
android:layout_height="fill_parent">
|
||||
<ImageView
|
||||
android:id="@+id/backdrop"
|
||||
@@ -52,7 +54,7 @@
|
||||
android:layout_alignParentBottom="true"
|
||||
|
||||
android:layout_marginBottom="0sp"
|
||||
android:layout_marginLeft="48dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
@@ -446,4 +448,4 @@
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</com.google.android.material.navigation.NavigationView>
|
||||
</keepass2android.FixedDrawerLayout>
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
@@ -0,0 +1,22 @@
|
||||
<resources>
|
||||
<style name="Kp2aTheme_ActionBar" parent="AppTheme.Primary">
|
||||
<item name="android:windowLightStatusBar">false</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
|
||||
<style name="Kp2aTheme_BlueActionBar" parent="AppTheme.Secondary">
|
||||
<item name="android:windowLightStatusBar">false</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
|
||||
<style name="Kp2aTheme_NoActionBar" parent="AppTheme.Primary.NoActionBar">
|
||||
<item name="android:windowLightStatusBar">false</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Kp2aTheme_BlueNoActionBar" parent="AppTheme.Secondary.NoActionBar">
|
||||
<item name="android:windowLightStatusBar">false</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
</resources>
|
22
src/keepass2android-app/Resources/values-v35/themes.xml
Normal file
22
src/keepass2android-app/Resources/values-v35/themes.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<resources>
|
||||
<style name="Kp2aTheme_ActionBar" parent="AppTheme.Primary">
|
||||
<item name="android:windowLightStatusBar">true</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
|
||||
<style name="Kp2aTheme_BlueActionBar" parent="AppTheme.Secondary">
|
||||
<item name="android:windowLightStatusBar">true</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
|
||||
<style name="Kp2aTheme_NoActionBar" parent="AppTheme.Primary.NoActionBar">
|
||||
<item name="android:windowLightStatusBar">true</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Kp2aTheme_BlueNoActionBar" parent="AppTheme.Secondary.NoActionBar">
|
||||
<item name="android:windowLightStatusBar">true</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
</resources>
|
@@ -4,7 +4,7 @@
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
|
||||
<dimen name="detail_backdrop_height">200dp</dimen>
|
||||
<dimen name="detail_backdrop_height">250dp</dimen>
|
||||
<dimen name="fab_margin">16dp</dimen>
|
||||
|
||||
<dimen name="splash_logo_width">79dp</dimen>
|
||||
|
@@ -35,7 +35,9 @@ using Android.Graphics.Drawables;
|
||||
using Android.Hardware.Display;
|
||||
using Android.Util;
|
||||
using Android.Views.InputMethods;
|
||||
using AndroidX.Core.View;
|
||||
using AndroidX.Core.View.InputMethod;
|
||||
using AndroidX.ViewPager2.Widget;
|
||||
using Google.Android.Material.Dialog;
|
||||
using KeePass.Util;
|
||||
using keepass2android;
|
||||
@@ -738,8 +740,74 @@ namespace keepass2android
|
||||
|
||||
|
||||
|
||||
public class InsetListener: Java.Lang.Object, IOnApplyWindowInsetsListener
|
||||
{
|
||||
private View _targetView;
|
||||
private readonly int _insetsType;
|
||||
private int _initialPaddingLeft;
|
||||
private int _initialPaddingTop;
|
||||
private int _initialPaddingRight;
|
||||
private int _initialPaddingBottom;
|
||||
|
||||
|
||||
public bool EnabledPaddingLeft { get; set; } = true;
|
||||
public bool EnablePaddingTop { get; set; } = true;
|
||||
public bool EnablePaddingRight { get; set; } = true;
|
||||
public bool EnablePaddingBottom { get; set; } = true;
|
||||
|
||||
public InsetListener(View targetView, int insetsType)
|
||||
{
|
||||
_targetView = targetView;
|
||||
_insetsType = insetsType;
|
||||
_initialPaddingLeft = targetView.PaddingLeft;
|
||||
_initialPaddingTop = targetView.PaddingTop;
|
||||
_initialPaddingRight = targetView.PaddingRight;
|
||||
_initialPaddingBottom = targetView.PaddingBottom;
|
||||
}
|
||||
|
||||
public InsetListener(View targetView): this(targetView, WindowInsetsCompat.Type.SystemBars())
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public WindowInsetsCompat OnApplyWindowInsets(View v, WindowInsetsCompat insets)
|
||||
{
|
||||
var systemBarsInsets = insets.GetInsets(_insetsType);
|
||||
|
||||
_targetView.SetPadding(
|
||||
_initialPaddingLeft + (EnabledPaddingLeft ? systemBarsInsets.Left : 0),
|
||||
_initialPaddingTop + (EnablePaddingTop ? systemBarsInsets.Top : 0),
|
||||
_initialPaddingRight + (EnablePaddingRight ? systemBarsInsets.Right : 0),
|
||||
_initialPaddingBottom + (EnablePaddingBottom ? systemBarsInsets.Bottom : 0)
|
||||
);
|
||||
|
||||
|
||||
return insets;
|
||||
}
|
||||
|
||||
public static InsetListener ForBottomElement(View view)
|
||||
{
|
||||
return new InsetListener(view, WindowInsetsCompat.Type.Ime() | WindowInsetsCompat.Type.SystemBars() | WindowInsetsCompat.Type.DisplayCutout())
|
||||
{
|
||||
EnablePaddingTop = false
|
||||
};
|
||||
}
|
||||
public static InsetListener ForTopElement(View view)
|
||||
{
|
||||
return new InsetListener(view, WindowInsetsCompat.Type.SystemBars() | WindowInsetsCompat.Type.DisplayCutout())
|
||||
{
|
||||
EnablePaddingBottom = false
|
||||
};
|
||||
}
|
||||
|
||||
public void Apply()
|
||||
{
|
||||
ViewCompat.SetOnApplyWindowInsetsListener(_targetView, this);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void MoveBottomBarButtons(int btn1Id, int btn2Id, int bottomBarId, Activity context)
|
||||
{
|
||||
var btn1 = context.FindViewById<Button>(btn1Id);
|
||||
|
@@ -1217,7 +1217,7 @@ namespace keepass2android
|
||||
{
|
||||
_design.ApplyTheme();
|
||||
base.OnCreate(savedInstanceState);
|
||||
|
||||
new Util.InsetListener(FindViewById(Resource.Id.settings)).Apply();
|
||||
|
||||
}
|
||||
|
||||
|
@@ -163,6 +163,7 @@ namespace keepass2android
|
||||
{
|
||||
_design.ApplyTheme();
|
||||
base.OnCreate(savedInstanceState);
|
||||
new Util.InsetListener(FindViewById(Resource.Id.settings)).Apply();
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user