image and icon

This commit is contained in:
Kyle Spearrin 2019-06-08 11:48:45 -04:00
parent 5f16066641
commit 2f66ee264b
5 changed files with 583 additions and 483 deletions

View file

@ -1,11 +1,17 @@
using Android.App; using Android.App;
using Android.Content; using Android.Content;
using Android.Graphics; using Android.Graphics;
using Android.Runtime;
using Android.Util;
using Android.Views; using Android.Views;
using Android.Views.InputMethods; using Android.Views.InputMethods;
using Android.Widget; using Android.Widget;
using Bit.App.Controls; using Bit.App.Controls;
using Bit.Droid.Renderers; using Bit.Droid.Renderers;
using FFImageLoading;
using FFImageLoading.Views;
using FFImageLoading.Work;
using System;
using System.ComponentModel; using System.ComponentModel;
using Xamarin.Forms; using Xamarin.Forms;
using Xamarin.Forms.Platform.Android; using Xamarin.Forms.Platform.Android;
@ -18,6 +24,8 @@ namespace Bit.Droid.Renderers
private static Typeface _faTypeface; private static Typeface _faTypeface;
private static Typeface _miTypeface; private static Typeface _miTypeface;
private AndroidCipherCell _cell;
protected override Android.Views.View GetCellCore(Cell item, Android.Views.View convertView, protected override Android.Views.View GetCellCore(Cell item, Android.Views.View convertView,
ViewGroup parent, Context context) ViewGroup parent, Context context)
{ {
@ -31,23 +39,26 @@ namespace Bit.Droid.Renderers
} }
var cipherCell = item as CipherViewCell; var cipherCell = item as CipherViewCell;
if(!(convertView is AndroidCipherCell cell)) _cell = convertView as AndroidCipherCell;
if(_cell == null)
{ {
cell = new AndroidCipherCell(context, cipherCell, _faTypeface, _miTypeface); _cell = new AndroidCipherCell(context, cipherCell, _faTypeface, _miTypeface);
} }
cell.CipherViewCell.PropertyChanged += CellPropertyChanged; else
cell.CipherViewCell = cipherCell; {
cell.CipherViewCell.PropertyChanged -= CellPropertyChanged; _cell.CipherViewCell.PropertyChanged -= CellPropertyChanged;
cell.UpdateCell(); }
return cell; cipherCell.PropertyChanged += CellPropertyChanged;
_cell.UpdateCell(cipherCell);
return _cell;
} }
public void CellPropertyChanged(object sender, PropertyChangedEventArgs e) public void CellPropertyChanged(object sender, PropertyChangedEventArgs e)
{ {
var nativeCell = sender as AndroidCipherCell; var cipherCell = sender as CipherViewCell;
if(e.PropertyName == CipherViewCell.CipherProperty.PropertyName) if(e.PropertyName == CipherViewCell.CipherProperty.PropertyName)
{ {
nativeCell.UpdateCell(); _cell.UpdateCell(cipherCell);
} }
} }
} }
@ -57,20 +68,25 @@ namespace Bit.Droid.Renderers
private readonly Typeface _faTypeface; private readonly Typeface _faTypeface;
private readonly Typeface _miTypeface; private readonly Typeface _miTypeface;
public AndroidCipherCell(Context context, CipherViewCell cipherCell, Typeface faTypeface, Typeface miTypeface) private IScheduledWork _currentTask;
public AndroidCipherCell(Context context, CipherViewCell cipherView, Typeface faTypeface, Typeface miTypeface)
: base(context) : base(context)
{ {
var view = (context as Activity).LayoutInflater.Inflate(Resource.Layout.CipherViewCell, null); CipherViewCell = cipherView;
CipherViewCell = cipherCell;
_faTypeface = faTypeface; _faTypeface = faTypeface;
_miTypeface = miTypeface; _miTypeface = miTypeface;
var view = (context as Activity).LayoutInflater.Inflate(Resource.Layout.CipherViewCell, null);
IconImage = view.FindViewById<IconImageView>(Resource.Id.CipherCellIconImage);
Icon = view.FindViewById<TextView>(Resource.Id.CipherCellIcon);
Name = view.FindViewById<TextView>(Resource.Id.CipherCellName); Name = view.FindViewById<TextView>(Resource.Id.CipherCellName);
SubTitle = view.FindViewById<TextView>(Resource.Id.CipherCellSubTitle); SubTitle = view.FindViewById<TextView>(Resource.Id.CipherCellSubTitle);
SharedIcon = view.FindViewById<TextView>(Resource.Id.CipherCellSharedIcon); SharedIcon = view.FindViewById<TextView>(Resource.Id.CipherCellSharedIcon);
AttachmentsIcon = view.FindViewById<TextView>(Resource.Id.CipherCellAttachmentsIcon); AttachmentsIcon = view.FindViewById<TextView>(Resource.Id.CipherCellAttachmentsIcon);
MoreButton = view.FindViewById<Android.Widget.Button>(Resource.Id.CipherCellButton); MoreButton = view.FindViewById<Android.Widget.Button>(Resource.Id.CipherCellButton);
Icon.Typeface = _faTypeface;
SharedIcon.Typeface = _faTypeface; SharedIcon.Typeface = _faTypeface;
AttachmentsIcon.Typeface = _faTypeface; AttachmentsIcon.Typeface = _faTypeface;
MoreButton.Typeface = _miTypeface; MoreButton.Typeface = _miTypeface;
@ -80,15 +96,39 @@ namespace Bit.Droid.Renderers
public CipherViewCell CipherViewCell { get; set; } public CipherViewCell CipherViewCell { get; set; }
public Element Element => CipherViewCell; public Element Element => CipherViewCell;
public IconImageView IconImage { get; set; }
public TextView Icon { get; set; }
public TextView Name { get; set; } public TextView Name { get; set; }
public TextView SubTitle { get; set; } public TextView SubTitle { get; set; }
public TextView SharedIcon { get; set; } public TextView SharedIcon { get; set; }
public TextView AttachmentsIcon { get; set; } public TextView AttachmentsIcon { get; set; }
public Android.Widget.Button MoreButton { get; set; } public Android.Widget.Button MoreButton { get; set; }
public void UpdateCell() public void UpdateCell(CipherViewCell cipherCell)
{ {
var cipher = CipherViewCell.Cipher; if(_currentTask != null && !_currentTask.IsCancelled && !_currentTask.IsCompleted)
{
_currentTask.Cancel();
}
var cipher = cipherCell.Cipher;
var iconImage = cipherCell.GetIconImage(cipher);
if(iconImage.Item2 != null)
{
IconImage.SetImageResource(Resource.Drawable.login);
IconImage.Visibility = ViewStates.Visible;
Icon.Visibility = ViewStates.Gone;
_currentTask = ImageService.Instance.LoadUrl(iconImage.Item2).DownSample(64).Into(IconImage);
IconImage.Key = iconImage.Item2;
}
else
{
IconImage.Visibility = ViewStates.Gone;
Icon.Visibility = ViewStates.Visible;
Icon.Text = iconImage.Item1;
}
Name.Text = cipher.Name; Name.Text = cipher.Name;
if(!string.IsNullOrWhiteSpace(cipher.SubTitle)) if(!string.IsNullOrWhiteSpace(cipher.SubTitle))
{ {
@ -103,4 +143,30 @@ namespace Bit.Droid.Renderers
AttachmentsIcon.Visibility = cipher.HasAttachments ? ViewStates.Visible : ViewStates.Gone; AttachmentsIcon.Visibility = cipher.HasAttachments ? ViewStates.Visible : ViewStates.Gone;
} }
} }
[Android.Runtime.Preserve(AllMembers = true)]
[Register("bit.droid.renderers.IconImageView")]
public class IconImageView : ImageViewAsync
{
public IconImageView(Context context) : base(context)
{ }
public IconImageView(IntPtr javaReference, JniHandleOwnership transfer)
: base(javaReference, transfer)
{ }
public IconImageView(Context context, IAttributeSet attrs)
: base(context, attrs)
{ }
public string Key { get; set; }
protected override void JavaFinalize()
{
SetImageDrawable(null);
SetImageBitmap(null);
ImageService.Instance.InvalidateCacheEntryAsync(Key, FFImageLoading.Cache.CacheType.Memory);
base.JavaFinalize();
}
}
} }

View file

@ -9128,44 +9128,50 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d00ae // aapt resource value: 0x7f0d00ae
public const int CellTitleContent = 2131558574; public const int CellTitleContent = 2131558574;
// aapt resource value: 0x7f0d00b9
public const int CipherCellAttachmentsIcon = 2131558585;
// aapt resource value: 0x7f0d00b5
public const int CipherCellButton = 2131558581;
// aapt resource value: 0x7f0d00b4
public const int CipherCellContent = 2131558580;
// aapt resource value: 0x7f0d00b6
public const int CipherCellContentTop = 2131558582;
// aapt resource value: 0x7f0d00b7
public const int CipherCellName = 2131558583;
// aapt resource value: 0x7f0d00b8
public const int CipherCellSharedIcon = 2131558584;
// aapt resource value: 0x7f0d00ba // aapt resource value: 0x7f0d00ba
public const int CipherCellSubTitle = 2131558586; public const int CipherCellAttachmentsIcon = 2131558586;
// aapt resource value: 0x7f0d00bb
public const int ContentCellBody = 2131558587;
// aapt resource value: 0x7f0d00bc // aapt resource value: 0x7f0d00bc
public const int ContentCellBorder = 2131558588; public const int CipherCellButton = 2131558588;
// aapt resource value: 0x7f0d00b6
public const int CipherCellContent = 2131558582;
// aapt resource value: 0x7f0d00b7
public const int CipherCellContentTop = 2131558583;
// aapt resource value: 0x7f0d00b5
public const int CipherCellIcon = 2131558581;
// aapt resource value: 0x7f0d00b4
public const int CipherCellIconImage = 2131558580;
// aapt resource value: 0x7f0d00b8
public const int CipherCellName = 2131558584;
// aapt resource value: 0x7f0d00b9
public const int CipherCellSharedIcon = 2131558585;
// aapt resource value: 0x7f0d00bb
public const int CipherCellSubTitle = 2131558587;
// aapt resource value: 0x7f0d00bd
public const int ContentCellBody = 2131558589;
// aapt resource value: 0x7f0d00be
public const int ContentCellBorder = 2131558590;
// aapt resource value: 0x7f0d0043 // aapt resource value: 0x7f0d0043
public const int FUNCTION = 2131558467; public const int FUNCTION = 2131558467;
// aapt resource value: 0x7f0d00d0
public const int FooterCellText = 2131558608;
// aapt resource value: 0x7f0d00d2 // aapt resource value: 0x7f0d00d2
public const int HeaderCellBorder = 2131558610; public const int FooterCellText = 2131558610;
// aapt resource value: 0x7f0d00d1 // aapt resource value: 0x7f0d00d4
public const int HeaderCellText = 2131558609; public const int HeaderCellBorder = 2131558612;
// aapt resource value: 0x7f0d00d3
public const int HeaderCellText = 2131558611;
// aapt resource value: 0x7f0d0044 // aapt resource value: 0x7f0d0044
public const int META = 2131558468; public const int META = 2131558468;
@ -9176,8 +9182,8 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d0046 // aapt resource value: 0x7f0d0046
public const int SYM = 2131558470; public const int SYM = 2131558470;
// aapt resource value: 0x7f0d0121 // aapt resource value: 0x7f0d0123
public const int action0 = 2131558689; public const int action0 = 2131558691;
// aapt resource value: 0x7f0d0094 // aapt resource value: 0x7f0d0094
public const int action_bar = 2131558548; public const int action_bar = 2131558548;
@ -9200,17 +9206,17 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d0070 // aapt resource value: 0x7f0d0070
public const int action_bar_title = 2131558512; public const int action_bar_title = 2131558512;
// aapt resource value: 0x7f0d011e // aapt resource value: 0x7f0d0120
public const int action_container = 2131558686; public const int action_container = 2131558688;
// aapt resource value: 0x7f0d0095 // aapt resource value: 0x7f0d0095
public const int action_context_bar = 2131558549; public const int action_context_bar = 2131558549;
// aapt resource value: 0x7f0d0125 // aapt resource value: 0x7f0d0127
public const int action_divider = 2131558693; public const int action_divider = 2131558695;
// aapt resource value: 0x7f0d011f // aapt resource value: 0x7f0d0121
public const int action_image = 2131558687; public const int action_image = 2131558689;
// aapt resource value: 0x7f0d0003 // aapt resource value: 0x7f0d0003
public const int action_menu_divider = 2131558403; public const int action_menu_divider = 2131558403;
@ -9227,11 +9233,11 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d0072 // aapt resource value: 0x7f0d0072
public const int action_mode_close_button = 2131558514; public const int action_mode_close_button = 2131558514;
// aapt resource value: 0x7f0d0120 // aapt resource value: 0x7f0d0122
public const int action_text = 2131558688; public const int action_text = 2131558690;
// aapt resource value: 0x7f0d012e // aapt resource value: 0x7f0d0130
public const int actions = 2131558702; public const int actions = 2131558704;
// aapt resource value: 0x7f0d0073 // aapt resource value: 0x7f0d0073
public const int activity_chooser_view_content = 2131558515; public const int activity_chooser_view_content = 2131558515;
@ -9293,26 +9299,26 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d0079 // aapt resource value: 0x7f0d0079
public const int buttonPanel = 2131558521; public const int buttonPanel = 2131558521;
// aapt resource value: 0x7f0d00e0 // aapt resource value: 0x7f0d00e2
public const int button_add_response = 2131558624; public const int button_add_response = 2131558626;
// aapt resource value: 0x7f0d00db // aapt resource value: 0x7f0d00dd
public const int button_attachment = 2131558619; public const int button_attachment = 2131558621;
// aapt resource value: 0x7f0d00e5 // aapt resource value: 0x7f0d00e7
public const int button_login = 2131558629; public const int button_login = 2131558631;
// aapt resource value: 0x7f0d00e1 // aapt resource value: 0x7f0d00e3
public const int button_refresh = 2131558625; public const int button_refresh = 2131558627;
// aapt resource value: 0x7f0d00dc // aapt resource value: 0x7f0d00de
public const int button_send = 2131558620; public const int button_send = 2131558622;
// aapt resource value: 0x7f0d00e9 // aapt resource value: 0x7f0d00eb
public const int button_update = 2131558633; public const int button_update = 2131558635;
// aapt resource value: 0x7f0d0122 // aapt resource value: 0x7f0d0124
public const int cancel_action = 2131558690; public const int cancel_action = 2131558692;
// aapt resource value: 0x7f0d0054 // aapt resource value: 0x7f0d0054
public const int center = 2131558484; public const int center = 2131558484;
@ -9326,8 +9332,8 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d008d // aapt resource value: 0x7f0d008d
public const int checkbox = 2131558541; public const int checkbox = 2131558541;
// aapt resource value: 0x7f0d012a // aapt resource value: 0x7f0d012c
public const int chronometer = 2131558698; public const int chronometer = 2131558700;
// aapt resource value: 0x7f0d0068 // aapt resource value: 0x7f0d0068
public const int clip_horizontal = 2131558504; public const int clip_horizontal = 2131558504;
@ -9338,20 +9344,20 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d0048 // aapt resource value: 0x7f0d0048
public const int collapseActionView = 2131558472; public const int collapseActionView = 2131558472;
// aapt resource value: 0x7f0d00bf // aapt resource value: 0x7f0d00c1
public const int container = 2131558591; public const int container = 2131558593;
// aapt resource value: 0x7f0d0089 // aapt resource value: 0x7f0d0089
public const int content = 2131558537; public const int content = 2131558537;
// aapt resource value: 0x7f0d013a // aapt resource value: 0x7f0d013c
public const int contentFrame = 2131558714; public const int contentFrame = 2131558716;
// aapt resource value: 0x7f0d007c // aapt resource value: 0x7f0d007c
public const int contentPanel = 2131558524; public const int contentPanel = 2131558524;
// aapt resource value: 0x7f0d00c0 // aapt resource value: 0x7f0d00c2
public const int coordinator = 2131558592; public const int coordinator = 2131558594;
// aapt resource value: 0x7f0d0083 // aapt resource value: 0x7f0d0083
public const int custom = 2131558531; public const int custom = 2131558531;
@ -9368,20 +9374,20 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d0076 // aapt resource value: 0x7f0d0076
public const int default_activity_button = 2131558518; public const int default_activity_button = 2131558518;
// aapt resource value: 0x7f0d00c2 // aapt resource value: 0x7f0d00c4
public const int design_bottom_sheet = 2131558594; public const int design_bottom_sheet = 2131558596;
// aapt resource value: 0x7f0d00c9
public const int design_menu_item_action_area = 2131558601;
// aapt resource value: 0x7f0d00c8
public const int design_menu_item_action_area_stub = 2131558600;
// aapt resource value: 0x7f0d00c7 // aapt resource value: 0x7f0d00c7
public const int design_menu_item_action_area = 2131558599; public const int design_menu_item_text = 2131558599;
// aapt resource value: 0x7f0d00c6 // aapt resource value: 0x7f0d00c6
public const int design_menu_item_action_area_stub = 2131558598; public const int design_navigation_view = 2131558598;
// aapt resource value: 0x7f0d00c5
public const int design_menu_item_text = 2131558597;
// aapt resource value: 0x7f0d00c4
public const int design_navigation_view = 2131558596;
// aapt resource value: 0x7f0d0030 // aapt resource value: 0x7f0d0030
public const int disableHome = 2131558448; public const int disableHome = 2131558448;
@ -9392,8 +9398,8 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d003f // aapt resource value: 0x7f0d003f
public const int end = 2131558463; public const int end = 2131558463;
// aapt resource value: 0x7f0d0130 // aapt resource value: 0x7f0d0132
public const int end_padder = 2131558704; public const int end_padder = 2131558706;
// aapt resource value: 0x7f0d004e // aapt resource value: 0x7f0d004e
public const int enterAlways = 2131558478; public const int enterAlways = 2131558478;
@ -9422,29 +9428,29 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d0066 // aapt resource value: 0x7f0d0066
public const int filled = 2131558502; public const int filled = 2131558502;
// aapt resource value: 0x7f0d00cc // aapt resource value: 0x7f0d00ce
public const int fingerprint_btnCancel = 2131558604; public const int fingerprint_btnCancel = 2131558606;
// aapt resource value: 0x7f0d00cd // aapt resource value: 0x7f0d00cf
public const int fingerprint_btnFallback = 2131558605; public const int fingerprint_btnFallback = 2131558607;
// aapt resource value: 0x7f0d00c9
public const int fingerprint_imgFingerprint = 2131558601;
// aapt resource value: 0x7f0d00ca
public const int fingerprint_txtHelp = 2131558602;
// aapt resource value: 0x7f0d00cb // aapt resource value: 0x7f0d00cb
public const int fingerprint_txtReason = 2131558603; public const int fingerprint_imgFingerprint = 2131558603;
// aapt resource value: 0x7f0d00cc
public const int fingerprint_txtHelp = 2131558604;
// aapt resource value: 0x7f0d00cd
public const int fingerprint_txtReason = 2131558605;
// aapt resource value: 0x7f0d0063 // aapt resource value: 0x7f0d0063
public const int @fixed = 2131558499; public const int @fixed = 2131558499;
// aapt resource value: 0x7f0d00ce // aapt resource value: 0x7f0d00d0
public const int flyoutcontent_appbar = 2131558606; public const int flyoutcontent_appbar = 2131558608;
// aapt resource value: 0x7f0d00cf // aapt resource value: 0x7f0d00d1
public const int flyoutcontent_recycler = 2131558607; public const int flyoutcontent_recycler = 2131558609;
// aapt resource value: 0x7f0d006e // aapt resource value: 0x7f0d006e
public const int forever = 2131558510; public const int forever = 2131558510;
@ -9464,8 +9470,8 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d0078 // aapt resource value: 0x7f0d0078
public const int icon = 2131558520; public const int icon = 2131558520;
// aapt resource value: 0x7f0d012f // aapt resource value: 0x7f0d0131
public const int icon_group = 2131558703; public const int icon_group = 2131558705;
// aapt resource value: 0x7f0d0027 // aapt resource value: 0x7f0d0027
public const int icon_only = 2131558439; public const int icon_only = 2131558439;
@ -9476,23 +9482,23 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d0075 // aapt resource value: 0x7f0d0075
public const int image = 2131558517; public const int image = 2131558517;
// aapt resource value: 0x7f0d012b // aapt resource value: 0x7f0d012d
public const int info = 2131558699; public const int info = 2131558701;
// aapt resource value: 0x7f0d00d7
public const int input_email = 2131558615;
// aapt resource value: 0x7f0d00d9 // aapt resource value: 0x7f0d00d9
public const int input_message = 2131558617; public const int input_email = 2131558617;
// aapt resource value: 0x7f0d00d6 // aapt resource value: 0x7f0d00db
public const int input_name = 2131558614; public const int input_message = 2131558619;
// aapt resource value: 0x7f0d00e4
public const int input_password = 2131558628;
// aapt resource value: 0x7f0d00d8 // aapt resource value: 0x7f0d00d8
public const int input_subject = 2131558616; public const int input_name = 2131558616;
// aapt resource value: 0x7f0d00e6
public const int input_password = 2131558630;
// aapt resource value: 0x7f0d00da
public const int input_subject = 2131558618;
// aapt resource value: 0x7f0d006f // aapt resource value: 0x7f0d006f
public const int italic = 2131558511; public const int italic = 2131558511;
@ -9500,32 +9506,32 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d0000 // aapt resource value: 0x7f0d0000
public const int item_touch_helper_previous_elevation = 2131558400; public const int item_touch_helper_previous_elevation = 2131558400;
// aapt resource value: 0x7f0d00eb
public const int label_author = 2131558635;
// aapt resource value: 0x7f0d00ec
public const int label_date = 2131558636;
// aapt resource value: 0x7f0d00de
public const int label_last_updated = 2131558622;
// aapt resource value: 0x7f0d00d3
public const int label_message = 2131558611;
// aapt resource value: 0x7f0d00ed // aapt resource value: 0x7f0d00ed
public const int label_text = 2131558637; public const int label_author = 2131558637;
// aapt resource value: 0x7f0d00e7 // aapt resource value: 0x7f0d00ee
public const int label_title = 2131558631; public const int label_date = 2131558638;
// aapt resource value: 0x7f0d00e8 // aapt resource value: 0x7f0d00e0
public const int label_version = 2131558632; public const int label_last_updated = 2131558624;
// aapt resource value: 0x7f0d00d5
public const int label_message = 2131558613;
// aapt resource value: 0x7f0d00ef
public const int label_text = 2131558639;
// aapt resource value: 0x7f0d00e9
public const int label_title = 2131558633;
// aapt resource value: 0x7f0d00ea
public const int label_version = 2131558634;
// aapt resource value: 0x7f0d0055 // aapt resource value: 0x7f0d0055
public const int labeled = 2131558485; public const int labeled = 2131558485;
// aapt resource value: 0x7f0d00be // aapt resource value: 0x7f0d00c0
public const int largeLabel = 2131558590; public const int largeLabel = 2131558592;
// aapt resource value: 0x7f0d005b // aapt resource value: 0x7f0d005b
public const int left = 2131558491; public const int left = 2131558491;
@ -9542,32 +9548,32 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d002d // aapt resource value: 0x7f0d002d
public const int listMode = 2131558445; public const int listMode = 2131558445;
// aapt resource value: 0x7f0d00ee // aapt resource value: 0x7f0d00f0
public const int list_attachments = 2131558638; public const int list_attachments = 2131558640;
// aapt resource value: 0x7f0d00e2 // aapt resource value: 0x7f0d00e4
public const int list_feedback_messages = 2131558626; public const int list_feedback_messages = 2131558628;
// aapt resource value: 0x7f0d0077 // aapt resource value: 0x7f0d0077
public const int list_item = 2131558519; public const int list_item = 2131558519;
// aapt resource value: 0x7f0d0131 // aapt resource value: 0x7f0d0133
public const int main_appbar = 2131558705; public const int main_appbar = 2131558707;
// aapt resource value: 0x7f0d0136
public const int main_scrollview = 2131558710;
// aapt resource value: 0x7f0d0135
public const int main_tablayout = 2131558709;
// aapt resource value: 0x7f0d0134 // aapt resource value: 0x7f0d0134
public const int main_scrollview = 2131558708; public const int main_toolbar = 2131558708;
// aapt resource value: 0x7f0d0133 // aapt resource value: 0x7f0d013e
public const int main_tablayout = 2131558707; public const int masked = 2131558718;
// aapt resource value: 0x7f0d0132 // aapt resource value: 0x7f0d0126
public const int main_toolbar = 2131558706; public const int media_actions = 2131558694;
// aapt resource value: 0x7f0d013c
public const int masked = 2131558716;
// aapt resource value: 0x7f0d0124
public const int media_actions = 2131558692;
// aapt resource value: 0x7f0d00a3 // aapt resource value: 0x7f0d00a3
public const int message = 2131558563; public const int message = 2131558563;
@ -9578,143 +9584,143 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d0060 // aapt resource value: 0x7f0d0060
public const int mini = 2131558496; public const int mini = 2131558496;
// aapt resource value: 0x7f0d010b // aapt resource value: 0x7f0d010d
public const int mr_art = 2131558667; public const int mr_art = 2131558669;
// aapt resource value: 0x7f0d00fc
public const int mr_cast_checkbox = 2131558652;
// aapt resource value: 0x7f0d00f5
public const int mr_cast_close_button = 2131558645;
// aapt resource value: 0x7f0d00f0
public const int mr_cast_group_icon = 2131558640;
// aapt resource value: 0x7f0d00f1
public const int mr_cast_group_name = 2131558641;
// aapt resource value: 0x7f0d00ef
public const int mr_cast_list = 2131558639;
// aapt resource value: 0x7f0d00f4
public const int mr_cast_meta = 2131558644;
// aapt resource value: 0x7f0d00f6
public const int mr_cast_meta_art = 2131558646;
// aapt resource value: 0x7f0d00f8
public const int mr_cast_meta_subtitle = 2131558648;
// aapt resource value: 0x7f0d00f7
public const int mr_cast_meta_title = 2131558647;
// aapt resource value: 0x7f0d00fa
public const int mr_cast_route_icon = 2131558650;
// aapt resource value: 0x7f0d00fb
public const int mr_cast_route_name = 2131558651;
// aapt resource value: 0x7f0d00f9
public const int mr_cast_stop_button = 2131558649;
// aapt resource value: 0x7f0d00fd
public const int mr_cast_volume_layout = 2131558653;
// aapt resource value: 0x7f0d00fe // aapt resource value: 0x7f0d00fe
public const int mr_cast_volume_slider = 2131558654; public const int mr_cast_checkbox = 2131558654;
// aapt resource value: 0x7f0d0100 // aapt resource value: 0x7f0d00f7
public const int mr_chooser_list = 2131558656; public const int mr_cast_close_button = 2131558647;
// aapt resource value: 0x7f0d0103
public const int mr_chooser_route_desc = 2131558659;
// aapt resource value: 0x7f0d0101
public const int mr_chooser_route_icon = 2131558657;
// aapt resource value: 0x7f0d0102
public const int mr_chooser_route_name = 2131558658;
// aapt resource value: 0x7f0d00ff
public const int mr_chooser_title = 2131558655;
// aapt resource value: 0x7f0d0108
public const int mr_close = 2131558664;
// aapt resource value: 0x7f0d010e
public const int mr_control_divider = 2131558670;
// aapt resource value: 0x7f0d0119
public const int mr_control_playback_ctrl = 2131558681;
// aapt resource value: 0x7f0d011c
public const int mr_control_subtitle = 2131558684;
// aapt resource value: 0x7f0d011b
public const int mr_control_title = 2131558683;
// aapt resource value: 0x7f0d011a
public const int mr_control_title_container = 2131558682;
// aapt resource value: 0x7f0d0109
public const int mr_custom_control = 2131558665;
// aapt resource value: 0x7f0d010a
public const int mr_default_control = 2131558666;
// aapt resource value: 0x7f0d0105
public const int mr_dialog_area = 2131558661;
// aapt resource value: 0x7f0d0114
public const int mr_dialog_header_name = 2131558676;
// aapt resource value: 0x7f0d0104
public const int mr_expandable_area = 2131558660;
// aapt resource value: 0x7f0d011d
public const int mr_group_expand_collapse = 2131558685;
// aapt resource value: 0x7f0d00f2 // aapt resource value: 0x7f0d00f2
public const int mr_group_volume_route_name = 2131558642; public const int mr_cast_group_icon = 2131558642;
// aapt resource value: 0x7f0d00f3 // aapt resource value: 0x7f0d00f3
public const int mr_group_volume_slider = 2131558643; public const int mr_cast_group_name = 2131558643;
// aapt resource value: 0x7f0d010c // aapt resource value: 0x7f0d00f1
public const int mr_media_main_control = 2131558668; public const int mr_cast_list = 2131558641;
// aapt resource value: 0x7f0d0107 // aapt resource value: 0x7f0d00f6
public const int mr_name = 2131558663; public const int mr_cast_meta = 2131558646;
// aapt resource value: 0x7f0d0115 // aapt resource value: 0x7f0d00f8
public const int mr_picker_close_button = 2131558677; public const int mr_cast_meta_art = 2131558648;
// aapt resource value: 0x7f0d0116 // aapt resource value: 0x7f0d00fa
public const int mr_picker_list = 2131558678; public const int mr_cast_meta_subtitle = 2131558650;
// aapt resource value: 0x7f0d0117 // aapt resource value: 0x7f0d00f9
public const int mr_picker_route_icon = 2131558679; public const int mr_cast_meta_title = 2131558649;
// aapt resource value: 0x7f0d0118 // aapt resource value: 0x7f0d00fc
public const int mr_picker_route_name = 2131558680; public const int mr_cast_route_icon = 2131558652;
// aapt resource value: 0x7f0d010d // aapt resource value: 0x7f0d00fd
public const int mr_playback_control = 2131558669; public const int mr_cast_route_name = 2131558653;
// aapt resource value: 0x7f0d0106 // aapt resource value: 0x7f0d00fb
public const int mr_title_bar = 2131558662; public const int mr_cast_stop_button = 2131558651;
// aapt resource value: 0x7f0d010f // aapt resource value: 0x7f0d00ff
public const int mr_volume_control = 2131558671; public const int mr_cast_volume_layout = 2131558655;
// aapt resource value: 0x7f0d0100
public const int mr_cast_volume_slider = 2131558656;
// aapt resource value: 0x7f0d0102
public const int mr_chooser_list = 2131558658;
// aapt resource value: 0x7f0d0105
public const int mr_chooser_route_desc = 2131558661;
// aapt resource value: 0x7f0d0103
public const int mr_chooser_route_icon = 2131558659;
// aapt resource value: 0x7f0d0104
public const int mr_chooser_route_name = 2131558660;
// aapt resource value: 0x7f0d0101
public const int mr_chooser_title = 2131558657;
// aapt resource value: 0x7f0d010a
public const int mr_close = 2131558666;
// aapt resource value: 0x7f0d0110 // aapt resource value: 0x7f0d0110
public const int mr_volume_group_list = 2131558672; public const int mr_control_divider = 2131558672;
// aapt resource value: 0x7f0d011b
public const int mr_control_playback_ctrl = 2131558683;
// aapt resource value: 0x7f0d011e
public const int mr_control_subtitle = 2131558686;
// aapt resource value: 0x7f0d011d
public const int mr_control_title = 2131558685;
// aapt resource value: 0x7f0d011c
public const int mr_control_title_container = 2131558684;
// aapt resource value: 0x7f0d010b
public const int mr_custom_control = 2131558667;
// aapt resource value: 0x7f0d010c
public const int mr_default_control = 2131558668;
// aapt resource value: 0x7f0d0107
public const int mr_dialog_area = 2131558663;
// aapt resource value: 0x7f0d0116
public const int mr_dialog_header_name = 2131558678;
// aapt resource value: 0x7f0d0106
public const int mr_expandable_area = 2131558662;
// aapt resource value: 0x7f0d011f
public const int mr_group_expand_collapse = 2131558687;
// aapt resource value: 0x7f0d00f4
public const int mr_group_volume_route_name = 2131558644;
// aapt resource value: 0x7f0d00f5
public const int mr_group_volume_slider = 2131558645;
// aapt resource value: 0x7f0d010e
public const int mr_media_main_control = 2131558670;
// aapt resource value: 0x7f0d0109
public const int mr_name = 2131558665;
// aapt resource value: 0x7f0d0117
public const int mr_picker_close_button = 2131558679;
// aapt resource value: 0x7f0d0118
public const int mr_picker_list = 2131558680;
// aapt resource value: 0x7f0d0119
public const int mr_picker_route_icon = 2131558681;
// aapt resource value: 0x7f0d011a
public const int mr_picker_route_name = 2131558682;
// aapt resource value: 0x7f0d010f
public const int mr_playback_control = 2131558671;
// aapt resource value: 0x7f0d0108
public const int mr_title_bar = 2131558664;
// aapt resource value: 0x7f0d0111
public const int mr_volume_control = 2131558673;
// aapt resource value: 0x7f0d0112 // aapt resource value: 0x7f0d0112
public const int mr_volume_item_icon = 2131558674; public const int mr_volume_group_list = 2131558674;
// aapt resource value: 0x7f0d0113 // aapt resource value: 0x7f0d0114
public const int mr_volume_slider = 2131558675; public const int mr_volume_item_icon = 2131558676;
// aapt resource value: 0x7f0d0115
public const int mr_volume_slider = 2131558677;
// aapt resource value: 0x7f0d0014 // aapt resource value: 0x7f0d0014
public const int mtrl_child_content_container = 2131558420; public const int mtrl_child_content_container = 2131558420;
@ -9725,8 +9731,8 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d0037 // aapt resource value: 0x7f0d0037
public const int multiply = 2131558455; public const int multiply = 2131558455;
// aapt resource value: 0x7f0d00c3 // aapt resource value: 0x7f0d00c5
public const int navigation_header_container = 2131558595; public const int navigation_header_container = 2131558597;
// aapt resource value: 0x7f0d004a // aapt resource value: 0x7f0d004a
public const int never = 2131558474; public const int never = 2131558474;
@ -9737,14 +9743,14 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d002e // aapt resource value: 0x7f0d002e
public const int normal = 2131558446; public const int normal = 2131558446;
// aapt resource value: 0x7f0d012d // aapt resource value: 0x7f0d012f
public const int notification_background = 2131558701; public const int notification_background = 2131558703;
// aapt resource value: 0x7f0d0127 // aapt resource value: 0x7f0d0129
public const int notification_main_column = 2131558695; public const int notification_main_column = 2131558697;
// aapt resource value: 0x7f0d0126 // aapt resource value: 0x7f0d0128
public const int notification_main_column_container = 2131558694; public const int notification_main_column_container = 2131558696;
// aapt resource value: 0x7f0d0067 // aapt resource value: 0x7f0d0067
public const int outline = 2131558503; public const int outline = 2131558503;
@ -9773,11 +9779,11 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d005c // aapt resource value: 0x7f0d005c
public const int right = 2131558492; public const int right = 2131558492;
// aapt resource value: 0x7f0d012c // aapt resource value: 0x7f0d012e
public const int right_icon = 2131558700; public const int right_icon = 2131558702;
// aapt resource value: 0x7f0d0128 // aapt resource value: 0x7f0d012a
public const int right_side = 2131558696; public const int right_side = 2131558698;
// aapt resource value: 0x7f0d000c // aapt resource value: 0x7f0d000c
public const int save_image_matrix = 2131558412; public const int save_image_matrix = 2131558412;
@ -9842,14 +9848,14 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d0056 // aapt resource value: 0x7f0d0056
public const int selected = 2131558486; public const int selected = 2131558486;
// aapt resource value: 0x7f0d0135
public const int shellcontent_appbar = 2131558709;
// aapt resource value: 0x7f0d0137 // aapt resource value: 0x7f0d0137
public const int shellcontent_scrollview = 2131558711; public const int shellcontent_appbar = 2131558711;
// aapt resource value: 0x7f0d0136 // aapt resource value: 0x7f0d0139
public const int shellcontent_toolbar = 2131558710; public const int shellcontent_scrollview = 2131558713;
// aapt resource value: 0x7f0d0138
public const int shellcontent_toolbar = 2131558712;
// aapt resource value: 0x7f0d008a // aapt resource value: 0x7f0d008a
public const int shortcut = 2131558538; public const int shortcut = 2131558538;
@ -9863,11 +9869,11 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d0034 // aapt resource value: 0x7f0d0034
public const int showTitle = 2131558452; public const int showTitle = 2131558452;
// aapt resource value: 0x7f0d0138 // aapt resource value: 0x7f0d013a
public const int sliding_tabs = 2131558712; public const int sliding_tabs = 2131558714;
// aapt resource value: 0x7f0d00bd // aapt resource value: 0x7f0d00bf
public const int smallLabel = 2131558589; public const int smallLabel = 2131558591;
// aapt resource value: 0x7f0d0016 // aapt resource value: 0x7f0d0016
public const int snackbar_action = 2131558422; public const int snackbar_action = 2131558422;
@ -9902,8 +9908,8 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d005d // aapt resource value: 0x7f0d005d
public const int start = 2131558493; public const int start = 2131558493;
// aapt resource value: 0x7f0d0123 // aapt resource value: 0x7f0d0125
public const int status_bar_latest_event_content = 2131558691; public const int status_bar_latest_event_content = 2131558693;
// aapt resource value: 0x7f0d0062 // aapt resource value: 0x7f0d0062
public const int stretch = 2131558498; public const int stretch = 2131558498;
@ -9944,11 +9950,11 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d0061 // aapt resource value: 0x7f0d0061
public const int textStart = 2131558497; public const int textStart = 2131558497;
// aapt resource value: 0x7f0d00e3 // aapt resource value: 0x7f0d00e5
public const int text_headline = 2131558627; public const int text_headline = 2131558629;
// aapt resource value: 0x7f0d00c8 // aapt resource value: 0x7f0d00ca
public const int text_input_password_toggle = 2131558600; public const int text_input_password_toggle = 2131558602;
// aapt resource value: 0x7f0d0018 // aapt resource value: 0x7f0d0018
public const int textinput_counter = 2131558424; public const int textinput_counter = 2131558424;
@ -9959,8 +9965,8 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d001a // aapt resource value: 0x7f0d001a
public const int textinput_helper_text = 2131558426; public const int textinput_helper_text = 2131558426;
// aapt resource value: 0x7f0d0129 // aapt resource value: 0x7f0d012b
public const int time = 2131558697; public const int time = 2131558699;
// aapt resource value: 0x7f0d0023 // aapt resource value: 0x7f0d0023
public const int title = 2131558435; public const int title = 2131558435;
@ -9971,8 +9977,8 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d0085 // aapt resource value: 0x7f0d0085
public const int title_template = 2131558533; public const int title_template = 2131558533;
// aapt resource value: 0x7f0d0139 // aapt resource value: 0x7f0d013b
public const int toolbar = 2131558713; public const int toolbar = 2131558715;
// aapt resource value: 0x7f0d004d // aapt resource value: 0x7f0d004d
public const int top = 2131558477; public const int top = 2131558477;
@ -9980,8 +9986,8 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d0084 // aapt resource value: 0x7f0d0084
public const int topPanel = 2131558532; public const int topPanel = 2131558532;
// aapt resource value: 0x7f0d00c1 // aapt resource value: 0x7f0d00c3
public const int touch_outside = 2131558593; public const int touch_outside = 2131558595;
// aapt resource value: 0x7f0d000f // aapt resource value: 0x7f0d000f
public const int transition_current_scene = 2131558415; public const int transition_current_scene = 2131558415;
@ -10010,20 +10016,20 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d0035 // aapt resource value: 0x7f0d0035
public const int useLogo = 2131558453; public const int useLogo = 2131558453;
// aapt resource value: 0x7f0d00e6 // aapt resource value: 0x7f0d00e8
public const int view_header = 2131558630; public const int view_header = 2131558632;
// aapt resource value: 0x7f0d001b // aapt resource value: 0x7f0d001b
public const int view_offset_helper = 2131558427; public const int view_offset_helper = 2131558427;
// aapt resource value: 0x7f0d013b // aapt resource value: 0x7f0d013d
public const int visible = 2131558715; public const int visible = 2131558717;
// aapt resource value: 0x7f0d0111 // aapt resource value: 0x7f0d0113
public const int volume_item_container = 2131558673; public const int volume_item_container = 2131558675;
// aapt resource value: 0x7f0d00ea // aapt resource value: 0x7f0d00ec
public const int web_update_details = 2131558634; public const int web_update_details = 2131558636;
// aapt resource value: 0x7f0d0029 // aapt resource value: 0x7f0d0029
public const int wide = 2131558441; public const int wide = 2131558441;
@ -10034,20 +10040,20 @@ namespace Bit.Droid
// aapt resource value: 0x7f0d003d // aapt resource value: 0x7f0d003d
public const int wrap_content = 2131558461; public const int wrap_content = 2131558461;
// aapt resource value: 0x7f0d00da // aapt resource value: 0x7f0d00dc
public const int wrapper_attachments = 2131558618; public const int wrapper_attachments = 2131558620;
// aapt resource value: 0x7f0d00d5 // aapt resource value: 0x7f0d00d7
public const int wrapper_feedback = 2131558613; public const int wrapper_feedback = 2131558615;
// aapt resource value: 0x7f0d00d4 // aapt resource value: 0x7f0d00d6
public const int wrapper_feedback_scroll = 2131558612; public const int wrapper_feedback_scroll = 2131558614;
// aapt resource value: 0x7f0d00dd
public const int wrapper_messages = 2131558621;
// aapt resource value: 0x7f0d00df // aapt resource value: 0x7f0d00df
public const int wrapper_messages_buttons = 2131558623; public const int wrapper_messages = 2131558623;
// aapt resource value: 0x7f0d00e1
public const int wrapper_messages_buttons = 2131558625;
static Id() static Id()
{ {

View file

@ -2,19 +2,33 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@android:color/holo_red_dark" android:minHeight="44dp"
android:minHeight="44dp">
<LinearLayout
android:id="@+id/CipherCellContent"
android:background="@android:color/holo_purple"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/CipherCellButton"
android:gravity="center_vertical"> android:gravity="center_vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<bit.droid.renderers.IconImageView
android:id="@+id/CipherCellIconImage"
android:layout_width="24dp"
android:layout_height="24dp"
android:gravity="center"
android:layout_gravity="center_vertical" />
<TextView
android:id="@+id/CipherCellIcon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:gravity="center"
android:text="[X]" />
<LinearLayout
android:id="@+id/CipherCellContent"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical">
<LinearLayout <LinearLayout
android:id="@+id/CipherCellContentTop" android:id="@+id/CipherCellContentTop"
android:background="@android:color/holo_green_dark"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
@ -22,33 +36,35 @@
android:id="@+id/CipherCellName" android:id="@+id/CipherCellName"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end" android:ellipsize="end"
android:text="Name" /> android:text="Name" />
<TextView <TextView
android:id="@+id/CipherCellSharedIcon" android:id="@+id/CipherCellSharedIcon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:singleLine="true"
android:text="&#xf1e0;" /> android:text="&#xf1e0;" />
<TextView <TextView
android:id="@+id/CipherCellAttachmentsIcon" android:id="@+id/CipherCellAttachmentsIcon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:singleLine="true"
android:text="&#xf0c6;" /> android:text="&#xf0c6;" />
</LinearLayout> </LinearLayout>
<TextView <TextView
android:id="@+id/CipherCellSubTitle" android:id="@+id/CipherCellSubTitle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true" android:singleLine="true"
android:ellipsize="end" android:ellipsize="end"
android:text="SubTitle" /> android:text="SubTitle" />
</LinearLayout> </LinearLayout>
<Button <Button
android:id="@+id/CipherCellButton" android:id="@+id/CipherCellButton"
android:layout_alignParentRight="true"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center" android:text="&#xe5d4;"
android:text="&#xe5d4;" /> android:gravity="center"/>
</LinearLayout>
</RelativeLayout> </RelativeLayout>

View file

@ -4,9 +4,6 @@
x:Class="Bit.App.Controls.CipherViewCell" x:Class="Bit.App.Controls.CipherViewCell"
xmlns:controls="clr-namespace:Bit.App.Controls" xmlns:controls="clr-namespace:Bit.App.Controls"
xmlns:ff="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"> xmlns:ff="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms">
<ViewCell.View>
<OnPlatform x:TypeArguments="View">
<On Platform="iOS">
<Grid x:Name="_grid" <Grid x:Name="_grid"
StyleClass="list-row, list-row-platform" StyleClass="list-row, list-row-platform"
RowSpacing="0" RowSpacing="0"
@ -86,7 +83,4 @@
Grid.Row="0" Grid.Row="0"
Grid.RowSpan="2" /> Grid.RowSpan="2" />
</Grid> </Grid>
</On>
</OnPlatform>
</ViewCell.View>
</ViewCell> </ViewCell>

View file

@ -5,7 +5,6 @@ using Bit.Core.Enums;
using Bit.Core.Models.View; using Bit.Core.Models.View;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using System; using System;
using System.Threading.Tasks;
using Xamarin.Forms; using Xamarin.Forms;
namespace Bit.App.Controls namespace Bit.App.Controls
@ -18,19 +17,26 @@ namespace Bit.App.Controls
public static readonly BindableProperty ButtonCommandProperty = BindableProperty.Create( public static readonly BindableProperty ButtonCommandProperty = BindableProperty.Create(
nameof(ButtonCommand), typeof(Command<CipherView>), typeof(CipherViewCell)); nameof(ButtonCommand), typeof(Command<CipherView>), typeof(CipherViewCell));
private readonly IStateService _stateService;
private readonly IEnvironmentService _environmentService; private readonly IEnvironmentService _environmentService;
private CipherViewCellViewModel _viewModel; private CipherViewCellViewModel _viewModel;
private bool _usingNativeCell;
public CipherViewCell() public CipherViewCell()
{
_environmentService = ServiceContainer.Resolve<IEnvironmentService>("environmentService");
if(Device.RuntimePlatform == Device.iOS)
{ {
InitializeComponent(); InitializeComponent();
_viewModel = _grid.BindingContext as CipherViewCellViewModel; _viewModel = _grid.BindingContext as CipherViewCellViewModel;
_stateService = ServiceContainer.Resolve<IStateService>("stateService");
_environmentService = ServiceContainer.Resolve<IEnvironmentService>("environmentService");
} }
else
{
_usingNativeCell = true;
}
}
public bool WebsiteIconsEnabled { get; set; } = true;
public CipherView Cipher public CipherView Cipher
{ {
@ -47,18 +53,25 @@ namespace Bit.App.Controls
protected override void OnPropertyChanged(string propertyName = null) protected override void OnPropertyChanged(string propertyName = null)
{ {
base.OnPropertyChanged(propertyName); base.OnPropertyChanged(propertyName);
if(_usingNativeCell)
{
return;
}
if(propertyName == CipherProperty.PropertyName) if(propertyName == CipherProperty.PropertyName)
{ {
_viewModel.Cipher = Cipher; _viewModel.Cipher = Cipher;
} }
} }
protected async override void OnBindingContextChanged() protected override void OnBindingContextChanged()
{ {
string icon = null; base.OnBindingContextChanged();
string image = null; if(_usingNativeCell)
_image.Source = null; {
return;
}
_image.Source = null;
CipherView cipher = null; CipherView cipher = null;
if(BindingContext is GroupingsPageListItem groupingsPageListItem) if(BindingContext is GroupingsPageListItem groupingsPageListItem)
{ {
@ -70,10 +83,31 @@ namespace Bit.App.Controls
} }
if(cipher != null) if(cipher != null)
{ {
var iconImage = GetIconImage(cipher);
if(iconImage.Item2 != null)
{
_image.IsVisible = true;
_icon.IsVisible = false;
_image.Source = iconImage.Item2;
_image.LoadingPlaceholder = "login.png";
}
else
{
_image.IsVisible = false;
_icon.IsVisible = true;
_icon.Text = iconImage.Item1;
}
}
}
public Tuple<string, string> GetIconImage(CipherView cipher)
{
string icon = null;
string image = null;
switch(cipher.Type) switch(cipher.Type)
{ {
case CipherType.Login: case CipherType.Login:
var loginIconImage = await GetLoginIconImage(cipher); var loginIconImage = GetLoginIconImage(cipher);
icon = loginIconImage.Item1; icon = loginIconImage.Item1;
image = loginIconImage.Item2; image = loginIconImage.Item2;
break; break;
@ -89,29 +123,13 @@ namespace Bit.App.Controls
default: default:
break; break;
} }
return new Tuple<string, string>(icon, image);
if(image != null)
{
_image.IsVisible = true;
_icon.IsVisible = false;
_image.Source = image;
_image.LoadingPlaceholder = "login.png";
}
else
{
_image.IsVisible = false;
_icon.IsVisible = true;
_icon.Text = icon;
}
}
base.OnBindingContextChanged();
} }
private async Task<Tuple<string, string>> GetLoginIconImage(CipherView cipher) private Tuple<string, string> GetLoginIconImage(CipherView cipher)
{ {
string icon = ""; string icon = "";
string image = null; string image = null;
var imageEnabled = !(await _stateService.GetAsync<bool?>(Constants.DisableFaviconKey)).GetValueOrDefault();
if(cipher.Login.Uri != null) if(cipher.Login.Uri != null)
{ {
var hostnameUri = cipher.Login.Uri; var hostnameUri = cipher.Login.Uri;
@ -125,17 +143,17 @@ namespace Bit.App.Controls
{ {
icon = ""; icon = "";
} }
else if(imageEnabled && !hostnameUri.Contains("://") && hostnameUri.Contains(".")) else if(WebsiteIconsEnabled && !hostnameUri.Contains("://") && hostnameUri.Contains("."))
{ {
hostnameUri = string.Concat("http://", hostnameUri); hostnameUri = string.Concat("http://", hostnameUri);
isWebsite = true; isWebsite = true;
} }
else if(imageEnabled) else if(WebsiteIconsEnabled)
{ {
isWebsite = hostnameUri.StartsWith("http") && hostnameUri.Contains("."); isWebsite = hostnameUri.StartsWith("http") && hostnameUri.Contains(".");
} }
if(imageEnabled && isWebsite) if(WebsiteIconsEnabled && isWebsite)
{ {
var hostname = CoreHelpers.GetHostname(hostnameUri); var hostname = CoreHelpers.GetHostname(hostnameUri);
var iconsUrl = _environmentService.IconsUrl; var iconsUrl = _environmentService.IconsUrl;