remove arc dialogs. create custom loading actions

This commit is contained in:
Kyle Spearrin 2017-12-22 23:56:45 -05:00
parent 0270cf6e45
commit 4dc388015c
27 changed files with 528 additions and 642 deletions

View file

@ -1,5 +1,4 @@
using System; using System;
using Acr.UserDialogs;
using Android.App; using Android.App;
using Android.Content; using Android.Content;
using Android.OS; using Android.OS;
@ -102,7 +101,6 @@ namespace Bit.Android
public static void SetIoc(Application application) public static void SetIoc(Application application)
{ {
UserDialogs.Init(application);
CachedImageRenderer.Init(); CachedImageRenderer.Init();
ZXing.Net.Mobile.Forms.Android.Platform.Init(); ZXing.Net.Mobile.Forms.Android.Platform.Init();
CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity); CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity);
@ -160,7 +158,6 @@ namespace Bit.Android
// Other // Other
container.RegisterSingleton(CrossSettings.Current); container.RegisterSingleton(CrossSettings.Current);
container.RegisterSingleton(CrossConnectivity.Current); container.RegisterSingleton(CrossConnectivity.Current);
container.RegisterSingleton(UserDialogs.Instance);
container.RegisterSingleton(CrossFingerprint.Current); container.RegisterSingleton(CrossFingerprint.Current);
// Push // Push

File diff suppressed because it is too large Load diff

View file

@ -32,6 +32,7 @@ namespace Bit.Android.Services
private readonly IAppSettingsService _appSettingsService; private readonly IAppSettingsService _appSettingsService;
private bool _cameraPermissionsDenied; private bool _cameraPermissionsDenied;
private DateTime? _lastAction; private DateTime? _lastAction;
private ProgressDialog _progressDialog;
public DeviceActionService( public DeviceActionService(
IAppSettingsService appSettingsService) IAppSettingsService appSettingsService)
@ -419,5 +420,31 @@ namespace Bit.Android.Services
intent.SetData(global::Android.Net.Uri.Parse("package:com.x8bit.bitwarden")); intent.SetData(global::Android.Net.Uri.Parse("package:com.x8bit.bitwarden"));
activity.StartActivity(intent); activity.StartActivity(intent);
} }
public void ShowLoading(string text)
{
if(_progressDialog != null)
{
HideLoading();
}
var activity = (MainActivity)CurrentContext;
_progressDialog = new ProgressDialog(activity);
_progressDialog.SetMessage(text);
_progressDialog.SetCancelable(true);
_progressDialog.Show();
}
public void HideLoading()
{
if(_progressDialog == null)
{
return;
}
_progressDialog.Dismiss();
_progressDialog.Dispose();
_progressDialog = null;
}
} }
} }

View file

@ -6,6 +6,8 @@ namespace Bit.App.Abstractions
{ {
public interface IDeviceActionService public interface IDeviceActionService
{ {
void ShowLoading(string text);
void HideLoading();
void Toast(string text, bool longDuration = false); void Toast(string text, bool longDuration = false);
void CopyToClipboard(string text); void CopyToClipboard(string text);
bool OpenFile(byte[] fileData, string id, string fileName); bool OpenFile(byte[] fileData, string id, string fileName);

View file

@ -16,7 +16,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Acr.UserDialogs" Version="6.3.10" />
<PackageReference Include="HockeySDK.Xamarin" Version="5.0.0" /> <PackageReference Include="HockeySDK.Xamarin" Version="5.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="PCLCrypto" Version="2.0.147" /> <PackageReference Include="PCLCrypto" Version="2.0.147" />

View file

@ -5,7 +5,6 @@ using Bit.App.Resources;
using Bit.App.Utilities; using Bit.App.Utilities;
using Xamarin.Forms; using Xamarin.Forms;
using XLabs.Ioc; using XLabs.Ioc;
using Acr.UserDialogs;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Bit.App.Pages namespace Bit.App.Pages

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Acr.UserDialogs;
using Bit.App.Abstractions; using Bit.App.Abstractions;
using Bit.App.Resources; using Bit.App.Resources;
using Xamarin.Forms; using Xamarin.Forms;

View file

@ -1,8 +1,6 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Acr.UserDialogs;
using Bit.App.Controls; using Bit.App.Controls;
using Bit.App.Resources; using Bit.App.Resources;
using Xamarin.Forms;
using XLabs.Ioc; using XLabs.Ioc;
using Bit.App.Abstractions; using Bit.App.Abstractions;

View file

@ -4,7 +4,6 @@ using Bit.App.Controls;
using Bit.App.Resources; using Bit.App.Resources;
using Xamarin.Forms; using Xamarin.Forms;
using XLabs.Ioc; using XLabs.Ioc;
using Acr.UserDialogs;
using System.Threading.Tasks; using System.Threading.Tasks;
using Plugin.Settings.Abstractions; using Plugin.Settings.Abstractions;
using Bit.App.Utilities; using Bit.App.Utilities;
@ -14,8 +13,8 @@ namespace Bit.App.Pages
public class LoginPage : ExtendedContentPage public class LoginPage : ExtendedContentPage
{ {
private IAuthService _authService; private IAuthService _authService;
private IUserDialogs _userDialogs;
private ISyncService _syncService; private ISyncService _syncService;
private IDeviceActionService _deviceActionService;
private ISettings _settings; private ISettings _settings;
private IGoogleAnalyticsService _googleAnalyticsService; private IGoogleAnalyticsService _googleAnalyticsService;
private IPushNotificationService _pushNotification; private IPushNotificationService _pushNotification;
@ -26,8 +25,8 @@ namespace Bit.App.Pages
{ {
_email = email; _email = email;
_authService = Resolver.Resolve<IAuthService>(); _authService = Resolver.Resolve<IAuthService>();
_userDialogs = Resolver.Resolve<IUserDialogs>();
_syncService = Resolver.Resolve<ISyncService>(); _syncService = Resolver.Resolve<ISyncService>();
_deviceActionService = Resolver.Resolve<IDeviceActionService>();
_settings = Resolver.Resolve<ISettings>(); _settings = Resolver.Resolve<ISettings>();
_googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>(); _googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
_pushNotification = Resolver.Resolve<IPushNotificationService>(); _pushNotification = Resolver.Resolve<IPushNotificationService>();
@ -179,9 +178,10 @@ namespace Bit.App.Pages
return; return;
} }
_userDialogs.ShowLoading(AppResources.LoggingIn, MaskType.Black); _deviceActionService.ShowLoading(AppResources.LoggingIn);
var result = await _authService.TokenPostAsync(EmailCell.Entry.Text, PasswordCell.Entry.Text); var result = await _authService.TokenPostAsync(EmailCell.Entry.Text, PasswordCell.Entry.Text);
_userDialogs.HideLoading(); _deviceActionService.HideLoading();
if(!result.Success) if(!result.Success)
{ {
await DisplayAlert(AppResources.AnErrorHasOccurred, result.ErrorMessage, AppResources.Ok); await DisplayAlert(AppResources.AnErrorHasOccurred, result.ErrorMessage, AppResources.Ok);

View file

@ -4,7 +4,6 @@ using Bit.App.Controls;
using Bit.App.Resources; using Bit.App.Resources;
using Xamarin.Forms; using Xamarin.Forms;
using XLabs.Ioc; using XLabs.Ioc;
using Acr.UserDialogs;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.App.Models; using Bit.App.Models;
using Bit.App.Utilities; using Bit.App.Utilities;
@ -19,7 +18,6 @@ namespace Bit.App.Pages
{ {
private DateTime? _lastAction; private DateTime? _lastAction;
private IAuthService _authService; private IAuthService _authService;
private IUserDialogs _userDialogs;
private ISyncService _syncService; private ISyncService _syncService;
private IDeviceInfoService _deviceInfoService; private IDeviceInfoService _deviceInfoService;
private IDeviceActionService _deviceActionService; private IDeviceActionService _deviceActionService;
@ -48,7 +46,6 @@ namespace Bit.App.Pages
_deviceActionService = Resolver.Resolve<IDeviceActionService>(); _deviceActionService = Resolver.Resolve<IDeviceActionService>();
_authService = Resolver.Resolve<IAuthService>(); _authService = Resolver.Resolve<IAuthService>();
_userDialogs = Resolver.Resolve<IUserDialogs>();
_syncService = Resolver.Resolve<ISyncService>(); _syncService = Resolver.Resolve<ISyncService>();
_appSettingsService = Resolver.Resolve<IAppSettingsService>(); _appSettingsService = Resolver.Resolve<IAppSettingsService>();
_googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>(); _googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
@ -402,10 +399,10 @@ namespace Bit.App.Pages
return; return;
} }
_userDialogs.ShowLoading(string.Concat(AppResources.Validating, "..."), MaskType.Black); _deviceActionService.ShowLoading(string.Concat(AppResources.Validating, "..."));
var response = await _authService.TokenPostTwoFactorAsync(_providerType.Value, token, RememberCell.On, var response = await _authService.TokenPostTwoFactorAsync(_providerType.Value, token, RememberCell.On,
_email, _masterPasswordHash, _key); _email, _masterPasswordHash, _key);
_userDialogs.HideLoading(); _deviceActionService.HideLoading();
if(!response.Success) if(!response.Success)
{ {

View file

@ -1,8 +1,6 @@
using System; using System;
using Bit.App.Controls; using Bit.App.Controls;
using Xamarin.Forms; using Xamarin.Forms;
using XLabs.Ioc;
using Bit.App.Abstractions;
namespace Bit.App.Pages namespace Bit.App.Pages
{ {

View file

@ -6,7 +6,6 @@ using Bit.App.Models.Api;
using Bit.App.Resources; using Bit.App.Resources;
using Xamarin.Forms; using Xamarin.Forms;
using XLabs.Ioc; using XLabs.Ioc;
using Acr.UserDialogs;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.App.Utilities; using Bit.App.Utilities;
@ -14,15 +13,14 @@ namespace Bit.App.Pages
{ {
public class PasswordHintPage : ExtendedContentPage public class PasswordHintPage : ExtendedContentPage
{ {
private IUserDialogs _userDialogs;
private IAccountsApiRepository _accountApiRepository; private IAccountsApiRepository _accountApiRepository;
private IDeviceActionService _deviceActionService;
public PasswordHintPage() public PasswordHintPage()
: base(updateActivity: false) : base(updateActivity: false)
{ {
_userDialogs = Resolver.Resolve<IUserDialogs>();
_accountApiRepository = Resolver.Resolve<IAccountsApiRepository>(); _accountApiRepository = Resolver.Resolve<IAccountsApiRepository>();
_deviceActionService = Resolver.Resolve<IDeviceActionService>();
Init(); Init();
} }
@ -124,9 +122,9 @@ namespace Bit.App.Pages
Email = EmailCell.Entry.Text Email = EmailCell.Entry.Text
}; };
_userDialogs.ShowLoading(AppResources.Submitting, MaskType.Black); _deviceActionService.ShowLoading(AppResources.Submitting);
var response = await _accountApiRepository.PostPasswordHintAsync(request); var response = await _accountApiRepository.PostPasswordHintAsync(request);
_userDialogs.HideLoading(); _deviceActionService.HideLoading();
if(!response.Succeeded) if(!response.Succeeded)
{ {

View file

@ -6,7 +6,6 @@ using Bit.App.Models.Api;
using Bit.App.Resources; using Bit.App.Resources;
using Xamarin.Forms; using Xamarin.Forms;
using XLabs.Ioc; using XLabs.Ioc;
using Acr.UserDialogs;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.App.Utilities; using Bit.App.Utilities;
@ -15,7 +14,7 @@ namespace Bit.App.Pages
public class RegisterPage : ExtendedContentPage public class RegisterPage : ExtendedContentPage
{ {
private ICryptoService _cryptoService; private ICryptoService _cryptoService;
private IUserDialogs _userDialogs; private IDeviceActionService _deviceActionService;
private IAccountsApiRepository _accountsApiRepository; private IAccountsApiRepository _accountsApiRepository;
private IGoogleAnalyticsService _googleAnalyticsService; private IGoogleAnalyticsService _googleAnalyticsService;
private HomePage _homePage; private HomePage _homePage;
@ -25,7 +24,7 @@ namespace Bit.App.Pages
{ {
_homePage = homePage; _homePage = homePage;
_cryptoService = Resolver.Resolve<ICryptoService>(); _cryptoService = Resolver.Resolve<ICryptoService>();
_userDialogs = Resolver.Resolve<IUserDialogs>(); _deviceActionService = Resolver.Resolve<IDeviceActionService>();
_accountsApiRepository = Resolver.Resolve<IAccountsApiRepository>(); _accountsApiRepository = Resolver.Resolve<IAccountsApiRepository>();
_googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>(); _googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
@ -213,9 +212,9 @@ namespace Bit.App.Pages
Key = encKey.EncryptedString Key = encKey.EncryptedString
}; };
_userDialogs.ShowLoading(AppResources.CreatingAccount, MaskType.Black); _deviceActionService.ShowLoading(AppResources.CreatingAccount);
var response = await _accountsApiRepository.PostRegisterAsync(request); var response = await _accountsApiRepository.PostRegisterAsync(request);
_userDialogs.HideLoading(); _deviceActionService.HideLoading();
if(!response.Succeeded) if(!response.Succeeded)
{ {

View file

@ -1,5 +1,4 @@
using System; using System;
using Acr.UserDialogs;
using Bit.App.Abstractions; using Bit.App.Abstractions;
using Bit.App.Controls; using Bit.App.Controls;
using Bit.App.Models; using Bit.App.Models;
@ -15,7 +14,6 @@ namespace Bit.App.Pages
public class SettingsAddFolderPage : ExtendedContentPage public class SettingsAddFolderPage : ExtendedContentPage
{ {
private readonly IFolderService _folderService; private readonly IFolderService _folderService;
private readonly IUserDialogs _userDialogs;
private readonly IDeviceActionService _deviceActionService; private readonly IDeviceActionService _deviceActionService;
private readonly IConnectivity _connectivity; private readonly IConnectivity _connectivity;
private readonly IGoogleAnalyticsService _googleAnalyticsService; private readonly IGoogleAnalyticsService _googleAnalyticsService;
@ -24,7 +22,6 @@ namespace Bit.App.Pages
public SettingsAddFolderPage() public SettingsAddFolderPage()
{ {
_folderService = Resolver.Resolve<IFolderService>(); _folderService = Resolver.Resolve<IFolderService>();
_userDialogs = Resolver.Resolve<IUserDialogs>();
_deviceActionService = Resolver.Resolve<IDeviceActionService>(); _deviceActionService = Resolver.Resolve<IDeviceActionService>();
_connectivity = Resolver.Resolve<IConnectivity>(); _connectivity = Resolver.Resolve<IConnectivity>();
_googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>(); _googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
@ -84,9 +81,9 @@ namespace Bit.App.Pages
Name = NameCell.Entry.Text.Encrypt() Name = NameCell.Entry.Text.Encrypt()
}; };
_userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); _deviceActionService.ShowLoading(AppResources.Saving);
var saveResult = await _folderService.SaveAsync(folder); var saveResult = await _folderService.SaveAsync(folder);
_userDialogs.HideLoading(); _deviceActionService.HideLoading();
if(saveResult.Succeeded) if(saveResult.Succeeded)
{ {

View file

@ -1,5 +1,4 @@
using System; using System;
using Acr.UserDialogs;
using Bit.App.Abstractions; using Bit.App.Abstractions;
using Bit.App.Controls; using Bit.App.Controls;
using Bit.App.Resources; using Bit.App.Resources;
@ -15,7 +14,6 @@ namespace Bit.App.Pages
{ {
private readonly string _folderId; private readonly string _folderId;
private readonly IFolderService _folderService; private readonly IFolderService _folderService;
private readonly IUserDialogs _userDialogs;
private readonly IDeviceActionService _deviceActionService; private readonly IDeviceActionService _deviceActionService;
private readonly IConnectivity _connectivity; private readonly IConnectivity _connectivity;
private readonly IGoogleAnalyticsService _googleAnalyticsService; private readonly IGoogleAnalyticsService _googleAnalyticsService;
@ -25,7 +23,6 @@ namespace Bit.App.Pages
{ {
_folderId = folderId; _folderId = folderId;
_folderService = Resolver.Resolve<IFolderService>(); _folderService = Resolver.Resolve<IFolderService>();
_userDialogs = Resolver.Resolve<IUserDialogs>();
_deviceActionService = Resolver.Resolve<IDeviceActionService>(); _deviceActionService = Resolver.Resolve<IDeviceActionService>();
_connectivity = Resolver.Resolve<IConnectivity>(); _connectivity = Resolver.Resolve<IConnectivity>();
_googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>(); _googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
@ -98,9 +95,9 @@ namespace Bit.App.Pages
folder.Name = NameCell.Entry.Text.Encrypt(); folder.Name = NameCell.Entry.Text.Encrypt();
_userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); _deviceActionService.ShowLoading(AppResources.Saving);
var saveResult = await _folderService.SaveAsync(folder); var saveResult = await _folderService.SaveAsync(folder);
_userDialogs.HideLoading(); _deviceActionService.HideLoading();
if(saveResult.Succeeded) if(saveResult.Succeeded)
{ {
@ -162,9 +159,9 @@ namespace Bit.App.Pages
return; return;
} }
_userDialogs.ShowLoading(AppResources.Deleting, MaskType.Black); _deviceActionService.ShowLoading(AppResources.Deleting);
var deleteTask = await _folderService.DeleteAsync(_folderId); var deleteTask = await _folderService.DeleteAsync(_folderId);
_userDialogs.HideLoading(); _deviceActionService.HideLoading();
if(deleteTask.Succeeded) if(deleteTask.Succeeded)
{ {

View file

@ -4,7 +4,6 @@ using Bit.App.Resources;
using Xamarin.Forms; using Xamarin.Forms;
using XLabs.Ioc; using XLabs.Ioc;
using Bit.App.Controls; using Bit.App.Controls;
using Acr.UserDialogs;
using Plugin.Settings.Abstractions; using Plugin.Settings.Abstractions;
using Plugin.Fingerprint.Abstractions; using Plugin.Fingerprint.Abstractions;
using Bit.App.Utilities; using Bit.App.Utilities;

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Acr.UserDialogs;
using Bit.App.Abstractions; using Bit.App.Abstractions;
using Bit.App.Controls; using Bit.App.Controls;
using Bit.App.Resources; using Bit.App.Resources;
@ -14,7 +13,6 @@ namespace Bit.App.Pages
public class SettingsSyncPage : ExtendedContentPage public class SettingsSyncPage : ExtendedContentPage
{ {
private readonly ISyncService _syncService; private readonly ISyncService _syncService;
private readonly IUserDialogs _userDialogs;
private readonly IDeviceActionService _deviceActionService; private readonly IDeviceActionService _deviceActionService;
private readonly IConnectivity _connectivity; private readonly IConnectivity _connectivity;
private readonly ISettings _settings; private readonly ISettings _settings;
@ -23,7 +21,6 @@ namespace Bit.App.Pages
public SettingsSyncPage() public SettingsSyncPage()
{ {
_syncService = Resolver.Resolve<ISyncService>(); _syncService = Resolver.Resolve<ISyncService>();
_userDialogs = Resolver.Resolve<IUserDialogs>();
_deviceActionService = Resolver.Resolve<IDeviceActionService>(); _deviceActionService = Resolver.Resolve<IDeviceActionService>();
_connectivity = Resolver.Resolve<IConnectivity>(); _connectivity = Resolver.Resolve<IConnectivity>();
_settings = Resolver.Resolve<ISettings>(); _settings = Resolver.Resolve<ISettings>();
@ -104,9 +101,9 @@ namespace Bit.App.Pages
return; return;
} }
_userDialogs.ShowLoading(AppResources.Syncing, MaskType.Black); _deviceActionService.ShowLoading(AppResources.Syncing);
var succeeded = await _syncService.FullSyncAsync(true); var succeeded = await _syncService.FullSyncAsync(true);
_userDialogs.HideLoading(); _deviceActionService.HideLoading();
if(succeeded) if(succeeded)
{ {
_deviceActionService.Toast(AppResources.SyncingComplete); _deviceActionService.Toast(AppResources.SyncingComplete);

View file

@ -1,6 +1,4 @@
using System; using System;
using System.Threading.Tasks;
using Acr.UserDialogs;
using Bit.App.Controls; using Bit.App.Controls;
using Bit.App.Models.Page; using Bit.App.Models.Page;
using Plugin.Settings.Abstractions; using Plugin.Settings.Abstractions;

View file

@ -1,5 +1,4 @@
using System; using System;
using Acr.UserDialogs;
using Bit.App.Abstractions; using Bit.App.Abstractions;
using Bit.App.Controls; using Bit.App.Controls;
using Bit.App.Models.Page; using Bit.App.Models.Page;

View file

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Acr.UserDialogs;
using Bit.App.Abstractions; using Bit.App.Abstractions;
using Bit.App.Controls; using Bit.App.Controls;
using Bit.App.Models; using Bit.App.Models;
@ -12,7 +11,6 @@ using XLabs.Ioc;
using Plugin.Settings.Abstractions; using Plugin.Settings.Abstractions;
using Bit.App.Utilities; using Bit.App.Utilities;
using Bit.App.Enums; using Bit.App.Enums;
using Bit.App.Models.Page;
namespace Bit.App.Pages namespace Bit.App.Pages
{ {
@ -23,7 +21,6 @@ namespace Bit.App.Pages
private readonly CipherType _type; private readonly CipherType _type;
private readonly ICipherService _cipherService; private readonly ICipherService _cipherService;
private readonly IFolderService _folderService; private readonly IFolderService _folderService;
private readonly IUserDialogs _userDialogs;
private readonly IConnectivity _connectivity; private readonly IConnectivity _connectivity;
private readonly IGoogleAnalyticsService _googleAnalyticsService; private readonly IGoogleAnalyticsService _googleAnalyticsService;
private readonly ISettings _settings; private readonly ISettings _settings;
@ -72,7 +69,6 @@ namespace Bit.App.Pages
_cipherService = Resolver.Resolve<ICipherService>(); _cipherService = Resolver.Resolve<ICipherService>();
_folderService = Resolver.Resolve<IFolderService>(); _folderService = Resolver.Resolve<IFolderService>();
_userDialogs = Resolver.Resolve<IUserDialogs>();
_connectivity = Resolver.Resolve<IConnectivity>(); _connectivity = Resolver.Resolve<IConnectivity>();
_googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>(); _googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
_settings = Resolver.Resolve<ISettings>(); _settings = Resolver.Resolve<ISettings>();
@ -744,9 +740,9 @@ namespace Bit.App.Pages
cipher.FolderId = Folders.ElementAt(FolderCell.Picker.SelectedIndex - 1).Id; cipher.FolderId = Folders.ElementAt(FolderCell.Picker.SelectedIndex - 1).Id;
} }
_userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); _deviceActionService.ShowLoading(AppResources.Saving);
var saveTask = await _cipherService.SaveAsync(cipher); var saveTask = await _cipherService.SaveAsync(cipher);
_userDialogs.HideLoading(); _deviceActionService.HideLoading();
if(saveTask.Succeeded) if(saveTask.Succeeded)
{ {

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Linq; using System.Linq;
using Acr.UserDialogs;
using Bit.App.Abstractions; using Bit.App.Abstractions;
using Bit.App.Controls; using Bit.App.Controls;
using Bit.App.Models.Page; using Bit.App.Models.Page;
@ -17,7 +16,6 @@ namespace Bit.App.Pages
public class VaultAttachmentsPage : ExtendedContentPage public class VaultAttachmentsPage : ExtendedContentPage
{ {
private readonly ICipherService _cipherService; private readonly ICipherService _cipherService;
private readonly IUserDialogs _userDialogs;
private readonly IConnectivity _connectivity; private readonly IConnectivity _connectivity;
private readonly IDeviceActionService _deviceActionService; private readonly IDeviceActionService _deviceActionService;
private readonly IGoogleAnalyticsService _googleAnalyticsService; private readonly IGoogleAnalyticsService _googleAnalyticsService;
@ -35,7 +33,6 @@ namespace Bit.App.Pages
_cipherId = cipherId; _cipherId = cipherId;
_cipherService = Resolver.Resolve<ICipherService>(); _cipherService = Resolver.Resolve<ICipherService>();
_connectivity = Resolver.Resolve<IConnectivity>(); _connectivity = Resolver.Resolve<IConnectivity>();
_userDialogs = Resolver.Resolve<IUserDialogs>();
_deviceActionService = Resolver.Resolve<IDeviceActionService>(); _deviceActionService = Resolver.Resolve<IDeviceActionService>();
_googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>(); _googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
_tokenService = Resolver.Resolve<ITokenService>(); _tokenService = Resolver.Resolve<ITokenService>();
@ -160,9 +157,9 @@ namespace Bit.App.Pages
return; return;
} }
_userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); _deviceActionService.ShowLoading(AppResources.Saving);
var saveTask = await _cipherService.EncryptAndSaveAttachmentAsync(_cipher, _fileBytes, FileLabel.Text); var saveTask = await _cipherService.EncryptAndSaveAttachmentAsync(_cipher, _fileBytes, FileLabel.Text);
_userDialogs.HideLoading(); _deviceActionService.HideLoading();
if(saveTask.Succeeded) if(saveTask.Succeeded)
{ {
@ -267,9 +264,9 @@ namespace Bit.App.Pages
return; return;
} }
_userDialogs.ShowLoading(AppResources.Deleting, MaskType.Black); _deviceActionService.ShowLoading(AppResources.Deleting);
var saveTask = await _cipherService.DeleteAttachmentAsync(_cipher, attachment.Id); var saveTask = await _cipherService.DeleteAttachmentAsync(_cipher, attachment.Id);
_userDialogs.HideLoading(); _deviceActionService.HideLoading();
if(saveTask.Succeeded) if(saveTask.Succeeded)
{ {

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Linq; using System.Linq;
using Acr.UserDialogs;
using Bit.App.Abstractions; using Bit.App.Abstractions;
using Bit.App.Controls; using Bit.App.Controls;
using Bit.App.Resources; using Bit.App.Resources;
@ -17,7 +16,6 @@ namespace Bit.App.Pages
public class VaultCustomFieldsPage : ExtendedContentPage public class VaultCustomFieldsPage : ExtendedContentPage
{ {
private readonly ICipherService _cipherService; private readonly ICipherService _cipherService;
private readonly IUserDialogs _userDialogs;
private readonly IDeviceActionService _deviceActionService; private readonly IDeviceActionService _deviceActionService;
private readonly IConnectivity _connectivity; private readonly IConnectivity _connectivity;
private readonly IGoogleAnalyticsService _googleAnalyticsService; private readonly IGoogleAnalyticsService _googleAnalyticsService;
@ -31,7 +29,6 @@ namespace Bit.App.Pages
_cipherId = cipherId; _cipherId = cipherId;
_cipherService = Resolver.Resolve<ICipherService>(); _cipherService = Resolver.Resolve<ICipherService>();
_connectivity = Resolver.Resolve<IConnectivity>(); _connectivity = Resolver.Resolve<IConnectivity>();
_userDialogs = Resolver.Resolve<IUserDialogs>();
_deviceActionService = Resolver.Resolve<IDeviceActionService>(); _deviceActionService = Resolver.Resolve<IDeviceActionService>();
_googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>(); _googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
@ -115,9 +112,9 @@ namespace Bit.App.Pages
_cipher.Fields = null; _cipher.Fields = null;
} }
_userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); _deviceActionService.ShowLoading(AppResources.Saving);
var saveTask = await _cipherService.SaveAsync(_cipher); var saveTask = await _cipherService.SaveAsync(_cipher);
_userDialogs.HideLoading(); _deviceActionService.HideLoading();
if(saveTask.Succeeded) if(saveTask.Succeeded)
{ {

View file

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Acr.UserDialogs;
using Bit.App.Abstractions; using Bit.App.Abstractions;
using Bit.App.Controls; using Bit.App.Controls;
using Bit.App.Resources; using Bit.App.Resources;
@ -19,7 +18,6 @@ namespace Bit.App.Pages
private readonly string _cipherId; private readonly string _cipherId;
private readonly ICipherService _cipherService; private readonly ICipherService _cipherService;
private readonly IFolderService _folderService; private readonly IFolderService _folderService;
private readonly IUserDialogs _userDialogs;
private readonly IDeviceActionService _deviceActionService; private readonly IDeviceActionService _deviceActionService;
private readonly IConnectivity _connectivity; private readonly IConnectivity _connectivity;
private readonly IDeviceInfoService _deviceInfo; private readonly IDeviceInfoService _deviceInfo;
@ -31,7 +29,6 @@ namespace Bit.App.Pages
_cipherId = cipherId; _cipherId = cipherId;
_cipherService = Resolver.Resolve<ICipherService>(); _cipherService = Resolver.Resolve<ICipherService>();
_folderService = Resolver.Resolve<IFolderService>(); _folderService = Resolver.Resolve<IFolderService>();
_userDialogs = Resolver.Resolve<IUserDialogs>();
_deviceActionService = Resolver.Resolve<IDeviceActionService>(); _deviceActionService = Resolver.Resolve<IDeviceActionService>();
_connectivity = Resolver.Resolve<IConnectivity>(); _connectivity = Resolver.Resolve<IConnectivity>();
_deviceInfo = Resolver.Resolve<IDeviceInfoService>(); _deviceInfo = Resolver.Resolve<IDeviceInfoService>();
@ -613,9 +610,9 @@ namespace Bit.App.Pages
Cipher.FolderId = null; Cipher.FolderId = null;
} }
_userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); _deviceActionService.ShowLoading(AppResources.Saving);
var saveTask = await _cipherService.SaveAsync(Cipher); var saveTask = await _cipherService.SaveAsync(Cipher);
_userDialogs.HideLoading(); _deviceActionService.HideLoading();
if(saveTask.Succeeded) if(saveTask.Succeeded)
{ {
@ -860,9 +857,9 @@ namespace Bit.App.Pages
return; return;
} }
_userDialogs.ShowLoading(AppResources.Deleting, MaskType.Black); _deviceActionService.ShowLoading(AppResources.Deleting);
var deleteTask = await _cipherService.DeleteAsync(_cipherId); var deleteTask = await _cipherService.DeleteAsync(_cipherId);
_userDialogs.HideLoading(); _deviceActionService.HideLoading();
if(deleteTask.Succeeded) if(deleteTask.Succeeded)
{ {

View file

@ -1,5 +1,4 @@
using System; using System;
using Acr.UserDialogs;
using Bit.App.Abstractions; using Bit.App.Abstractions;
using Bit.App.Controls; using Bit.App.Controls;
using Bit.App.Models.Page; using Bit.App.Models.Page;
@ -20,7 +19,6 @@ namespace Bit.App.Pages
private readonly CipherType _type; private readonly CipherType _type;
private readonly string _cipherId; private readonly string _cipherId;
private readonly ICipherService _cipherService; private readonly ICipherService _cipherService;
private readonly IUserDialogs _userDialogs;
private readonly IDeviceActionService _deviceActionService; private readonly IDeviceActionService _deviceActionService;
private readonly ITokenService _tokenService; private readonly ITokenService _tokenService;
private bool _pageDisappeared = true; private bool _pageDisappeared = true;
@ -30,7 +28,6 @@ namespace Bit.App.Pages
_type = type; _type = type;
_cipherId = cipherId; _cipherId = cipherId;
_cipherService = Resolver.Resolve<ICipherService>(); _cipherService = Resolver.Resolve<ICipherService>();
_userDialogs = Resolver.Resolve<IUserDialogs>();
_deviceActionService = Resolver.Resolve<IDeviceActionService>(); _deviceActionService = Resolver.Resolve<IDeviceActionService>();
_tokenService = Resolver.Resolve<ITokenService>(); _tokenService = Resolver.Resolve<ITokenService>();
@ -438,8 +435,8 @@ namespace Bit.App.Pages
} }
// 10 MB warning // 10 MB warning
if(attachment.Size >= 10485760 && !(await _userDialogs.ConfirmAsync( if(attachment.Size >= 10485760 && !(await DisplayAlert(
string.Format(AppResources.AttachmentLargeWarning, attachment.SizeName), null, null, string.Format(AppResources.AttachmentLargeWarning, attachment.SizeName),
AppResources.Yes, AppResources.No))) AppResources.Yes, AppResources.No)))
{ {
return; return;
@ -451,9 +448,9 @@ namespace Bit.App.Pages
return; return;
} }
_userDialogs.ShowLoading(AppResources.Downloading, MaskType.Black); _deviceActionService.ShowLoading(AppResources.Downloading);
var data = await _cipherService.DownloadAndDecryptAttachmentAsync(attachment.Url, cipher.OrganizationId); var data = await _cipherService.DownloadAndDecryptAttachmentAsync(attachment.Url, cipher.OrganizationId);
_userDialogs.HideLoading(); _deviceActionService.HideLoading();
if(data == null) if(data == null)
{ {

View file

@ -10,7 +10,6 @@ using Bit.App.Enums;
using Xamarin.Forms; using Xamarin.Forms;
using Bit.App.Pages; using Bit.App.Pages;
using Bit.App.Controls; using Bit.App.Controls;
using Acr.UserDialogs;
using XLabs.Ioc; using XLabs.Ioc;
namespace Bit.App.Services namespace Bit.App.Services

View file

@ -1,5 +1,4 @@
using Acr.UserDialogs; using Bit.App.Abstractions;
using Bit.App.Abstractions;
using Bit.App.Enums; using Bit.App.Enums;
using Bit.App.Models.Page; using Bit.App.Models.Page;
using Bit.App.Pages; using Bit.App.Pages;

View file

@ -11,6 +11,7 @@ using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.App.Models.Page; using Bit.App.Models.Page;
using Bit.iOS.Core.Views; using Bit.iOS.Core.Views;
using CoreGraphics;
namespace Bit.iOS.Services namespace Bit.iOS.Services
{ {
@ -18,6 +19,7 @@ namespace Bit.iOS.Services
{ {
private readonly IAppSettingsService _appSettingsService; private readonly IAppSettingsService _appSettingsService;
private readonly IDeviceInfoService _deviceInfoService; private readonly IDeviceInfoService _deviceInfoService;
private UIAlertController _progressAlert;
public DeviceActionService( public DeviceActionService(
IAppSettingsService appSettingsService, IAppSettingsService appSettingsService,
@ -264,5 +266,43 @@ namespace Bit.iOS.Services
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public void ShowLoading(string text)
{
var loadingIndicator = new UIActivityIndicatorView(new CGRect(10, 5, 50, 50));
loadingIndicator.HidesWhenStopped = true;
loadingIndicator.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray;
loadingIndicator.StartAnimating();
_progressAlert = UIAlertController.Create(null, text, UIAlertControllerStyle.Alert);
_progressAlert.View.TintColor = UIColor.Black;
_progressAlert.View.Add(loadingIndicator);
var window = UIApplication.SharedApplication.KeyWindow;
var vc = window.RootViewController;
while(vc.PresentedViewController != null)
{
vc = vc.PresentedViewController;
}
vc.PresentViewController(_progressAlert, true, null);
}
public void HideLoading()
{
if(_progressAlert == null)
{
return;
}
_progressAlert.DismissViewController(true, () => { });
_progressAlert.Dispose();
_progressAlert = null;
}
public Task LaunchAppAsync(string appName, Page page)
{
throw new NotImplementedException();
}
} }
} }