# project structure.
# Project target.
-target=android-2
+target=android-3
# apk configurations. This property allows creation of APK files with limited
# resources. For example, if your application contains many locales and
# you wish to release multiple smaller apks instead of a large one, you can
\r
<string name="pref_dialog_title_lock_timeout">Auto lock timeout</string>\r
\r
+ <!-- Preference title -->\r
+ <string name="pref_title_lock_on_screen_lock">Lock on screen lock</string>\r
+ \r
+ <!-- Preference summary for lock on screen lock -->\r
+ <string name="pref_summary_lock_on_screen_lock">Lock when the screen locks</string>\r
+ \r
<!-- Preference title: use a numeric keypad to enter the password -->\r
<string name="pref_title_keypad">Keypad</string>\r
\r
android:entryValues="@array/pref_entryvalues_lock_timeout"
android:dialogTitle="@string/pref_dialog_title_lock_timeout"\r
android:defaultValue="5" />
-
+ <CheckBoxPreference
+ android:title="@string/pref_title_lock_on_screen_lock"
+ android:summary="@string/pref_summary_lock_on_screen_lock"
+ android:key="lock_on_screen_lock"
+ android:defaultValue="true"/>
<CheckBoxPreference
android:title="@string/pref_title_keypad"
android:summary="@string/pref_summary_keypad"
private Intent restartTimerIntent;
private int lastPosition=0;
+ private boolean lockOnScreenLock=true;
+
BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
if (debug) Log.d(TAG,"caught ACTION_SCREEN_OFF");
- masterKey=null;
+ if (lockOnScreenLock) {
+ masterKey=null;
+ }
} else if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
lockAndShutFrontDoor();
}
showFirstTimeWarningDialog();
+ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
+ lockOnScreenLock = sp.getBoolean(Preferences.PREFERENCE_LOCK_ON_SCREEN_LOCK, true);
}
/**
private CryptoHelper ch;\r
\r
// service elements\r
- private ServiceDispatch service;\r
+ private static ServiceDispatch service=null;\r
private ServiceDispatchConnection conn;\r
private Intent mServiceIntent;\r
\r
private void setServiceParametersFromExtrasAndDispatchAction(Intent data) {\r
salt = data.getStringExtra("salt");\r
masterKey = data.getStringExtra("masterKey");\r
- String timeout = mPreferences.getString(Preferences.PREFERENCE_LOCK_TIMEOUT, Preferences.PREFERENCE_LOCK_TIMEOUT_DEFAULT_VALUE); \r
+ String timeout = mPreferences.getString(Preferences.PREFERENCE_LOCK_TIMEOUT, Preferences.PREFERENCE_LOCK_TIMEOUT_DEFAULT_VALUE);\r
+ boolean lockOnScreenLock = mPreferences.getBoolean(Preferences.PREFERENCE_LOCK_ON_SCREEN_LOCK, true);\r
+\r
int timeoutMinutes=5; // default to 5\r
try {\r
timeoutMinutes = Integer.valueOf(timeout);\r
\r
try {\r
service.setTimeoutMinutes(timeoutMinutes);\r
+ service.setLockOnScreenLock(lockOnScreenLock);\r
service.setSalt(salt);\r
service.setPassword(masterKey); // should already be connected.\r
} catch (RemoteException e1) {\r
\r
if (debug) Log.d( TAG,"onServiceDisconnected" );\r
}\r
+ \r
};\r
\r
+ public static void setLockOnScreenLock(boolean lock)\r
+ {\r
+ if (service!=null) {\r
+ try {\r
+ service.setLockOnScreenLock(lock);\r
+ } catch (RemoteException e) {\r
+ Log.d(TAG, e.toString());\r
+ }\r
+ }\r
+ }\r
+\r
}\r
package org.openintents.safe;
+import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
+import android.preference.PreferenceManager;
public class Preferences extends PreferenceActivity {
public static final String PREFERENCE_ALLOW_EXTERNAL_ACCESS = "external_access";
public static final String PREFERENCE_LOCK_TIMEOUT = "lock_timeout";
public static final String PREFERENCE_LOCK_TIMEOUT_DEFAULT_VALUE = "5";
+ public static final String PREFERENCE_LOCK_ON_SCREEN_LOCK = "lock_on_screen_lock";
public static final String PREFERENCE_FIRST_TIME_WARNING = "first_time_warning";
public static final String PREFERENCE_KEYPAD = "keypad";
public static final String PREFERENCE_KEYPAD_MUTE = "keypad_mute";
}
}
+ @Override
+ protected void onPause() {
+ super.onPause();
+
+ SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
+ boolean lockOnScreenLock = mPreferences.getBoolean(Preferences.PREFERENCE_LOCK_ON_SCREEN_LOCK, true);
+ IntentHandler.setLockOnScreenLock(lockOnScreenLock);
+ }
+
}
String encrypt (String clearText);\r
String decrypt (String cryptoText);\r
void setTimeoutMinutes(int timeoutMinutesIn);\r
+ void setLockOnScreenLock (boolean lock);\r
}\r
private int timeoutMinutes = 5;
private long timeoutUntilStop = timeoutMinutes * 60000;
private BroadcastReceiver mIntentReceiver;
+ private boolean lockOnScreenLock=true;
@Override
public IBinder onBind(Intent intent) {
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
if (debug) Log.d(TAG,"caught ACTION_SCREEN_OFF");
- stopSelf();
+ if (lockOnScreenLock) {
+ stopSelf();
+ }
} else if (intent.getAction().equals(CryptoIntents.ACTION_RESTART_TIMER)) {
restartTimer();
}
Log.d(TAG,"set timeout to "+timeoutMinutes);
}
+ public void setLockOnScreenLock (boolean lock){
+ lockOnScreenLock = lock;
+ }
+
+
};
}