Added option to kill the application process from the password activity

This commit is contained in:
Philipp Crocoll 2013-11-11 06:38:15 +01:00
parent 8b86e15a29
commit 574a56c2e3
7 changed files with 1074 additions and 1007 deletions

View File

@ -197,6 +197,7 @@ namespace keepass2android
} }
internal AppTask AppTask; internal AppTask AppTask;
private bool _killOnDestroy;
protected override void OnCreate(Bundle savedInstanceState) protected override void OnCreate(Bundle savedInstanceState)
{ {
@ -281,6 +282,10 @@ namespace keepass2android
.PrepareFileUsage(new FileStorageSetupInitiatorActivity(this, OnActivityResult, null), _ioConnection, 0, false); .PrepareFileUsage(new FileStorageSetupInitiatorActivity(this, OnActivityResult, null), _ioConnection, 0, false);
}; };
/*CheckBox checkBox = (CheckBox) FindViewById(Resource.Id.show_password); /*CheckBox checkBox = (CheckBox) FindViewById(Resource.Id.show_password);
// Show or hide password // Show or hide password
checkBox.CheckedChange += delegate(object sender, CompoundButton.CheckedChangeEventArgs e) { checkBox.CheckedChange += delegate(object sender, CompoundButton.CheckedChangeEventArgs e) {
@ -459,6 +464,24 @@ namespace keepass2android
{ {
base.OnResume(); base.OnResume();
View killButton = FindViewById(Resource.Id.kill_app);
if (PreferenceManager.GetDefaultSharedPreferences(this)
.GetBoolean(GetString(Resource.String.show_kill_app_key), false))
{
killButton.Click += (sender, args) =>
{
_killOnDestroy = true;
Finish();
};
killButton.Visibility = ViewStates.Visible;
}
else
{
killButton.Visibility = ViewStates.Gone;
}
MakePasswordMaskedOrVisible(); MakePasswordMaskedOrVisible();
// OnResume is run every time the activity comes to the foreground. This code should only run when the activity is started (OnStart), but must // OnResume is run every time the activity comes to the foreground. This code should only run when the activity is started (OnStart), but must
@ -521,6 +544,13 @@ namespace keepass2android
SetEditText(Resource.Id.pass_keyfile, _keyFile); SetEditText(Resource.Id.pass_keyfile, _keyFile);
} }
protected override void OnDestroy()
{
base.OnDestroy();
if (_killOnDestroy)
Process.KillProcess(Process.MyPid());
}
/* /*
private void errorMessage(CharSequence text) private void errorMessage(CharSequence text)
{ {

File diff suppressed because it is too large Load Diff

View File

@ -96,10 +96,16 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/keyfileLine" /> android:layout_below="@id/keyfileLine" />
<Button
android:id="@+id/kill_app"
android:text="@string/kill_app_label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/pass_ok" />
<CheckBox <CheckBox
android:id="@+id/enable_quickunlock" android:id="@+id/enable_quickunlock"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/pass_ok" android:layout_below="@id/kill_app"
android:text="@string/enable_quickunlock" /> android:text="@string/enable_quickunlock" />
</RelativeLayout> </RelativeLayout>

View File

@ -84,10 +84,16 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/pass_keyfile" /> android:layout_below="@id/pass_keyfile" />
<Button
android:id="@+id/kill_app"
android:text="@string/kill_app_label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/pass_ok" />
<CheckBox <CheckBox
android:id="@+id/enable_quickunlock" android:id="@+id/enable_quickunlock"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/pass_ok" android:layout_below="@id/kill_app"
android:text="@string/enable_quickunlock" /> android:text="@string/enable_quickunlock" />
</RelativeLayout> </RelativeLayout>

View File

@ -46,6 +46,7 @@
<string name="algorithm_key">algorithm</string> <string name="algorithm_key">algorithm</string>
<string name="app_key">app</string> <string name="app_key">app</string>
<string name="app_timeout_key">app_timeout_key</string> <string name="app_timeout_key">app_timeout_key</string>
<string name="show_kill_app_key">show_kill_app_key</string>
<string name="clipboard_timeout_key">clip_timeout_key</string> <string name="clipboard_timeout_key">clip_timeout_key</string>
<string name="db_key">db</string> <string name="db_key">db</string>
<string name="rounds_key">rounds</string> <string name="rounds_key">rounds</string>

View File

@ -19,6 +19,9 @@
<string name="short_app_name_nonet">KP2A Offline</string> <string name="short_app_name_nonet">KP2A Offline</string>
<string name="app_timeout">Application timeout</string> <string name="app_timeout">Application timeout</string>
<string name="app_timeout_summary">Time before locking database when the application is inactive.</string> <string name="app_timeout_summary">Time before locking database when the application is inactive.</string>
<string name="kill_app_label">Kill application process</string>
<string name="show_kill_app">Close-Button</string>
<string name="show_kill_app_summary">Show a button in password screen to kill the application process (for paranoid users)</string>
<string name="application">Application</string> <string name="application">Application</string>
<string name="application_settings">Application settings</string> <string name="application_settings">Application settings</string>

View File

@ -84,6 +84,12 @@
android:summary="@string/remember_keyfile_summary" android:summary="@string/remember_keyfile_summary"
android:defaultValue="@bool/keyfile_default"/> android:defaultValue="@bool/keyfile_default"/>
<CheckBoxPreference
android:key="@string/show_kill_app_key"
android:title="@string/show_kill_app"
android:summary="@string/show_kill_app_summary"
android:defaultValue="false"/>
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen <PreferenceScreen
android:key="@string/display_prefs_key" android:key="@string/display_prefs_key"