added option to disable "clear password on leave" (eg. for switching between KP2A and Google Authenticator)

directly load db when enter key is pressed
This commit is contained in:
Philipp Crocoll 2015-02-17 06:05:48 +01:00
parent 99a56f8e52
commit 95f5524425
6 changed files with 85 additions and 18 deletions

View File

@ -35,6 +35,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MasterKeePlugin", "MasterKe
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlayServicesTest", "PlayServicesTest\PlayServicesTest.csproj", "{B8E78075-3936-42E9-9AB4-C82B341935A6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App1", "App1\App1.csproj", "{A29ECF2C-3313-4F93-8B78-DC3F1319E835}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -378,6 +380,30 @@ Global
{B8E78075-3936-42E9-9AB4-C82B341935A6}.ReleaseNoNet|Win32.Build.0 = Release|Any CPU
{B8E78075-3936-42E9-9AB4-C82B341935A6}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU
{B8E78075-3936-42E9-9AB4-C82B341935A6}.ReleaseNoNet|x64.Build.0 = Release|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.Debug|Mixed Platforms.Deploy.0 = Debug|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.Debug|Win32.ActiveCfg = Debug|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.Debug|x64.ActiveCfg = Debug|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.Release|Any CPU.Build.0 = Release|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.Release|Any CPU.Deploy.0 = Release|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.Release|Mixed Platforms.Deploy.0 = Release|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.Release|Win32.ActiveCfg = Release|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.Release|x64.ActiveCfg = Release|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.ReleaseNoNet|Any CPU.Deploy.0 = Release|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.ReleaseNoNet|Mixed Platforms.ActiveCfg = Release|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.ReleaseNoNet|Mixed Platforms.Build.0 = Release|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.ReleaseNoNet|Mixed Platforms.Deploy.0 = Release|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
{A29ECF2C-3313-4F93-8B78-DC3F1319E835}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -28,6 +28,7 @@ using Android.Graphics.Drawables;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Views.InputMethods;
using Android.Widget;
using Java.Net;
using Android.Preferences;
@ -638,6 +639,11 @@ namespace keepass2android
_password = FindViewById<EditText>(Resource.Id.password).Text;
UpdateOkButtonState();
};
FindViewById<EditText>(Resource.Id.password).EditorAction += (sender, args) =>
{
if ((args.ActionId == ImeAction.Done) || ((args.ActionId == ImeAction.ImeNull) && (args.Event.Action == KeyEventActions.Down)))
OnOk();
};
FindViewById<EditText>(Resource.Id.pass_otpsecret).TextChanged += (sender, args) => UpdateOkButtonState();
@ -766,11 +772,16 @@ namespace keepass2android
{
Button confirmButton = (Button) FindViewById(Resource.Id.pass_ok);
confirmButton.Click += (sender, e) =>
{
OnOk();
};
}
private void OnOk()
{
App.Kp2a.GetFileStorage(_ioConnection)
.PrepareFileUsage(new FileStorageSetupInitiatorActivity(this, OnActivityResult, null), _ioConnection,
RequestCodePrepareDbFile, false);
};
}
private void InitializeTogglePasswordButton()
@ -1276,9 +1287,15 @@ namespace keepass2android
}
if (!_keepPasswordInOnResume)
{
if (
PreferenceManager.GetDefaultSharedPreferences(this)
.GetBoolean(GetString(Resource.String.ClearPasswordOnLeave_key), true))
{
ClearEnteredPassword();
}
}
_keepPasswordInOnResume = false;
MakePasswordMaskedOrVisible();

View File

@ -100,6 +100,29 @@ namespace keepass2android
Button btnUnlock = (Button) FindViewById(Resource.Id.QuickUnlock_button);
btnUnlock.Click += (object sender, EventArgs e) =>
{
OnUnlock(quickUnlockLength, pwd);
};
Button btnLock = (Button) FindViewById(Resource.Id.QuickUnlock_buttonLock);
btnLock.Click += (object sender, EventArgs e) =>
{
App.Kp2a.LockDatabase(false);
Finish();
};
pwd.EditorAction += (sender, args) =>
{
if ((args.ActionId == ImeAction.Done) || ((args.ActionId == ImeAction.ImeNull) && (args.Event.Action == KeyEventActions.Down)))
OnUnlock(quickUnlockLength, pwd);
};
_intentReceiver = new QuickUnlockBroadcastReceiver(this);
IntentFilter filter = new IntentFilter();
filter.AddAction(Intents.DatabaseLocked);
RegisterReceiver(_intentReceiver, filter);
}
private void OnUnlock(int quickUnlockLength, EditText pwd)
{
KcpPassword kcpPassword = (KcpPassword) App.Kp2a.GetDb().KpDatabase.MasterKey.GetUserKey(typeof (KcpPassword));
String password = kcpPassword.Password.ReadString();
@ -115,19 +138,6 @@ namespace keepass2android
Toast.MakeText(this, GetString(Resource.String.QuickUnlock_fail), ToastLength.Long).Show();
}
Finish();
};
Button btnLock = (Button) FindViewById(Resource.Id.QuickUnlock_buttonLock);
btnLock.Click += (object sender, EventArgs e) =>
{
App.Kp2a.LockDatabase(false);
Finish();
};
_intentReceiver = new QuickUnlockBroadcastReceiver(this);
IntentFilter filter = new IntentFilter();
filter.AddAction(Intents.DatabaseLocked);
RegisterReceiver(_intentReceiver, filter);
}
private void OnLockDatabase()

View File

@ -172,4 +172,6 @@
<string name="PreloadDatabaseEnabled_key">PreloadDatabaseEnabled</string>
<bool name="PreloadDatabaseEnabled_default">true</bool>
<string name="ClearPasswordOnLeave_key">ClearPasswordOnLeave</string>
</resources>

View File

@ -283,6 +283,9 @@
<string name="LockWhenScreenOff_title">Lock when screen off</string>
<string name="LockWhenScreenOff_summary">Lock the database when screen is switched off.</string>
<string name="ClearPasswordOnLeave_title">Clear entered master password</string>
<string name="ClearPasswordOnLeave_summary">Clear the entered master password when leaving the screen without unlocking the database.</string>
<string name="LockWhenNavigateBack_title">Lock when leaving app</string>
<string name="LockWhenNavigateBack_summary">Lock the database when leaving the app by pressing the back button.</string>

View File

@ -128,6 +128,15 @@
android:summary="@string/show_kill_app_summary"
android:defaultValue="false"/>
<CheckBoxPreference
android:enabled="true"
android:persistent="true"
android:summary="@string/ClearPasswordOnLeave_summary"
android:defaultValue="false"
android:title="@string/ClearPasswordOnLeave_title"
android:key="@string/ClearPasswordOnLeave_key" />
</PreferenceScreen>
<PreferenceScreen
android:key="@string/display_prefs_key"