mirror of
https://github.com/bitwarden/mobile.git
synced 2024-12-23 16:27:51 +01:00
Remove android icon from nav bar. Persist selection for lock options.
This commit is contained in:
parent
3e14f4a19c
commit
83e872f4b6
@ -205,6 +205,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controls\ExtendedEditorRenderer.cs" />
|
||||
<Compile Include="Controls\ExtendedNavigationPage.cs" />
|
||||
<Compile Include="Controls\ExtendedSwitchCellRenderer.cs" />
|
||||
<Compile Include="Controls\ExtendedViewCellRenderer.cs" />
|
||||
<Compile Include="Controls\ExtendedTextCellRenderer.cs" />
|
||||
|
27
src/Android/Controls/ExtendedNavigationPage.cs
Normal file
27
src/Android/Controls/ExtendedNavigationPage.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using Android.App;
|
||||
using Android.Graphics.Drawables;
|
||||
using Bit.Android.Controls;
|
||||
using Bit.App.Controls;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.Android;
|
||||
|
||||
[assembly: ExportRenderer(typeof(ExtendedNavigationPage), typeof(ExtendedNavigationRenderer))]
|
||||
namespace Bit.Android.Controls
|
||||
{
|
||||
public class ExtendedNavigationRenderer : NavigationRenderer
|
||||
{
|
||||
protected override void OnElementChanged(ElementChangedEventArgs<NavigationPage> e)
|
||||
{
|
||||
base.OnElementChanged(e);
|
||||
|
||||
RemoveAppIconFromActionBar();
|
||||
}
|
||||
|
||||
private void RemoveAppIconFromActionBar()
|
||||
{
|
||||
// ref: http://stackoverflow.com/questions/14606294/remove-icon-logo-from-action-bar-on-android
|
||||
var actionBar = ((Activity)Context).ActionBar;
|
||||
actionBar.SetIcon(new ColorDrawable(Color.Transparent.ToAndroid()));
|
||||
}
|
||||
}
|
||||
}
|
@ -53,9 +53,9 @@ namespace Bit.App.Pages
|
||||
LockOptionsCell = new ExtendedTextCell
|
||||
{
|
||||
Text = "Lock Options",
|
||||
// TODO: Set detail based on setting
|
||||
Detail = "Immediately",
|
||||
ShowDisclousure = true
|
||||
Detail = GetLockOptionsDetailsText(),
|
||||
ShowDisclousure = true,
|
||||
TextColor = Color.FromHex("333333")
|
||||
};
|
||||
LockOptionsCell.Tapped += LockOptionsCell_Tapped;
|
||||
|
||||
@ -125,7 +125,12 @@ namespace Bit.App.Pages
|
||||
private async void LockOptionsCell_Tapped(object sender, EventArgs e)
|
||||
{
|
||||
var selection = await DisplayActionSheet("Lock Options", AppResources.Cancel, null,
|
||||
"Immediately", "1 minute", "3 minutes", "15 minutes", "1 hour", "8 hours", "24 hours", "Never");
|
||||
"Immediately", "1 minute", "15 minutes", "1 hour", "4 hours", "Never");
|
||||
|
||||
if(selection == AppResources.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(selection == "Immediately")
|
||||
{
|
||||
@ -135,10 +140,24 @@ namespace Bit.App.Pages
|
||||
{
|
||||
_settings.AddOrUpdateValue(Constants.SettingLockSeconds, 60);
|
||||
}
|
||||
// TODO: others
|
||||
else
|
||||
else if(selection == "5 minutes")
|
||||
{
|
||||
_settings.AddOrUpdateValue(Constants.SettingLockSeconds, 60 * 5);
|
||||
}
|
||||
else if(selection == "15 minutes")
|
||||
{
|
||||
_settings.AddOrUpdateValue(Constants.SettingLockSeconds, 60 * 15);
|
||||
}
|
||||
else if(selection == "1 hour")
|
||||
{
|
||||
_settings.AddOrUpdateValue(Constants.SettingLockSeconds, 60 * 60);
|
||||
}
|
||||
else if(selection == "4 hours")
|
||||
{
|
||||
_settings.AddOrUpdateValue(Constants.SettingLockSeconds, 60 * 60 * 4);
|
||||
}
|
||||
else if(selection == "Never")
|
||||
{
|
||||
// Never lock
|
||||
_settings.Remove(Constants.SettingLockSeconds);
|
||||
}
|
||||
|
||||
@ -208,5 +227,39 @@ namespace Bit.App.Pages
|
||||
{
|
||||
Navigation.PushAsync(new SettingsListFoldersPage());
|
||||
}
|
||||
|
||||
private string GetLockOptionsDetailsText()
|
||||
{
|
||||
var lockSeconds = _settings.GetValueOrDefault<int?>(Constants.SettingLockSeconds);
|
||||
if(!lockSeconds.HasValue)
|
||||
{
|
||||
return "Never";
|
||||
}
|
||||
|
||||
if(lockSeconds.Value == 60)
|
||||
{
|
||||
return "1 minute";
|
||||
}
|
||||
else if(lockSeconds.Value == 60 * 5)
|
||||
{
|
||||
return "5 minutes";
|
||||
}
|
||||
else if(lockSeconds.Value == 60 * 15)
|
||||
{
|
||||
return "15 minutes";
|
||||
}
|
||||
else if(lockSeconds.Value == 60 * 60)
|
||||
{
|
||||
return "1 hour";
|
||||
}
|
||||
else if(lockSeconds.Value == 60 * 60 * 4)
|
||||
{
|
||||
return "4 hours";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Immediately";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user