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
public const int ApplicationName = 2131361873;
// aapt resource value: 0x7f0a00ab
public const int AutoFillServiceDescription = 2131361963;
// aapt resource value: 0x7f0a00b2
public const int AutoFillServiceDescription = 2131361970;
// aapt resource value: 0x7f0a00aa
public const int AutoFillServiceSummary = 2131361962;
// aapt resource value: 0x7f0a00b1
public const int AutoFillServiceSummary = 2131361969;
// aapt resource value: 0x7f0a0050
public const int Hello = 2131361872;
// aapt resource value: 0x7f0a00ac
public const int MyVault = 2131361964;
// aapt resource value: 0x7f0a00b3
public const int MyVault = 2131361971;
// aapt resource value: 0x7f0a0027
public const int abc_action_bar_home_description = 2131361831;
@ -6671,6 +6671,27 @@ namespace Bit.Android
// aapt resource value: 0x7f0a000f
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
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)
{
HideLoading();
await HideLoadingAsync();
}
var activity = (MainActivity)CurrentContext;
@ -459,16 +459,16 @@ namespace Bit.Android.Services
_progressDialog.Show();
}
public void HideLoading()
public Task HideLoadingAsync()
{
if(_progressDialog == null)
if(_progressDialog != null)
{
return;
_progressDialog.Dismiss();
_progressDialog.Dispose();
_progressDialog = null;
}
_progressDialog.Dismiss();
_progressDialog.Dispose();
_progressDialog = null;
return Task.FromResult(0);
}
public Task<string> DisplayPromptAync(string title = null, string description = null, string text = null)
@ -487,7 +487,7 @@ namespace Bit.Android.Services
{
InputType = global::Android.Text.InputTypes.ClassText
};
if(text == null)
{
text = string.Empty;

View file

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

View file

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

View file

@ -416,10 +416,10 @@ namespace Bit.App.Pages
return;
}
_deviceActionService.ShowLoading(string.Concat(AppResources.Validating, "..."));
await _deviceActionService.ShowLoadingAsync(string.Concat(AppResources.Validating, "..."));
var response = await _authService.TokenPostTwoFactorAsync(_providerType.Value, token, RememberCell.On,
_email, _masterPasswordHash, _key);
_deviceActionService.HideLoading();
await _deviceActionService.HideLoadingAsync();
if(!response.Success)
{

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -151,14 +151,16 @@ namespace Bit.UWP.Services
}.Show();
}
public void ShowLoading(string text)
public Task ShowLoadingAsync(string text)
{
_userDialogs.ShowLoading(text, MaskType.Black);
return Task.FromResult(0);
}
public void HideLoading()
public Task HideLoadingAsync()
{
_userDialogs.HideLoading();
return Task.FromResult(0);
}
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);
}
public void HideLoading()
public Task HideLoadingAsync()
{
// do nothing
return Task.FromResult(0);
}
public Task LaunchAppAsync(string appName, Page page)
@ -83,9 +83,9 @@ namespace Bit.iOS.Core.Services
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)

View file

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