mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
New clear all button in recent pages
First-time open of app correctly shows Welcome page New Home button in group and entry pages
This commit is contained in:
@@ -10,5 +10,6 @@ namespace ModernKeePass.Interfaces
|
|||||||
Task<IStorageItem> GetFileAsync(string token);
|
Task<IStorageItem> GetFileAsync(string token);
|
||||||
ObservableCollection<IRecentItem> GetAllFiles(bool removeIfNonExistant = true);
|
ObservableCollection<IRecentItem> GetAllFiles(bool removeIfNonExistant = true);
|
||||||
void Add(IStorageItem file, string metadata);
|
void Add(IStorageItem file, string metadata);
|
||||||
|
void ClearAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -377,6 +377,13 @@
|
|||||||
<Page.BottomAppBar>
|
<Page.BottomAppBar>
|
||||||
<CommandBar x:Name="CommandBar" VerticalAlignment="Center">
|
<CommandBar x:Name="CommandBar" VerticalAlignment="Center">
|
||||||
<CommandBar.SecondaryCommands>
|
<CommandBar.SecondaryCommands>
|
||||||
|
<AppBarButton Icon="Home" Label="Home">
|
||||||
|
<interactivity:Interaction.Behaviors>
|
||||||
|
<core:EventTriggerBehavior EventName="Click">
|
||||||
|
<core:NavigateToPageAction TargetPage="ModernKeePass.Pages.MainPage" />
|
||||||
|
</core:EventTriggerBehavior>
|
||||||
|
</interactivity:Interaction.Behaviors>
|
||||||
|
</AppBarButton>
|
||||||
<AppBarButton Icon="Save" Label="Save">
|
<AppBarButton Icon="Save" Label="Save">
|
||||||
<interactivity:Interaction.Behaviors>
|
<interactivity:Interaction.Behaviors>
|
||||||
<core:EventTriggerBehavior EventName="Click">
|
<core:EventTriggerBehavior EventName="Click">
|
||||||
|
@@ -27,6 +27,13 @@
|
|||||||
<Page.BottomAppBar>
|
<Page.BottomAppBar>
|
||||||
<CommandBar x:Name="CommandBar" VerticalAlignment="Center">
|
<CommandBar x:Name="CommandBar" VerticalAlignment="Center">
|
||||||
<CommandBar.SecondaryCommands>
|
<CommandBar.SecondaryCommands>
|
||||||
|
<AppBarButton Icon="Home" Label="Home">
|
||||||
|
<interactivity:Interaction.Behaviors>
|
||||||
|
<core:EventTriggerBehavior EventName="Click">
|
||||||
|
<core:NavigateToPageAction TargetPage="ModernKeePass.Pages.MainPage" />
|
||||||
|
</core:EventTriggerBehavior>
|
||||||
|
</interactivity:Interaction.Behaviors>
|
||||||
|
</AppBarButton>
|
||||||
<AppBarButton Icon="Save" Label="Save">
|
<AppBarButton Icon="Save" Label="Save">
|
||||||
<interactivity:Interaction.Behaviors>
|
<interactivity:Interaction.Behaviors>
|
||||||
<core:EventTriggerBehavior EventName="Click">
|
<core:EventTriggerBehavior EventName="Click">
|
||||||
|
@@ -65,7 +65,6 @@
|
|||||||
Background="{ThemeResource AppBarBackgroundThemeBrush}"
|
Background="{ThemeResource AppBarBackgroundThemeBrush}"
|
||||||
ItemsSource="{Binding Source={StaticResource MenuItemsSource}}"
|
ItemsSource="{Binding Source={StaticResource MenuItemsSource}}"
|
||||||
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
|
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
|
||||||
IsSynchronizedWithCurrentItem="False"
|
|
||||||
ItemContainerStyle="{StaticResource ListViewLeftIndicatorItemExpanded}">
|
ItemContainerStyle="{StaticResource ListViewLeftIndicatorItemExpanded}">
|
||||||
<controls:ListViewWithDisable.ItemTemplate>
|
<controls:ListViewWithDisable.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
|
@@ -17,36 +17,53 @@
|
|||||||
<Page.DataContext>
|
<Page.DataContext>
|
||||||
<viewModels:RecentVm/>
|
<viewModels:RecentVm/>
|
||||||
</Page.DataContext>
|
</Page.DataContext>
|
||||||
<ListView Background="{StaticResource ApplicationPageBackgroundThemeBrush}"
|
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
|
||||||
ItemsSource="{Binding Source={StaticResource RecentItemsSource}}"
|
<Grid.RowDefinitions>
|
||||||
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
|
<RowDefinition Height="40" />
|
||||||
ItemContainerStyle="{StaticResource ListViewLeftIndicatorItemExpanded}">
|
<RowDefinition Height="*" />
|
||||||
<ListView.ItemTemplate>
|
</Grid.RowDefinitions>
|
||||||
<DataTemplate>
|
<HyperlinkButton Grid.Row="0" HorizontalAlignment="Right">
|
||||||
<Grid Margin="10,0,10,0">
|
<StackPanel Orientation="Horizontal">
|
||||||
<Grid.RowDefinitions>
|
<SymbolIcon Symbol="Cancel" />
|
||||||
<RowDefinition />
|
<TextBlock x:Uid="RecentClear" VerticalAlignment="Center" Margin="10,0,0,0" />
|
||||||
<RowDefinition />
|
</StackPanel>
|
||||||
<RowDefinition />
|
<interactivity:Interaction.Behaviors>
|
||||||
</Grid.RowDefinitions>
|
<core:EventTriggerBehavior EventName="Click">
|
||||||
<Grid.ColumnDefinitions>
|
<core:CallMethodAction TargetObject="{Binding}" MethodName="ClearAll" />
|
||||||
<ColumnDefinition Width="*"/>
|
</core:EventTriggerBehavior>
|
||||||
</Grid.ColumnDefinitions>
|
</interactivity:Interaction.Behaviors>
|
||||||
<TextBlock Grid.Row="0" Text="{Binding Name}" Padding="5,0,0,0" />
|
</HyperlinkButton>
|
||||||
<TextBlock Grid.Row="1" Text="{Binding Path}" Padding="5,0,0,0" FontSize="10" />
|
<ListView Grid.Row="1"
|
||||||
<local:CompositeKeyUserControl Grid.Row="2" x:Name="DatabaseUserControl" HorizontalAlignment="Stretch" MinWidth="400" Margin="0,10,0,0" Visibility="{Binding IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}" ButtonLabel="Open">
|
ItemsSource="{Binding Source={StaticResource RecentItemsSource}}"
|
||||||
<interactivity:Interaction.Behaviors>
|
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
|
||||||
<core:EventTriggerBehavior EventName="ValidationChecking">
|
ItemContainerStyle="{StaticResource ListViewLeftIndicatorItemExpanded}">
|
||||||
<core:CallMethodAction TargetObject="{Binding}" MethodName="OpenDatabaseFile" />
|
<ListView.ItemTemplate>
|
||||||
</core:EventTriggerBehavior>
|
<DataTemplate>
|
||||||
<core:EventTriggerBehavior EventName="ValidationChecked">
|
<Grid Margin="10,0,10,0">
|
||||||
<core:CallMethodAction TargetObject="{Binding}" MethodName="UpdateAccessTime" />
|
<Grid.RowDefinitions>
|
||||||
<core:NavigateToPageAction TargetPage="ModernKeePass.Pages.GroupDetailPage" />
|
<RowDefinition />
|
||||||
</core:EventTriggerBehavior>
|
<RowDefinition />
|
||||||
</interactivity:Interaction.Behaviors>
|
<RowDefinition />
|
||||||
</local:CompositeKeyUserControl>
|
</Grid.RowDefinitions>
|
||||||
</Grid>
|
<Grid.ColumnDefinitions>
|
||||||
</DataTemplate>
|
<ColumnDefinition Width="*"/>
|
||||||
</ListView.ItemTemplate>
|
</Grid.ColumnDefinitions>
|
||||||
</ListView>
|
<TextBlock Grid.Row="0" Text="{Binding Name}" Padding="5,0,0,0" />
|
||||||
|
<TextBlock Grid.Row="1" Text="{Binding Path}" Padding="5,0,0,0" FontSize="10" />
|
||||||
|
<local:CompositeKeyUserControl Grid.Row="2" x:Name="DatabaseUserControl" HorizontalAlignment="Stretch" MinWidth="400" Margin="0,10,0,0" Visibility="{Binding IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}" ButtonLabel="Open">
|
||||||
|
<interactivity:Interaction.Behaviors>
|
||||||
|
<core:EventTriggerBehavior EventName="ValidationChecking">
|
||||||
|
<core:CallMethodAction TargetObject="{Binding}" MethodName="OpenDatabaseFile" />
|
||||||
|
</core:EventTriggerBehavior>
|
||||||
|
<core:EventTriggerBehavior EventName="ValidationChecked">
|
||||||
|
<core:CallMethodAction TargetObject="{Binding}" MethodName="UpdateAccessTime" />
|
||||||
|
<core:NavigateToPageAction TargetPage="ModernKeePass.Pages.GroupDetailPage" />
|
||||||
|
</core:EventTriggerBehavior>
|
||||||
|
</interactivity:Interaction.Behaviors>
|
||||||
|
</local:CompositeKeyUserControl>
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListView.ItemTemplate>
|
||||||
|
</ListView>
|
||||||
|
</Grid>
|
||||||
</Page>
|
</Page>
|
@@ -37,6 +37,11 @@ namespace ModernKeePass.Services
|
|||||||
_mru.Add(file, metadata);
|
_mru.Add(file, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ClearAll()
|
||||||
|
{
|
||||||
|
_mru.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IStorageItem> GetFileAsync(string token)
|
public async Task<IStorageItem> GetFileAsync(string token)
|
||||||
{
|
{
|
||||||
return await _mru.GetFileAsync(token);
|
return await _mru.GetFileAsync(token);
|
||||||
|
@@ -228,6 +228,9 @@
|
|||||||
<data name="PasswordGeneratorUpper.Content" xml:space="preserve">
|
<data name="PasswordGeneratorUpper.Content" xml:space="preserve">
|
||||||
<value>Upper case (A, B, C, ...)</value>
|
<value>Upper case (A, B, C, ...)</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="RecentClear.Text" xml:space="preserve">
|
||||||
|
<value>Clear all</value>
|
||||||
|
</data>
|
||||||
<data name="SaveAsButton.Content" xml:space="preserve">
|
<data name="SaveAsButton.Content" xml:space="preserve">
|
||||||
<value>Save as...</value>
|
<value>Save as...</value>
|
||||||
</data>
|
</data>
|
||||||
|
@@ -22,16 +22,6 @@ namespace ModernKeePass.ViewModels
|
|||||||
Success = 5
|
Success = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
//private readonly App _app = Application.Current as App;
|
|
||||||
private bool _hasPassword;
|
|
||||||
private bool _hasKeyFile;
|
|
||||||
private string _password = string.Empty;
|
|
||||||
private string _status;
|
|
||||||
private StatusTypes _statusType;
|
|
||||||
private StorageFile _keyFile;
|
|
||||||
private string _keyFileText;
|
|
||||||
private readonly IResource _resource;
|
|
||||||
|
|
||||||
public IDatabase Database { get; set; }
|
public IDatabase Database { get; set; }
|
||||||
|
|
||||||
public bool HasPassword
|
public bool HasPassword
|
||||||
@@ -54,7 +44,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsValid => HasPassword || HasKeyFile && KeyFile != null;
|
public bool IsValid => !_isOpening && (HasPassword || HasKeyFile && KeyFile != null);
|
||||||
|
|
||||||
public string Status
|
public string Status
|
||||||
{
|
{
|
||||||
@@ -101,6 +91,16 @@ namespace ModernKeePass.ViewModels
|
|||||||
|
|
||||||
public double PasswordComplexityIndicator => QualityEstimation.EstimatePasswordBits(Password?.ToCharArray());
|
public double PasswordComplexityIndicator => QualityEstimation.EstimatePasswordBits(Password?.ToCharArray());
|
||||||
|
|
||||||
|
private bool _hasPassword;
|
||||||
|
private bool _hasKeyFile;
|
||||||
|
private bool _isOpening;
|
||||||
|
private string _password = string.Empty;
|
||||||
|
private string _status;
|
||||||
|
private StatusTypes _statusType;
|
||||||
|
private StorageFile _keyFile;
|
||||||
|
private string _keyFileText;
|
||||||
|
private readonly IResource _resource;
|
||||||
|
|
||||||
public CompositeKeyVm() : this((Application.Current as App)?.Database, new ResourcesService()) { }
|
public CompositeKeyVm() : this((Application.Current as App)?.Database, new ResourcesService()) { }
|
||||||
|
|
||||||
public CompositeKeyVm(IDatabase database, IResource resource)
|
public CompositeKeyVm(IDatabase database, IResource resource)
|
||||||
@@ -115,12 +115,17 @@ namespace ModernKeePass.ViewModels
|
|||||||
var error = string.Empty;
|
var error = string.Empty;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
_isOpening = true;
|
||||||
Database.Open(CreateCompositeKey(), createNew);
|
Database.Open(CreateCompositeKey(), createNew);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
error = $"{_resource.GetResourceValue("CompositeKeyErrorOpen")}: {e.Message}";
|
error = $"{_resource.GetResourceValue("CompositeKeyErrorOpen")}: {e.Message}";
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_isOpening = false;
|
||||||
|
}
|
||||||
switch ((DatabaseService.DatabaseStatus)Database.Status)
|
switch ((DatabaseService.DatabaseStatus)Database.Status)
|
||||||
{
|
{
|
||||||
case DatabaseService.DatabaseStatus.Opened:
|
case DatabaseService.DatabaseStatus.Opened:
|
||||||
|
@@ -111,6 +111,8 @@ namespace ModernKeePass.ViewModels
|
|||||||
};
|
};
|
||||||
// Auto-select the Recent Items menu item if the conditions are met
|
// Auto-select the Recent Items menu item if the conditions are met
|
||||||
SelectedItem = mainMenuItems.FirstOrDefault(m => m.IsSelected);
|
SelectedItem = mainMenuItems.FirstOrDefault(m => m.IsSelected);
|
||||||
|
|
||||||
|
// Add currently opened database to the menu
|
||||||
if (database != null && database.Status == (int) DatabaseService.DatabaseStatus.Opened)
|
if (database != null && database.Status == (int) DatabaseService.DatabaseStatus.Opened)
|
||||||
mainMenuItems.Add(new MainMenuItemVm
|
mainMenuItems.Add(new MainMenuItemVm
|
||||||
{
|
{
|
||||||
|
@@ -7,6 +7,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
{
|
{
|
||||||
public class RecentVm : NotifyPropertyChangedBase, IHasSelectableObject
|
public class RecentVm : NotifyPropertyChangedBase, IHasSelectableObject
|
||||||
{
|
{
|
||||||
|
private readonly IRecent _recent;
|
||||||
private ISelectableModel _selectedItem;
|
private ISelectableModel _selectedItem;
|
||||||
private ObservableCollection<IRecentItem> _recentItems = new ObservableCollection<IRecentItem>();
|
private ObservableCollection<IRecentItem> _recentItems = new ObservableCollection<IRecentItem>();
|
||||||
|
|
||||||
@@ -39,10 +40,16 @@ namespace ModernKeePass.ViewModels
|
|||||||
|
|
||||||
public RecentVm(IRecent recent)
|
public RecentVm(IRecent recent)
|
||||||
{
|
{
|
||||||
RecentItems = recent.GetAllFiles();
|
_recent = recent;
|
||||||
|
RecentItems = _recent.GetAllFiles();
|
||||||
if (RecentItems.Count > 0)
|
if (RecentItems.Count > 0)
|
||||||
SelectedItem = RecentItems[0] as RecentItemVm;
|
SelectedItem = RecentItems[0] as RecentItemVm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ClearAll()
|
||||||
|
{
|
||||||
|
_recent.ClearAll();
|
||||||
|
RecentItems.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user