<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.openintents.safe" \r
- android:versionName="1.1.1" android:versionCode="8">\r
+ android:versionCode="9" android:versionName="1.2.0">\r
<!-- History:
+ 1.2.0 [9]: 2009-08-22
1.1.1 [8]: 2009-05-30\r
1.1.0 [6]: 2009-03-17\r
1.0.0 [4]: 2009-02-02\r
android:value="@string/about_email" />\r
<activity class=".FrontDoor" android:name="FrontDoor" android:label="@string/app_name"\r
- android:theme="@android:style/Theme.Translucent.NoTitleBar">
+ android:theme="@android:style/Theme.Translucent.NoTitleBar" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />\r
</intent-filter>
+ <intent-filter>
+ <action android:name="org.openintents.action.A" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
</activity>
<activity class=".IntentHandler" android:name="IntentHandler" android:label="@string/app_name"
- android:permission="org.openintents.safe.ACCESS_INTENTS">
+ android:permission="org.openintents.safe.ACCESS_INTENTS" android:launchMode="singleTop">
<intent-filter android:label="@string/intent_encrypt">
<action android:name="org.openintents.action.ENCRYPT" />
<category android:name="android.intent.category.DEFAULT" />
<activity class=".PassList" android:name="PassList" android:label="@string/app_name" />
<activity class=".PassEdit" android:name="PassEdit" android:label="@string/app_name" />
<activity class=".CategoryList" android:name="CategoryList" android:label="@string/app_name" />
- <activity class=".AskPassword" android:name="AskPassword" android:label="@string/app_name"/>\r
+ <activity class=".Search" android:name="Search" android:label="@string/app_name" />
+ <activity class=".AskPassword" android:name="AskPassword" android:label="@string/app_name" android:launchMode="singleTop"/>\r
<activity class=".Help" android:name="Help" android:label="@string/app_name" />
<activity class=".ChangePass" android:name="ChangePass" android:label="@string/app_name" />
<activity class=".Restore" android:name="Restore" android:label="@string/app_name" />
<EditText android:id="@+id/website"\r
android:layout_width="wrap_content"
android:layout_height="wrap_content"\r
- android:singleLine="true"
+ android:singleLine="true" \r
+ android:inputType="textUri"
android:layout_weight="1"/>\r
<Button android:id="@+id/go" \r
- android:text="@string/go"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
+ android:text="@string/go"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
/>
</TableRow>\r
<TableRow>\r
android:text="@string/password" />
<EditText android:id="@+id/password"\r
android:singleLine="true"\r
+ android:inputType="textVisiblePassword"\r
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<EditText android:id="@+id/note" android:layout_width="fill_parent"
android:gravity="top" \r
android:layout_height="wrap_content"
- android:layout_weight="1"
+ android:layout_weight="1"\r
+ android:inputType="textShortMessage"
android:scrollbars="vertical" />
</LinearLayout>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* $Id$
+*
+* Copyright (C) 2009 OpenIntents.org
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+
+ <TableLayout android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+ <TableRow>
+ <EditText android:id="@+id/search_criteria"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:inputType="textFilter"
+ android:maxLength="50"
+ android:hint="@string/search_hint"
+ android:layout_weight="1"/>
+ <Button android:id="@+id/go_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/search"/>
+ </TableRow>
+ <TableRow>
+ <ListView
+ android:id="@id/android:list"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+ </TableRow>
+ </TableLayout>
+</LinearLayout>
<string name="dialog_summary_first_time_warning">A new random master key has been created. Use menu > backup and store this key in a safe place. Without this key you may lose encrypted data.</string>\r
<string name="switch_mode">Switch mode</string>\r
<string name="decrypt_progress">Decrypting...</string>\r
+ <string name="search">Search</string>\r
+ <string name="search_progress">Searching...</string>\r
+ <string name="search_hint">Type search criteria</string>\r
\r
\r
<!-- ***************************\r
<string-array name="pref_entries_lock_timeout">\r
<item>1 minute</item>\r
<item>5 minutes</item>\r
+ <item>10 minutes</item>\r
+ <item>15 minutes</item>\r
<item>30 minutes</item> \r
</string-array>\r
\r
<string-array name="pref_entryvalues_lock_timeout">\r
<item>1</item>\r
<item>5</item>\r
+ <item>10</item>\r
+ <item>15</item>\r
<item>30</item> \r
</string-array>\r
\r
*/\r
public static final String ACTION_CRYPTO_LOGGED_OUT = "org.openintents.action.CRYPTO_LOGGED_OUT";\r
\r
+ /**\r
+ * Activity Action: Initiate automatic locking of the safe.\r
+ * This is used internally from any activity to launch the lock screen.\r
+ * \r
+ * <p>Constant Value: "org.openintents.action.AUTOLOCK"</p>\r
+ */\r
+ public static final String ACTION_AUTOLOCK = "org.openintents.action.AUTOLOCK";\r
+\r
/**\r
* The text to encrypt or decrypt, or the location for the return result.\r
* \r
*/
package org.openintents.safe;
+import org.openintents.intents.CryptoIntents;
+
import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
private EditText nameText;
private Long RowId;
+ Intent frontdoor;
+ private Intent restartTimerIntent=null;
+
+ BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
+ if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
+ startActivity(frontdoor);
+ }
+ }
+ };
+
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (debug) Log.d(TAG, "onCreate");
+ frontdoor = new Intent(this, FrontDoor.class);
+ frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
+ if (CategoryList.isSignedIn()==false) {
+ startActivity(frontdoor);
+ }
+ restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
+
String title = getResources().getString(R.string.app_name) + " - " +
getResources().getString(R.string.edit_entry);
setTitle(title);
protected void onPause() {
super.onPause();
if (debug) Log.d(TAG, "onPause");
+
+ try {
+ unregisterReceiver(mIntentReceiver);
+ } catch (IllegalArgumentException e) {
+ if (debug) Log.d(TAG,"IllegalArgumentException");
+ }
}
@Override
if (!CategoryList.isSignedIn()) {
Intent frontdoor = new Intent(this, FrontDoor.class);
startActivity(frontdoor);
- finish();
return;
}
populateFields();
+ IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
+ registerReceiver(mIntentReceiver, filter);
}
private void saveState() {
nameText.setText(catEntry.plainName);
}
}
+
+ @Override
+ public void onUserInteraction() {
+ super.onUserInteraction();
+
+ if (debug) Log.d(TAG,"onUserInteraction()");
+
+ if (CategoryList.isSignedIn()==false) {
+ startActivity(frontdoor);
+ }else{
+ if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
+ }
+ }
}
public static final int ADD_CATEGORY_INDEX = Menu.FIRST + 3;
public static final int DEL_CATEGORY_INDEX = Menu.FIRST + 4;
public static final int HELP_INDEX = Menu.FIRST + 5;
- public static final int EXPORT_INDEX = Menu.FIRST + 6;
- public static final int IMPORT_INDEX = Menu.FIRST + 7;
- public static final int CHANGE_PASS_INDEX = Menu.FIRST + 8;
- public static final int BACKUP_INDEX = Menu.FIRST + 9;
- public static final int RESTORE_INDEX = Menu.FIRST + 10;
- public static final int PREFERENCES_INDEX = Menu.FIRST + 11;
- public static final int ABOUT_INDEX = Menu.FIRST + 12;
+ public static final int SEARCH_INDEX = Menu.FIRST + 6;
+ public static final int EXPORT_INDEX = Menu.FIRST + 7;
+ public static final int IMPORT_INDEX = Menu.FIRST + 8;
+ public static final int CHANGE_PASS_INDEX = Menu.FIRST + 9;
+ public static final int BACKUP_INDEX = Menu.FIRST + 10;
+ public static final int RESTORE_INDEX = Menu.FIRST + 11;
+ public static final int PREFERENCES_INDEX = Menu.FIRST + 12;
+ public static final int ABOUT_INDEX = Menu.FIRST + 13;
public static final int REQUEST_ONCREATE = 0;
public static final int REQUEST_EDIT_CATEGORY = 1;
private static String masterKey;
private List<CategoryEntry> rows;
- private Intent restartTimerIntent;
+ private Intent restartTimerIntent=null;
private int lastPosition=0;
private boolean lockOnScreenLock=true;
if (isSignedIn()==false) {
Intent frontdoor = new Intent(this, FrontDoor.class);
+ frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
startActivity(frontdoor);
- finish();
return;
}
if (isSignedIn()==false) {
Intent frontdoor = new Intent(this, FrontDoor.class);
- startActivity(frontdoor);
- finish();
+ frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
+ startActivity(frontdoor);
return;
}
+ IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
+ registerReceiver(mIntentReceiver, filter);
showFirstTimeWarningDialog();
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
try { backupThread.join(maxWaitToDie); }
catch(InterruptedException e){} // ignore
}
+ try {
+ unregisterReceiver(mIntentReceiver);
+ } catch (IllegalArgumentException e) {
+ if (debug) Log.d(TAG,"IllegalArgumentException");
+ }
}
@Override
super.onStop();
if (debug) Log.d(TAG,"onStop()");
-// dbHelper.close();
}
@Override
public void onDestroy() {
super.onDestroy();
- if (mIntentReceiver!=null) {
+ if (debug) Log.d(TAG,"onDestroy()");
+ try {
unregisterReceiver(mIntentReceiver);
- mIntentReceiver=null;
+ } catch (IllegalArgumentException e) {
+ if (debug) Log.d(TAG,"IllegalArgumentException");
}
- if (debug) Log.d(TAG,"onDestroy()");
}
@Override
public void onCreateContextMenu(ContextMenu menu, View view,
.setIcon(android.R.drawable.ic_menu_add)
.setShortcut('2', 'a');
+ menu.add(0, SEARCH_INDEX, 0, R.string.search)
+ .setIcon(android.R.drawable.ic_menu_search);
+
menu.add(0, DEL_CATEGORY_INDEX, 0, R.string.password_delete)
.setIcon(android.R.drawable.ic_menu_delete)
.setShortcut('3', 'd')
Intent help = new Intent(this, Help.class);
startActivity(help);
break;
+ case SEARCH_INDEX:
+ Intent search = new Intent(this, Search.class);
+ startActivity(search);
+ break;
case EXPORT_INDEX:
Dialog exportDialog = new AlertDialog.Builder(CategoryList.this)
.setIcon(R.drawable.passicon)
stopService(serviceIntent);
masterKey=null;
Intent frontdoor = new Intent(this, FrontDoor.class);
- frontdoor.setAction(Intent.ACTION_MAIN);
+ frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
startActivity(frontdoor);
- finish();
}
/**
importMessage=getString(R.string.import_file_error);
}
}
+
+ @Override
+ public void onUserInteraction() {
+ super.onUserInteraction();
+
+ if (debug) Log.d(TAG,"onUserInteraction()");
+
+ if (CategoryList.isSignedIn()==false) {
+ Intent frontdoor = new Intent(this, FrontDoor.class);
+ frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
+ startActivity(frontdoor);
+ }else{
+ if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
+ }
+ }
}
\ No newline at end of file
import java.util.List;
+import org.openintents.intents.CryptoIntents;
+
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
}
};
+ Intent frontdoor;
+ private Intent restartTimerIntent=null;
+
+ BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
+ if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
+ startActivity(frontdoor);
+ }
+ }
+ };
+
/**
* Called when the activity is first created.
*/
if (debug) Log.d(TAG,"onCreate()");
+ frontdoor = new Intent(this, FrontDoor.class);
+ frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
if (CategoryList.isSignedIn()==false) {
- finish();
- return;
- }
+ startActivity(frontdoor);
+ }
+ restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
setContentView(R.layout.chg_pass);
String title = getResources().getString(R.string.app_name) + " - " +
try { changePassThread.join(maxWaitToDie); }
catch(InterruptedException e){} // ignore
}
+ try {
+ unregisterReceiver(mIntentReceiver);
+ } catch (IllegalArgumentException e) {
+ if (debug) Log.d(TAG,"IllegalArgumentException");
+ }
}
@Override
if (debug) Log.d(TAG,"onResume()");
if (CategoryList.isSignedIn()==false) {
- finish();
+ startActivity(frontdoor);
return;
- }
+ }
+ IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
+ registerReceiver(mIntentReceiver, filter);
}
@Override
return false;
}
+ @Override
+ public void onUserInteraction() {
+ super.onUserInteraction();
+
+ if (debug) Log.d(TAG,"onUserInteraction()");
+
+ if (CategoryList.isSignedIn()==false) {
+ startActivity(frontdoor);
+ }else{
+ if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
+ }
+ }
}
*/\r
package org.openintents.safe;\r
\r
+import org.openintents.intents.CryptoIntents;\r
+\r
import android.app.Activity;\r
import android.content.Intent;\r
import android.os.Bundle;\r
+import android.util.Log;\r
\r
\r
/**\r
*/\r
public class FrontDoor extends Activity {\r
\r
+ private static final String TAG = "FrontDoor";\r
+ private static final boolean debug = false;\r
+\r
+// public static final String KEY_AUTOLOCK = "autolock";\r
+ \r
/** Called when the activity is first created. */\r
@Override\r
public void onCreate(Bundle icicle) {\r
super.onCreate(icicle);\r
+ \r
+ if (debug) Log.d(TAG,"onCreate()");\r
final Intent thisIntent = getIntent();\r
final String action = thisIntent.getAction();\r
- if (action == null || action.equals(Intent.ACTION_MAIN)){\r
+ if (action == null || action.equals(Intent.ACTION_MAIN) || action.equals(CryptoIntents.ACTION_AUTOLOCK)){\r
//TODO: When launched from debugger, action is null. Other such cases?\r
Intent i = new Intent(getApplicationContext(),\r
IntentHandler.class);\r
+// boolean autoLock = icicle != null ? icicle.getBoolean(FrontDoor.KEY_AUTOLOCK) : false;\r
+ if (debug) Log.d(TAG,"action="+action);\r
+// if (action.equals(CryptoIntents.ACTION_AUTOLOCK)) {\r
+ // i.setAction(CryptoIntents.ACTION_AUTOLOCK);\r
+ // }\r
+ i.setAction(action);\r
startActivity(i);\r
} // otherwise, do not start intents, those must be protected by permissions\r
finish();\r
import java.io.IOException;
import java.io.InputStream;
+
+import org.openintents.intents.CryptoIntents;
+
import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
// Menu Item order
public static final int CLOSE_HELP_INDEX = Menu.FIRST;
+
+ Intent frontdoor;
+ private Intent restartTimerIntent=null;
+
+ BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
+ if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
+ startActivity(frontdoor);
+ }
+ }
+ };
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
+ frontdoor = new Intent(this, FrontDoor.class);
+ frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
if (CategoryList.isSignedIn()==false) {
- finish();
- return;
- }
+ startActivity(frontdoor);
+ }
+ restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
//Setup layout
setContentView(R.layout.help);
}
+ @Override
+ protected void onPause() {
+ super.onPause();
+ try {
+ unregisterReceiver(mIntentReceiver);
+ } catch (IllegalArgumentException e) {
+ if (debug) Log.d(TAG,"IllegalArgumentException");
+ }
+ }
+
@Override
protected void onResume() {
super.onResume();
if (debug) Log.d(TAG,"onResume()");
if (CategoryList.isSignedIn()==false) {
- finish();
+ startActivity(frontdoor);
return;
}
+ IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
+ registerReceiver(mIntentReceiver, filter);
}
@Override
}
return super.onOptionsItemSelected(item);
}
+
+ @Override
+ public void onUserInteraction() {
+ super.onUserInteraction();
+
+ if (debug) Log.d(TAG,"onUserInteraction()");
+
+ if (CategoryList.isSignedIn()==false) {
+ startActivity(frontdoor);
+ }else{
+ if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
+ }
+ }
}
\ No newline at end of file
switch (requestCode) {\r
case REQUEST_CODE_ASK_PASSWORD:\r
if (resultCode == RESULT_OK) {\r
-\r
+ if (debug) Log.d(TAG,"RESULT_OK");\r
if (service == null) {\r
mServiceIntent = data;\r
// setServiceParametersFromExtrasAndDispatchAction() is called in onServiceConnected.\r
\r
setServiceParametersFromExtrasAndDispatchAction(data);\r
\r
- } else { // resultCode == RESULT_CANCELED\r
+ } else { // resultCode == RESULT_CANCELED, which means the user hit Back at AskPassword\r
+ if (debug) Log.d(TAG,"RESULT_CANCELED");\r
+ moveTaskToBack(true);\r
setResult(RESULT_CANCELED);\r
finish();\r
}\r
Intent i = new Intent(getApplicationContext(),\r
CategoryList.class);\r
startActivity(i);\r
+ } else if (action.equals(CryptoIntents.ACTION_AUTOLOCK)) {\r
+ if (debug) Log.d(TAG,"autolock");\r
+ finish();\r
} else if (externalAccess){\r
\r
// which action?\r
final Intent thisIntent = getIntent();\r
String inputBody = thisIntent.getStringExtra (CryptoIntents.EXTRA_TEXT);\r
\r
+ String action=thisIntent.getAction();\r
+ if (action!=null && action.equals(CryptoIntents.ACTION_AUTOLOCK)) {\r
+ if (debug) Log.d(TAG,"autolock");\r
+ askPassIsLocal=true;\r
+ }\r
askPass.putExtra (CryptoIntents.EXTRA_TEXT, inputBody);\r
askPass.putExtra (AskPassword.EXTRA_IS_LOCAL, askPassIsLocal);\r
//TODO: Is there a way to make sure all the extras are set? \r
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.IntentFilter;
import android.net.Uri;
import android.os.Bundle;
import android.text.ClipboardManager;
public static final int RESULT_DELETED = RESULT_FIRST_USER;
- private Intent restartTimerIntent;
-
private EditText descriptionText;
private EditText passwordText;
private EditText usernameText;
private EditText websiteText;
private EditText noteText;
private Long RowId;
+ private Long CategoryId;
private boolean pass_gen_ret = false;
private boolean discardEntry = false;
public static boolean entryEdited = false;
boolean populated = false;
+
Intent frontdoor;
+ private Intent restartTimerIntent=null;
BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
- frontdoor.setAction(Intent.ACTION_MAIN);
startActivity(frontdoor);
}
}
if (debug) Log.d(TAG,"onCreate()");
frontdoor = new Intent(this, FrontDoor.class);
+ frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
if (CategoryList.isSignedIn()==false) {
startActivity(frontdoor);
- // normally we'd do a finish() here, but
- // by starting frontdoor from here the user could
- // potentially find this activity and continue editing
}
restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
Bundle extras = getIntent().getExtras();
RowId = extras != null ? extras.getLong(PassList.KEY_ID) : null;
}
+ CategoryId = icicle != null ? icicle.getLong(PassList.KEY_CATEGORY_ID) : null;
+ if (CategoryId == null) {
+ Bundle extras = getIntent().getExtras();
+ CategoryId = extras != null ? extras.getLong(PassList.KEY_CATEGORY_ID) : null;
+ }
+ if (debug) Log.d(TAG,"RowId="+RowId);
+ if (debug) Log.d(TAG,"CategoryId="+CategoryId);
entryEdited = false;
} else {
outState.putLong(PassList.KEY_ID, -1);
}
+ outState.putLong(PassList.KEY_CATEGORY_ID, CategoryId);
}
@Override
if (isFinishing() && discardEntry==false) {
savePassword();
}
+ try {
+ unregisterReceiver(mIntentReceiver);
+ } catch (IllegalArgumentException e) {
+ if (debug) Log.d(TAG,"IllegalArgumentException");
+ }
}
@Override
if (CategoryList.isSignedIn()==false) {
saveState();
- finish();
+ startActivity(frontdoor);
return;
}
+ IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
+ registerReceiver(mIntentReceiver, filter);
+
populateFields();
}
private void saveState() {
PassEntry entry = new PassEntry();
- entry.category = PassList.getCategoryId();
+ entry.category = CategoryId;
entry.plainDescription = descriptionText.getText().toString();
entry.plainWebsite = websiteText.getText().toString();
entry.plainUsername = usernameText.getText().toString();
}
if ((RowId != null) && (RowId != -1)) {
PassEntry passEntry = Passwords.getPassEntry(RowId, true, false);
- descriptionText.setText(passEntry.plainDescription);
- websiteText.setText(passEntry.plainWebsite);
- usernameText.setText(passEntry.plainUsername);
- passwordText.setText(passEntry.plainPassword);
- noteText.setText(passEntry.plainNote);
+ if (passEntry!=null) {
+ descriptionText.setText(passEntry.plainDescription);
+ websiteText.setText(passEntry.plainWebsite);
+ usernameText.setText(passEntry.plainUsername);
+ passwordText.setText(passEntry.plainPassword);
+ noteText.setText(passEntry.plainNote);
+ }
}
populated=true;
}
}
}
}
+
+ @Override
+ public void onUserInteraction() {
+ super.onUserInteraction();
+
+ if (debug) Log.d(TAG,"onUserInteraction()");
+
+ if (CategoryList.isSignedIn()==false) {
+ startActivity(frontdoor);
+ }else{
+ if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
+ }
+ }
}
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
+import org.openintents.intents.CryptoIntents;
+
import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.os.Bundle;
import android.text.ClipboardManager;
+import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
* @author Steven Osborn - http://steven.bitsetters.com
*/
public class PassGen extends Activity {
-
+
+ private static boolean debug = false;
+ private static String TAG = "PassGen";
+
public static final int CHANGE_ENTRY_RESULT = 2;
public static final String NEW_PASS_KEY="new_pass";
Button copy_entry;
Button cancel;
+ Intent frontdoor;
+ private Intent restartTimerIntent=null;
+
+ BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
+ if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
+ startActivity(frontdoor);
+ }
+ }
+ };
+
private final OnClickListener update_click = new OnClickListener() {
public void onClick(View v) {
genPassword();
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
+ frontdoor = new Intent(this, FrontDoor.class);
+ frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
if (CategoryList.isSignedIn()==false) {
- finish();
- return;
- }
+ startActivity(frontdoor);
+ }
+ restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
setContentView(R.layout.pass_gen);
@Override
protected void onPause() {
super.onPause();
+
+ try {
+ unregisterReceiver(mIntentReceiver);
+ } catch (IllegalArgumentException e) {
+ if (debug) Log.d(TAG,"IllegalArgumentException");
+ }
}
@Override
super.onResume();
if (CategoryList.isSignedIn()==false) {
- finish();
+ startActivity(frontdoor);
return;
}
+ IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
+ registerReceiver(mIntentReceiver, filter);
}
@Override
return false;
}
+ @Override
+ public void onUserInteraction() {
+ super.onUserInteraction();
+
+ if (debug) Log.d(TAG,"onUserInteraction()");
+
+ if (CategoryList.isSignedIn()==false) {
+ startActivity(frontdoor);
+ }else{
+ if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
+ }
+ }
}
import android.app.Dialog;
import android.app.ListActivity;
import android.app.ProgressDialog;
+import android.content.BroadcastReceiver;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
public static final String KEY_ID = "id"; // Intent keys
public static final String KEY_CATEGORY_ID = "categoryId"; // Intent keys
- private static Long CategoryId=null;
- private Intent restartTimerIntent;
+ private Long CategoryId=null;
+
+ Intent frontdoor;
+ private Intent restartTimerIntent=null;
private static String salt;
private static String masterKey;
}
};
+ BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
+ if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
+ startActivity(frontdoor);
+ }
+ }
+ };
+
/**
* Called when the activity is first created.
*/
super.onCreate(icicle);
if (debug) Log.d(TAG,"onCreate()");
+
+ frontdoor = new Intent(this, FrontDoor.class);
+ frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
if (CategoryList.isSignedIn()==false) {
- finish();
return;
}
restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
try { fillerThread.join(maxWaitToDie); }
catch(InterruptedException e){} // ignore
}
+ try {
+ unregisterReceiver(mIntentReceiver);
+ } catch (IllegalArgumentException e) {
+ if (debug) Log.d(TAG,"IllegalArgumentException");
+ }
}
@Override
if (debug) Log.d(TAG,"onResume()");
if (CategoryList.isSignedIn()==false) {
- finish();
+ startActivity(frontdoor);
return;
}
+ IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
+ registerReceiver(mIntentReceiver, filter);
}
@Override
return masterKey;
}
- static long getCategoryId() {
- return CategoryId;
- }
-
private void addPassword() {
Intent i = new Intent(this, PassEdit.class);
+ i.putExtra(PassList.KEY_ID, (long)-1);
+ i.putExtra(PassList.KEY_CATEGORY_ID, CategoryId);
startActivityForResult(i,REQUEST_ADD_PASSWORD);
}
/**
fillData();
}
}
+
+ @Override
+ public void onUserInteraction() {
+ super.onUserInteraction();
+
+ if (debug) Log.d(TAG,"onUserInteraction()");
+
+ if (CategoryList.isSignedIn()==false) {
+ startActivity(frontdoor);
+ }else{
+ if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
+ }
+ }
}
import java.util.ArrayList;
+import org.openintents.intents.CryptoIntents;
+
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
+import android.content.BroadcastReceiver;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
private Long CategoryId;
public static boolean entryEdited=false;
+ Intent frontdoor;
+ private Intent restartTimerIntent=null;
+
+ BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
+ if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
+ startActivity(frontdoor);
+ }
+ }
+ };
+
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (debug) Log.d(TAG,"onCreate()");
+
+ frontdoor = new Intent(this, FrontDoor.class);
+ frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
if (CategoryList.isSignedIn()==false) {
- finish();
- return;
+ startActivity(frontdoor);
}
+ restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
String title = getResources().getString(R.string.app_name) + " - "
+ getResources().getString(R.string.view_entry);
@Override
protected void onPause() {
super.onPause();
+
+ if (debug) Log.d(TAG,"onResume()");
+
+ try {
+ unregisterReceiver(mIntentReceiver);
+ } catch (IllegalArgumentException e) {
+ if (debug) Log.d(TAG,"IllegalArgumentException");
+ }
+ // hide the window from view
+ Window w=getWindow();
+ WindowManager.LayoutParams attrs=w.getAttributes();
+ attrs.alpha=0;
+ w.setAttributes(attrs);
+// w.setLayout(0, 0);
}
@Override
if (debug) Log.d(TAG,"onResume()");
if (CategoryList.isSignedIn()==false) {
- finish();
+ startActivity(frontdoor);
return;
}
+ IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
+ registerReceiver(mIntentReceiver, filter);
+ // show the window
+ Window w=getWindow();
+ WindowManager.LayoutParams attrs=w.getAttributes();
+ attrs.alpha=1;
+ w.setAttributes(attrs);
+// w.setLayout(getWallpaperDesiredMinimumWidth(), getWallpaperDesiredMinimumWidth());
}
@Override
if (debug) Log.d(TAG,"populateFields()");
if (RowId != null) {
PassEntry row = Passwords.getPassEntry(RowId, true, false);
+ if (row==null) {
+ if (debug) Log.d(TAG,"populateFields: row=null");
+ return;
+ }
ArrayList<String> packageAccess = Passwords.getPackageAccess(RowId);
descriptionText.setText(row.plainDescription);
websiteText.setText(row.plainWebsite);
}
}
}
+
+ @Override
+ public void onUserInteraction() {
+ super.onUserInteraction();
+
+ if (debug) Log.d(TAG,"onUserInteraction()");
+
+ if (CategoryList.isSignedIn()==false) {
+ startActivity(frontdoor);
+ }else{
+ if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
+ }
+ }
}
package org.openintents.safe;
+import org.openintents.intents.CryptoIntents;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
+import android.util.Log;
public class Preferences extends PreferenceActivity {
+ private static boolean debug = false;
+ private static String TAG = "Preferences";
+
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_FIRST_TIME_WARNING = "first_time_warning";
public static final String PREFERENCE_KEYPAD = "keypad";
public static final String PREFERENCE_KEYPAD_MUTE = "keypad_mute";
-
+
+ Intent frontdoor;
+ private Intent restartTimerIntent=null;
+
+ BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
+ if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
+ startActivity(frontdoor);
+ }
+ }
+ };
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ frontdoor = new Intent(this, FrontDoor.class);
+ frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
if (CategoryList.isSignedIn()==false) {
- finish();
- return;
- }
+ startActivity(frontdoor);
+ }
+ restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
super.onResume();
if (CategoryList.isSignedIn()==false) {
- finish();
+ startActivity(frontdoor);
return;
}
+ IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
+ registerReceiver(mIntentReceiver, filter);
}
@Override
SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
boolean lockOnScreenLock = mPreferences.getBoolean(Preferences.PREFERENCE_LOCK_ON_SCREEN_LOCK, true);
IntentHandler.setLockOnScreenLock(lockOnScreenLock);
+
+ try {
+ unregisterReceiver(mIntentReceiver);
+ } catch (IllegalArgumentException e) {
+ if (debug) Log.d(TAG,"IllegalArgumentException");
+ }
}
+ @Override
+ public void onUserInteraction() {
+ super.onUserInteraction();
+
+ if (debug) Log.d(TAG,"onUserInteraction()");
+
+ if (CategoryList.isSignedIn()==false) {
+ startActivity(frontdoor);
+ }else{
+ if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
+ }
+ }
}
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
+import org.openintents.intents.CryptoIntents;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
+import android.content.BroadcastReceiver;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
public static final String KEY_FIRST_TIME = "first_time"; // Intent keys
+ Intent frontdoor;
+ private Intent restartTimerIntent=null;
+
+ BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
+ if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
+ startActivity(frontdoor);
+ }
+ }
+ };
+
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
firstTime = extras != null ? extras.getBoolean(Restore.KEY_FIRST_TIME) : false;
}
+ frontdoor = new Intent(this, FrontDoor.class);
+ frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
if ((!firstTime) && (CategoryList.isSignedIn()==false)) {
- Intent frontdoor = new Intent(this, FrontDoor.class);
startActivity(frontdoor);
- finish();
return;
}
+ restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
setContentView(R.layout.restore);
String title = getResources().getString(R.string.app_name) + " - " +
});
}
+ @Override
+ protected void onPause() {
+ super.onPause();
+
+ try {
+ unregisterReceiver(mIntentReceiver);
+ } catch (IllegalArgumentException e) {
+ if (debug) Log.d(TAG,"IllegalArgumentException");
+ }
+ }
+
@Override
protected void onResume() {
super.onResume();
if (debug) Log.d(TAG,"onResume()");
if ((!firstTime) && (CategoryList.isSignedIn()==false)) {
- Intent frontdoor = new Intent(this, FrontDoor.class);
startActivity(frontdoor);
- finish();
return;
}
+ IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
+ registerReceiver(mIntentReceiver, filter);
}
private boolean backupFileExists(String filename) {
setResult(RESULT_OK);
finish();
}
+
+ @Override
+ public void onUserInteraction() {
+ super.onUserInteraction();
+
+ if (debug) Log.d(TAG,"onUserInteraction()");
+
+ if (CategoryList.isSignedIn()==false) {
+ startActivity(frontdoor);
+ }else{
+ if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
+ }
+ }
}
--- /dev/null
+/* $Id$
+ *
+ * Copyright (C) 2009 OpenIntents.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openintents.safe;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.openintents.intents.CryptoIntents;
+
+import android.app.Dialog;
+import android.app.ListActivity;
+import android.app.ProgressDialog;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ListView;
+
+public class Search extends ListActivity {
+
+ private static final String TAG = "Search";
+ private static boolean debug = false;
+
+ public static final int REQUEST_VIEW_PASSWORD = 1;
+
+ private static final int SEARCH_PROGRESS_KEY = 0;
+
+ private static final int MSG_SEARCH_COMPLETE = 0;
+
+ private Thread searchThread=null;
+
+ private EditText etSearchCriteria;
+ private String searchCriteria="";
+ private List<PassEntry> results=null;
+ private ArrayAdapter<String> entries=null;
+
+ Intent frontdoor;
+ private Intent restartTimerIntent=null;
+
+ public Handler myViewUpdateHandler = new Handler(){
+ // @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MSG_SEARCH_COMPLETE:
+ setListAdapter(entries);
+ break;
+ }
+ super.handleMessage(msg);
+ }
+ };
+
+ BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
+ if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
+ startActivity(frontdoor);
+ }
+ }
+ };
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+
+ if (debug) Log.d(TAG,"onCreate()");
+
+ setContentView(R.layout.search);
+ String title = getResources().getString(R.string.app_name) + " - " +
+ getResources().getString(R.string.search);
+ setTitle(title);
+
+ frontdoor = new Intent(this, FrontDoor.class);
+ frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
+ if (CategoryList.isSignedIn()==false) {
+ startActivity(frontdoor);
+ }
+ restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
+
+ etSearchCriteria = (EditText) findViewById(R.id.search_criteria);
+ results=new ArrayList<PassEntry>();
+
+ Button goButton = (Button) findViewById(R.id.go_button);
+ goButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View arg0) {
+ searchCriteria = etSearchCriteria.getText().toString().trim().toLowerCase();
+ searchThreadStart();
+ }
+ });
+
+ restoreMe();
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+
+ if (debug) Log.d(TAG,"onPause()");
+
+ if ((searchThread != null) && (searchThread.isAlive())) {
+ if (debug) Log.d(TAG,"wait for search thread");
+ int maxWaitToDie=500000;
+ try { searchThread.join(maxWaitToDie); }
+ catch(InterruptedException e){} // ignore
+ }
+ try {
+ unregisterReceiver(mIntentReceiver);
+ } catch (IllegalArgumentException e) {
+ if (debug) Log.d(TAG,"IllegalArgumentException");
+ }
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ if (debug) Log.d(TAG,"onResume()");
+
+ if (CategoryList.isSignedIn()==false) {
+ startActivity(frontdoor);
+ return;
+ }
+ IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
+ registerReceiver(mIntentReceiver, filter);
+
+ }
+
+ protected void onListItemClick(ListView l, View v, int position, long id) {
+ super.onListItemClick(l, v, position, id);
+
+ if (debug) Log.d(TAG,"onListItemClick: position="+position);
+ if ((results==null) || (results.size()==0)) {
+ return;
+ }
+ Intent passView = new Intent(this, PassView.class);
+ passView.putExtra(PassList.KEY_ID, results.get(position).id);
+ if (debug) Log.d(TAG,"onListItemClick: category="+results.get(position).category);
+ passView.putExtra(PassList.KEY_CATEGORY_ID, results.get(position).category);
+ startActivityForResult(passView,REQUEST_VIEW_PASSWORD);
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent i) {
+ super.onActivityResult(requestCode, resultCode, i);
+
+ if (((requestCode==REQUEST_VIEW_PASSWORD)&&(PassView.entryEdited)) ||
+ (resultCode==RESULT_OK)) {
+ searchThreadStart();
+ }
+ }
+
+ @Override
+ protected Dialog onCreateDialog(int id) {
+ switch (id) {
+ case SEARCH_PROGRESS_KEY: {
+ ProgressDialog dialog = new ProgressDialog(this);
+ dialog.setMessage(getString(R.string.search_progress));
+ dialog.setIndeterminate(false);
+ dialog.setCancelable(false);
+ return dialog;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Start a separate thread to search the database. By running
+ * the search in a thread it allows the main UI thread to return
+ * and permit the updating of the progress dialog.
+ */
+ private void searchThreadStart(){
+ showDialog(SEARCH_PROGRESS_KEY);
+ searchThread = new Thread(new Runnable() {
+ public void run() {
+ doSearch();
+ dismissDialog(SEARCH_PROGRESS_KEY);
+ sendBroadcast (restartTimerIntent);
+
+ Message m = new Message();
+ m.what = MSG_SEARCH_COMPLETE;
+ Search.this.myViewUpdateHandler.sendMessage(m);
+
+ if (debug) Log.d(TAG,"thread end");
+ }
+ });
+ searchThread.start();
+ }
+
+ private void doSearch() {
+ if (debug) Log.d(TAG,"doSearch: searchCriteria="+searchCriteria);
+ results.clear();
+ if (searchCriteria.length()==0) {
+ // don't bother searching for nothing
+ return;
+ }
+
+
+ List<CategoryEntry> categories=Passwords.getCategoryEntries();
+ for (CategoryEntry catRow : categories) {
+ if (debug) Log.d(TAG,"doSearch: category="+catRow.plainName);
+ List<PassEntry> passwords=Passwords.getPassEntries(catRow.id, true, false);
+ for (PassEntry passRow : passwords) {
+ if (searchThread.isInterrupted()) {
+ return;
+ }
+
+ String description=passRow.plainDescription.toLowerCase();
+ String website=passRow.plainWebsite.toLowerCase();
+ String username=passRow.plainUsername.toLowerCase();
+ String password=passRow.plainPassword.toLowerCase();
+ String note=passRow.plainNote.toLowerCase();
+ if (description.contains(searchCriteria) ||
+ website.contains(searchCriteria) ||
+ username.contains(searchCriteria) ||
+ password.contains(searchCriteria) ||
+ note.contains(searchCriteria)) {
+ if (debug) Log.d(TAG,"matches: "+passRow.plainDescription);
+ results.add(passRow);
+ continue;
+ }
+ }
+ }
+
+ updateListFromResults();
+ }
+
+ @Override
+ public Object onRetainNonConfigurationInstance() {
+ return(results);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void restoreMe() {
+ if (getLastNonConfigurationInstance()!=null) {
+ results=(List<PassEntry>)getLastNonConfigurationInstance();
+ updateListFromResults();
+ setListAdapter(entries);
+ }
+ }
+
+ private void updateListFromResults() {
+ if ((results==null) || (results.size()==0)) {
+ return;
+ }
+
+ List<String> passDescriptions=new ArrayList<String>();
+
+ for (PassEntry passRow : results) {
+ passDescriptions.add(passRow.plainDescription);
+ }
+ entries =
+ new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
+ passDescriptions);
+ }
+
+ @Override
+ public void onUserInteraction() {
+ super.onUserInteraction();
+
+ if (debug) Log.d(TAG,"onUserInteraction()");
+
+ if (CategoryList.isSignedIn()==false) {
+ startActivity(frontdoor);
+ }else{
+ if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
+ }
+ }
+}
import android.os.CountDownTimer;
public class ServiceDispatchImpl extends Service {
- private static boolean debug = false;
+ private static boolean debug = true;
private static String TAG = "ServiceDispatchIMPL";
public static CryptoHelper ch; // TODO Peli: Could clean this up by moving it into a singleton? Or at least a separate static class?
private String salt;
@Override
public void onDestroy() {
super.onDestroy();
+
+ if (debug) Log.d( TAG,"onDestroy" );
masterKey = null;
ch = null;
unregisterReceiver(mIntentReceiver);
ServiceNotification.clearNotification(ServiceDispatchImpl.this);
+ CategoryList.setSignedOut();
Intent intent = new Intent(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
sendBroadcast(intent);
- CategoryList.setSignedOut();
- if (debug) Log.d( TAG,"onDestroy" );
}
private void startTimer () {
if (debug) Log.d(TAG,"startTimer with timeoutUntilStop="+timeoutUntilStop);
- t = new CountDownTimer(timeoutUntilStop, timeoutUntilStop) {
+ t = new CountDownTimer(timeoutUntilStop, 10000) {
public void onTick(long millisUntilFinished) {
//doing nothing.
if (debug) Log.d(TAG, "tick: " + millisUntilFinished );