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);
|
||||
ObservableCollection<IRecentItem> GetAllFiles(bool removeIfNonExistant = true);
|
||||
void Add(IStorageItem file, string metadata);
|
||||
void ClearAll();
|
||||
}
|
||||
}
|
@@ -377,6 +377,13 @@
|
||||
<Page.BottomAppBar>
|
||||
<CommandBar x:Name="CommandBar" VerticalAlignment="Center">
|
||||
<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">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
|
@@ -27,6 +27,13 @@
|
||||
<Page.BottomAppBar>
|
||||
<CommandBar x:Name="CommandBar" VerticalAlignment="Center">
|
||||
<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">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
|
@@ -65,7 +65,6 @@
|
||||
Background="{ThemeResource AppBarBackgroundThemeBrush}"
|
||||
ItemsSource="{Binding Source={StaticResource MenuItemsSource}}"
|
||||
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
|
||||
IsSynchronizedWithCurrentItem="False"
|
||||
ItemContainerStyle="{StaticResource ListViewLeftIndicatorItemExpanded}">
|
||||
<controls:ListViewWithDisable.ItemTemplate>
|
||||
<DataTemplate>
|
||||
|
@@ -17,36 +17,53 @@
|
||||
<Page.DataContext>
|
||||
<viewModels:RecentVm/>
|
||||
</Page.DataContext>
|
||||
<ListView Background="{StaticResource ApplicationPageBackgroundThemeBrush}"
|
||||
ItemsSource="{Binding Source={StaticResource RecentItemsSource}}"
|
||||
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
|
||||
ItemContainerStyle="{StaticResource ListViewLeftIndicatorItemExpanded}">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Margin="10,0,10,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<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 Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<HyperlinkButton Grid.Row="0" HorizontalAlignment="Right">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<SymbolIcon Symbol="Cancel" />
|
||||
<TextBlock x:Uid="RecentClear" VerticalAlignment="Center" Margin="10,0,0,0" />
|
||||
</StackPanel>
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<core:CallMethodAction TargetObject="{Binding}" MethodName="ClearAll" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</HyperlinkButton>
|
||||
<ListView Grid.Row="1"
|
||||
ItemsSource="{Binding Source={StaticResource RecentItemsSource}}"
|
||||
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
|
||||
ItemContainerStyle="{StaticResource ListViewLeftIndicatorItemExpanded}">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Margin="10,0,10,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<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>
|
@@ -37,6 +37,11 @@ namespace ModernKeePass.Services
|
||||
_mru.Add(file, metadata);
|
||||
}
|
||||
|
||||
public void ClearAll()
|
||||
{
|
||||
_mru.Clear();
|
||||
}
|
||||
|
||||
public async Task<IStorageItem> GetFileAsync(string token)
|
||||
{
|
||||
return await _mru.GetFileAsync(token);
|
||||
|
@@ -228,6 +228,9 @@
|
||||
<data name="PasswordGeneratorUpper.Content" xml:space="preserve">
|
||||
<value>Upper case (A, B, C, ...)</value>
|
||||
</data>
|
||||
<data name="RecentClear.Text" xml:space="preserve">
|
||||
<value>Clear all</value>
|
||||
</data>
|
||||
<data name="SaveAsButton.Content" xml:space="preserve">
|
||||
<value>Save as...</value>
|
||||
</data>
|
||||
|
@@ -22,16 +22,6 @@ namespace ModernKeePass.ViewModels
|
||||
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 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
|
||||
{
|
||||
@@ -101,6 +91,16 @@ namespace ModernKeePass.ViewModels
|
||||
|
||||
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(IDatabase database, IResource resource)
|
||||
@@ -115,12 +115,17 @@ namespace ModernKeePass.ViewModels
|
||||
var error = string.Empty;
|
||||
try
|
||||
{
|
||||
_isOpening = true;
|
||||
Database.Open(CreateCompositeKey(), createNew);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
error = $"{_resource.GetResourceValue("CompositeKeyErrorOpen")}: {e.Message}";
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isOpening = false;
|
||||
}
|
||||
switch ((DatabaseService.DatabaseStatus)Database.Status)
|
||||
{
|
||||
case DatabaseService.DatabaseStatus.Opened:
|
||||
|
@@ -111,6 +111,8 @@ namespace ModernKeePass.ViewModels
|
||||
};
|
||||
// Auto-select the Recent Items menu item if the conditions are met
|
||||
SelectedItem = mainMenuItems.FirstOrDefault(m => m.IsSelected);
|
||||
|
||||
// Add currently opened database to the menu
|
||||
if (database != null && database.Status == (int) DatabaseService.DatabaseStatus.Opened)
|
||||
mainMenuItems.Add(new MainMenuItemVm
|
||||
{
|
||||
|
@@ -7,6 +7,7 @@ namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class RecentVm : NotifyPropertyChangedBase, IHasSelectableObject
|
||||
{
|
||||
private readonly IRecent _recent;
|
||||
private ISelectableModel _selectedItem;
|
||||
private ObservableCollection<IRecentItem> _recentItems = new ObservableCollection<IRecentItem>();
|
||||
|
||||
@@ -39,10 +40,16 @@ namespace ModernKeePass.ViewModels
|
||||
|
||||
public RecentVm(IRecent recent)
|
||||
{
|
||||
RecentItems = recent.GetAllFiles();
|
||||
_recent = recent;
|
||||
RecentItems = _recent.GetAllFiles();
|
||||
if (RecentItems.Count > 0)
|
||||
SelectedItem = RecentItems[0] as RecentItemVm;
|
||||
}
|
||||
|
||||
public void ClearAll()
|
||||
{
|
||||
_recent.ClearAll();
|
||||
RecentItems.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user