android back on main pages goes to vault first

This commit is contained in:
Kyle Spearrin 2018-01-08 11:33:51 -05:00
parent 8f77df4ebb
commit 3f1aab27d6
5 changed files with 691 additions and 643 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,31 +1,35 @@
using System;
using Bit.App.Controls;
using Bit.App.Controls;
using Xamarin.Forms;
namespace Bit.App.Pages
{
public class MainPage : ExtendedTabbedPage
{
private ExtendedNavigationPage _vaultPage;
public MainPage()
{
TintColor = Color.FromHex("3c8dbc");
var vaultNavigation = new ExtendedNavigationPage(new VaultListGroupingsPage());
var passwordGeneratorNavigation = new ExtendedNavigationPage(new ToolsPasswordGeneratorPage());
var toolsNavigation = new ExtendedNavigationPage(new ToolsPage());
var settingsNavigation = new ExtendedNavigationPage(new SettingsPage());
_vaultPage = new ExtendedNavigationPage(new VaultListGroupingsPage());
var passwordGeneratorNavigation = new ExtendedNavigationPage(new ToolsPasswordGeneratorPage(this));
var toolsNavigation = new ExtendedNavigationPage(new ToolsPage(this));
var settingsNavigation = new ExtendedNavigationPage(new SettingsPage(this));
vaultNavigation.Icon = "fa_lock.png";
_vaultPage.Icon = "fa_lock.png";
passwordGeneratorNavigation.Icon = "refresh.png";
toolsNavigation.Icon = "tools.png";
settingsNavigation.Icon = "cogs.png";
Children.Add(vaultNavigation);
Children.Add(_vaultPage);
Children.Add(passwordGeneratorNavigation);
Children.Add(toolsNavigation);
Children.Add(settingsNavigation);
}
SelectedItem = vaultNavigation;
public void ResetToVaultPage()
{
CurrentPage = _vaultPage;
}
}
}

View file

@ -20,11 +20,13 @@ namespace Bit.App.Pages
private readonly IDeviceActionService _deviceActionService;
private readonly IDeviceInfoService _deviceInfoService;
private readonly ILockService _lockService;
private readonly MainPage _mainPage;
// TODO: Model binding context?
public SettingsPage()
public SettingsPage(MainPage mainPage)
{
_mainPage = mainPage;
_authService = Resolver.Resolve<IAuthService>();
_settings = Resolver.Resolve<ISettings>();
_fingerprint = Resolver.Resolve<IFingerprint>();
@ -266,6 +268,17 @@ namespace Bit.App.Pages
}
}
protected override bool OnBackButtonPressed()
{
if(Device.RuntimePlatform == Device.Android && _mainPage != null)
{
_mainPage.ResetToVaultPage();
return true;
}
return base.OnBackButtonPressed();
}
private async void TwoStepCell_Tapped(object sender, EventArgs e)
{
var confirmed = await DisplayAlert(null, AppResources.TwoStepLoginConfirmation, AppResources.Yes,

View file

@ -13,9 +13,11 @@ namespace Bit.App.Pages
{
private readonly IGoogleAnalyticsService _googleAnalyticsService;
private readonly IDeviceInfoService _deviceInfoService;
private readonly MainPage _mainPage;
public ToolsPage()
public ToolsPage(MainPage mainPage)
{
_mainPage = mainPage;
_googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
_deviceInfoService = Resolver.Resolve<IDeviceInfoService>();
@ -113,6 +115,17 @@ namespace Bit.App.Pages
}
protected override bool OnBackButtonPressed()
{
if(Device.RuntimePlatform == Device.Android && _mainPage != null)
{
_mainPage.ResetToVaultPage();
return true;
}
return base.OnBackButtonPressed();
}
private void AutofillCell_Tapped(object sender, EventArgs e)
{
if(_deviceInfoService.AutofillServiceSupported)

View file

@ -18,6 +18,7 @@ namespace Bit.App.Pages
private readonly IGoogleAnalyticsService _googleAnalyticsService;
private readonly Action<string> _passwordValueAction;
private readonly bool _fromAutofill;
private readonly MainPage _mainPage;
public ToolsPasswordGeneratorPage(Action<string> passwordValueAction = null, bool fromAutofill = false)
{
@ -31,6 +32,12 @@ namespace Bit.App.Pages
Init();
}
public ToolsPasswordGeneratorPage(MainPage mainPage)
: this()
{
_mainPage = mainPage;
}
public PasswordGeneratorPageModel Model { get; private set; } = new PasswordGeneratorPageModel();
public Label Password { get; private set; }
public SliderViewCell SliderCell { get; private set; }
@ -253,6 +260,17 @@ namespace Bit.App.Pages
SliderCell.Dispose();
}
protected override bool OnBackButtonPressed()
{
if(Device.RuntimePlatform == Device.Android && _mainPage != null)
{
_mainPage.ResetToVaultPage();
return true;
}
return base.OnBackButtonPressed();
}
private void RegenerateCell_Tapped(object sender, EventArgs e)
{
Model.Password = _passwordGenerationService.GeneratePassword();