mirror of
https://github.com/bitwarden/android.git
synced 2024-12-20 16:21:55 +03:00
Android UI updates.
This commit is contained in:
parent
610789fd6d
commit
34cb04cbde
9 changed files with 173 additions and 43 deletions
|
@ -7,6 +7,7 @@ using Xamarin.Forms;
|
||||||
using Xamarin.Forms.Platform.Android;
|
using Xamarin.Forms.Platform.Android;
|
||||||
using AView = Android.Views.View;
|
using AView = Android.Views.View;
|
||||||
using Android.Widget;
|
using Android.Widget;
|
||||||
|
using Android.Text;
|
||||||
|
|
||||||
[assembly: ExportRenderer(typeof(ExtendedTextCell), typeof(ExtendedTextCellRenderer))]
|
[assembly: ExportRenderer(typeof(ExtendedTextCell), typeof(ExtendedTextCellRenderer))]
|
||||||
namespace Bit.Android.Controls
|
namespace Bit.Android.Controls
|
||||||
|
@ -42,7 +43,9 @@ namespace Bit.Android.Controls
|
||||||
if(View.ChildCount > 1)
|
if(View.ChildCount > 1)
|
||||||
{
|
{
|
||||||
var layout = View.GetChildAt(1) as LinearLayout;
|
var layout = View.GetChildAt(1) as LinearLayout;
|
||||||
if(layout != null && layout.ChildCount > 0)
|
if(layout != null)
|
||||||
|
{
|
||||||
|
if(layout.ChildCount > 0)
|
||||||
{
|
{
|
||||||
var textView = layout.GetChildAt(0) as TextView;
|
var textView = layout.GetChildAt(0) as TextView;
|
||||||
if(textView != null)
|
if(textView != null)
|
||||||
|
@ -50,6 +53,16 @@ namespace Bit.Android.Controls
|
||||||
textView.TextSize = (float)Device.GetNamedSize(NamedSize.Medium, typeof(Label));
|
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
|
// 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 class DisclosureImage : ImageView
|
||||||
{
|
{
|
||||||
private ExtendedTextCell _cell;
|
private ExtendedTextCell _cell;
|
||||||
|
|
|
@ -42,6 +42,8 @@ namespace Bit.App.Controls
|
||||||
set { SetValue(DisclousureImageProperty, value); }
|
set { SetValue(DisclousureImageProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LineBreakMode DetailLineBreakMode { get; set; } = LineBreakMode.TailTruncation;
|
||||||
|
|
||||||
public event EventHandler DisclousureTapped;
|
public event EventHandler DisclousureTapped;
|
||||||
|
|
||||||
public void OnDisclousureTapped()
|
public void OnDisclousureTapped()
|
||||||
|
|
|
@ -81,7 +81,7 @@ namespace Bit.App.Controls
|
||||||
{
|
{
|
||||||
if(!useLabelAsPlaceholder)
|
if(!useLabelAsPlaceholder)
|
||||||
{
|
{
|
||||||
Entry.Margin = new Thickness(-11, 0, -11, -5);
|
Entry.Margin = new Thickness(-4, -7, -4, -11);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,10 @@ namespace Bit.App.Controls
|
||||||
HorizontalOptions = LayoutOptions.StartAndExpand,
|
HorizontalOptions = LayoutOptions.StartAndExpand,
|
||||||
VerticalOptions = LayoutOptions.CenterAndExpand,
|
VerticalOptions = LayoutOptions.CenterAndExpand,
|
||||||
Children = { Label, Detail },
|
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
|
Spacing = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,17 @@ namespace Bit.App.Controls
|
||||||
Orientation = StackOrientation.Horizontal,
|
Orientation = StackOrientation.Horizontal,
|
||||||
Children = { Label, StepperValueLabel, Stepper },
|
Children = { Label, StepperValueLabel, Stepper },
|
||||||
Spacing = 15,
|
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;
|
View = stackLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,9 +53,18 @@ Fingerprint by masterpage.com from the Noun Project")
|
||||||
var layout = new StackLayout
|
var layout = new StackLayout
|
||||||
{
|
{
|
||||||
Children = { label },
|
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;
|
View = layout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,15 +41,6 @@ namespace Bit.App.Pages
|
||||||
|
|
||||||
private void Init()
|
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<bool>(Constants.SettingFingerprintUnlockOn),
|
|
||||||
IsEnabled = _fingerprint.IsAvailable
|
|
||||||
};
|
|
||||||
FingerprintCell.OnChanged += FingerprintCell_Changed;
|
|
||||||
|
|
||||||
PinCell = new ExtendedSwitchCell
|
PinCell = new ExtendedSwitchCell
|
||||||
{
|
{
|
||||||
Text = "Unlock with PIN Code",
|
Text = "Unlock with PIN Code",
|
||||||
|
@ -72,6 +63,26 @@ namespace Bit.App.Pages
|
||||||
};
|
};
|
||||||
twoStepCell.Tapped += TwoStepCell_Tapped; ;
|
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<bool>(Constants.SettingFingerprintUnlockOn),
|
||||||
|
IsEnabled = _fingerprint.IsAvailable
|
||||||
|
};
|
||||||
|
FingerprintCell.OnChanged += FingerprintCell_Changed;
|
||||||
|
securitySecion.Insert(1, FingerprintCell);
|
||||||
|
}
|
||||||
|
|
||||||
var changeMasterPasswordCell = new ExtendedTextCell
|
var changeMasterPasswordCell = new ExtendedTextCell
|
||||||
{
|
{
|
||||||
Text = "Change Master Password",
|
Text = "Change Master Password",
|
||||||
|
@ -126,30 +137,38 @@ namespace Bit.App.Pages
|
||||||
};
|
};
|
||||||
helpCell.Tapped += HelpCell_Tapped;
|
helpCell.Tapped += HelpCell_Tapped;
|
||||||
|
|
||||||
var rateCell = new LongDetailViewCell("Rate the App", null);
|
var otherSection = new TableSection("Other")
|
||||||
rateCell.Tapped += RateCell_Tapped;
|
{
|
||||||
|
aboutCell,
|
||||||
|
helpCell
|
||||||
|
};
|
||||||
|
|
||||||
if(Device.OS == TargetPlatform.iOS)
|
if(Device.OS == TargetPlatform.iOS)
|
||||||
{
|
{
|
||||||
rateCell.Detail.Text = "App Store ratings are reset with every new version of bitwarden."
|
var rateCell = new LongDetailViewCell("Rate the App",
|
||||||
+ " Please consider helping us out with a good review!";
|
"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
|
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
|
Table = new CustomTable
|
||||||
{
|
{
|
||||||
Root = new TableRoot
|
Root = new TableRoot
|
||||||
{
|
{
|
||||||
new TableSection("Security")
|
securitySecion,
|
||||||
{
|
|
||||||
LockOptionsCell,
|
|
||||||
FingerprintCell,
|
|
||||||
PinCell,
|
|
||||||
twoStepCell
|
|
||||||
},
|
|
||||||
new TableSection("Account")
|
new TableSection("Account")
|
||||||
{
|
{
|
||||||
changeMasterPasswordCell,
|
changeMasterPasswordCell,
|
||||||
|
@ -165,12 +184,7 @@ namespace Bit.App.Pages
|
||||||
lockCell,
|
lockCell,
|
||||||
logOutCell
|
logOutCell
|
||||||
},
|
},
|
||||||
new TableSection("Other")
|
otherSection
|
||||||
{
|
|
||||||
aboutCell,
|
|
||||||
helpCell,
|
|
||||||
rateCell
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -349,8 +363,12 @@ namespace Bit.App.Pages
|
||||||
_settings.AddOrUpdateValue(Constants.SettingPinUnlockOn, true);
|
_settings.AddOrUpdateValue(Constants.SettingPinUnlockOn, true);
|
||||||
_settings.AddOrUpdateValue(Constants.SettingFingerprintUnlockOn, false);
|
_settings.AddOrUpdateValue(Constants.SettingFingerprintUnlockOn, false);
|
||||||
PinCell.On = true;
|
PinCell.On = true;
|
||||||
|
|
||||||
|
if(FingerprintCell != null)
|
||||||
|
{
|
||||||
FingerprintCell.On = false;
|
FingerprintCell.On = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void FoldersCell_Tapped(object sender, EventArgs e)
|
private void FoldersCell_Tapped(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -430,12 +448,6 @@ namespace Bit.App.Pages
|
||||||
Padding = new Thickness(15)
|
Padding = new Thickness(15)
|
||||||
};
|
};
|
||||||
|
|
||||||
if(Device.OS == TargetPlatform.Android)
|
|
||||||
{
|
|
||||||
labelDetailStackLayout.Spacing = 5;
|
|
||||||
Label.TextColor = Color.Black;
|
|
||||||
}
|
|
||||||
|
|
||||||
ShowDisclousure = true;
|
ShowDisclousure = true;
|
||||||
View = labelDetailStackLayout;
|
View = labelDetailStackLayout;
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,9 +209,17 @@ namespace Bit.App.Pages
|
||||||
Orientation = StackOrientation.Horizontal,
|
Orientation = StackOrientation.Horizontal,
|
||||||
Spacing = 15,
|
Spacing = 15,
|
||||||
Children = { label, LengthSlider, Value },
|
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;
|
View = stackLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,9 +45,46 @@ namespace Bit.iOS.Controls
|
||||||
}
|
}
|
||||||
|
|
||||||
WireUpForceUpdateSizeRequested(item, cell, tv);
|
WireUpForceUpdateSizeRequested(item, cell, tv);
|
||||||
|
UpdateLineBreakMode(cell.DetailTextLabel, extendedCell.DetailLineBreakMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cell;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue