Added option not to remember recently opened files

This commit is contained in:
Philipp Crocoll 2013-07-24 20:32:39 +02:00
parent 57506336c1
commit 4294791d76
6 changed files with 680 additions and 634 deletions

File diff suppressed because it is too large Load Diff

View File

@ -42,6 +42,7 @@
<string name="timeout_key">timeout_key</string>
<string name="TanExpiresOnUse_key">TanExpiresOnUse_key</string>
<string name="ShowUsernameInList_key">ShowUsernameInList_key</string>
<string name="RememberRecentFiles_key">RememberRecentFiles_key</string>
<string name="default_username_key">defaultUsername</string>
<string name="database_name_key">databaseName</string>
<string name="BinaryDirectory_key">binaryDirectory</string>
@ -53,6 +54,8 @@
<bool name="TanExpiresOnUse_default">true</bool>
<bool name="ShowUsernameInList_default">true</bool>
<bool name="RememberRecentFiles_default">true</bool>
<string name="QuickUnlockDefaultEnabled_key">Enable_QuickUnlock_by_default</string>
<string name="QuickUnlockLength_key">QuickUnlockLength</string>
<string name="QuickUnlockLength_default">3</string>

View File

@ -179,7 +179,10 @@
<string name="TanExpiresOnUse_summary">Mark TAN entries expired when using them</string>
<string name="ShowUsernameInList_title">Display username in list</string>
<string name="ShowUsernameInList_summary">Display usernames below entry titles. Useful for multiple accounts or TANs.</string>
<string name="kp2a_findUrl">Keepass2Android: Find password</string>
<string name="RememberRecentFiles_title">Remember databases</string>
<string name="RememberRecentFiles_summary">Remember recently opened databases and show them in the Open database screen.</string>
<string name="kp2a_findUrl">Keepass2Android: Find password</string>
<string name="excludeExpiredEntries">Exclude expired entries</string>
<string name="search_options">Options</string>
<string name="caseSensitive">Case sensitive</string>

View File

@ -149,6 +149,12 @@
android:defaultValue="true"
android:title="@string/UseFileTransactions_title"
android:key="@string/UseFileTransactions_key" />
<CheckBoxPreference
android:key="@string/RememberRecentFiles_key"
android:title="@string/RememberRecentFiles_title"
android:summary="@string/RememberRecentFiles_summary"
android:defaultValue="@bool/RememberRecentFiles_default"/>
<CheckBoxPreference
android:enabled="true"
android:persistent="true"

View File

@ -180,6 +180,10 @@ namespace keepass2android
public void DeleteFile(String filename) {
mDb.Delete(FileTable, KeyFileFilename + " = ?", new[] {filename});
}
public void DeleteAll()
{
mDb.Delete(FileTable, null, null);
}
static string[] GetColumnList()
{

View File

@ -19,6 +19,7 @@ using System;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Preferences;
using Android.Runtime;
using Android.Views;
using Android.Widget;
@ -211,7 +212,7 @@ namespace keepass2android
_DbHelper = App.Kp2a.FileDbHelper;
if (_DbHelper.HasRecentFiles())
if (ShowRecentFiles())
{
_recentMode = true;
@ -283,6 +284,21 @@ namespace keepass2android
}
private bool ShowRecentFiles()
{
if (!RememberRecentFiles())
{
_DbHelper.DeleteAll();
}
return _DbHelper.HasRecentFiles();
}
private bool RememberRecentFiles()
{
return PreferenceManager.GetDefaultSharedPreferences(this).GetBoolean(GetString(Resource.String.RememberRecentFiles_key), Resources.GetBoolean(Resource.Boolean.RememberRecentFiles_default));
}
protected override void OnSaveInstanceState(Bundle outState)
{
@ -303,12 +319,14 @@ namespace keepass2android
public override void Run() {
if (Success) {
// Add to recent files
FileDbHelper dbHelper = App.Kp2a.FileDbHelper;
//TODO: getFilename always returns "" -> bug?
dbHelper.CreateFile(_ioc, Filename);
if (_activity.RememberRecentFiles())
{
// Add to recent files
FileDbHelper dbHelper = App.Kp2a.FileDbHelper;
//TODO: getFilename always returns "" -> bug?
dbHelper.CreateFile(_ioc, Filename);
}
GroupActivity.Launch(_activity, _activity.AppTask);
} else {
@ -333,8 +351,8 @@ namespace keepass2android
}
private void FillData() {
private void FillData()
{
// Get all of the rows from the database and create the item list
Android.Database.ICursor filesCursor = _DbHelper.FetchAllFiles();
StartManagingCursor(filesCursor);
@ -460,7 +478,7 @@ namespace keepass2android
Kp2aLog.Log("FileSelect.OnResume");
// Check to see if we need to change modes
if (_DbHelper.HasRecentFiles() != _recentMode)
if (ShowRecentFiles() != _recentMode)
{
// Restart the activity
Intent intent = Intent;