mirror of
https://github.com/bitwarden/mobile
synced 2025-12-16 00:03:22 +00:00
layout tweaks
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user