diff --git a/src/Android/Controls/ExtendedTextCellRenderer.cs b/src/Android/Controls/ExtendedTextCellRenderer.cs index 373a81759..261cffc7c 100644 --- a/src/Android/Controls/ExtendedTextCellRenderer.cs +++ b/src/Android/Controls/ExtendedTextCellRenderer.cs @@ -7,6 +7,7 @@ using Xamarin.Forms; using Xamarin.Forms.Platform.Android; using AView = Android.Views.View; using Android.Widget; +using Android.Text; [assembly: ExportRenderer(typeof(ExtendedTextCell), typeof(ExtendedTextCellRenderer))] namespace Bit.Android.Controls @@ -42,12 +43,24 @@ namespace Bit.Android.Controls if(View.ChildCount > 1) { var layout = View.GetChildAt(1) as LinearLayout; - if(layout != null && layout.ChildCount > 0) + if(layout != null) { - var textView = layout.GetChildAt(0) as TextView; - if(textView != null) + if(layout.ChildCount > 0) { - textView.TextSize = (float)Device.GetNamedSize(NamedSize.Medium, typeof(Label)); + var textView = layout.GetChildAt(0) as TextView; + if(textView != null) + { + textView.TextSize = (float)Device.GetNamedSize(NamedSize.Medium, typeof(Label)); + } + } + + if(layout.ChildCount > 1) + { + var detailView = layout.GetChildAt(1) as TextView; + if(detailView != null) + { + UpdateLineBreakMode(detailView, extendedCell.DetailLineBreakMode); + } } } } @@ -70,6 +83,44 @@ namespace Bit.Android.Controls // TODO: other properties } + private void UpdateLineBreakMode(TextView view, LineBreakMode lineBreakMode) + { + if(view == null) + { + return; + } + + switch(lineBreakMode) + { + case LineBreakMode.NoWrap: + view.SetSingleLine(true); + view.Ellipsize = null; + break; + case LineBreakMode.WordWrap: + view.SetSingleLine(false); + view.Ellipsize = null; + view.SetMaxLines(100); + break; + case LineBreakMode.CharacterWrap: + view.SetSingleLine(false); + view.Ellipsize = null; + view.SetMaxLines(100); + break; + case LineBreakMode.HeadTruncation: + view.SetSingleLine(true); + view.Ellipsize = TextUtils.TruncateAt.Start; + break; + case LineBreakMode.TailTruncation: + view.SetSingleLine(true); + view.Ellipsize = TextUtils.TruncateAt.End; + break; + case LineBreakMode.MiddleTruncation: + view.SetSingleLine(true); + view.Ellipsize = TextUtils.TruncateAt.Middle; + break; + } + } + private class DisclosureImage : ImageView { private ExtendedTextCell _cell; diff --git a/src/App/Controls/ExtendedTextCell.cs b/src/App/Controls/ExtendedTextCell.cs index d2192b813..eb595bdec 100644 --- a/src/App/Controls/ExtendedTextCell.cs +++ b/src/App/Controls/ExtendedTextCell.cs @@ -42,6 +42,8 @@ namespace Bit.App.Controls set { SetValue(DisclousureImageProperty, value); } } + public LineBreakMode DetailLineBreakMode { get; set; } = LineBreakMode.TailTruncation; + public event EventHandler DisclousureTapped; public void OnDisclousureTapped() diff --git a/src/App/Controls/FormEntryCell.cs b/src/App/Controls/FormEntryCell.cs index 947699a62..a6575cb9a 100644 --- a/src/App/Controls/FormEntryCell.cs +++ b/src/App/Controls/FormEntryCell.cs @@ -81,7 +81,7 @@ namespace Bit.App.Controls { if(!useLabelAsPlaceholder) { - Entry.Margin = new Thickness(-11, 0, -11, -5); + Entry.Margin = new Thickness(-4, -7, -4, -11); } } diff --git a/src/App/Controls/LabeledDetailCell.cs b/src/App/Controls/LabeledDetailCell.cs index 656ff30f9..54e03006c 100644 --- a/src/App/Controls/LabeledDetailCell.cs +++ b/src/App/Controls/LabeledDetailCell.cs @@ -24,7 +24,10 @@ namespace Bit.App.Controls HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, Children = { Label, Detail }, - Padding = new Thickness(15, 5, 5, 5), + Padding = Device.OnPlatform( + iOS: new Thickness(15, 5, 5, 5), + Android: new Thickness(15, 0, 5, 5), + WinPhone: new Thickness(15, 5, 5, 5)), Spacing = 0 }; diff --git a/src/App/Controls/StepperCell.cs b/src/App/Controls/StepperCell.cs index 6a3050456..fdb566ba0 100644 --- a/src/App/Controls/StepperCell.cs +++ b/src/App/Controls/StepperCell.cs @@ -41,9 +41,17 @@ namespace Bit.App.Controls Orientation = StackOrientation.Horizontal, Children = { Label, StepperValueLabel, Stepper }, Spacing = 15, - Padding = new Thickness(15, 8) + Padding = Device.OnPlatform( + iOS: new Thickness(15, 8), + Android: new Thickness(15, 2), + WinPhone: new Thickness(15, 8)) }; + if(Device.OS == TargetPlatform.Android) + { + Label.TextColor = Color.Black; + } + View = stackLayout; } diff --git a/src/App/Pages/Settings/SettingsCreditsPage.cs b/src/App/Pages/Settings/SettingsCreditsPage.cs index 45fe1013d..031f11ae8 100644 --- a/src/App/Pages/Settings/SettingsCreditsPage.cs +++ b/src/App/Pages/Settings/SettingsCreditsPage.cs @@ -53,9 +53,18 @@ Fingerprint by masterpage.com from the Noun Project") var layout = new StackLayout { Children = { label }, - Padding = new Thickness(15, 20) + Padding = Device.OnPlatform( + iOS: new Thickness(15, 20), + Android: new Thickness(16, 20), + WinPhone: new Thickness(15, 20)), + BackgroundColor = Color.White }; + if(Device.OS == TargetPlatform.Android) + { + label.TextColor = Color.Black; + } + View = layout; } } diff --git a/src/App/Pages/Settings/SettingsPage.cs b/src/App/Pages/Settings/SettingsPage.cs index 8c5080e25..ea07c12ea 100644 --- a/src/App/Pages/Settings/SettingsPage.cs +++ b/src/App/Pages/Settings/SettingsPage.cs @@ -41,15 +41,6 @@ namespace Bit.App.Pages private void Init() { - var fingerprintName = Device.OnPlatform(iOS: "Touch ID", Android: "Fingerprint", WinPhone: "Fingerprint"); - FingerprintCell = new ExtendedSwitchCell - { - Text = "Unlock with " + fingerprintName + (!_fingerprint.IsAvailable ? " (Unavilable)" : null), - On = _settings.GetValueOrDefault(Constants.SettingFingerprintUnlockOn), - IsEnabled = _fingerprint.IsAvailable - }; - FingerprintCell.OnChanged += FingerprintCell_Changed; - PinCell = new ExtendedSwitchCell { Text = "Unlock with PIN Code", @@ -72,6 +63,26 @@ namespace Bit.App.Pages }; twoStepCell.Tapped += TwoStepCell_Tapped; ; + var securitySecion = new TableSection("Security") + { + LockOptionsCell, + PinCell, + twoStepCell + }; + + if(_fingerprint.IsAvailable) + { + var fingerprintName = Device.OnPlatform(iOS: "Touch ID", Android: "Fingerprint", WinPhone: "Fingerprint"); + FingerprintCell = new ExtendedSwitchCell + { + Text = "Unlock with " + fingerprintName, + On = _settings.GetValueOrDefault(Constants.SettingFingerprintUnlockOn), + IsEnabled = _fingerprint.IsAvailable + }; + FingerprintCell.OnChanged += FingerprintCell_Changed; + securitySecion.Insert(1, FingerprintCell); + } + var changeMasterPasswordCell = new ExtendedTextCell { Text = "Change Master Password", @@ -126,30 +137,38 @@ namespace Bit.App.Pages }; helpCell.Tapped += HelpCell_Tapped; - var rateCell = new LongDetailViewCell("Rate the App", null); - rateCell.Tapped += RateCell_Tapped; + var otherSection = new TableSection("Other") + { + aboutCell, + helpCell + }; if(Device.OS == TargetPlatform.iOS) { - rateCell.Detail.Text = "App Store ratings are reset with every new version of bitwarden." - + " Please consider helping us out with a good review!"; + var rateCell = new LongDetailViewCell("Rate the App", + "App Store ratings are reset with every new version of bitwarden." + + " Please consider helping us out with a good review!"); + rateCell.Tapped += RateCell_Tapped; + otherSection.Add(rateCell); } else { - rateCell.Detail.Text = "Please consider helping us out with a good review!"; + var rateCell = new ExtendedTextCell + { + Text = "Rate the App", + Detail = "Please consider helping us out with a good review!", + ShowDisclousure = true, + DetailLineBreakMode = LineBreakMode.WordWrap + }; + rateCell.Tapped += RateCell_Tapped; + otherSection.Add(rateCell); } Table = new CustomTable { Root = new TableRoot { - new TableSection("Security") - { - LockOptionsCell, - FingerprintCell, - PinCell, - twoStepCell - }, + securitySecion, new TableSection("Account") { changeMasterPasswordCell, @@ -165,12 +184,7 @@ namespace Bit.App.Pages lockCell, logOutCell }, - new TableSection("Other") - { - aboutCell, - helpCell, - rateCell - } + otherSection } }; @@ -349,7 +363,11 @@ namespace Bit.App.Pages _settings.AddOrUpdateValue(Constants.SettingPinUnlockOn, true); _settings.AddOrUpdateValue(Constants.SettingFingerprintUnlockOn, false); PinCell.On = true; - FingerprintCell.On = false; + + if(FingerprintCell != null) + { + FingerprintCell.On = false; + } } private void FoldersCell_Tapped(object sender, EventArgs e) @@ -430,12 +448,6 @@ namespace Bit.App.Pages Padding = new Thickness(15) }; - if(Device.OS == TargetPlatform.Android) - { - labelDetailStackLayout.Spacing = 5; - Label.TextColor = Color.Black; - } - ShowDisclousure = true; View = labelDetailStackLayout; } diff --git a/src/App/Pages/Tools/ToolsPasswordGeneratorPage.cs b/src/App/Pages/Tools/ToolsPasswordGeneratorPage.cs index 1fc414fe1..ee698395a 100644 --- a/src/App/Pages/Tools/ToolsPasswordGeneratorPage.cs +++ b/src/App/Pages/Tools/ToolsPasswordGeneratorPage.cs @@ -209,9 +209,17 @@ namespace Bit.App.Pages Orientation = StackOrientation.Horizontal, Spacing = 15, Children = { label, LengthSlider, Value }, - Padding = new Thickness(15, 8) + Padding = Device.OnPlatform( + iOS: new Thickness(15, 8), + Android: new Thickness(16, 10), + WinPhone: new Thickness(15, 8)) }; + if(Device.OS == TargetPlatform.Android) + { + label.TextColor = Color.Black; + } + View = stackLayout; } diff --git a/src/iOS/Controls/ExtendedTextCellRenderer.cs b/src/iOS/Controls/ExtendedTextCellRenderer.cs index a525dde06..14f41fa22 100644 --- a/src/iOS/Controls/ExtendedTextCellRenderer.cs +++ b/src/iOS/Controls/ExtendedTextCellRenderer.cs @@ -45,9 +45,46 @@ namespace Bit.iOS.Controls } WireUpForceUpdateSizeRequested(item, cell, tv); + UpdateLineBreakMode(cell.DetailTextLabel, extendedCell.DetailLineBreakMode); } return cell; } + + private void UpdateLineBreakMode(UILabel label, LineBreakMode lineBreakMode) + { + if(label == null) + { + return; + } + + switch(lineBreakMode) + { + case LineBreakMode.NoWrap: + label.LineBreakMode = UILineBreakMode.Clip; + label.Lines = 1; + break; + case LineBreakMode.WordWrap: + label.LineBreakMode = UILineBreakMode.WordWrap; + label.Lines = 0; + break; + case LineBreakMode.CharacterWrap: + label.LineBreakMode = UILineBreakMode.CharacterWrap; + label.Lines = 0; + break; + case LineBreakMode.HeadTruncation: + label.LineBreakMode = UILineBreakMode.HeadTruncation; + label.Lines = 1; + break; + case LineBreakMode.MiddleTruncation: + label.LineBreakMode = UILineBreakMode.MiddleTruncation; + label.Lines = 1; + break; + case LineBreakMode.TailTruncation: + label.LineBreakMode = UILineBreakMode.TailTruncation; + label.Lines = 1; + break; + } + } } }