1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-12-24 16:38:22 +01:00

layout tweaks

This commit is contained in:
Kyle Spearrin 2019-04-05 22:30:11 -04:00
parent 3539d7389e
commit 3f5115728b
12 changed files with 95 additions and 125 deletions

View File

@ -218,6 +218,7 @@ namespace Bit.Droid.Renderers.BoxedView
holder.TextView.SetBackgroundColor(_boxedView.HeaderBackgroundColor.ToAndroid());
holder.TextView.SetMaxLines(1);
holder.TextView.SetMinLines(1);
holder.TextView.SetTypeface(null, Android.Graphics.TypefaceStyle.Bold);
holder.TextView.Ellipsize = TextUtils.TruncateAt.End;
if(_boxedView.HeaderTextColor != Color.Default)

View File

@ -17,6 +17,7 @@ namespace Bit.Droid.Renderers.BoxedView
[Preserve(AllMembers = true)]
public class BaseCellView : ARelativeLayout, INativeElementView
{
private bool _debugWithColors = false;
private CancellationTokenSource _iconTokenSource;
private Android.Graphics.Color _defaultTextColor;
private ColorDrawable _backgroundColor;
@ -87,6 +88,14 @@ namespace Bit.Droid.Renderers.BoxedView
_defaultTextColor = new Android.Graphics.Color(CellTitle.CurrentTextColor);
_defaultFontSize = CellTitle.TextSize;
if(_debugWithColors)
{
contentView.Background = _Context.GetDrawable(Android.Resource.Color.HoloGreenLight);
CellContent.Background = _Context.GetDrawable(Android.Resource.Color.HoloOrangeLight);
CellButtonContent.Background = _Context.GetDrawable(Android.Resource.Color.HoloOrangeDark);
CellTitle.Background = _Context.GetDrawable(Android.Resource.Color.HoloBlueLight);
}
}
public virtual void CellPropertyChanged(object sender, PropertyChangedEventArgs e)
@ -187,7 +196,8 @@ namespace Bit.Droid.Renderers.BoxedView
}
else
{
cellButton.Background = _Context.GetDrawable(icon);
cellButton.SetImageDrawable(_Context.GetDrawable(icon));
cellButton.SetImageDrawable(_Context.GetDrawable(icon));
cellButton.Visibility = ViewStates.Visible;
}
}

View File

@ -1,5 +1,4 @@
using Android.Content;
using Android.Content.Res;
using Android.OS;
using Android.Runtime;
using Android.Text;
@ -22,28 +21,29 @@ namespace Bit.Droid.Renderers.BoxedView
{ }
[Preserve(AllMembers = true)]
public class EntryCellView : BaseCellView, ITextWatcher, TextView.IOnFocusChangeListener,
public class EntryCellView : BaseCellView, ITextWatcher, Android.Views.View.IOnFocusChangeListener,
TextView.IOnEditorActionListener
{
private bool _debugWithColors = false;
private CustomEditText _editText;
public EntryCellView(Context context, Cell cell)
: base(context, cell)
{
_editText = new CustomEditText(context);
_editText.Focusable = true;
_editText.ImeOptions = ImeAction.Done;
_editText = new CustomEditText(context)
{
Focusable = true,
ImeOptions = ImeAction.Done,
OnFocusChangeListener = this,
Ellipsize = TextUtils.TruncateAt.End,
ClearFocusAction = DoneEdit,
Background = _Context.GetDrawable(Android.Resource.Color.Transparent)
};
_editText.SetPadding(0, 0, 0, 0);
_editText.SetOnEditorActionListener(this);
_editText.OnFocusChangeListener = this;
_editText.SetSingleLine(true);
_editText.Ellipsize = TextUtils.TruncateAt.End;
_editText.InputType |= InputTypes.TextFlagNoSuggestions; // Disabled spell check
_editText.Background.Alpha = 0; // Hide underline
_editText.ClearFocusAction = DoneEdit;
Click += EntryCellView_Click;
using(var lParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent,
@ -51,6 +51,11 @@ namespace Bit.Droid.Renderers.BoxedView
{
CellContent.AddView(_editText, lParams);
}
if(_debugWithColors)
{
_editText.Background = _Context.GetDrawable(Android.Resource.Color.HoloRedLight);
}
}
App.Controls.BoxedView.EntryCell _EntryCell => Cell as App.Controls.BoxedView.EntryCell;
@ -62,7 +67,6 @@ namespace Bit.Droid.Renderers.BoxedView
UpdateValueTextFontSize();
UpdateKeyboard();
UpdatePlaceholder();
UpdateAccentColor();
UpdateTextAlignment();
UpdateIsPassword();
base.UpdateCell();
@ -91,10 +95,6 @@ namespace Bit.Droid.Renderers.BoxedView
{
UpdatePlaceholder();
}
else if(e.PropertyName == App.Controls.BoxedView.EntryCell.AccentColorProperty.PropertyName)
{
UpdateAccentColor();
}
else if(e.PropertyName == App.Controls.BoxedView.EntryCell.TextAlignmentProperty.PropertyName)
{
UpdateTextAlignment();
@ -116,10 +116,6 @@ namespace Bit.Droid.Renderers.BoxedView
{
UpdateWithForceLayout(UpdateValueTextFontSize);
}
else if(e.PropertyName == App.Controls.BoxedView.BoxedView.CellAccentColorProperty.PropertyName)
{
UpdateAccentColor();
}
}
protected override void Dispose(bool disposing)
@ -138,21 +134,6 @@ namespace Bit.Droid.Renderers.BoxedView
base.Dispose(disposing);
}
protected override void SetEnabledAppearance(bool isEnabled)
{
if(isEnabled)
{
_editText.Enabled = true;
_editText.Alpha = 1.0f;
}
else
{
_editText.Enabled = false;
_editText.Alpha = 0.3f;
}
base.SetEnabledAppearance(isEnabled);
}
private void EntryCellView_Click(object sender, EventArgs e)
{
_editText.RequestFocus();
@ -214,33 +195,6 @@ namespace Bit.Droid.Renderers.BoxedView
_editText.Gravity = _EntryCell.TextAlignment.ToAndroidHorizontal();
}
private void UpdateAccentColor()
{
if(_EntryCell.AccentColor != Color.Default)
{
ChangeTextViewBack(_EntryCell.AccentColor.ToAndroid());
}
else if(CellParent != null && CellParent.CellAccentColor != Color.Default)
{
ChangeTextViewBack(CellParent.CellAccentColor.ToAndroid());
}
}
private void ChangeTextViewBack(Android.Graphics.Color accent)
{
var colorlist = new ColorStateList(
new int[][]
{
new int[]{Android.Resource.Attribute.StateFocused},
new int[]{-Android.Resource.Attribute.StateFocused},
},
new int[] {
Android.Graphics.Color.Argb(255,accent.R,accent.G,accent.B),
Android.Graphics.Color.Argb(255, 200, 200, 200)
});
_editText.Background.SetTintList(colorlist);
}
private void DoneEdit()
{
var entryCell = (IEntryCellController)Cell;

View File

@ -19,24 +19,32 @@ namespace Bit.Droid.Renderers.BoxedView
[Preserve(AllMembers = true)]
public class LabelCellView : BaseCellView
{
private bool _debugWithColors = false;
private TextView _valueLabel;
public LabelCellView(Context context, Cell cell)
: base(context, cell)
{
ValueLabel = new TextView(context);
ValueLabel.SetSingleLine(true);
ValueLabel.Ellipsize = TextUtils.TruncateAt.End;
ValueLabel.Gravity = GravityFlags.Left;
_valueLabel = new TextView(context)
{
Ellipsize = TextUtils.TruncateAt.End,
Gravity = GravityFlags.Left,
};
_valueLabel.SetSingleLine(true);
using(var lParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent,
ViewGroup.LayoutParams.WrapContent))
{
CellContent.AddView(ValueLabel, lParams);
CellContent.AddView(_valueLabel, lParams);
}
if(_debugWithColors)
{
_valueLabel.Background = _Context.GetDrawable(Android.Resource.Color.HoloRedLight);
}
}
private LabelCell _LabelCell => Cell as LabelCell;
public TextView ValueLabel { get; set; }
private LabelCell LabelCell => Cell as LabelCell;
public override void CellPropertyChanged(object sender, PropertyChangedEventArgs e)
{
@ -76,46 +84,33 @@ namespace Bit.Droid.Renderers.BoxedView
UpdateValueTextFontSize();
}
protected override void SetEnabledAppearance(bool isEnabled)
{
if(isEnabled)
{
ValueLabel.Alpha = 1f;
}
else
{
ValueLabel.Alpha = 0.3f;
}
base.SetEnabledAppearance(isEnabled);
}
protected void UpdateValueText()
{
ValueLabel.Text = _LabelCell.ValueText;
_valueLabel.Text = LabelCell.ValueText;
}
private void UpdateValueTextFontSize()
{
if(_LabelCell.ValueTextFontSize > 0)
if(LabelCell.ValueTextFontSize > 0)
{
ValueLabel.SetTextSize(Android.Util.ComplexUnitType.Sp, (float)_LabelCell.ValueTextFontSize);
_valueLabel.SetTextSize(Android.Util.ComplexUnitType.Sp, (float)LabelCell.ValueTextFontSize);
}
else if(CellParent != null)
{
ValueLabel.SetTextSize(Android.Util.ComplexUnitType.Sp, (float)CellParent.CellValueTextFontSize);
_valueLabel.SetTextSize(Android.Util.ComplexUnitType.Sp, (float)CellParent.CellValueTextFontSize);
}
Invalidate();
}
private void UpdateValueTextColor()
{
if(_LabelCell.ValueTextColor != Color.Default)
if(LabelCell.ValueTextColor != Color.Default)
{
ValueLabel.SetTextColor(_LabelCell.ValueTextColor.ToAndroid());
_valueLabel.SetTextColor(LabelCell.ValueTextColor.ToAndroid());
}
else if(CellParent != null && CellParent.CellValueTextColor != Color.Default)
{
ValueLabel.SetTextColor(CellParent.CellValueTextColor.ToAndroid());
_valueLabel.SetTextColor(CellParent.CellValueTextColor.ToAndroid());
}
}
@ -123,8 +118,8 @@ namespace Bit.Droid.Renderers.BoxedView
{
if(disposing)
{
ValueLabel?.Dispose();
ValueLabel = null;
_valueLabel?.Dispose();
_valueLabel = null;
}
base.Dispose(disposing);
}

View File

@ -6534,29 +6534,29 @@ namespace Bit.Droid
// aapt resource value: 0x7f0a003a
public const int CTRL = 2131361850;
// aapt resource value: 0x7f0a00ac
public const int CellAccessory = 2131361964;
// aapt resource value: 0x7f0a00a9
public const int CellButton1 = 2131361961;
public const int CellAccessory = 2131361961;
// aapt resource value: 0x7f0a00aa
public const int CellButton2 = 2131361962;
public const int CellButton1 = 2131361962;
// aapt resource value: 0x7f0a00ab
public const int CellButton3 = 2131361963;
public const int CellButton2 = 2131361963;
// aapt resource value: 0x7f0a00a8
public const int CellButtonContent = 2131361960;
// aapt resource value: 0x7f0a00ac
public const int CellButton3 = 2131361964;
// aapt resource value: 0x7f0a00a6
public const int CellButtonContent = 2131361958;
// aapt resource value: 0x7f0a00a5
public const int CellContent = 2131361957;
// aapt resource value: 0x7f0a00a7
public const int CellTitle = 2131361959;
// aapt resource value: 0x7f0a00a8
public const int CellTitle = 2131361960;
// aapt resource value: 0x7f0a00a6
public const int CellTitleContent = 2131361958;
// aapt resource value: 0x7f0a00a7
public const int CellTitleContent = 2131361959;
// aapt resource value: 0x7f0a00ad
public const int ContentCellBody = 2131361965;

View File

@ -3,16 +3,17 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="44dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="4dp"
android:paddingBottom="4dp">
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<LinearLayout
android:id="@+id/CellContent"
android:orientation="vertical"
android:layout_centerVertical="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/CellButtonContent"
android:gravity="center_vertical">
<LinearLayout
android:id="@+id/CellTitleContent"
@ -39,23 +40,30 @@
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/CellAccessory"
android:gravity="center_vertical">
<ImageButton
android:id="@+id/CellButton1"
android:visibility="gone"
android:background="@android:color/transparent"
android:paddingLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="match_parent" />
<ImageButton
android:id="@+id/CellButton2"
android:visibility="gone"
android:background="@android:color/transparent"
android:paddingLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="match_parent" />
<ImageButton
android:id="@+id/CellButton3"
android:visibility="gone"
android:background="@android:color/transparent"
android:paddingLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:id="@+id/CellAccessory"

View File

@ -9,6 +9,8 @@
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top|left" />

View File

@ -11,7 +11,7 @@
android:layout_alignParentLeft="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left" />
android:gravity="bottom|left" />
<LinearLayout
android:id="@+id/HeaderCellBorder"
android:layout_alignParentLeft="true"

View File

@ -22,7 +22,7 @@ namespace Bit.App.Controls.BoxedView
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty HeaderPaddingProperty = BindableProperty.Create(
nameof(HeaderPadding), typeof(Thickness), typeof(BoxedView), new Thickness(14, 8, 8, 8),
nameof(HeaderPadding), typeof(Thickness), typeof(BoxedView), new Thickness(15, 8, 15, 8),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty HeaderTextColorProperty = BindableProperty.Create(
@ -30,7 +30,7 @@ namespace Bit.App.Controls.BoxedView
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty HeaderFontSizeProperty = BindableProperty.Create(
nameof(HeaderFontSize), typeof(double), typeof(BoxedView), -1.0d,
nameof(HeaderFontSize), typeof(double), typeof(BoxedView), 14.0,
defaultBindingMode: BindingMode.OneWay,
defaultValueCreator: bindable => Device.GetNamedSize(NamedSize.Small, (BoxedView)bindable));
@ -50,7 +50,7 @@ namespace Bit.App.Controls.BoxedView
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty FooterFontSizeProperty = BindableProperty.Create(
nameof(FooterFontSize), typeof(double), typeof(BoxedView), -1.0d,
nameof(FooterFontSize), typeof(double), typeof(BoxedView), 14.0,
defaultBindingMode: BindingMode.OneWay,
defaultValueCreator: bindable => Device.GetNamedSize(NamedSize.Small, (BoxedView)bindable));
@ -59,7 +59,7 @@ namespace Bit.App.Controls.BoxedView
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty FooterPaddingProperty = BindableProperty.Create(
nameof(FooterPadding), typeof(Thickness), typeof(BoxedView), new Thickness(14, 8, 14, 8),
nameof(FooterPadding), typeof(Thickness), typeof(BoxedView), new Thickness(15, 8, 15, 8),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty CellTitleColorProperty = BindableProperty.Create(

View File

@ -10,11 +10,11 @@ namespace Bit.App.Controls.BoxedView
nameof(Title), typeof(string), typeof(BaseCell), default(string), defaultBindingMode: BindingMode.OneWay);
public static BindableProperty TitleColorProperty = BindableProperty.Create(
nameof(TitleColor), typeof(Color), typeof(BaseCell), default(Color),
nameof(TitleColor), typeof(Color), typeof(BaseCell), Color.Gray,
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty TitleFontSizeProperty = BindableProperty.Create(
nameof(TitleFontSize), typeof(double), typeof(BaseCell), -1.0, defaultBindingMode: BindingMode.OneWay);
nameof(TitleFontSize), typeof(double), typeof(BaseCell), 14.0, defaultBindingMode: BindingMode.OneWay);
public static BindableProperty Button1IconProperty = BindableProperty.Create(
nameof(Button1Icon), typeof(string), typeof(BaseCell), default(string),

View File

@ -11,11 +11,11 @@ namespace Bit.App.Controls.BoxedView
// propertyChanging: ValueTextPropertyChanging);
public static BindableProperty ValueTextColorProperty = BindableProperty.Create(
nameof(ValueTextColor), typeof(Color), typeof(EntryCell), default(Color),
nameof(ValueTextColor), typeof(Color), typeof(EntryCell), Color.Black,
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty ValueTextFontSizeProperty = BindableProperty.Create(
nameof(ValueTextFontSize), typeof(double), typeof(EntryCell), -1.0,
nameof(ValueTextFontSize), typeof(double), typeof(EntryCell), 18.0,
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty KeyboardProperty = BindableProperty.Create(

View File

@ -9,11 +9,11 @@ namespace Bit.App.Controls.BoxedView
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty ValueTextColorProperty = BindableProperty.Create(
nameof(ValueTextColor), typeof(Color), typeof(LabelCell), default(Color),
nameof(ValueTextColor), typeof(Color), typeof(LabelCell), Color.Black,
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty ValueTextFontSizeProperty = BindableProperty.Create(
nameof(ValueTextFontSize), typeof(double), typeof(LabelCell), -1.0,
nameof(ValueTextFontSize), typeof(double), typeof(LabelCell), 18.0,
defaultBindingMode: BindingMode.OneWay);
public string ValueText