diff --git a/CHANGELOG b/CHANGELOG
index 320cf445c..2ccc8159d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+KeePassDroid (1.5.10)
+ * Add setting to control timeout duration.
+
KeePassDroid (1.5.9)
* Bump target sdk to 8
* Allow install to sdcard
diff --git a/res/values/config.xml b/res/values/config.xml
index e04c29fd7..4c29ad035 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -24,6 +24,7 @@
algorithm
app
+ app_timeout_key
clip_timeout_key
db
rounds
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 03314bc98..87f6c5216 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -29,6 +29,8 @@
Algorithm
Algorithm:
KeePassDroid
+ Application timeout
+ Time before locking database when the application is inactive.
Application
Application settings
Building search index...
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index 5441181e1..76da7d084 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -52,6 +52,14 @@
android:entryValues="@array/clipboard_timeout_values"
android:dialogTitle="@string/clipboard_timeout"
android:defaultValue="@string/clipboard_timeout_default"/>
+
0 ) {
mTimer.schedule(new ClearClipboardTask(this, text), clipClearTime);
diff --git a/src/com/keepassdroid/timers/Timeout.java b/src/com/keepassdroid/timers/Timeout.java
index 24b1cb185..dd27b4fc2 100644
--- a/src/com/keepassdroid/timers/Timeout.java
+++ b/src/com/keepassdroid/timers/Timeout.java
@@ -4,8 +4,11 @@ import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
import android.util.Log;
+import com.android.keepass.R;
import com.keepassdroid.intents.Intents;
import com.keepassdroid.services.TimeoutService;
@@ -23,9 +26,25 @@ public class Timeout {
public static void start(Context ctx) {
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
+ String sTimeout = prefs.getString(ctx.getString(R.string.app_timeout_key), ctx.getString(R.string.clipboard_timeout_default));
+
+ long timeout;
+ try {
+ timeout = Long.parseLong(sTimeout);
+ } catch (NumberFormatException e) {
+ timeout = DEFAULT_TIMEOUT;
+ }
+
+ if ( timeout == -1 ) {
+ // No timeout don't start timeout service
+ return;
+ }
+
ctx.startService(new Intent(ctx, TimeoutService.class));
- long triggerTime = System.currentTimeMillis() + DEFAULT_TIMEOUT;
+ long triggerTime = System.currentTimeMillis() + timeout;
AlarmManager am = (AlarmManager) ctx.getSystemService(Context.ALARM_SERVICE);
Log.d(TAG, "Timeout start");