mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
Added Scale to device info service. Stack layout padding adjsutments depending on android scale.
This commit is contained in:
parent
5ff9131910
commit
0cdba2a13d
12 changed files with 79 additions and 10 deletions
|
@ -1,4 +1,6 @@
|
|||
using Android.App;
|
||||
using Android.OS;
|
||||
using Android.Util;
|
||||
using Bit.App.Abstractions;
|
||||
|
||||
namespace Bit.Android.Services
|
||||
|
@ -7,5 +9,38 @@ namespace Bit.Android.Services
|
|||
{
|
||||
public string Model => Build.Model;
|
||||
public int Version => (int)Build.VERSION.SdkInt;
|
||||
public float Scale
|
||||
{
|
||||
get
|
||||
{
|
||||
var density = Application.Context.Resources.DisplayMetrics.Density;
|
||||
if(density <= 0.75)
|
||||
{
|
||||
return 0.75f;
|
||||
}
|
||||
else if(density <= 1)
|
||||
{
|
||||
return 1f;
|
||||
}
|
||||
else if(density <= 1.5)
|
||||
{
|
||||
return 1.5f;
|
||||
}
|
||||
else if(density <= 2)
|
||||
{
|
||||
return 2f;
|
||||
}
|
||||
else if(density <= 3)
|
||||
{
|
||||
return 3f;
|
||||
}
|
||||
else if(density <= 4)
|
||||
{
|
||||
return 4f;
|
||||
}
|
||||
|
||||
return 1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,5 +4,6 @@
|
|||
{
|
||||
string Model { get; }
|
||||
int Version { get; }
|
||||
float Scale { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ namespace Bit.App
|
|||
var lockPinPage = Current.MainPage.Navigation.ModalStack.LastOrDefault() as LockPinPage;
|
||||
if(lockPinPage != null)
|
||||
{
|
||||
lockPinPage.PinControl.Entry.Focus();
|
||||
lockPinPage.PinControl.Entry.FocusWithDelay();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,13 +228,7 @@ namespace Bit.App
|
|||
await Current.MainPage.Navigation.PushModalAsync(new ExtendedNavigationPage(new LockFingerprintPage(!forceLock)), false);
|
||||
break;
|
||||
case Enums.LockType.PIN:
|
||||
var lockPinPage = (currentPage?.CurrentPage as LockPinPage);
|
||||
if(lockPinPage == null)
|
||||
{
|
||||
lockPinPage = new LockPinPage();
|
||||
await Current.MainPage.Navigation.PushModalAsync(new ExtendedNavigationPage(lockPinPage), false);
|
||||
lockPinPage.PinControl.Entry.Focus();
|
||||
}
|
||||
await Current.MainPage.Navigation.PushModalAsync(new ExtendedNavigationPage(new LockPinPage()), false);
|
||||
break;
|
||||
case Enums.LockType.Password:
|
||||
await Current.MainPage.Navigation.PushModalAsync(new ExtendedNavigationPage(new LockPasswordPage()), false);
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace Bit.App.Controls
|
|||
|
||||
Tapped += FormEditorCell_Tapped;
|
||||
Editor.AdjustMarginsForDevice();
|
||||
stackLayout.AdjustPaddingForDevice();
|
||||
|
||||
View = stackLayout;
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace Bit.App.Controls
|
|||
{
|
||||
if(deviceInfo.Version < 21)
|
||||
{
|
||||
Entry.Margin = new Thickness(-9, 0);
|
||||
Entry.Margin = new Thickness(-9, 1, -9, 0);
|
||||
}
|
||||
else if(deviceInfo.Version == 21)
|
||||
{
|
||||
|
@ -97,6 +97,11 @@ namespace Bit.App.Controls
|
|||
{
|
||||
Entry.AdjustMarginsForDevice();
|
||||
}
|
||||
|
||||
if(containerPadding == null)
|
||||
{
|
||||
imageStackLayout.AdjustPaddingForDevice();
|
||||
}
|
||||
}
|
||||
|
||||
if(!useLabelAsPlaceholder)
|
||||
|
|
|
@ -40,6 +40,7 @@ namespace Bit.App.Controls
|
|||
stackLayout.Spacing = 0;
|
||||
}
|
||||
Picker.AdjustMarginsForDevice();
|
||||
stackLayout.AdjustPaddingForDevice();
|
||||
|
||||
Tapped += FormPickerCell_Tapped;
|
||||
|
||||
|
|
|
@ -92,6 +92,9 @@ namespace Bit.App.Controls
|
|||
{
|
||||
Button2.Padding = new Thickness(5);
|
||||
}
|
||||
|
||||
|
||||
containerStackLayout.AdjustPaddingForDevice();
|
||||
}
|
||||
|
||||
containerStackLayout.Children.Add(buttonStackLayout);
|
||||
|
|
|
@ -51,6 +51,7 @@ namespace Bit.App.Controls
|
|||
{
|
||||
Label.TextColor = Color.Black;
|
||||
}
|
||||
stackLayout.AdjustPaddingForDevice();
|
||||
|
||||
View = stackLayout;
|
||||
}
|
||||
|
|
|
@ -139,6 +139,8 @@ namespace Bit.App.Pages
|
|||
WinPhone: new Thickness(15, 25))
|
||||
};
|
||||
|
||||
containerStackLayout.AdjustPaddingForDevice();
|
||||
|
||||
ShowDisclousure = true;
|
||||
View = containerStackLayout;
|
||||
}
|
||||
|
|
|
@ -215,6 +215,7 @@ namespace Bit.App.Pages
|
|||
WinPhone: new Thickness(15, 8))
|
||||
};
|
||||
|
||||
stackLayout.AdjustPaddingForDevice();
|
||||
if(Device.OS == TargetPlatform.Android)
|
||||
{
|
||||
label.TextColor = Color.Black;
|
||||
|
|
|
@ -64,5 +64,29 @@ namespace Bit.App
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void AdjustPaddingForDevice(this StackLayout view)
|
||||
{
|
||||
if(Device.OS == TargetPlatform.Android)
|
||||
{
|
||||
var deviceInfo = Resolver.Resolve<IDeviceInfoService>();
|
||||
if(deviceInfo.Scale == 1) // mdpi
|
||||
{
|
||||
view.Padding = new Thickness(21, view.Padding.Top, 21, view.Padding.Bottom);
|
||||
}
|
||||
else if(deviceInfo.Scale < 2) // hdpi
|
||||
{
|
||||
view.Padding = new Thickness(19, view.Padding.Top, 19, view.Padding.Bottom);
|
||||
}
|
||||
else if(deviceInfo.Scale < 3) // xhdpi
|
||||
{
|
||||
view.Padding = new Thickness(17, view.Padding.Top, 17, view.Padding.Bottom);
|
||||
}
|
||||
else // xxhdpi and xxxhdpi
|
||||
{
|
||||
view.Padding = new Thickness(15, view.Padding.Top, 15, view.Padding.Bottom);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,5 +21,6 @@ namespace Bit.iOS.Core.Services
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
public float Scale => (float)UIScreen.MainScreen.Scale;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue