mirror of
https://github.com/moparisthebest/keepass2android
synced 2024-11-22 09:12:17 -05:00
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:
parent
99a56f8e52
commit
95f5524425
@ -35,6 +35,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MasterKeePlugin", "MasterKe
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlayServicesTest", "PlayServicesTest\PlayServicesTest.csproj", "{B8E78075-3936-42E9-9AB4-C82B341935A6}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlayServicesTest", "PlayServicesTest\PlayServicesTest.csproj", "{B8E78075-3936-42E9-9AB4-C82B341935A6}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App1", "App1\App1.csproj", "{A29ECF2C-3313-4F93-8B78-DC3F1319E835}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
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|Win32.Build.0 = Release|Any CPU
|
||||||
{B8E78075-3936-42E9-9AB4-C82B341935A6}.ReleaseNoNet|x64.ActiveCfg = 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
|
{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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -28,6 +28,7 @@ using Android.Graphics.Drawables;
|
|||||||
using Android.OS;
|
using Android.OS;
|
||||||
using Android.Runtime;
|
using Android.Runtime;
|
||||||
using Android.Views;
|
using Android.Views;
|
||||||
|
using Android.Views.InputMethods;
|
||||||
using Android.Widget;
|
using Android.Widget;
|
||||||
using Java.Net;
|
using Java.Net;
|
||||||
using Android.Preferences;
|
using Android.Preferences;
|
||||||
@ -638,6 +639,11 @@ namespace keepass2android
|
|||||||
_password = FindViewById<EditText>(Resource.Id.password).Text;
|
_password = FindViewById<EditText>(Resource.Id.password).Text;
|
||||||
UpdateOkButtonState();
|
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();
|
FindViewById<EditText>(Resource.Id.pass_otpsecret).TextChanged += (sender, args) => UpdateOkButtonState();
|
||||||
|
|
||||||
@ -767,12 +773,17 @@ namespace keepass2android
|
|||||||
Button confirmButton = (Button) FindViewById(Resource.Id.pass_ok);
|
Button confirmButton = (Button) FindViewById(Resource.Id.pass_ok);
|
||||||
confirmButton.Click += (sender, e) =>
|
confirmButton.Click += (sender, e) =>
|
||||||
{
|
{
|
||||||
App.Kp2a.GetFileStorage(_ioConnection)
|
OnOk();
|
||||||
.PrepareFileUsage(new FileStorageSetupInitiatorActivity(this, OnActivityResult, null), _ioConnection,
|
|
||||||
RequestCodePrepareDbFile, false);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnOk()
|
||||||
|
{
|
||||||
|
App.Kp2a.GetFileStorage(_ioConnection)
|
||||||
|
.PrepareFileUsage(new FileStorageSetupInitiatorActivity(this, OnActivityResult, null), _ioConnection,
|
||||||
|
RequestCodePrepareDbFile, false);
|
||||||
|
}
|
||||||
|
|
||||||
private void InitializeTogglePasswordButton()
|
private void InitializeTogglePasswordButton()
|
||||||
{
|
{
|
||||||
ImageButton btnTogglePassword = (ImageButton) FindViewById(Resource.Id.toggle_password);
|
ImageButton btnTogglePassword = (ImageButton) FindViewById(Resource.Id.toggle_password);
|
||||||
@ -1277,7 +1288,13 @@ namespace keepass2android
|
|||||||
|
|
||||||
if (!_keepPasswordInOnResume)
|
if (!_keepPasswordInOnResume)
|
||||||
{
|
{
|
||||||
ClearEnteredPassword();
|
if (
|
||||||
|
PreferenceManager.GetDefaultSharedPreferences(this)
|
||||||
|
.GetBoolean(GetString(Resource.String.ClearPasswordOnLeave_key), true))
|
||||||
|
{
|
||||||
|
ClearEnteredPassword();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
_keepPasswordInOnResume = false;
|
_keepPasswordInOnResume = false;
|
||||||
|
|
||||||
|
@ -101,20 +101,7 @@ namespace keepass2android
|
|||||||
Button btnUnlock = (Button) FindViewById(Resource.Id.QuickUnlock_button);
|
Button btnUnlock = (Button) FindViewById(Resource.Id.QuickUnlock_button);
|
||||||
btnUnlock.Click += (object sender, EventArgs e) =>
|
btnUnlock.Click += (object sender, EventArgs e) =>
|
||||||
{
|
{
|
||||||
KcpPassword kcpPassword = (KcpPassword) App.Kp2a.GetDb().KpDatabase.MasterKey.GetUserKey(typeof (KcpPassword));
|
OnUnlock(quickUnlockLength, pwd);
|
||||||
String password = kcpPassword.Password.ReadString();
|
|
||||||
String expectedPasswordPart = password.Substring(Math.Max(0, password.Length - quickUnlockLength),
|
|
||||||
Math.Min(password.Length, quickUnlockLength));
|
|
||||||
if (pwd.Text == expectedPasswordPart)
|
|
||||||
{
|
|
||||||
App.Kp2a.UnlockDatabase();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
App.Kp2a.LockDatabase(false);
|
|
||||||
Toast.MakeText(this, GetString(Resource.String.QuickUnlock_fail), ToastLength.Long).Show();
|
|
||||||
}
|
|
||||||
Finish();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Button btnLock = (Button) FindViewById(Resource.Id.QuickUnlock_buttonLock);
|
Button btnLock = (Button) FindViewById(Resource.Id.QuickUnlock_buttonLock);
|
||||||
@ -123,6 +110,11 @@ namespace keepass2android
|
|||||||
App.Kp2a.LockDatabase(false);
|
App.Kp2a.LockDatabase(false);
|
||||||
Finish();
|
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);
|
_intentReceiver = new QuickUnlockBroadcastReceiver(this);
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
@ -130,6 +122,24 @@ namespace keepass2android
|
|||||||
RegisterReceiver(_intentReceiver, filter);
|
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();
|
||||||
|
String expectedPasswordPart = password.Substring(Math.Max(0, password.Length - quickUnlockLength),
|
||||||
|
Math.Min(password.Length, quickUnlockLength));
|
||||||
|
if (pwd.Text == expectedPasswordPart)
|
||||||
|
{
|
||||||
|
App.Kp2a.UnlockDatabase();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
App.Kp2a.LockDatabase(false);
|
||||||
|
Toast.MakeText(this, GetString(Resource.String.QuickUnlock_fail), ToastLength.Long).Show();
|
||||||
|
}
|
||||||
|
Finish();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnLockDatabase()
|
private void OnLockDatabase()
|
||||||
{
|
{
|
||||||
CheckIfUnloaded();
|
CheckIfUnloaded();
|
||||||
|
@ -172,4 +172,6 @@
|
|||||||
<string name="PreloadDatabaseEnabled_key">PreloadDatabaseEnabled</string>
|
<string name="PreloadDatabaseEnabled_key">PreloadDatabaseEnabled</string>
|
||||||
<bool name="PreloadDatabaseEnabled_default">true</bool>
|
<bool name="PreloadDatabaseEnabled_default">true</bool>
|
||||||
|
|
||||||
|
<string name="ClearPasswordOnLeave_key">ClearPasswordOnLeave</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -283,6 +283,9 @@
|
|||||||
<string name="LockWhenScreenOff_title">Lock when screen off</string>
|
<string name="LockWhenScreenOff_title">Lock when screen off</string>
|
||||||
<string name="LockWhenScreenOff_summary">Lock the database when screen is switched 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_title">Lock when leaving app</string>
|
||||||
<string name="LockWhenNavigateBack_summary">Lock the database when leaving the app by pressing the back button.</string>
|
<string name="LockWhenNavigateBack_summary">Lock the database when leaving the app by pressing the back button.</string>
|
||||||
|
|
||||||
|
@ -128,6 +128,15 @@
|
|||||||
android:summary="@string/show_kill_app_summary"
|
android:summary="@string/show_kill_app_summary"
|
||||||
android:defaultValue="false"/>
|
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>
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:key="@string/display_prefs_key"
|
android:key="@string/display_prefs_key"
|
||||||
|
Loading…
Reference in New Issue
Block a user