From 2262e1c4c256a2e1f6bb5aa30e3f3c116607729c Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 23 Aug 2016 23:57:11 -0400 Subject: [PATCH] Created extension for adjusting margins on entry fields for specific android API levels. --- src/App/Controls/FormEditorCell.cs | 6 +----- src/App/Controls/FormEntryCell.cs | 15 ++++++--------- src/App/Controls/FormPickerCell.cs | 2 +- src/App/Utilities/Extentions.cs | 20 ++++++++++++++++++++ 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/App/Controls/FormEditorCell.cs b/src/App/Controls/FormEditorCell.cs index a74aa13e7..f323bc14c 100644 --- a/src/App/Controls/FormEditorCell.cs +++ b/src/App/Controls/FormEditorCell.cs @@ -27,11 +27,7 @@ namespace Bit.App.Controls stackLayout.Children.Add(Editor); Tapped += FormEditorCell_Tapped; - - if(Device.OS == TargetPlatform.Android) - { - Editor.Margin = new Thickness(-4, -2, -4, -10); - } + Editor.AdjustMarginsForDevice(); View = stackLayout; } diff --git a/src/App/Controls/FormEntryCell.cs b/src/App/Controls/FormEntryCell.cs index feb488cf6..b6c48e4e7 100644 --- a/src/App/Controls/FormEntryCell.cs +++ b/src/App/Controls/FormEntryCell.cs @@ -84,21 +84,18 @@ namespace Bit.App.Controls var deviceInfo = Resolver.Resolve(); if(useLabelAsPlaceholder) { - if(deviceInfo.Version == 21) + if(deviceInfo.Version < 21) + { + Entry.Margin = new Thickness(-9, 0); + } + else if(deviceInfo.Version == 21) { Entry.Margin = new Thickness(0, 4, 0, -4); } } else { - if(deviceInfo.Version == 21) - { - Entry.Margin = new Thickness(-4, -2, -4, -11); - } - else - { - Entry.Margin = new Thickness(-4, -7, -4, -11); - } + Entry.AdjustMarginsForDevice(); } } diff --git a/src/App/Controls/FormPickerCell.cs b/src/App/Controls/FormPickerCell.cs index 23bacce30..a9d40a8f6 100644 --- a/src/App/Controls/FormPickerCell.cs +++ b/src/App/Controls/FormPickerCell.cs @@ -38,8 +38,8 @@ namespace Bit.App.Controls if(Device.OS == TargetPlatform.Android) { stackLayout.Spacing = 0; - Picker.Margin = new Thickness(-4, -2, -4, -10); } + Picker.AdjustMarginsForDevice(); Tapped += FormPickerCell_Tapped; diff --git a/src/App/Utilities/Extentions.cs b/src/App/Utilities/Extentions.cs index ab06365cf..529820663 100644 --- a/src/App/Utilities/Extentions.cs +++ b/src/App/Utilities/Extentions.cs @@ -44,5 +44,25 @@ namespace Bit.App entry.Focus(); } } + + public static void AdjustMarginsForDevice(this View view) + { + if(Device.OS == TargetPlatform.Android) + { + var deviceInfo = Resolver.Resolve(); + if(deviceInfo.Version < 21) + { + view.Margin = new Thickness(-12, -5, -12, -6); + } + else if(deviceInfo.Version == 21) + { + view.Margin = new Thickness(-4, -2, -4, -11); + } + else + { + view.Margin = new Thickness(-4, -7, -4, -11); + } + } + } } }