diff --git a/src/Android/Android.csproj b/src/Android/Android.csproj index 7b2f2a68a..ee8f1fc0f 100644 --- a/src/Android/Android.csproj +++ b/src/Android/Android.csproj @@ -82,6 +82,7 @@ + diff --git a/src/Android/Renderers/ExtendedListViewRenderer.cs b/src/Android/Renderers/ExtendedListViewRenderer.cs new file mode 100644 index 000000000..8ce796f8a --- /dev/null +++ b/src/Android/Renderers/ExtendedListViewRenderer.cs @@ -0,0 +1,29 @@ +using Android.Content; +using Android.Views; +using Bit.App.Controls; +using Bit.Droid.Renderers; +using Xamarin.Forms; +using Xamarin.Forms.Platform.Android; + +[assembly: ExportRenderer(typeof(ExtendedListView), typeof(ExtendedListViewRenderer))] +namespace Bit.Droid.Renderers +{ + public class ExtendedListViewRenderer : ListViewRenderer + { + public ExtendedListViewRenderer(Context context) + : base(context) + { } + + protected override void OnElementChanged(ElementChangedEventArgs e) + { + base.OnElementChanged(e); + if(Control != null && e.NewElement != null && e.NewElement is ExtendedListView listView) + { + // Pad for FAB + Control.SetPadding(0, 0, 0, 170); + Control.SetClipToPadding(false); + Control.ScrollBarStyle = ScrollbarStyles.OutsideOverlay; + } + } + } +} diff --git a/src/App/Controls/ExtendedListView.cs b/src/App/Controls/ExtendedListView.cs new file mode 100644 index 000000000..814abae35 --- /dev/null +++ b/src/App/Controls/ExtendedListView.cs @@ -0,0 +1,12 @@ +using Xamarin.Forms; + +namespace Bit.App.Controls +{ + public class ExtendedListView : ListView + { + public ExtendedListView() { } + + public ExtendedListView(ListViewCachingStrategy cachingStrategy) + : base(cachingStrategy) { } + } +} diff --git a/src/App/Pages/Vault/AddEditPage.xaml.cs b/src/App/Pages/Vault/AddEditPage.xaml.cs index 3c2b94d18..d503cc43d 100644 --- a/src/App/Pages/Vault/AddEditPage.xaml.cs +++ b/src/App/Pages/Vault/AddEditPage.xaml.cs @@ -1,4 +1,5 @@ -using Xamarin.Forms; +using Bit.Core.Enums; +using Xamarin.Forms; namespace Bit.App.Pages { @@ -8,6 +9,7 @@ namespace Bit.App.Pages public AddEditPage( string cipherId = null, + CipherType? type = null, string folderId = null, string collectionId = null, string organizationId = null) @@ -18,6 +20,7 @@ namespace Bit.App.Pages _vm.CipherId = cipherId; _vm.FolderId = folderId; _vm.OrganizationId = organizationId; + _vm.Type = type; _vm.Init(); SetActivityIndicator(); diff --git a/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml b/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml index 33f43e90c..79bd4d400 100644 --- a/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml +++ b/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml @@ -48,7 +48,7 @@ - + @@ -68,7 +68,7 @@ IsVisible="{Binding ShowAddCipherButton}"> - + + RecycleElement + + @@ -95,7 +98,7 @@ - + diff --git a/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs b/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs index 5872e5b3f..76c59bb6b 100644 --- a/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs +++ b/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs @@ -1,4 +1,5 @@ -using Bit.Core.Abstractions; +using Bit.App.Resources; +using Bit.Core.Abstractions; using Bit.Core.Enums; using Bit.Core.Utilities; using System.Threading.Tasks; @@ -38,6 +39,10 @@ namespace Bit.App.Pages { _absLayout.Children.Remove(_fab); } + else + { + _fab.Clicked = AddButton_Clicked; + } } protected async override void OnAppearing() @@ -116,5 +121,41 @@ namespace Bit.App.Pages await Navigation.PushModalAsync(new NavigationPage(page), false); } } + + private async void AddButton_Clicked(object sender, System.EventArgs e) + { + var type = await DisplayActionSheet(AppResources.SelectTypeAdd, AppResources.Cancel, null, + AppResources.TypeLogin, AppResources.TypeCard, AppResources.TypeIdentity, + AppResources.TypeSecureNote); + + var selectedType = CipherType.SecureNote; + if(type == null || type == AppResources.Cancel) + { + return; + } + else if(type == AppResources.TypeLogin) + { + selectedType = CipherType.Login; + } + else if(type == AppResources.TypeCard) + { + selectedType = CipherType.Card; + } + else if(type == AppResources.TypeIdentity) + { + selectedType = CipherType.Identity; + } + else if(type == AppResources.TypeSecureNote) + { + selectedType = CipherType.SecureNote; + } + else + { + return; + } + + var page = new AddEditPage(null, selectedType); + await Navigation.PushModalAsync(new NavigationPage(page)); + } } } diff --git a/src/App/Styles/Android.xaml b/src/App/Styles/Android.xaml index b5de864ac..07ebc86f9 100644 --- a/src/App/Styles/Android.xaml +++ b/src/App/Styles/Android.xaml @@ -36,9 +36,10 @@ - +