mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-26 12:16:07 +01:00
adjust toolbar after loading completes
This commit is contained in:
parent
bc0bb7c7bb
commit
c7938a8630
@ -6,6 +6,7 @@ using Bit.Core.Abstractions;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Utilities;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
@ -126,65 +127,15 @@ namespace Bit.App.Pages
|
||||
if(!success)
|
||||
{
|
||||
await Navigation.PopModalAsync();
|
||||
return;
|
||||
}
|
||||
else if(!_vm.EditMode && string.IsNullOrWhiteSpace(_vm.Cipher.Name))
|
||||
AdjustToolbar();
|
||||
await ShowAlertsAsync();
|
||||
if(!_vm.EditMode && string.IsNullOrWhiteSpace(_vm.Cipher?.Name))
|
||||
{
|
||||
RequestFocus(_nameEntry);
|
||||
}
|
||||
});
|
||||
if(_vm.EditMode && Device.RuntimePlatform == Device.Android)
|
||||
{
|
||||
if(_vm.Cipher.OrganizationId == null)
|
||||
{
|
||||
if(ToolbarItems.Contains(_collectionsItem))
|
||||
{
|
||||
ToolbarItems.Remove(_collectionsItem);
|
||||
}
|
||||
if(!ToolbarItems.Contains(_shareItem))
|
||||
{
|
||||
ToolbarItems.Insert(2, _shareItem);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ToolbarItems.Contains(_shareItem))
|
||||
{
|
||||
ToolbarItems.Remove(_shareItem);
|
||||
}
|
||||
if(!ToolbarItems.Contains(_collectionsItem))
|
||||
{
|
||||
ToolbarItems.Insert(2, _collectionsItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!_vm.EditMode)
|
||||
{
|
||||
var addLoginShown = await _storageService.GetAsync<bool?>(Constants.AddSitePromptShownKey);
|
||||
if(_vm.Cipher.Type == CipherType.Login && !_fromAutofill && !addLoginShown.GetValueOrDefault())
|
||||
{
|
||||
await _storageService.SaveAsync(Constants.AddSitePromptShownKey, true);
|
||||
if(Device.RuntimePlatform == Device.iOS)
|
||||
{
|
||||
if(_deviceActionService.SystemMajorVersion() < 12)
|
||||
{
|
||||
await DisplayAlert(AppResources.BitwardenAppExtension,
|
||||
AppResources.BitwardenAppExtensionAlert2, AppResources.Ok);
|
||||
}
|
||||
else
|
||||
{
|
||||
await DisplayAlert(AppResources.PasswordAutofill,
|
||||
AppResources.BitwardenAutofillAlert2, AppResources.Ok);
|
||||
}
|
||||
}
|
||||
else if(Device.RuntimePlatform == Device.Android &&
|
||||
!_deviceActionService.AutofillAccessibilityServiceRunning() &&
|
||||
!_deviceActionService.AutofillServiceEnabled())
|
||||
{
|
||||
await DisplayAlert(AppResources.BitwardenAutofillService,
|
||||
AppResources.BitwardenAutofillServiceAlert2, AppResources.Ok);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDisappearing()
|
||||
@ -281,5 +232,74 @@ namespace Bit.App.Pages
|
||||
await Navigation.PushModalAsync(new NavigationPage(page));
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ShowAlertsAsync()
|
||||
{
|
||||
if(!_vm.EditMode)
|
||||
{
|
||||
if(_vm.Cipher == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var addLoginShown = await _storageService.GetAsync<bool?>(Constants.AddSitePromptShownKey);
|
||||
if(_vm.Cipher.Type == CipherType.Login && !_fromAutofill && !addLoginShown.GetValueOrDefault())
|
||||
{
|
||||
await _storageService.SaveAsync(Constants.AddSitePromptShownKey, true);
|
||||
if(Device.RuntimePlatform == Device.iOS)
|
||||
{
|
||||
if(_deviceActionService.SystemMajorVersion() < 12)
|
||||
{
|
||||
await DisplayAlert(AppResources.BitwardenAppExtension,
|
||||
AppResources.BitwardenAppExtensionAlert2, AppResources.Ok);
|
||||
}
|
||||
else
|
||||
{
|
||||
await DisplayAlert(AppResources.PasswordAutofill,
|
||||
AppResources.BitwardenAutofillAlert2, AppResources.Ok);
|
||||
}
|
||||
}
|
||||
else if(Device.RuntimePlatform == Device.Android &&
|
||||
!_deviceActionService.AutofillAccessibilityServiceRunning() &&
|
||||
!_deviceActionService.AutofillServiceEnabled())
|
||||
{
|
||||
await DisplayAlert(AppResources.BitwardenAutofillService,
|
||||
AppResources.BitwardenAutofillServiceAlert2, AppResources.Ok);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AdjustToolbar()
|
||||
{
|
||||
if(_vm.EditMode && Device.RuntimePlatform == Device.Android)
|
||||
{
|
||||
if(_vm.Cipher == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(_vm.Cipher.OrganizationId == null)
|
||||
{
|
||||
if(ToolbarItems.Contains(_collectionsItem))
|
||||
{
|
||||
ToolbarItems.Remove(_collectionsItem);
|
||||
}
|
||||
if(!ToolbarItems.Contains(_shareItem))
|
||||
{
|
||||
ToolbarItems.Insert(2, _shareItem);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ToolbarItems.Contains(_shareItem))
|
||||
{
|
||||
ToolbarItems.Remove(_shareItem);
|
||||
}
|
||||
if(!ToolbarItems.Contains(_collectionsItem))
|
||||
{
|
||||
ToolbarItems.Insert(2, _collectionsItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,13 +54,12 @@ namespace Bit.App.Pages
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
IsBusy = false;
|
||||
var data = message.Data as Dictionary<string, object>;
|
||||
if(data.ContainsKey("successfully"))
|
||||
if(message.Data is Dictionary<string, object> data && data.ContainsKey("successfully"))
|
||||
{
|
||||
var success = data["successfully"] as bool?;
|
||||
if(success.HasValue && success.Value)
|
||||
if(success.GetValueOrDefault())
|
||||
{
|
||||
var task = _vm.LoadAsync();
|
||||
var task = _vm.LoadAsync(() => AdjustToolbar());
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -68,37 +67,12 @@ namespace Bit.App.Pages
|
||||
});
|
||||
await LoadOnAppearedAsync(_scrollView, true, async () =>
|
||||
{
|
||||
var success = await _vm.LoadAsync();
|
||||
var success = await _vm.LoadAsync(() => AdjustToolbar());
|
||||
if(!success)
|
||||
{
|
||||
await Navigation.PopModalAsync();
|
||||
}
|
||||
}, _mainContent);
|
||||
if(Device.RuntimePlatform == Device.Android)
|
||||
{
|
||||
if(_vm.Cipher.OrganizationId == null)
|
||||
{
|
||||
if(ToolbarItems.Contains(_collectionsItem))
|
||||
{
|
||||
ToolbarItems.Remove(_collectionsItem);
|
||||
}
|
||||
if(!ToolbarItems.Contains(_shareItem))
|
||||
{
|
||||
ToolbarItems.Insert(1, _shareItem);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ToolbarItems.Contains(_shareItem))
|
||||
{
|
||||
ToolbarItems.Remove(_shareItem);
|
||||
}
|
||||
if(!ToolbarItems.Contains(_collectionsItem))
|
||||
{
|
||||
ToolbarItems.Insert(1, _collectionsItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDisappearing()
|
||||
@ -167,5 +141,38 @@ namespace Bit.App.Pages
|
||||
await Navigation.PushModalAsync(new NavigationPage(page));
|
||||
}
|
||||
}
|
||||
|
||||
private void AdjustToolbar()
|
||||
{
|
||||
if(Device.RuntimePlatform == Device.Android)
|
||||
{
|
||||
if(_vm.Cipher == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(_vm.Cipher.OrganizationId == null)
|
||||
{
|
||||
if(ToolbarItems.Contains(_collectionsItem))
|
||||
{
|
||||
ToolbarItems.Remove(_collectionsItem);
|
||||
}
|
||||
if(!ToolbarItems.Contains(_shareItem))
|
||||
{
|
||||
ToolbarItems.Insert(1, _shareItem);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ToolbarItems.Contains(_shareItem))
|
||||
{
|
||||
ToolbarItems.Remove(_shareItem);
|
||||
}
|
||||
if(!ToolbarItems.Contains(_collectionsItem))
|
||||
{
|
||||
ToolbarItems.Insert(1, _collectionsItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,12 +206,13 @@ namespace Bit.App.Pages
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> LoadAsync()
|
||||
public async Task<bool> LoadAsync(Action finishedLoadingAction = null)
|
||||
{
|
||||
CleanUp();
|
||||
var cipher = await _cipherService.GetAsync(CipherId);
|
||||
if(cipher == null)
|
||||
{
|
||||
finishedLoadingAction?.Invoke();
|
||||
return false;
|
||||
}
|
||||
Cipher = await cipher.DecryptAsync();
|
||||
@ -235,6 +236,7 @@ namespace Bit.App.Pages
|
||||
return true;
|
||||
});
|
||||
}
|
||||
finishedLoadingAction?.Invoke();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user