show/hide loading are async now

This commit is contained in:
Kyle Spearrin 2018-03-22 11:07:41 -04:00
parent 215ded8a77
commit b5747fbb44
17 changed files with 85 additions and 57 deletions

View file

@ -6506,17 +6506,17 @@ namespace Bit.Android
// aapt resource value: 0x7f0a0051 // aapt resource value: 0x7f0a0051
public const int ApplicationName = 2131361873; public const int ApplicationName = 2131361873;
// aapt resource value: 0x7f0a00ab // aapt resource value: 0x7f0a00b2
public const int AutoFillServiceDescription = 2131361963; public const int AutoFillServiceDescription = 2131361970;
// aapt resource value: 0x7f0a00aa // aapt resource value: 0x7f0a00b1
public const int AutoFillServiceSummary = 2131361962; public const int AutoFillServiceSummary = 2131361969;
// aapt resource value: 0x7f0a0050 // aapt resource value: 0x7f0a0050
public const int Hello = 2131361872; public const int Hello = 2131361872;
// aapt resource value: 0x7f0a00ac // aapt resource value: 0x7f0a00b3
public const int MyVault = 2131361964; public const int MyVault = 2131361971;
// aapt resource value: 0x7f0a0027 // aapt resource value: 0x7f0a0027
public const int abc_action_bar_home_description = 2131361831; public const int abc_action_bar_home_description = 2131361831;
@ -6671,6 +6671,27 @@ namespace Bit.Android
// aapt resource value: 0x7f0a000f // aapt resource value: 0x7f0a000f
public const int common_signin_button_text_long = 2131361807; public const int common_signin_button_text_long = 2131361807;
// aapt resource value: 0x7f0a00ac
public const int default_web_client_id = 2131361964;
// aapt resource value: 0x7f0a00ad
public const int firebase_database_url = 2131361965;
// aapt resource value: 0x7f0a00aa
public const int gcm_defaultSenderId = 2131361962;
// aapt resource value: 0x7f0a00ae
public const int google_api_key = 2131361966;
// aapt resource value: 0x7f0a00ab
public const int google_app_id = 2131361963;
// aapt resource value: 0x7f0a00af
public const int google_crash_reporting_api_key = 2131361967;
// aapt resource value: 0x7f0a00b0
public const int google_storage_bucket = 2131361968;
// aapt resource value: 0x7f0a0052 // aapt resource value: 0x7f0a0052
public const int hockeyapp_crash_dialog_app_name_fallback = 2131361874; public const int hockeyapp_crash_dialog_app_name_fallback = 2131361874;

View file

@ -445,11 +445,11 @@ namespace Bit.Android.Services
} }
} }
public void ShowLoading(string text) public async Task ShowLoadingAsync(string text)
{ {
if(_progressDialog != null) if(_progressDialog != null)
{ {
HideLoading(); await HideLoadingAsync();
} }
var activity = (MainActivity)CurrentContext; var activity = (MainActivity)CurrentContext;
@ -459,16 +459,16 @@ namespace Bit.Android.Services
_progressDialog.Show(); _progressDialog.Show();
} }
public void HideLoading() public Task HideLoadingAsync()
{ {
if(_progressDialog == null) if(_progressDialog != null)
{ {
return; _progressDialog.Dismiss();
_progressDialog.Dispose();
_progressDialog = null;
} }
_progressDialog.Dismiss(); return Task.FromResult(0);
_progressDialog.Dispose();
_progressDialog = null;
} }
public Task<string> DisplayPromptAync(string title = null, string description = null, string text = null) public Task<string> DisplayPromptAync(string title = null, string description = null, string text = null)

View file

@ -6,8 +6,8 @@ namespace Bit.App.Abstractions
{ {
public interface IDeviceActionService public interface IDeviceActionService
{ {
void ShowLoading(string text); Task ShowLoadingAsync(string text);
void HideLoading(); Task HideLoadingAsync();
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

@ -179,9 +179,9 @@ namespace Bit.App.Pages
return; return;
} }
_deviceActionService.ShowLoading(AppResources.LoggingIn); await _deviceActionService.ShowLoadingAsync(AppResources.LoggingIn);
var result = await _authService.TokenPostAsync(EmailCell.Entry.Text, PasswordCell.Entry.Text); var result = await _authService.TokenPostAsync(EmailCell.Entry.Text, PasswordCell.Entry.Text);
_deviceActionService.HideLoading(); await _deviceActionService.HideLoadingAsync();
if(!result.Success) if(!result.Success)
{ {

View file

@ -416,10 +416,10 @@ namespace Bit.App.Pages
return; return;
} }
_deviceActionService.ShowLoading(string.Concat(AppResources.Validating, "...")); await _deviceActionService.ShowLoadingAsync(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);
_deviceActionService.HideLoading(); await _deviceActionService.HideLoadingAsync();
if(!response.Success) if(!response.Success)
{ {

View file

@ -123,9 +123,9 @@ namespace Bit.App.Pages
Email = EmailCell.Entry.Text Email = EmailCell.Entry.Text
}; };
_deviceActionService.ShowLoading(AppResources.Submitting); await _deviceActionService.ShowLoadingAsync(AppResources.Submitting);
var response = await _accountApiRepository.PostPasswordHintAsync(request); var response = await _accountApiRepository.PostPasswordHintAsync(request);
_deviceActionService.HideLoading(); await _deviceActionService.HideLoadingAsync();
if(!response.Succeeded) if(!response.Succeeded)
{ {

View file

@ -204,9 +204,9 @@ namespace Bit.App.Pages
Key = encKey.EncryptedString Key = encKey.EncryptedString
}; };
_deviceActionService.ShowLoading(AppResources.CreatingAccount); await _deviceActionService.ShowLoadingAsync(AppResources.CreatingAccount);
var response = await _accountsApiRepository.PostRegisterAsync(request); var response = await _accountsApiRepository.PostRegisterAsync(request);
_deviceActionService.HideLoading(); await _deviceActionService.HideLoadingAsync();
if(!response.Succeeded) if(!response.Succeeded)
{ {

View file

@ -85,9 +85,9 @@ namespace Bit.App.Pages
Name = NameCell.Entry.Text.Encrypt() Name = NameCell.Entry.Text.Encrypt()
}; };
_deviceActionService.ShowLoading(AppResources.Saving); await _deviceActionService.ShowLoadingAsync(AppResources.Saving);
var saveResult = await _folderService.SaveAsync(folder); var saveResult = await _folderService.SaveAsync(folder);
_deviceActionService.HideLoading(); await _deviceActionService.HideLoadingAsync();
if(saveResult.Succeeded) if(saveResult.Succeeded)
{ {

View file

@ -97,9 +97,9 @@ namespace Bit.App.Pages
folder.Name = NameCell.Entry.Text.Encrypt(); folder.Name = NameCell.Entry.Text.Encrypt();
_deviceActionService.ShowLoading(AppResources.Saving); await _deviceActionService.ShowLoadingAsync(AppResources.Saving);
var saveResult = await _folderService.SaveAsync(folder); var saveResult = await _folderService.SaveAsync(folder);
_deviceActionService.HideLoading(); await _deviceActionService.HideLoadingAsync();
if(saveResult.Succeeded) if(saveResult.Succeeded)
{ {
@ -161,9 +161,9 @@ namespace Bit.App.Pages
return; return;
} }
_deviceActionService.ShowLoading(AppResources.Deleting); await _deviceActionService.ShowLoadingAsync(AppResources.Deleting);
var deleteTask = await _folderService.DeleteAsync(_folderId); var deleteTask = await _folderService.DeleteAsync(_folderId);
_deviceActionService.HideLoading(); await _deviceActionService.HideLoadingAsync();
if(deleteTask.Succeeded) if(deleteTask.Succeeded)
{ {

View file

@ -101,9 +101,9 @@ namespace Bit.App.Pages
return; return;
} }
_deviceActionService.ShowLoading(AppResources.Syncing); await _deviceActionService.ShowLoadingAsync(AppResources.Syncing);
var succeeded = await _syncService.FullSyncAsync(true); var succeeded = await _syncService.FullSyncAsync(true);
_deviceActionService.HideLoading(); await _deviceActionService.HideLoadingAsync();
if(succeeded) if(succeeded)
{ {
_deviceActionService.Toast(AppResources.SyncingComplete); _deviceActionService.Toast(AppResources.SyncingComplete);

View file

@ -775,9 +775,9 @@ namespace Bit.App.Pages
Helpers.ProcessFieldsSectionForSave(FieldsSection, cipher); Helpers.ProcessFieldsSectionForSave(FieldsSection, cipher);
_deviceActionService.ShowLoading(AppResources.Saving); await _deviceActionService.ShowLoadingAsync(AppResources.Saving);
var saveTask = await _cipherService.SaveAsync(cipher); var saveTask = await _cipherService.SaveAsync(cipher);
_deviceActionService.HideLoading(); await _deviceActionService.HideLoadingAsync();
if(saveTask.Succeeded) if(saveTask.Succeeded)
{ {

View file

@ -154,9 +154,9 @@ namespace Bit.App.Pages
return; return;
} }
_deviceActionService.ShowLoading(AppResources.Saving); await _deviceActionService.ShowLoadingAsync(AppResources.Saving);
var saveTask = await _cipherService.EncryptAndSaveAttachmentAsync(_cipher, _fileBytes, FileLabel.Text); var saveTask = await _cipherService.EncryptAndSaveAttachmentAsync(_cipher, _fileBytes, FileLabel.Text);
_deviceActionService.HideLoading(); await _deviceActionService.HideLoadingAsync();
if(saveTask.Succeeded) if(saveTask.Succeeded)
{ {
@ -280,9 +280,9 @@ namespace Bit.App.Pages
return; return;
} }
_deviceActionService.ShowLoading(AppResources.Deleting); await _deviceActionService.ShowLoadingAsync(AppResources.Deleting);
var saveTask = await _cipherService.DeleteAttachmentAsync(_cipher, attachment.Id); var saveTask = await _cipherService.DeleteAttachmentAsync(_cipher, attachment.Id);
_deviceActionService.HideLoading(); await _deviceActionService.HideLoadingAsync();
if(saveTask.Succeeded) if(saveTask.Succeeded)
{ {

View file

@ -639,9 +639,9 @@ namespace Bit.App.Pages
Helpers.ProcessFieldsSectionForSave(FieldsSection, Cipher); Helpers.ProcessFieldsSectionForSave(FieldsSection, Cipher);
_deviceActionService.ShowLoading(AppResources.Saving); await _deviceActionService.ShowLoadingAsync(AppResources.Saving);
var saveTask = await _cipherService.SaveAsync(Cipher); var saveTask = await _cipherService.SaveAsync(Cipher);
_deviceActionService.HideLoading(); await _deviceActionService.HideLoadingAsync();
if(saveTask.Succeeded) if(saveTask.Succeeded)
{ {
@ -892,9 +892,9 @@ namespace Bit.App.Pages
return; return;
} }
_deviceActionService.ShowLoading(AppResources.Deleting); await _deviceActionService.ShowLoadingAsync(AppResources.Deleting);
var deleteTask = await _cipherService.DeleteAsync(_cipherId); var deleteTask = await _cipherService.DeleteAsync(_cipherId);
_deviceActionService.HideLoading(); await _deviceActionService.HideLoadingAsync();
if(deleteTask.Succeeded) if(deleteTask.Succeeded)
{ {

View file

@ -462,9 +462,9 @@ namespace Bit.App.Pages
return; return;
} }
_deviceActionService.ShowLoading(AppResources.Downloading); await _deviceActionService.ShowLoadingAsync(AppResources.Downloading);
var data = await _cipherService.DownloadAndDecryptAttachmentAsync(attachment.Url, cipher.OrganizationId); var data = await _cipherService.DownloadAndDecryptAttachmentAsync(attachment.Url, cipher.OrganizationId);
_deviceActionService.HideLoading(); await _deviceActionService.HideLoadingAsync();
if(data == null) if(data == null)
{ {

View file

@ -151,14 +151,16 @@ namespace Bit.UWP.Services
}.Show(); }.Show();
} }
public void ShowLoading(string text) public Task ShowLoadingAsync(string text)
{ {
_userDialogs.ShowLoading(text, MaskType.Black); _userDialogs.ShowLoading(text, MaskType.Black);
return Task.FromResult(0);
} }
public void HideLoading() public Task HideLoadingAsync()
{ {
_userDialogs.HideLoading(); _userDialogs.HideLoading();
return Task.FromResult(0);
} }
public Task LaunchAppAsync(string appName, Xamarin.Forms.Page page) public Task LaunchAppAsync(string appName, Xamarin.Forms.Page page)

View file

@ -48,9 +48,9 @@ namespace Bit.iOS.Core.Services
return Task.FromResult<string>(null); return Task.FromResult<string>(null);
} }
public void HideLoading() public Task HideLoadingAsync()
{ {
// do nothing return Task.FromResult(0);
} }
public Task LaunchAppAsync(string appName, Page page) public Task LaunchAppAsync(string appName, Page page)
@ -83,9 +83,9 @@ namespace Bit.iOS.Core.Services
return Task.FromResult(0); return Task.FromResult(0);
} }
public void ShowLoading(string text) public Task ShowLoadingAsync(string text)
{ {
// do nothing return Task.FromResult(0);
} }
public void Toast(string text, bool longDuration = false) public void Toast(string text, bool longDuration = false)

View file

@ -286,13 +286,15 @@ namespace Bit.iOS.Services
throw new NotImplementedException(); throw new NotImplementedException();
} }
public void ShowLoading(string text) public Task ShowLoadingAsync(string text)
{ {
if(_progressAlert != null) if(_progressAlert != null)
{ {
HideLoading(); HideLoadingAsync().GetAwaiter().GetResult();
} }
var result = new TaskCompletionSource<int>();
var loadingIndicator = new UIActivityIndicatorView(new CGRect(10, 5, 50, 50)); var loadingIndicator = new UIActivityIndicatorView(new CGRect(10, 5, 50, 50));
loadingIndicator.HidesWhenStopped = true; loadingIndicator.HidesWhenStopped = true;
loadingIndicator.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray; loadingIndicator.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray;
@ -303,19 +305,22 @@ namespace Bit.iOS.Services
_progressAlert.View.Add(loadingIndicator); _progressAlert.View.Add(loadingIndicator);
var vc = GetPresentedViewController(); var vc = GetPresentedViewController();
vc?.PresentViewController(_progressAlert, false, null); vc?.PresentViewController(_progressAlert, false, () => result.TrySetResult(0));
return result.Task;
} }
public void HideLoading() public Task HideLoadingAsync()
{ {
var result = new TaskCompletionSource<int>();
if(_progressAlert == null) if(_progressAlert == null)
{ {
return; result.TrySetResult(0);
} }
_progressAlert.DismissViewController(false, null); _progressAlert.DismissViewController(false, () => result.TrySetResult(0));
_progressAlert.Dispose(); _progressAlert.Dispose();
_progressAlert = null; _progressAlert = null;
return result.Task;
} }
public Task LaunchAppAsync(string appName, Page page) public Task LaunchAppAsync(string appName, Page page)