From 92e74274e0a2783496bcdc15f6c0ddedb13963e1 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 3 May 2016 02:08:50 -0400 Subject: [PATCH] wip --- src/Android/Android.csproj | 28 ++ src/Android/MainActivity.cs | 8 +- src/Android/Resources/Resource.Designer.cs | 471 ++++++++++++------ src/Android/packages.config | 4 + .../Abstractions/Services/IFolderService.cs | 5 +- src/App/Abstractions/Services/ISiteService.cs | 3 +- src/App/App.csproj | 20 + src/App/Models/Api/Request/FolderRequest.cs | 5 + src/App/Models/Api/Request/SiteRequest.cs | 10 + src/App/Models/Cipher.cs | 3 +- src/App/Models/Data/FolderData.cs | 15 +- src/App/Models/Data/SiteData.cs | 24 +- src/App/Models/Folder.cs | 8 +- src/App/Models/Site.cs | 14 +- src/App/Models/View/VaultView.cs | 4 +- src/App/Pages/VaultAddFolderPage.cs | 28 +- src/App/Pages/VaultAddSitePage.cs | 9 +- src/App/Pages/VaultListPage.cs | 2 +- src/App/Services/FolderService.cs | 41 +- src/App/Services/SiteService.cs | 45 +- src/App/packages.config | 3 + src/iOS/AppDelegate.cs | 6 +- src/iOS/iOS.csproj | 28 ++ src/iOS/packages.config | 4 + 24 files changed, 574 insertions(+), 214 deletions(-) diff --git a/src/Android/Android.csproj b/src/Android/Android.csproj index ac8bd692b..a589de58c 100644 --- a/src/Android/Android.csproj +++ b/src/Android/Android.csproj @@ -72,6 +72,22 @@ False + + ..\..\packages\Acr.Support.2.0.2\lib\MonoAndroid10\Acr.Support.Android.dll + True + + + ..\..\packages\Acr.UserDialogs.5.0.1\lib\MonoAndroid10\Acr.UserDialogs.dll + True + + + ..\..\packages\Acr.UserDialogs.5.0.1\lib\MonoAndroid10\Acr.UserDialogs.Interface.dll + True + + + ..\..\packages\Acr.UserDialogs.5.0.1\lib\MonoAndroid10\AndHUD.dll + True + ..\..\packages\Xamarin.Forms.2.2.0.31\lib\MonoAndroid10\FormsViewGroup.dll True @@ -94,6 +110,14 @@ ..\..\packages\modernhttpclient.2.4.2\lib\MonoAndroid\OkHttp.dll True + + ..\..\packages\Xam.Plugin.Connectivity.2.1.2\lib\MonoAndroid10\Plugin.Connectivity.dll + True + + + ..\..\packages\Xam.Plugin.Connectivity.2.1.2\lib\MonoAndroid10\Plugin.Connectivity.Abstractions.dll + True + ..\..\packages\Xam.Plugins.Settings.2.1.0\lib\MonoAndroid10\Plugin.Settings.dll True @@ -102,6 +126,10 @@ ..\..\packages\Xam.Plugins.Settings.2.1.0\lib\MonoAndroid10\Plugin.Settings.Abstractions.dll True + + ..\..\packages\Splat.1.6.2\lib\monoandroid\Splat.dll + True + ..\..\packages\sqlite-net-pcl.1.1.1\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SQLite-net.dll True diff --git a/src/Android/MainActivity.cs b/src/Android/MainActivity.cs index 312f8f3a1..2b3b55c85 100644 --- a/src/Android/MainActivity.cs +++ b/src/Android/MainActivity.cs @@ -13,6 +13,8 @@ using XLabs.Ioc.Unity; using XLabs.Ioc; using Bit.Android.Services; using Plugin.Settings; +using Plugin.Connectivity; +using Acr.UserDialogs; namespace Bit.Android { @@ -46,9 +48,13 @@ namespace Bit.Android .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) - .RegisterType(new ContainerControlledLifetimeManager()); + .RegisterType(new ContainerControlledLifetimeManager()) + .RegisterInstance(CrossConnectivity.Current, new ContainerControlledLifetimeManager()) + .RegisterInstance(UserDialogs.Instance, new ContainerControlledLifetimeManager()); Resolver.SetResolver(new UnityResolver(container)); + + UserDialogs.Init(this); } } } diff --git a/src/Android/Resources/Resource.Designer.cs b/src/Android/Resources/Resource.Designer.cs index a202801b9..269d5f82e 100644 --- a/src/Android/Resources/Resource.Designer.cs +++ b/src/Android/Resources/Resource.Designer.cs @@ -26,7 +26,45 @@ namespace Bit.Android public static void UpdateIdValues() { + global::AndroidHUD.Resource.Attribute.ahBarColor = global::Bit.Android.Resource.Attribute.ahBarColor; + global::AndroidHUD.Resource.Attribute.ahBarLength = global::Bit.Android.Resource.Attribute.ahBarLength; + global::AndroidHUD.Resource.Attribute.ahBarWidth = global::Bit.Android.Resource.Attribute.ahBarWidth; + global::AndroidHUD.Resource.Attribute.ahCircleColor = global::Bit.Android.Resource.Attribute.ahCircleColor; + global::AndroidHUD.Resource.Attribute.ahDelayMillis = global::Bit.Android.Resource.Attribute.ahDelayMillis; + global::AndroidHUD.Resource.Attribute.ahRadius = global::Bit.Android.Resource.Attribute.ahRadius; + global::AndroidHUD.Resource.Attribute.ahRimColor = global::Bit.Android.Resource.Attribute.ahRimColor; + global::AndroidHUD.Resource.Attribute.ahRimWidth = global::Bit.Android.Resource.Attribute.ahRimWidth; + global::AndroidHUD.Resource.Attribute.ahSpinSpeed = global::Bit.Android.Resource.Attribute.ahSpinSpeed; + global::AndroidHUD.Resource.Attribute.ahText = global::Bit.Android.Resource.Attribute.ahText; + global::AndroidHUD.Resource.Attribute.ahTextColor = global::Bit.Android.Resource.Attribute.ahTextColor; + global::AndroidHUD.Resource.Attribute.ahTextSize = global::Bit.Android.Resource.Attribute.ahTextSize; + global::AndroidHUD.Resource.Drawable.ic_errorstatus = global::Bit.Android.Resource.Drawable.ic_errorstatus; + global::AndroidHUD.Resource.Drawable.ic_successstatus = global::Bit.Android.Resource.Drawable.ic_successstatus; + global::AndroidHUD.Resource.Drawable.roundedbg = global::Bit.Android.Resource.Drawable.roundedbg; + global::AndroidHUD.Resource.Drawable.roundedbgdark = global::Bit.Android.Resource.Drawable.roundedbgdark; + global::AndroidHUD.Resource.Id.loadingImage = global::Bit.Android.Resource.Id.loadingImage; + global::AndroidHUD.Resource.Id.loadingProgressBar = global::Bit.Android.Resource.Id.loadingProgressBar; + global::AndroidHUD.Resource.Id.loadingProgressWheel = global::Bit.Android.Resource.Id.loadingProgressWheel; + global::AndroidHUD.Resource.Id.textViewStatus = global::Bit.Android.Resource.Id.textViewStatus; + global::AndroidHUD.Resource.Layout.loading = global::Bit.Android.Resource.Layout.loading; + global::AndroidHUD.Resource.Layout.loadingimage = global::Bit.Android.Resource.Layout.loadingimage; + global::AndroidHUD.Resource.Layout.loadingprogress = global::Bit.Android.Resource.Layout.loadingprogress; + global::AndroidHUD.Resource.String.library_name = global::Bit.Android.Resource.String.library_name; + global::AndroidHUD.Resource.Styleable.ProgressWheel = global::Bit.Android.Resource.Styleable.ProgressWheel; + global::AndroidHUD.Resource.Styleable.ProgressWheel_ahBarColor = global::Bit.Android.Resource.Styleable.ProgressWheel_ahBarColor; + global::AndroidHUD.Resource.Styleable.ProgressWheel_ahBarLength = global::Bit.Android.Resource.Styleable.ProgressWheel_ahBarLength; + global::AndroidHUD.Resource.Styleable.ProgressWheel_ahBarWidth = global::Bit.Android.Resource.Styleable.ProgressWheel_ahBarWidth; + global::AndroidHUD.Resource.Styleable.ProgressWheel_ahCircleColor = global::Bit.Android.Resource.Styleable.ProgressWheel_ahCircleColor; + global::AndroidHUD.Resource.Styleable.ProgressWheel_ahDelayMillis = global::Bit.Android.Resource.Styleable.ProgressWheel_ahDelayMillis; + global::AndroidHUD.Resource.Styleable.ProgressWheel_ahRadius = global::Bit.Android.Resource.Styleable.ProgressWheel_ahRadius; + global::AndroidHUD.Resource.Styleable.ProgressWheel_ahRimColor = global::Bit.Android.Resource.Styleable.ProgressWheel_ahRimColor; + global::AndroidHUD.Resource.Styleable.ProgressWheel_ahRimWidth = global::Bit.Android.Resource.Styleable.ProgressWheel_ahRimWidth; + global::AndroidHUD.Resource.Styleable.ProgressWheel_ahSpinSpeed = global::Bit.Android.Resource.Styleable.ProgressWheel_ahSpinSpeed; + global::AndroidHUD.Resource.Styleable.ProgressWheel_ahText = global::Bit.Android.Resource.Styleable.ProgressWheel_ahText; + global::AndroidHUD.Resource.Styleable.ProgressWheel_ahTextColor = global::Bit.Android.Resource.Styleable.ProgressWheel_ahTextColor; + global::AndroidHUD.Resource.Styleable.ProgressWheel_ahTextSize = global::Bit.Android.Resource.Styleable.ProgressWheel_ahTextSize; global::ModernHttpClient.Resource.String.library_name = global::Bit.Android.Resource.String.library_name; + global::Splat.Resource.String.library_name = global::Bit.Android.Resource.String.library_name; global::Xamarin.Forms.Platform.Android.Resource.Attribute.actionBarSize = global::Bit.Android.Resource.Attribute.actionBarSize; } @@ -199,6 +237,42 @@ namespace Bit.Android // aapt resource value: 0x7f010083 public const int activityChooserViewStyle = 2130772099; + // aapt resource value: 0x7f01013f + public const int ahBarColor = 2130772287; + + // aapt resource value: 0x7f010147 + public const int ahBarLength = 2130772295; + + // aapt resource value: 0x7f010146 + public const int ahBarWidth = 2130772294; + + // aapt resource value: 0x7f010144 + public const int ahCircleColor = 2130772292; + + // aapt resource value: 0x7f010143 + public const int ahDelayMillis = 2130772291; + + // aapt resource value: 0x7f010145 + public const int ahRadius = 2130772293; + + // aapt resource value: 0x7f010140 + public const int ahRimColor = 2130772288; + + // aapt resource value: 0x7f010141 + public const int ahRimWidth = 2130772289; + + // aapt resource value: 0x7f010142 + public const int ahSpinSpeed = 2130772290; + + // aapt resource value: 0x7f01013c + public const int ahText = 2130772284; + + // aapt resource value: 0x7f01013d + public const int ahTextColor = 2130772285; + + // aapt resource value: 0x7f01013e + public const int ahTextSize = 2130772286; + // aapt resource value: 0x7f0100a6 public const int alertDialogButtonGroupStyle = 2130772134; @@ -2049,160 +2123,172 @@ namespace Bit.Android public const int ic_collapse_00015 = 2130837613; // aapt resource value: 0x7f02006e - public const int ic_expand = 2130837614; + public const int ic_errorstatus = 2130837614; // aapt resource value: 0x7f02006f - public const int ic_expand_00000 = 2130837615; + public const int ic_expand = 2130837615; // aapt resource value: 0x7f020070 - public const int ic_expand_00001 = 2130837616; + public const int ic_expand_00000 = 2130837616; // aapt resource value: 0x7f020071 - public const int ic_expand_00002 = 2130837617; + public const int ic_expand_00001 = 2130837617; // aapt resource value: 0x7f020072 - public const int ic_expand_00003 = 2130837618; + public const int ic_expand_00002 = 2130837618; // aapt resource value: 0x7f020073 - public const int ic_expand_00004 = 2130837619; + public const int ic_expand_00003 = 2130837619; // aapt resource value: 0x7f020074 - public const int ic_expand_00005 = 2130837620; + public const int ic_expand_00004 = 2130837620; // aapt resource value: 0x7f020075 - public const int ic_expand_00006 = 2130837621; + public const int ic_expand_00005 = 2130837621; // aapt resource value: 0x7f020076 - public const int ic_expand_00007 = 2130837622; + public const int ic_expand_00006 = 2130837622; // aapt resource value: 0x7f020077 - public const int ic_expand_00008 = 2130837623; + public const int ic_expand_00007 = 2130837623; // aapt resource value: 0x7f020078 - public const int ic_expand_00009 = 2130837624; + public const int ic_expand_00008 = 2130837624; // aapt resource value: 0x7f020079 - public const int ic_expand_00010 = 2130837625; + public const int ic_expand_00009 = 2130837625; // aapt resource value: 0x7f02007a - public const int ic_expand_00011 = 2130837626; + public const int ic_expand_00010 = 2130837626; // aapt resource value: 0x7f02007b - public const int ic_expand_00012 = 2130837627; + public const int ic_expand_00011 = 2130837627; // aapt resource value: 0x7f02007c - public const int ic_expand_00013 = 2130837628; + public const int ic_expand_00012 = 2130837628; // aapt resource value: 0x7f02007d - public const int ic_expand_00014 = 2130837629; + public const int ic_expand_00013 = 2130837629; // aapt resource value: 0x7f02007e - public const int ic_expand_00015 = 2130837630; + public const int ic_expand_00014 = 2130837630; // aapt resource value: 0x7f02007f - public const int ic_media_pause = 2130837631; + public const int ic_expand_00015 = 2130837631; // aapt resource value: 0x7f020080 - public const int ic_media_play = 2130837632; + public const int ic_media_pause = 2130837632; // aapt resource value: 0x7f020081 - public const int ic_media_route_disabled_mono_dark = 2130837633; + public const int ic_media_play = 2130837633; // aapt resource value: 0x7f020082 - public const int ic_media_route_off_mono_dark = 2130837634; + public const int ic_media_route_disabled_mono_dark = 2130837634; // aapt resource value: 0x7f020083 - public const int ic_media_route_on_0_mono_dark = 2130837635; + public const int ic_media_route_off_mono_dark = 2130837635; // aapt resource value: 0x7f020084 - public const int ic_media_route_on_1_mono_dark = 2130837636; + public const int ic_media_route_on_0_mono_dark = 2130837636; // aapt resource value: 0x7f020085 - public const int ic_media_route_on_2_mono_dark = 2130837637; + public const int ic_media_route_on_1_mono_dark = 2130837637; // aapt resource value: 0x7f020086 - public const int ic_media_route_on_mono_dark = 2130837638; + public const int ic_media_route_on_2_mono_dark = 2130837638; // aapt resource value: 0x7f020087 - public const int ic_pause_dark = 2130837639; + public const int ic_media_route_on_mono_dark = 2130837639; // aapt resource value: 0x7f020088 - public const int ic_pause_light = 2130837640; + public const int ic_pause_dark = 2130837640; // aapt resource value: 0x7f020089 - public const int ic_play_dark = 2130837641; + public const int ic_pause_light = 2130837641; // aapt resource value: 0x7f02008a - public const int ic_play_light = 2130837642; + public const int ic_play_dark = 2130837642; // aapt resource value: 0x7f02008b - public const int ic_speaker_dark = 2130837643; + public const int ic_play_light = 2130837643; // aapt resource value: 0x7f02008c - public const int ic_speaker_group_dark = 2130837644; + public const int ic_speaker_dark = 2130837644; // aapt resource value: 0x7f02008d - public const int ic_speaker_group_light = 2130837645; + public const int ic_speaker_group_dark = 2130837645; // aapt resource value: 0x7f02008e - public const int ic_speaker_light = 2130837646; + public const int ic_speaker_group_light = 2130837646; // aapt resource value: 0x7f02008f - public const int ic_tv_dark = 2130837647; + public const int ic_speaker_light = 2130837647; // aapt resource value: 0x7f020090 - public const int ic_tv_light = 2130837648; + public const int ic_successstatus = 2130837648; // aapt resource value: 0x7f020091 - public const int icon = 2130837649; + public const int ic_tv_dark = 2130837649; // aapt resource value: 0x7f020092 - public const int mr_dialog_material_background_dark = 2130837650; + public const int ic_tv_light = 2130837650; // aapt resource value: 0x7f020093 - public const int mr_dialog_material_background_light = 2130837651; + public const int icon = 2130837651; // aapt resource value: 0x7f020094 - public const int mr_ic_audiotrack_light = 2130837652; + public const int mr_dialog_material_background_dark = 2130837652; // aapt resource value: 0x7f020095 - public const int mr_ic_cast_dark = 2130837653; + public const int mr_dialog_material_background_light = 2130837653; // aapt resource value: 0x7f020096 - public const int mr_ic_cast_light = 2130837654; + public const int mr_ic_audiotrack_light = 2130837654; // aapt resource value: 0x7f020097 - public const int mr_ic_close_dark = 2130837655; + public const int mr_ic_cast_dark = 2130837655; // aapt resource value: 0x7f020098 - public const int mr_ic_close_light = 2130837656; + public const int mr_ic_cast_light = 2130837656; // aapt resource value: 0x7f020099 - public const int mr_ic_media_route_connecting_mono_dark = 2130837657; + public const int mr_ic_close_dark = 2130837657; // aapt resource value: 0x7f02009a - public const int mr_ic_media_route_connecting_mono_light = 2130837658; + public const int mr_ic_close_light = 2130837658; // aapt resource value: 0x7f02009b - public const int mr_ic_media_route_mono_dark = 2130837659; + public const int mr_ic_media_route_connecting_mono_dark = 2130837659; // aapt resource value: 0x7f02009c - public const int mr_ic_media_route_mono_light = 2130837660; + public const int mr_ic_media_route_connecting_mono_light = 2130837660; // aapt resource value: 0x7f02009d - public const int mr_ic_pause_dark = 2130837661; + public const int mr_ic_media_route_mono_dark = 2130837661; // aapt resource value: 0x7f02009e - public const int mr_ic_pause_light = 2130837662; + public const int mr_ic_media_route_mono_light = 2130837662; // aapt resource value: 0x7f02009f - public const int mr_ic_play_dark = 2130837663; + public const int mr_ic_pause_dark = 2130837663; // aapt resource value: 0x7f0200a0 - public const int mr_ic_play_light = 2130837664; + public const int mr_ic_pause_light = 2130837664; // aapt resource value: 0x7f0200a1 - public const int notification_template_icon_bg = 2130837665; + public const int mr_ic_play_dark = 2130837665; + + // aapt resource value: 0x7f0200a2 + public const int mr_ic_play_light = 2130837666; + + // aapt resource value: 0x7f0200a5 + public const int notification_template_icon_bg = 2130837669; + + // aapt resource value: 0x7f0200a3 + public const int roundedbg = 2130837667; + + // aapt resource value: 0x7f0200a4 + public const int roundedbgdark = 2130837668; static Drawable() { @@ -2217,8 +2303,8 @@ namespace Bit.Android public partial class Id { - // aapt resource value: 0x7f07008b - public const int action0 = 2131165323; + // aapt resource value: 0x7f07008f + public const int action0 = 2131165327; // aapt resource value: 0x7f07005a public const int action_bar = 2131165274; @@ -2244,8 +2330,8 @@ namespace Bit.Android // aapt resource value: 0x7f07005b public const int action_context_bar = 2131165275; - // aapt resource value: 0x7f07008f - public const int action_divider = 2131165327; + // aapt resource value: 0x7f070093 + public const int action_divider = 2131165331; // aapt resource value: 0x7f070003 public const int action_menu_divider = 2131165187; @@ -2280,8 +2366,8 @@ namespace Bit.Android // aapt resource value: 0x7f070044 public const int buttonPanel = 2131165252; - // aapt resource value: 0x7f07008c - public const int cancel_action = 2131165324; + // aapt resource value: 0x7f070090 + public const int cancel_action = 2131165328; // aapt resource value: 0x7f07002b public const int center = 2131165227; @@ -2295,8 +2381,8 @@ namespace Bit.Android // aapt resource value: 0x7f070052 public const int checkbox = 2131165266; - // aapt resource value: 0x7f070092 - public const int chronometer = 2131165330; + // aapt resource value: 0x7f070096 + public const int chronometer = 2131165334; // aapt resource value: 0x7f070033 public const int clip_horizontal = 2131165235; @@ -2346,8 +2432,8 @@ namespace Bit.Android // aapt resource value: 0x7f07001c public const int end = 2131165212; - // aapt resource value: 0x7f070097 - public const int end_padder = 2131165335; + // aapt resource value: 0x7f07009b + public const int end_padder = 2131165339; // aapt resource value: 0x7f070023 public const int enterAlways = 2131165219; @@ -2391,8 +2477,8 @@ namespace Bit.Android // aapt resource value: 0x7f07003f public const int image = 2131165247; - // aapt resource value: 0x7f070096 - public const int info = 2131165334; + // aapt resource value: 0x7f07009a + public const int info = 2131165338; // aapt resource value: 0x7f070000 public const int item_touch_helper_previous_elevation = 2131165184; @@ -2400,11 +2486,11 @@ namespace Bit.Android // aapt resource value: 0x7f07002f public const int left = 2131165231; - // aapt resource value: 0x7f070090 - public const int line1 = 2131165328; - // aapt resource value: 0x7f070094 - public const int line3 = 2131165332; + public const int line1 = 2131165332; + + // aapt resource value: 0x7f070098 + public const int line3 = 2131165336; // aapt resource value: 0x7f07000b public const int listMode = 2131165195; @@ -2412,8 +2498,17 @@ namespace Bit.Android // aapt resource value: 0x7f070041 public const int list_item = 2131165249; - // aapt resource value: 0x7f07008e - public const int media_actions = 2131165326; + // aapt resource value: 0x7f070074 + public const int loadingImage = 2131165300; + + // aapt resource value: 0x7f070072 + public const int loadingProgressBar = 2131165298; + + // aapt resource value: 0x7f070075 + public const int loadingProgressWheel = 2131165301; + + // aapt resource value: 0x7f070092 + public const int media_actions = 2131165330; // aapt resource value: 0x7f07001d public const int middle = 2131165213; @@ -2421,77 +2516,77 @@ namespace Bit.Android // aapt resource value: 0x7f070037 public const int mini = 2131165239; - // aapt resource value: 0x7f07007d - public const int mr_art = 2131165309; - - // aapt resource value: 0x7f070072 - public const int mr_chooser_list = 2131165298; - - // aapt resource value: 0x7f070075 - public const int mr_chooser_route_desc = 2131165301; - - // aapt resource value: 0x7f070073 - public const int mr_chooser_route_icon = 2131165299; - - // aapt resource value: 0x7f070074 - public const int mr_chooser_route_name = 2131165300; - - // aapt resource value: 0x7f07007a - public const int mr_close = 2131165306; - - // aapt resource value: 0x7f070080 - public const int mr_control_divider = 2131165312; - - // aapt resource value: 0x7f070086 - public const int mr_control_play_pause = 2131165318; - - // aapt resource value: 0x7f070089 - public const int mr_control_subtitle = 2131165321; - - // aapt resource value: 0x7f070088 - public const int mr_control_title = 2131165320; - - // aapt resource value: 0x7f070087 - public const int mr_control_title_container = 2131165319; - - // aapt resource value: 0x7f07007b - public const int mr_custom_control = 2131165307; - - // aapt resource value: 0x7f07007c - public const int mr_default_control = 2131165308; - - // aapt resource value: 0x7f070077 - public const int mr_dialog_area = 2131165303; + // aapt resource value: 0x7f070081 + public const int mr_art = 2131165313; // aapt resource value: 0x7f070076 - public const int mr_expandable_area = 2131165302; - - // aapt resource value: 0x7f07008a - public const int mr_group_expand_collapse = 2131165322; - - // aapt resource value: 0x7f07007e - public const int mr_media_main_control = 2131165310; + public const int mr_chooser_list = 2131165302; // aapt resource value: 0x7f070079 - public const int mr_name = 2131165305; + public const int mr_chooser_route_desc = 2131165305; - // aapt resource value: 0x7f07007f - public const int mr_playback_control = 2131165311; + // aapt resource value: 0x7f070077 + public const int mr_chooser_route_icon = 2131165303; // aapt resource value: 0x7f070078 - public const int mr_title_bar = 2131165304; + public const int mr_chooser_route_name = 2131165304; - // aapt resource value: 0x7f070081 - public const int mr_volume_control = 2131165313; - - // aapt resource value: 0x7f070082 - public const int mr_volume_group_list = 2131165314; + // aapt resource value: 0x7f07007e + public const int mr_close = 2131165310; // aapt resource value: 0x7f070084 - public const int mr_volume_item_icon = 2131165316; + public const int mr_control_divider = 2131165316; + + // aapt resource value: 0x7f07008a + public const int mr_control_play_pause = 2131165322; + + // aapt resource value: 0x7f07008d + public const int mr_control_subtitle = 2131165325; + + // aapt resource value: 0x7f07008c + public const int mr_control_title = 2131165324; + + // aapt resource value: 0x7f07008b + public const int mr_control_title_container = 2131165323; + + // aapt resource value: 0x7f07007f + public const int mr_custom_control = 2131165311; + + // aapt resource value: 0x7f070080 + public const int mr_default_control = 2131165312; + + // aapt resource value: 0x7f07007b + public const int mr_dialog_area = 2131165307; + + // aapt resource value: 0x7f07007a + public const int mr_expandable_area = 2131165306; + + // aapt resource value: 0x7f07008e + public const int mr_group_expand_collapse = 2131165326; + + // aapt resource value: 0x7f070082 + public const int mr_media_main_control = 2131165314; + + // aapt resource value: 0x7f07007d + public const int mr_name = 2131165309; + + // aapt resource value: 0x7f070083 + public const int mr_playback_control = 2131165315; + + // aapt resource value: 0x7f07007c + public const int mr_title_bar = 2131165308; // aapt resource value: 0x7f070085 - public const int mr_volume_slider = 2131165317; + public const int mr_volume_control = 2131165317; + + // aapt resource value: 0x7f070086 + public const int mr_volume_group_list = 2131165318; + + // aapt resource value: 0x7f070088 + public const int mr_volume_item_icon = 2131165320; + + // aapt resource value: 0x7f070089 + public const int mr_volume_slider = 2131165321; // aapt resource value: 0x7f070016 public const int multiply = 2131165206; @@ -2619,8 +2714,8 @@ namespace Bit.Android // aapt resource value: 0x7f070031 public const int start = 2131165233; - // aapt resource value: 0x7f07008d - public const int status_bar_latest_event_content = 2131165325; + // aapt resource value: 0x7f070091 + public const int status_bar_latest_event_content = 2131165329; // aapt resource value: 0x7f070065 public const int submit_area = 2131165285; @@ -2628,17 +2723,20 @@ namespace Bit.Android // aapt resource value: 0x7f07000d public const int tabMode = 2131165197; - // aapt resource value: 0x7f070095 - public const int text = 2131165333; + // aapt resource value: 0x7f070099 + public const int text = 2131165337; - // aapt resource value: 0x7f070093 - public const int text2 = 2131165331; + // aapt resource value: 0x7f070097 + public const int text2 = 2131165335; // aapt resource value: 0x7f07004d public const int textSpacerNoButtons = 2131165261; - // aapt resource value: 0x7f070091 - public const int time = 2131165329; + // aapt resource value: 0x7f070073 + public const int textViewStatus = 2131165299; + + // aapt resource value: 0x7f070095 + public const int time = 2131165333; // aapt resource value: 0x7f070043 public const int title = 2131165251; @@ -2664,8 +2762,8 @@ namespace Bit.Android // aapt resource value: 0x7f07000a public const int view_offset_helper = 2131165194; - // aapt resource value: 0x7f070083 - public const int volume_item_container = 2131165315; + // aapt resource value: 0x7f070087 + public const int volume_item_container = 2131165319; // aapt resource value: 0x7f070022 public const int withText = 2131165218; @@ -2860,58 +2958,67 @@ namespace Bit.Android public const int design_navigation_menu_item = 2130903076; // aapt resource value: 0x7f030025 - public const int mr_chooser_dialog = 2130903077; + public const int loading = 2130903077; // aapt resource value: 0x7f030026 - public const int mr_chooser_list_item = 2130903078; + public const int loadingimage = 2130903078; // aapt resource value: 0x7f030027 - public const int mr_controller_material_dialog_b = 2130903079; + public const int loadingprogress = 2130903079; // aapt resource value: 0x7f030028 - public const int mr_controller_volume_item = 2130903080; + public const int mr_chooser_dialog = 2130903080; // aapt resource value: 0x7f030029 - public const int mr_playback_control = 2130903081; + public const int mr_chooser_list_item = 2130903081; // aapt resource value: 0x7f03002a - public const int mr_volume_control = 2130903082; + public const int mr_controller_material_dialog_b = 2130903082; // aapt resource value: 0x7f03002b - public const int notification_media_action = 2130903083; + public const int mr_controller_volume_item = 2130903083; // aapt resource value: 0x7f03002c - public const int notification_media_cancel_action = 2130903084; + public const int mr_playback_control = 2130903084; // aapt resource value: 0x7f03002d - public const int notification_template_big_media = 2130903085; + public const int mr_volume_control = 2130903085; // aapt resource value: 0x7f03002e - public const int notification_template_big_media_narrow = 2130903086; + public const int notification_media_action = 2130903086; // aapt resource value: 0x7f03002f - public const int notification_template_lines = 2130903087; + public const int notification_media_cancel_action = 2130903087; // aapt resource value: 0x7f030030 - public const int notification_template_media = 2130903088; + public const int notification_template_big_media = 2130903088; // aapt resource value: 0x7f030031 - public const int notification_template_part_chronometer = 2130903089; + public const int notification_template_big_media_narrow = 2130903089; // aapt resource value: 0x7f030032 - public const int notification_template_part_time = 2130903090; + public const int notification_template_lines = 2130903090; // aapt resource value: 0x7f030033 - public const int select_dialog_item_material = 2130903091; + public const int notification_template_media = 2130903091; // aapt resource value: 0x7f030034 - public const int select_dialog_multichoice_material = 2130903092; + public const int notification_template_part_chronometer = 2130903092; // aapt resource value: 0x7f030035 - public const int select_dialog_singlechoice_material = 2130903093; + public const int notification_template_part_time = 2130903093; // aapt resource value: 0x7f030036 - public const int support_simple_spinner_dropdown_item = 2130903094; + public const int select_dialog_item_material = 2130903094; + + // aapt resource value: 0x7f030037 + public const int select_dialog_multichoice_material = 2130903095; + + // aapt resource value: 0x7f030038 + public const int select_dialog_singlechoice_material = 2130903096; + + // aapt resource value: 0x7f030039 + public const int support_simple_spinner_dropdown_item = 2130903097; static Layout() { @@ -5407,6 +5514,56 @@ namespace Bit.Android // aapt resource value: 0 public const int PopupWindowBackgroundState_state_above_anchor = 0; + public static int[] ProgressWheel = new int[] { + 2130772284, + 2130772285, + 2130772286, + 2130772287, + 2130772288, + 2130772289, + 2130772290, + 2130772291, + 2130772292, + 2130772293, + 2130772294, + 2130772295}; + + // aapt resource value: 3 + public const int ProgressWheel_ahBarColor = 3; + + // aapt resource value: 11 + public const int ProgressWheel_ahBarLength = 11; + + // aapt resource value: 10 + public const int ProgressWheel_ahBarWidth = 10; + + // aapt resource value: 8 + public const int ProgressWheel_ahCircleColor = 8; + + // aapt resource value: 7 + public const int ProgressWheel_ahDelayMillis = 7; + + // aapt resource value: 9 + public const int ProgressWheel_ahRadius = 9; + + // aapt resource value: 4 + public const int ProgressWheel_ahRimColor = 4; + + // aapt resource value: 5 + public const int ProgressWheel_ahRimWidth = 5; + + // aapt resource value: 6 + public const int ProgressWheel_ahSpinSpeed = 6; + + // aapt resource value: 0 + public const int ProgressWheel_ahText = 0; + + // aapt resource value: 1 + public const int ProgressWheel_ahTextColor = 1; + + // aapt resource value: 2 + public const int ProgressWheel_ahTextSize = 2; + public static int[] RecyclerView = new int[] { 16842948, 2130771968, diff --git a/src/Android/packages.config b/src/Android/packages.config index 0e7c53e42..6b0f2a16d 100644 --- a/src/Android/packages.config +++ b/src/Android/packages.config @@ -1,10 +1,14 @@  + + + + diff --git a/src/App/Abstractions/Services/IFolderService.cs b/src/App/Abstractions/Services/IFolderService.cs index 9fcde5512..35496e3d5 100644 --- a/src/App/Abstractions/Services/IFolderService.cs +++ b/src/App/Abstractions/Services/IFolderService.cs @@ -1,13 +1,14 @@ using System.Collections.Generic; using System.Threading.Tasks; using Bit.App.Models; +using Bit.App.Models.Api; namespace Bit.App.Abstractions { public interface IFolderService { - Task GetByIdAsync(int id); + Task GetByIdAsync(string id); Task> GetAllAsync(); - Task SaveAsync(Folder folder); + Task> SaveAsync(Folder folder); } } diff --git a/src/App/Abstractions/Services/ISiteService.cs b/src/App/Abstractions/Services/ISiteService.cs index 0ba7d815f..8f377ed48 100644 --- a/src/App/Abstractions/Services/ISiteService.cs +++ b/src/App/Abstractions/Services/ISiteService.cs @@ -1,12 +1,13 @@ using System.Collections.Generic; using System.Threading.Tasks; using Bit.App.Models; +using Bit.App.Models.Api; namespace Bit.App.Abstractions { public interface ISiteService { Task> GetAllAsync(); - Task SaveAsync(Site site); + Task> SaveAsync(Site site); } } diff --git a/src/App/App.csproj b/src/App/App.csproj index 94de56846..ee588f2e8 100644 --- a/src/App/App.csproj +++ b/src/App/App.csproj @@ -89,6 +89,14 @@ + + ..\..\packages\Acr.UserDialogs.5.0.1\lib\portable-win+net45+wp8+win8+wpa81\Acr.UserDialogs.dll + True + + + ..\..\packages\Acr.UserDialogs.5.0.1\lib\portable-win+net45+wp8+win8+wpa81\Acr.UserDialogs.Interface.dll + True + ..\..\packages\Portable.BouncyCastle.1.8.1\lib\portable-net45+win8+wpa81+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10\crypto.dll True @@ -109,6 +117,14 @@ ..\..\packages\Newtonsoft.Json.8.0.3\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll True + + ..\..\packages\Xam.Plugin.Connectivity.2.1.2\lib\portable-net45+wp80+wp81+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+Xamarin.Mac20+UAP10\Plugin.Connectivity.dll + True + + + ..\..\packages\Xam.Plugin.Connectivity.2.1.2\lib\portable-net45+wp80+wp81+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+Xamarin.Mac20+UAP10\Plugin.Connectivity.Abstractions.dll + True + ..\..\packages\Xam.Plugins.Settings.2.1.0\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\Plugin.Settings.dll True @@ -117,6 +133,10 @@ ..\..\packages\Xam.Plugins.Settings.2.1.0\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\Plugin.Settings.Abstractions.dll True + + ..\..\packages\Splat.1.6.2\lib\Portable-net45+win+wpa81+wp80\Splat.dll + True + ..\..\packages\sqlite-net-pcl.1.1.1\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SQLite-net.dll True diff --git a/src/App/Models/Api/Request/FolderRequest.cs b/src/App/Models/Api/Request/FolderRequest.cs index 81cf0c73e..9d90e9ef6 100644 --- a/src/App/Models/Api/Request/FolderRequest.cs +++ b/src/App/Models/Api/Request/FolderRequest.cs @@ -2,6 +2,11 @@ { public class FolderRequest { + public FolderRequest(Folder folder) + { + Name = folder.Name?.EncryptedString; + } + public string Name { get; set; } } } diff --git a/src/App/Models/Api/Request/SiteRequest.cs b/src/App/Models/Api/Request/SiteRequest.cs index 436da25ce..7db37575d 100644 --- a/src/App/Models/Api/Request/SiteRequest.cs +++ b/src/App/Models/Api/Request/SiteRequest.cs @@ -2,6 +2,16 @@ { public class SiteRequest { + public SiteRequest(Site site) + { + FolderId = site.FolderId; + Name = site.Name?.EncryptedString; + Uri = site.Uri?.EncryptedString; + Username = site.Username?.EncryptedString; + Password = site.Password?.EncryptedString; + Notes = site.Notes?.EncryptedString; + } + public string FolderId { get; set; } public string Name { get; set; } public string Uri { get; set; } diff --git a/src/App/Models/Cipher.cs b/src/App/Models/Cipher.cs index 14c12420c..1d276ed6d 100644 --- a/src/App/Models/Cipher.cs +++ b/src/App/Models/Cipher.cs @@ -4,8 +4,7 @@ namespace Bit.App.Models { public abstract class Cipher { - public int Id { get; set; } - public string ServerId { get; set; } + public string Id { get; set; } public CipherString Name { get; set; } } } diff --git a/src/App/Models/Data/FolderData.cs b/src/App/Models/Data/FolderData.cs index e75cc8bed..91e22f635 100644 --- a/src/App/Models/Data/FolderData.cs +++ b/src/App/Models/Data/FolderData.cs @@ -1,11 +1,12 @@ using System; using SQLite; using Bit.App.Abstractions; +using Bit.App.Models.Api; namespace Bit.App.Models.Data { [Table("Folder")] - public class FolderData : IDataObject + public class FolderData : IDataObject { public FolderData() { } @@ -13,15 +14,19 @@ namespace Bit.App.Models.Data public FolderData(Folder folder, string userId) { Id = folder.Id; - ServerId = folder.ServerId; UserId = userId; Name = folder.Name?.EncryptedString; } + public FolderData(FolderResponse folder, string userId) + { + Id = folder.Id; + UserId = userId; + Name = folder.Name; + } + [PrimaryKey] - [AutoIncrement] - public int Id { get; set; } - public string ServerId { get; set; } + public string Id { get; set; } public string UserId { get; set; } public string Name { get; set; } public DateTime RevisionDateTime { get; set; } = DateTime.UtcNow; diff --git a/src/App/Models/Data/SiteData.cs b/src/App/Models/Data/SiteData.cs index e2eba614e..28d978943 100644 --- a/src/App/Models/Data/SiteData.cs +++ b/src/App/Models/Data/SiteData.cs @@ -1,11 +1,12 @@ using System; using SQLite; using Bit.App.Abstractions; +using Bit.App.Models.Api; namespace Bit.App.Models.Data { [Table("Site")] - public class SiteData : IDataObject + public class SiteData : IDataObject { public SiteData() { } @@ -13,9 +14,7 @@ namespace Bit.App.Models.Data public SiteData(Site site, string userId) { Id = site.Id; - ServerId = site.ServerId; FolderId = site.FolderId; - ServerFolderId = site.ServerFolderId; UserId = userId; Name = site.Name?.EncryptedString; Uri = site.Uri?.EncryptedString; @@ -24,12 +23,21 @@ namespace Bit.App.Models.Data Notes = site.Notes?.EncryptedString; } + public SiteData(SiteResponse site, string userId) + { + Id = site.Id; + FolderId = site.FolderId; + UserId = userId; + Name = site.Name; + Uri = site.Uri; + Username = site.Username; + Password = site.Password; + Notes = site.Notes; + } + [PrimaryKey] - [AutoIncrement] - public int Id { get; set; } - public string ServerId { get; set; } - public int? FolderId { get; set; } - public string ServerFolderId { get; set; } + public string Id { get; set; } + public string FolderId { get; set; } public string UserId { get; set; } public string Name { get; set; } public string Uri { get; set; } diff --git a/src/App/Models/Folder.cs b/src/App/Models/Folder.cs index c8d5915aa..c37d5258c 100644 --- a/src/App/Models/Folder.cs +++ b/src/App/Models/Folder.cs @@ -11,16 +11,20 @@ namespace Bit.App.Models public Folder(FolderData data) { Id = data.Id; - ServerId = data.ServerId; Name = data.Name != null ? new CipherString(data.Name) : null; } public Folder(FolderResponse response) { - ServerId = response.Id; + Id = response.Id; Name = response.Name != null ? new CipherString(response.Name) : null; } + public FolderRequest ToFolderRequest() + { + return new FolderRequest(this); + } + public FolderData ToFolderData(string userId) { return new FolderData(this, userId); diff --git a/src/App/Models/Site.cs b/src/App/Models/Site.cs index 454ce0a78..3b5b77904 100644 --- a/src/App/Models/Site.cs +++ b/src/App/Models/Site.cs @@ -11,9 +11,7 @@ namespace Bit.App.Models public Site(SiteData data) { Id = data.Id; - ServerId = data.ServerId; FolderId = data.FolderId; - ServerFolderId = data.ServerFolderId; Name = data.Name != null ? new CipherString(data.Name) : null; Uri = data.Uri != null ? new CipherString(data.Uri) : null; Username = data.Username != null ? new CipherString(data.Username) : null; @@ -23,8 +21,8 @@ namespace Bit.App.Models public Site(SiteResponse response) { - ServerId = response.Id; - ServerFolderId = response.FolderId; + Id = response.Id; + FolderId = response.FolderId; Name = response.Name != null ? new CipherString(response.Name) : null; Uri = response.Uri != null ? new CipherString(response.Uri) : null; Username = response.Username != null ? new CipherString(response.Username) : null; @@ -32,13 +30,17 @@ namespace Bit.App.Models Notes = response.Notes != null ? new CipherString(response.Notes) : null; } - public int? FolderId { get; set; } - public string ServerFolderId { get; set; } + public string FolderId { get; set; } public CipherString Uri { get; set; } public CipherString Username { get; set; } public CipherString Password { get; set; } public CipherString Notes { get; set; } + public SiteRequest ToSiteRequest() + { + return new SiteRequest(this); + } + public SiteData ToSiteData(string userId) { return new SiteData(this, userId); diff --git a/src/App/Models/View/VaultView.cs b/src/App/Models/View/VaultView.cs index c464a80fa..960e53836 100644 --- a/src/App/Models/View/VaultView.cs +++ b/src/App/Models/View/VaultView.cs @@ -15,7 +15,7 @@ namespace Bit.App.Models.View Username = site.Username?.Decrypt(); } - public int Id { get; set; } + public string Id { get; set; } public string Name { get; set; } public string Username { get; set; } } @@ -40,7 +40,7 @@ namespace Bit.App.Models.View Name = folder.Name?.Decrypt(); } - public int? Id { get; set; } + public string Id { get; set; } public string Name { get; set; } public string FirstLetter { get { return Name.Substring(0, 1); } } } diff --git a/src/App/Pages/VaultAddFolderPage.cs b/src/App/Pages/VaultAddFolderPage.cs index fbc35ce55..8855de577 100644 --- a/src/App/Pages/VaultAddFolderPage.cs +++ b/src/App/Pages/VaultAddFolderPage.cs @@ -3,8 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Reflection.Emit; using System.Text; +using System.Threading.Tasks; +using Acr.UserDialogs; using Bit.App.Abstractions; using Bit.App.Models; +using Plugin.Connectivity.Abstractions; using Xamarin.Forms; using XLabs.Ioc; @@ -16,6 +19,8 @@ namespace Bit.App.Pages { var cryptoService = Resolver.Resolve(); var folderService = Resolver.Resolve(); + var userDialogs = Resolver.Resolve(); + var connectivity = Resolver.Resolve(); var nameEntry = new Entry(); @@ -31,6 +36,12 @@ namespace Bit.App.Pages var saveToolBarItem = new ToolbarItem("Save", null, async () => { + if(!connectivity.IsConnected) + { + AlertNoConnection(); + return; + } + if(string.IsNullOrWhiteSpace(nameEntry.Text)) { await DisplayAlert("An error has occurred", "The Name field is required.", "Ok"); @@ -42,13 +53,28 @@ namespace Bit.App.Pages Name = nameEntry.Text.Encrypt() }; - await folderService.SaveAsync(folder); + var saveTask = folderService.SaveAsync(folder); + userDialogs.ShowLoading("Saving...", MaskType.Black); + await saveTask; + + userDialogs.HideLoading(); await Navigation.PopAsync(); + userDialogs.SuccessToast(nameEntry.Text, "New folder created."); }, ToolbarItemOrder.Default, 0); Title = "Add Folder"; Content = scrollView; ToolbarItems.Add(saveToolBarItem); + + if(!connectivity.IsConnected) + { + AlertNoConnection(); + } + } + + public void AlertNoConnection() + { + DisplayAlert("No internet connection", "Adding a new folder required an internet connection. Please connect to the internet before continuing.", "Ok"); } } } diff --git a/src/App/Pages/VaultAddSitePage.cs b/src/App/Pages/VaultAddSitePage.cs index 8ed8dd3ab..156907659 100644 --- a/src/App/Pages/VaultAddSitePage.cs +++ b/src/App/Pages/VaultAddSitePage.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection.Emit; using System.Text; +using Acr.UserDialogs; using Bit.App.Abstractions; using Bit.App.Models; using Xamarin.Forms; @@ -17,6 +18,7 @@ namespace Bit.App.Pages var cryptoService = Resolver.Resolve(); var siteService = Resolver.Resolve(); var folderService = Resolver.Resolve(); + var userDialogs = Resolver.Resolve(); var folders = folderService.GetAllAsync().GetAwaiter().GetResult().OrderBy(f => f.Name); @@ -81,8 +83,13 @@ namespace Bit.App.Pages site.FolderId = folders.ElementAt(folderPicker.SelectedIndex - 1).Id; } - await siteService.SaveAsync(site); + var saveTask = siteService.SaveAsync(site); + userDialogs.ShowLoading("Saving...", MaskType.Black); + await saveTask; + + userDialogs.HideLoading(); await Navigation.PopAsync(); + userDialogs.SuccessToast(nameEntry.Text, "New site created."); }, ToolbarItemOrder.Default, 0); Title = "Add Site"; diff --git a/src/App/Pages/VaultListPage.cs b/src/App/Pages/VaultListPage.cs index 558e392f8..d4773f283 100644 --- a/src/App/Pages/VaultListPage.cs +++ b/src/App/Pages/VaultListPage.cs @@ -62,7 +62,7 @@ namespace Bit.App.Pages var folderItems = folders.Select(f => new VaultView.Folder(f, sites.Where(s => s.FolderId == f.Id))).ToList(); // add the sites with no folder - folderItems.Add(new VaultView.Folder(sites.Where(s => !s.FolderId.HasValue))); + folderItems.Add(new VaultView.Folder(sites.Where(s => s.FolderId != null))); _listView.ItemsSource = folderItems; } diff --git a/src/App/Services/FolderService.cs b/src/App/Services/FolderService.cs index b51f0717f..ebee5c280 100644 --- a/src/App/Services/FolderService.cs +++ b/src/App/Services/FolderService.cs @@ -5,22 +5,29 @@ using System.Threading.Tasks; using Bit.App.Abstractions; using Bit.App.Models; using Bit.App.Models.Data; +using Bit.App.Models.Api; +using Newtonsoft.Json; +using System.Net.Http; +using System.Text; namespace Bit.App.Services { - public class FolderService : Repository, IFolderService + public class FolderService : Repository, IFolderService { private readonly IAuthService _authService; + private readonly IApiService _apiService; public FolderService( ISqlService sqlService, - IAuthService authService) + IAuthService authService, + IApiService apiService) : base(sqlService) { _authService = authService; + _apiService = apiService; } - public new Task GetByIdAsync(int id) + public new Task GetByIdAsync(string id) { var data = Connection.Table().Where(f => f.UserId == _authService.UserId && f.Id == id).FirstOrDefault(); return Task.FromResult(new Folder(data)); @@ -32,21 +39,39 @@ namespace Bit.App.Services return Task.FromResult(data.Select(f => new Folder(f))); } - public async Task SaveAsync(Folder folder) + public async Task> SaveAsync(Folder folder) { - var data = new FolderData(folder, _authService.UserId); - data.RevisionDateTime = DateTime.UtcNow; + var request = new FolderRequest(folder); + var requestContent = JsonConvert.SerializeObject(request); + var requestMessage = new HttpRequestMessage + { + Method = folder.Id == null ? HttpMethod.Post : HttpMethod.Put, + RequestUri = new Uri(_apiService.Client.BaseAddress, folder.Id == null ? "/folders" : string.Concat("/folders/", folder.Id)), + Content = new StringContent(requestContent, Encoding.UTF8, "application/json") + }; + requestMessage.Headers.Add("Authorization", string.Concat("Bearer ", _authService.Token)); - if(folder.Id == 0) + var response = await _apiService.Client.SendAsync(requestMessage); + if(!response.IsSuccessStatusCode) + { + return await _apiService.HandleErrorAsync(response); + } + + var responseContent = await response.Content.ReadAsStringAsync(); + var responseObj = JsonConvert.DeserializeObject(responseContent); + var data = new FolderData(responseObj, _authService.UserId); + + if(folder.Id == null) { await CreateAsync(data); + folder.Id = responseObj.Id; } else { await ReplaceAsync(data); } - folder.Id = data.Id; + return ApiResult.Success(responseObj, response.StatusCode); } } } diff --git a/src/App/Services/SiteService.cs b/src/App/Services/SiteService.cs index 9c2535b9c..3bc7f6d90 100644 --- a/src/App/Services/SiteService.cs +++ b/src/App/Services/SiteService.cs @@ -1,26 +1,30 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; +using System.Text; using System.Threading.Tasks; using Bit.App.Abstractions; using Bit.App.Models; +using Bit.App.Models.Api; using Bit.App.Models.Data; +using Newtonsoft.Json; namespace Bit.App.Services { - public class SiteService : Repository, ISiteService + public class SiteService : Repository, ISiteService { private readonly IAuthService _authService; - private readonly IFolderService _folderService; + private readonly IApiService _apiService; public SiteService( ISqlService sqlService, IAuthService authService, - IFolderService folderService) + IApiService apiService) : base(sqlService) { _authService = authService; - _folderService = folderService; + _apiService = apiService; } public new Task> GetAllAsync() @@ -29,30 +33,39 @@ namespace Bit.App.Services return Task.FromResult(data.Select(s => new Site(s))); } - public async Task SaveAsync(Site site) + public async Task> SaveAsync(Site site) { - var data = new SiteData(site, _authService.UserId); - data.RevisionDateTime = DateTime.UtcNow; - - if(site.FolderId.HasValue && site.ServerFolderId == null) + var request = new SiteRequest(site); + var requestContent = JsonConvert.SerializeObject(request); + var requestMessage = new HttpRequestMessage { - var folder = await _folderService.GetByIdAsync(site.FolderId.Value); - if(folder != null) - { - site.ServerFolderId = folder.ServerId; - } + Method = site.Id == null ? HttpMethod.Post : HttpMethod.Put, + RequestUri = new Uri(_apiService.Client.BaseAddress, site.Id == null ? "/sites" : string.Concat("/folders/", site.Id)), + Content = new StringContent(requestContent, Encoding.UTF8, "application/json") + }; + requestMessage.Headers.Add("Authorization", string.Concat("Bearer ", _authService.Token)); + + var response = await _apiService.Client.SendAsync(requestMessage); + if(!response.IsSuccessStatusCode) + { + return await _apiService.HandleErrorAsync(response); } - if(site.Id == 0) + var responseContent = await response.Content.ReadAsStringAsync(); + var responseObj = JsonConvert.DeserializeObject(responseContent); + var data = new SiteData(responseObj, _authService.UserId); + + if(site.Id == null) { await CreateAsync(data); + site.Id = responseObj.Id; } else { await ReplaceAsync(data); } - site.Id = data.Id; + return ApiResult.Success(responseObj, response.StatusCode); } } } diff --git a/src/App/packages.config b/src/App/packages.config index 83b572c13..df0760244 100644 --- a/src/App/packages.config +++ b/src/App/packages.config @@ -1,12 +1,15 @@  + + + diff --git a/src/iOS/AppDelegate.cs b/src/iOS/AppDelegate.cs index 1e4ad1afb..c09c7e4ba 100644 --- a/src/iOS/AppDelegate.cs +++ b/src/iOS/AppDelegate.cs @@ -11,6 +11,8 @@ using Bit.App.Services; using Microsoft.Practices.Unity; using Bit.iOS.Services; using Plugin.Settings; +using Plugin.Connectivity; +using Acr.UserDialogs; namespace Bit.iOS { @@ -54,7 +56,9 @@ namespace Bit.iOS .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) - .RegisterType(new ContainerControlledLifetimeManager()); + .RegisterType(new ContainerControlledLifetimeManager()) + .RegisterInstance(CrossConnectivity.Current, new ContainerControlledLifetimeManager()) + .RegisterInstance(UserDialogs.Instance, new ContainerControlledLifetimeManager()); Resolver.SetResolver(new UnityResolver(container)); } diff --git a/src/iOS/iOS.csproj b/src/iOS/iOS.csproj index 795630a06..ff83fd540 100644 --- a/src/iOS/iOS.csproj +++ b/src/iOS/iOS.csproj @@ -118,6 +118,22 @@ + + ..\..\packages\Acr.Support.2.0.2\lib\Xamarin.iOS10\Acr.Support.iOS.dll + True + + + ..\..\packages\Acr.UserDialogs.5.0.1\lib\Xamarin.iOS10\Acr.UserDialogs.dll + True + + + ..\..\packages\Acr.UserDialogs.5.0.1\lib\Xamarin.iOS10\Acr.UserDialogs.Interface.dll + True + + + ..\..\packages\Acr.UserDialogs.5.0.1\lib\Xamarin.iOS10\BTProgressHUD.dll + True + ..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll True @@ -130,6 +146,14 @@ ..\..\packages\modernhttpclient.2.4.2\lib\Xamarin.iOS10\ModernHttpClient.dll True + + ..\..\packages\Xam.Plugin.Connectivity.2.1.2\lib\Xamarin.iOS10\Plugin.Connectivity.dll + True + + + ..\..\packages\Xam.Plugin.Connectivity.2.1.2\lib\Xamarin.iOS10\Plugin.Connectivity.Abstractions.dll + True + ..\..\packages\Xam.Plugins.Settings.2.1.0\lib\Xamarin.iOS10\Plugin.Settings.dll True @@ -138,6 +162,10 @@ ..\..\packages\Xam.Plugins.Settings.2.1.0\lib\Xamarin.iOS10\Plugin.Settings.Abstractions.dll True + + ..\..\packages\Splat.1.6.2\lib\Xamarin.iOS10\Splat.dll + True + ..\..\packages\sqlite-net-pcl.1.1.1\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SQLite-net.dll True diff --git a/src/iOS/packages.config b/src/iOS/packages.config index 26bb17603..ff17114d1 100644 --- a/src/iOS/packages.config +++ b/src/iOS/packages.config @@ -1,10 +1,14 @@  + + + +