From 0d3cb7c11713d105582b8ae53b32ec6b60dcf5b1 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 15 Jun 2016 00:36:50 -0400 Subject: [PATCH] added "more" disclosure image for vault listing cell "more options" action sheet. --- src/Android/Android.csproj | 15 ++++++ .../Controls/ExtendedTextCellRenderer.cs | 28 +++++++++++- src/Android/Resources/Resource.Designer.cs | 43 ++++++++++-------- src/Android/Resources/drawable-hdpi/more.png | Bin 0 -> 584 bytes src/Android/Resources/drawable-mdpi/more.png | Bin 0 -> 584 bytes src/Android/Resources/drawable-xhdpi/more.png | Bin 0 -> 584 bytes .../Resources/drawable-xxhdpi/more.png | Bin 0 -> 584 bytes src/Android/Resources/drawable/more.png | Bin 0 -> 584 bytes src/App/Controls/ExtendedTextCell.cs | 10 +++- src/App/Pages/VaultListSitesPage.cs | 22 ++++++--- src/iOS/Controls/ExtendedTextCellRenderer.cs | 16 +++++-- src/iOS/Resources/more.png | Bin 0 -> 584 bytes src/iOS/Resources/more@2x.png | Bin 0 -> 479 bytes src/iOS/Resources/more@3x.png | Bin 0 -> 271 bytes src/iOS/Resources/more_selected.png | Bin 0 -> 271 bytes src/iOS/Resources/more_selected@2x.png | Bin 0 -> 479 bytes src/iOS/Resources/more_selected@3x.png | Bin 0 -> 584 bytes src/iOS/iOS.csproj | 18 ++++++++ 18 files changed, 118 insertions(+), 34 deletions(-) create mode 100644 src/Android/Resources/drawable-hdpi/more.png create mode 100644 src/Android/Resources/drawable-mdpi/more.png create mode 100644 src/Android/Resources/drawable-xhdpi/more.png create mode 100644 src/Android/Resources/drawable-xxhdpi/more.png create mode 100644 src/Android/Resources/drawable/more.png create mode 100644 src/iOS/Resources/more.png create mode 100644 src/iOS/Resources/more@2x.png create mode 100644 src/iOS/Resources/more@3x.png create mode 100644 src/iOS/Resources/more_selected.png create mode 100644 src/iOS/Resources/more_selected@2x.png create mode 100644 src/iOS/Resources/more_selected@3x.png diff --git a/src/Android/Android.csproj b/src/Android/Android.csproj index c7b6ccf0e..80e469bfb 100644 --- a/src/Android/Android.csproj +++ b/src/Android/Android.csproj @@ -299,6 +299,21 @@ + + + + + + + + + + + + + + + diff --git a/src/Android/Controls/ExtendedTextCellRenderer.cs b/src/Android/Controls/ExtendedTextCellRenderer.cs index 06bb30c73..8e68fa4a5 100644 --- a/src/Android/Controls/ExtendedTextCellRenderer.cs +++ b/src/Android/Controls/ExtendedTextCellRenderer.cs @@ -33,9 +33,9 @@ namespace Bit.Android.Controls resourceId = context.Resources.GetIdentifier(fileName, "drawable", context.PackageName); } - var image = new ImageView(context); + var image = new DisclosureImage(context, extendedCell); image.SetImageResource(resourceId); - image.SetPadding(0, 0, 30, 0); + image.SetPadding(10, 10, 30, 10); View.SetAccessoryView(image); } } @@ -43,6 +43,30 @@ namespace Bit.Android.Controls return View; } + private class DisclosureImage : ImageView + { + private ExtendedTextCell _cell; + + public DisclosureImage(Context context, ExtendedTextCell cell) : base(context) + { + _cell = cell; + } + + public override bool OnTouchEvent(MotionEvent e) + { + switch(e.Action) + { + case MotionEventActions.Up: + _cell.OnDisclousureTapped(); + break; + default: + break; + } + + return true; + } + } + protected override void OnCellPropertyChanged(object sender, PropertyChangedEventArgs args) { base.OnCellPropertyChanged(sender, args); diff --git a/src/Android/Resources/Resource.Designer.cs b/src/Android/Resources/Resource.Designer.cs index 11e763df3..0e1761d02 100644 --- a/src/Android/Resources/Resource.Designer.cs +++ b/src/Android/Resources/Resource.Designer.cs @@ -2274,58 +2274,61 @@ namespace Bit.Android public const int ion_plus = 2130837656; // aapt resource value: 0x7f020099 - public const int mr_dialog_material_background_dark = 2130837657; + public const int more = 2130837657; // aapt resource value: 0x7f02009a - public const int mr_dialog_material_background_light = 2130837658; + public const int mr_dialog_material_background_dark = 2130837658; // aapt resource value: 0x7f02009b - public const int mr_ic_audiotrack_light = 2130837659; + public const int mr_dialog_material_background_light = 2130837659; // aapt resource value: 0x7f02009c - public const int mr_ic_cast_dark = 2130837660; + public const int mr_ic_audiotrack_light = 2130837660; // aapt resource value: 0x7f02009d - public const int mr_ic_cast_light = 2130837661; + public const int mr_ic_cast_dark = 2130837661; // aapt resource value: 0x7f02009e - public const int mr_ic_close_dark = 2130837662; + public const int mr_ic_cast_light = 2130837662; // aapt resource value: 0x7f02009f - public const int mr_ic_close_light = 2130837663; + public const int mr_ic_close_dark = 2130837663; // aapt resource value: 0x7f0200a0 - public const int mr_ic_media_route_connecting_mono_dark = 2130837664; + public const int mr_ic_close_light = 2130837664; // aapt resource value: 0x7f0200a1 - public const int mr_ic_media_route_connecting_mono_light = 2130837665; + public const int mr_ic_media_route_connecting_mono_dark = 2130837665; // aapt resource value: 0x7f0200a2 - public const int mr_ic_media_route_mono_dark = 2130837666; + public const int mr_ic_media_route_connecting_mono_light = 2130837666; // aapt resource value: 0x7f0200a3 - public const int mr_ic_media_route_mono_light = 2130837667; + public const int mr_ic_media_route_mono_dark = 2130837667; // aapt resource value: 0x7f0200a4 - public const int mr_ic_pause_dark = 2130837668; + public const int mr_ic_media_route_mono_light = 2130837668; // aapt resource value: 0x7f0200a5 - public const int mr_ic_pause_light = 2130837669; + public const int mr_ic_pause_dark = 2130837669; // aapt resource value: 0x7f0200a6 - public const int mr_ic_play_dark = 2130837670; + public const int mr_ic_pause_light = 2130837670; // aapt resource value: 0x7f0200a7 - public const int mr_ic_play_light = 2130837671; - - // aapt resource value: 0x7f0200aa - public const int notification_template_icon_bg = 2130837674; + public const int mr_ic_play_dark = 2130837671; // aapt resource value: 0x7f0200a8 - public const int roundedbg = 2130837672; + public const int mr_ic_play_light = 2130837672; + + // aapt resource value: 0x7f0200ab + public const int notification_template_icon_bg = 2130837675; // aapt resource value: 0x7f0200a9 - public const int roundedbgdark = 2130837673; + public const int roundedbg = 2130837673; + + // aapt resource value: 0x7f0200aa + public const int roundedbgdark = 2130837674; static Drawable() { diff --git a/src/Android/Resources/drawable-hdpi/more.png b/src/Android/Resources/drawable-hdpi/more.png new file mode 100644 index 0000000000000000000000000000000000000000..f7968b5dafea468adbb52e6f1856e425f3cef796 GIT binary patch literal 584 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I3?%1nZ+ru!&II^`xB}_j!v!Rt-Mts+ALo)F zzhDMNCRTP1PA+al7AXxs}=7srr@*0-0h^EDZWG(6n({a$o{;P-o6 zS@-|X^;sh4ck#%Pj7LX*>hHfK9Hfyf;udL3V>$MC7ga`wuYrb9Uc4GWn3uiKL2#F0ryh zY$ui-Qaj;RaX?D9V1BB4&O7U!2C*L)gx9;wlNWQgowRfRPqz2x623j+IacBDAWOgI zi)aMjoqzmZ2~snd!V-%lKdQgbyUq1zuhfg3t8T<6ovZoUTKLBLUDGb3@4FuBWkeT$ iexw%wbn=z@5@v~&sn2A^n7;!3%;4$j=d#Wzp$P!@xHt*` literal 0 HcmV?d00001 diff --git a/src/Android/Resources/drawable-mdpi/more.png b/src/Android/Resources/drawable-mdpi/more.png new file mode 100644 index 0000000000000000000000000000000000000000..f7968b5dafea468adbb52e6f1856e425f3cef796 GIT binary patch literal 584 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I3?%1nZ+ru!&II^`xB}_j!v!Rt-Mts+ALo)F zzhDMNCRTP1PA+al7AXxs}=7srr@*0-0h^EDZWG(6n({a$o{;P-o6 zS@-|X^;sh4ck#%Pj7LX*>hHfK9Hfyf;udL3V>$MC7ga`wuYrb9Uc4GWn3uiKL2#F0ryh zY$ui-Qaj;RaX?D9V1BB4&O7U!2C*L)gx9;wlNWQgowRfRPqz2x623j+IacBDAWOgI zi)aMjoqzmZ2~snd!V-%lKdQgbyUq1zuhfg3t8T<6ovZoUTKLBLUDGb3@4FuBWkeT$ iexw%wbn=z@5@v~&sn2A^n7;!3%;4$j=d#Wzp$P!@xHt*` literal 0 HcmV?d00001 diff --git a/src/Android/Resources/drawable-xhdpi/more.png b/src/Android/Resources/drawable-xhdpi/more.png new file mode 100644 index 0000000000000000000000000000000000000000..f7968b5dafea468adbb52e6f1856e425f3cef796 GIT binary patch literal 584 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I3?%1nZ+ru!&II^`xB}_j!v!Rt-Mts+ALo)F zzhDMNCRTP1PA+al7AXxs}=7srr@*0-0h^EDZWG(6n({a$o{;P-o6 zS@-|X^;sh4ck#%Pj7LX*>hHfK9Hfyf;udL3V>$MC7ga`wuYrb9Uc4GWn3uiKL2#F0ryh zY$ui-Qaj;RaX?D9V1BB4&O7U!2C*L)gx9;wlNWQgowRfRPqz2x623j+IacBDAWOgI zi)aMjoqzmZ2~snd!V-%lKdQgbyUq1zuhfg3t8T<6ovZoUTKLBLUDGb3@4FuBWkeT$ iexw%wbn=z@5@v~&sn2A^n7;!3%;4$j=d#Wzp$P!@xHt*` literal 0 HcmV?d00001 diff --git a/src/Android/Resources/drawable-xxhdpi/more.png b/src/Android/Resources/drawable-xxhdpi/more.png new file mode 100644 index 0000000000000000000000000000000000000000..f7968b5dafea468adbb52e6f1856e425f3cef796 GIT binary patch literal 584 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I3?%1nZ+ru!&II^`xB}_j!v!Rt-Mts+ALo)F zzhDMNCRTP1PA+al7AXxs}=7srr@*0-0h^EDZWG(6n({a$o{;P-o6 zS@-|X^;sh4ck#%Pj7LX*>hHfK9Hfyf;udL3V>$MC7ga`wuYrb9Uc4GWn3uiKL2#F0ryh zY$ui-Qaj;RaX?D9V1BB4&O7U!2C*L)gx9;wlNWQgowRfRPqz2x623j+IacBDAWOgI zi)aMjoqzmZ2~snd!V-%lKdQgbyUq1zuhfg3t8T<6ovZoUTKLBLUDGb3@4FuBWkeT$ iexw%wbn=z@5@v~&sn2A^n7;!3%;4$j=d#Wzp$P!@xHt*` literal 0 HcmV?d00001 diff --git a/src/Android/Resources/drawable/more.png b/src/Android/Resources/drawable/more.png new file mode 100644 index 0000000000000000000000000000000000000000..f7968b5dafea468adbb52e6f1856e425f3cef796 GIT binary patch literal 584 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I3?%1nZ+ru!&II^`xB}_j!v!Rt-Mts+ALo)F zzhDMNCRTP1PA+al7AXxs}=7srr@*0-0h^EDZWG(6n({a$o{;P-o6 zS@-|X^;sh4ck#%Pj7LX*>hHfK9Hfyf;udL3V>$MC7ga`wuYrb9Uc4GWn3uiKL2#F0ryh zY$ui-Qaj;RaX?D9V1BB4&O7U!2C*L)gx9;wlNWQgowRfRPqz2x623j+IacBDAWOgI zi)aMjoqzmZ2~snd!V-%lKdQgbyUq1zuhfg3t8T<6ovZoUTKLBLUDGb3@4FuBWkeT$ iexw%wbn=z@5@v~&sn2A^n7;!3%;4$j=d#Wzp$P!@xHt*` literal 0 HcmV?d00001 diff --git a/src/App/Controls/ExtendedTextCell.cs b/src/App/Controls/ExtendedTextCell.cs index 83baf743a..a9d176edc 100644 --- a/src/App/Controls/ExtendedTextCell.cs +++ b/src/App/Controls/ExtendedTextCell.cs @@ -1,4 +1,5 @@ -using Xamarin.Forms; +using System; +using Xamarin.Forms; namespace Bit.App.Controls { @@ -30,5 +31,12 @@ namespace Bit.App.Controls get { return (string)GetValue(DisclousureImageProperty); } set { SetValue(DisclousureImageProperty, value); } } + + public event EventHandler DisclousureTapped; + + public void OnDisclousureTapped() + { + DisclousureTapped?.Invoke(this, EventArgs.Empty); + } } } diff --git a/src/App/Pages/VaultListSitesPage.cs b/src/App/Pages/VaultListSitesPage.cs index 1afcbe88f..2d0d46ef1 100644 --- a/src/App/Pages/VaultListSitesPage.cs +++ b/src/App/Pages/VaultListSitesPage.cs @@ -10,6 +10,7 @@ using Bit.App.Resources; using Xamarin.Forms; using XLabs.Ioc; using Bit.App.Utilities; +using System.Diagnostics; namespace Bit.App.Pages { @@ -83,8 +84,8 @@ namespace Bit.App.Pages private async void MoreClickedAsync(object sender, EventArgs e) { - var mi = sender as MenuItem; - var site = mi.CommandParameter as VaultListPageModel.Site; + var cell = sender as VaultListViewCell; + var site = cell.CommandParameter as VaultListPageModel.Site; var selection = await DisplayActionSheet(AppResources.MoreOptions, AppResources.Cancel, null, AppResources.View, AppResources.Edit, AppResources.CopyPassword, AppResources.CopyUsername, AppResources.GoToWebsite); @@ -163,23 +164,32 @@ namespace Bit.App.Pages private class VaultListViewCell : ExtendedTextCell { + private VaultListSitesPage _page; + public VaultListViewCell(VaultListSitesPage page) { - var moreAction = new MenuItem { Text = AppResources.More }; - moreAction.SetBinding(MenuItem.CommandParameterProperty, new Binding(".")); - moreAction.Clicked += page.MoreClickedAsync; + _page = page; var deleteAction = new MenuItem { Text = AppResources.Delete, IsDestructive = true }; deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding(".")); deleteAction.Clicked += page.DeleteClickedAsync; + SetBinding(CommandParameterProperty, new Binding(".")); this.SetBinding(TextProperty, s => s.Name); this.SetBinding(DetailProperty, s => s.Username); - ContextActions.Add(moreAction); ContextActions.Add(deleteAction); TextColor = Color.FromHex("333333"); DetailColor = Color.FromHex("777777"); + + DisclousureTapped += VaultListViewCell_DisclousureTapped; + ShowDisclousure = true; + DisclousureImage = "more"; + } + + private void VaultListViewCell_DisclousureTapped(object sender, EventArgs e) + { + _page.MoreClickedAsync(sender, e); } } diff --git a/src/iOS/Controls/ExtendedTextCellRenderer.cs b/src/iOS/Controls/ExtendedTextCellRenderer.cs index 57102c379..db41f7157 100644 --- a/src/iOS/Controls/ExtendedTextCellRenderer.cs +++ b/src/iOS/Controls/ExtendedTextCellRenderer.cs @@ -25,14 +25,20 @@ namespace Bit.iOS.Controls { var detailDisclosureButton = UIButton.FromType(UIButtonType.Custom); detailDisclosureButton.SetImage(UIImage.FromBundle(extendedCell.DisclousureImage), UIControlState.Normal); - detailDisclosureButton.SetImage(UIImage.FromBundle(extendedCell.DisclousureImage), UIControlState.Selected); - detailDisclosureButton.Frame = new CGRect(0f, 0f, 30f, 30f); + try + { + detailDisclosureButton.SetImage(UIImage.FromBundle(extendedCell.DisclousureImage + "_selected"), UIControlState.Selected); + } + catch + { + detailDisclosureButton.SetImage(UIImage.FromBundle(extendedCell.DisclousureImage), UIControlState.Selected); + } + + detailDisclosureButton.Frame = new CGRect(0f, 0f, 30f, 40f); detailDisclosureButton.TouchUpInside += (sender, e) => { - var index = tv.IndexPathForCell(cell); - tv.SelectRow(index, true, UITableViewScrollPosition.None); - tv.Source.AccessoryButtonTapped(tv, index); + extendedCell.OnDisclousureTapped(); }; cell.AccessoryView = detailDisclosureButton; } diff --git a/src/iOS/Resources/more.png b/src/iOS/Resources/more.png new file mode 100644 index 0000000000000000000000000000000000000000..f7968b5dafea468adbb52e6f1856e425f3cef796 GIT binary patch literal 584 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I3?%1nZ+ru!&II^`xB}_j!v!Rt-Mts+ALo)F zzhDMNCRTP1PA+al7AXxs}=7srr@*0-0h^EDZWG(6n({a$o{;P-o6 zS@-|X^;sh4ck#%Pj7LX*>hHfK9Hfyf;udL3V>$MC7ga`wuYrb9Uc4GWn3uiKL2#F0ryh zY$ui-Qaj;RaX?D9V1BB4&O7U!2C*L)gx9;wlNWQgowRfRPqz2x623j+IacBDAWOgI zi)aMjoqzmZ2~snd!V-%lKdQgbyUq1zuhfg3t8T<6ovZoUTKLBLUDGb3@4FuBWkeT$ iexw%wbn=z@5@v~&sn2A^n7;!3%;4$j=d#Wzp$P!@xHt*` literal 0 HcmV?d00001 diff --git a/src/iOS/Resources/more@2x.png b/src/iOS/Resources/more@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..39a930b497b2d93d79e632279785774de7825d99 GIT binary patch literal 479 zcmeAS@N?(olHy`uVBq!ia0vp^dLYcf3?viMZ?gia)d4;su0VSC5CQ9dun$_?hz;uim_M z=k5E?U%&tU`!(rWF39ViE{-7{-fz#}n{URu>n3Iu0VP>&A@>_8$JUqkShuD z3ua(r=j7t!7m!ePboL93iR)jqc*W}VTely6@aW027t0sF^8%`L_H=O!(FlHf(wwP5 zfq~_qX}aKn{URu>n3Iu0Xn+W?<#_><*v>awS22 z!3=EdoLqeT0usuO&VGS0as7)HuUNf)>-NJB9zA*XV)^2CUO<)3o-U3d8o_T*nlm*h zFt8jnO&2_~===ZlTT!KZ2O;0 f*mYch^&8XfODuMl>p89ijbre1^>bP0l+XkKVHIiy literal 0 HcmV?d00001 diff --git a/src/iOS/Resources/more_selected@2x.png b/src/iOS/Resources/more_selected@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..685c25d5cc80d71c1db812407d3339ca8692696a GIT binary patch literal 479 zcmeAS@N?(olHy`uVBq!ia0vp^dLYcf3?viMZ?gia)d4;su0XnchyYFo<>Nr-T9gF& z1v4-)v#_%93knH~h^nb;XzLjoTie<>IL0KUq~{d&^iP~Rea5WqI}aQ_e&+net2b}m zdHeqJ*YCgoeoeZT3-Y?Bi(`m~_uKO~`I-y_S|4&9tql(;V0J8YU&;0Ue~Q)I%%Hs9 zPV>L-_dRT3NLHKta{JEC8+;DdgqnqY4uHUv#PJD*V zC-o#~aV`n+ z3ua(sVrA#x0zn%q=J^E-kNXXziRbb@7(1 zM~|O6bME}b%U7@8{P_9n&)}#KWFG=~iI<+)Kw7cTsM*Gw9ya&4yWH+cqMBaM8{{WLeXZNimlMe}*>PCFhxtg!7g>S6iHSIF`zU#4GMs)G# hM|uH3Cts;AVU}2#`b<`g`76-R44$rjF6*2UngEN-0cZdK literal 0 HcmV?d00001 diff --git a/src/iOS/iOS.csproj b/src/iOS/iOS.csproj index d6deab4d7..d159e8b75 100644 --- a/src/iOS/iOS.csproj +++ b/src/iOS/iOS.csproj @@ -375,6 +375,24 @@ + + + + + + + + + + + + + + + + + +