<string name="open_safe">Open OI Safe</string>\r
<string name="lock">Lock</string>\r
<string name="continue_text">Continue</string>\r
+ <string name="generate_password">Generate Password</string>\r
<string name="pass_gen_length">Password Length</string>\r
<string name="pass_gen_uppercase">Uppercase [A-Z]</string>\r
<string name="pass_gen_lowercase">Lowercase [a-z]</string>\r
*/
public class AskPassword extends Activity {
- private boolean debug = false;
+ private boolean debug = true;
private static String TAG = "AskPassword";
public static String EXTRA_IS_LOCAL = "org.openintents.safe.bundle.EXTRA_IS_REMOTE";
return;
}
- if (debug) Log.d(TAG, "onCreate()");
+ if (debug) Log.d(TAG,"onCreate("+icicle+")");
dbHelper = new DBHelper(this);
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- if (debug) Log.d(TAG, "onCreate");
+ if (debug) Log.d(TAG,"onCreate("+icicle+")");
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) + " - " +
Bundle extras = getIntent().getExtras();
RowId = extras != null ? extras.getLong(CategoryList.KEY_ID) : null;
}
-
- populateFields();
+ if ((RowId==null) || (RowId<1)) {
+ finish(); // no valid category
+ return;
+ }
confirmButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
try {
unregisterReceiver(mIntentReceiver);
} catch (IllegalArgumentException e) {
- if (debug) Log.d(TAG,"IllegalArgumentException");
+ //if (debug) Log.d(TAG,"IllegalArgumentException");
}
}
startActivity(frontdoor);
return;
}
- populateFields();
IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
registerReceiver(mIntentReceiver, filter);
+
+ Passwords.Initialize(this);
+
+ populateFields();
}
private void saveState() {
*/
public class CategoryList extends ListActivity {
- private static boolean debug = false;
+ private static boolean debug = true;
private static final String TAG = "CategoryList";
// Menu Item order
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- if (debug) Log.d(TAG,"onCreate()");
+ if (debug) Log.d(TAG,"onCreate("+icicle+")");
restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
- if (isSignedIn()==false) {
- Intent frontdoor = new Intent(this, FrontDoor.class);
- frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
- startActivity(frontdoor);
- return;
- }
-
- try {
- Passwords.InitCrypto(CryptoHelper.EncryptionMedium, salt, masterKey);
- } catch (Exception e) {
- e.printStackTrace();
- Toast.makeText(CategoryList.this, "CategoryList: " + getString(R.string.crypto_error),
- Toast.LENGTH_SHORT).show();
- }
-
+ Passwords.Initialize(this);
+
setContentView(R.layout.cat_list);
String title = getResources().getString(R.string.app_name) + " - " +
getResources().getString(R.string.categories);
filter.addAction (CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
registerReceiver(mIntentReceiver, filter);
-// fillData();
-
final ListView list = getListView();
list.setFocusable(true);
list.setOnCreateContextMenuListener(this);
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
lockOnScreenLock = sp.getBoolean(Preferences.PREFERENCE_LOCK_ON_SCREEN_LOCK, true);
+ Passwords.Initialize(this);
+
ListAdapter la=getListAdapter();
if (la!=null) {
if (debug) Log.d(TAG,"onResume: count="+la.getCount());
try {
unregisterReceiver(mIntentReceiver);
} catch (IllegalArgumentException e) {
- if (debug) Log.d(TAG,"IllegalArgumentException");
+ //if (debug) Log.d(TAG,"IllegalArgumentException");
}
}
frontdoor = new Intent(this, FrontDoor.class);
frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
- if (CategoryList.isSignedIn()==false) {
- startActivity(frontdoor);
- }
restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
setContentView(R.layout.chg_pass);
try {
unregisterReceiver(mIntentReceiver);
} catch (IllegalArgumentException e) {
- if (debug) Log.d(TAG,"IllegalArgumentException");
+ //if (debug) Log.d(TAG,"IllegalArgumentException");
}
}
}
IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
registerReceiver(mIntentReceiver, filter);
+
+ Passwords.Initialize(this);
}
@Override
frontdoor = new Intent(this, FrontDoor.class);
frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
- if (CategoryList.isSignedIn()==false) {
- startActivity(frontdoor);
- }
restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
//Setup layout
try {
unregisterReceiver(mIntentReceiver);
} catch (IllegalArgumentException e) {
- if (debug) Log.d(TAG,"IllegalArgumentException");
+ //if (debug) Log.d(TAG,"IllegalArgumentException");
}
}
*/\r
public class IntentHandler extends Activity {\r
\r
- private static final boolean debug = false;\r
+ private static final boolean debug = true;\r
private static String TAG = "IntentHandler";\r
\r
private static final int REQUEST_CODE_ASK_PASSWORD = 1;\r
*/
public class PassEdit extends Activity {
- private static boolean debug = false;
+ private static boolean debug = true;
private static String TAG = "PassEdit";
public static final int REQUEST_GEN_PASS = 10;
public static final int GEN_PASSWORD_INDEX = Menu.FIRST + 3;
public static final int RESULT_DELETED = RESULT_FIRST_USER;
+
+ public static final String KEY_DESCRIPTION = "description";
+ public static final String KEY_WEBSITE = "website";
+ public static final String KEY_USERNAME = "username";
+ public static final String KEY_PASSWORD = "password";
+ public static final String KEY_NOTE = "note";
private EditText descriptionText;
private EditText passwordText;
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- if (debug) Log.d(TAG,"onCreate()");
-
+ if (debug) Log.d(TAG,"onCreate("+icicle+")");
+
+ RowId = icicle != null ? icicle.getLong(PassList.KEY_ID) : null;
+ if (RowId == null) {
+ 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);
+
+ if ((RowId==null) || (CategoryId==null) ||
+ (RowId<1) || (CategoryId<1)) {
+ // invalid Row or Category
+ finish();
+ return;
+ }
+
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);
-
setContentView(R.layout.pass_edit);
descriptionText = (EditText) findViewById(R.id.description);
noteText = (EditText) findViewById(R.id.note);
websiteText = (EditText) findViewById(R.id.website);
- Button goButton = (Button) findViewById(R.id.go);
-
- RowId = icicle != null ? icicle.getLong(PassList.KEY_ID) : null;
- if (RowId == null) {
- 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 (icicle!=null) {
+ String plainDescription = icicle.getString(PassEdit.KEY_DESCRIPTION);
+ if (plainDescription == null) {
+ descriptionText.setText(plainDescription);
+ populated=true;
+ }
+ String plainPassword = icicle.getString(PassEdit.KEY_PASSWORD);
+ String plainUsername = icicle.getString(PassEdit.KEY_USERNAME);
+ String plainNote = icicle.getString(PassEdit.KEY_NOTE);
+ String plainWebsite = icicle.getString(PassEdit.KEY_WEBSITE);
}
- if (debug) Log.d(TAG,"RowId="+RowId);
- if (debug) Log.d(TAG,"CategoryId="+CategoryId);
+
+ Button goButton = (Button) findViewById(R.id.go);
entryEdited = false;
outState.putLong(PassList.KEY_ID, -1);
}
outState.putLong(PassList.KEY_CATEGORY_ID, CategoryId);
+
+ String plainDescription = getTextFromField(descriptionText);
+ String plainWebsite = getTextFromField(websiteText);
+ String plainUsername = getTextFromField(usernameText);
+ String plainPassword = getTextFromField(passwordText);
+ String plainNote = getTextFromField(noteText);
+
+ outState.putString(PassEdit.KEY_DESCRIPTION, plainDescription);
+ outState.putString(PassEdit.KEY_WEBSITE, plainWebsite);
+ outState.putString(PassEdit.KEY_USERNAME, plainUsername);
+ outState.putString(PassEdit.KEY_PASSWORD, plainPassword);
+ outState.putString(PassEdit.KEY_NOTE, plainNote);
}
@Override
protected void onPause() {
super.onPause();
+ if (debug) Log.d(TAG,"onResume()");
+
if (isFinishing() && discardEntry==false) {
savePassword();
}
try {
unregisterReceiver(mIntentReceiver);
} catch (IllegalArgumentException e) {
- if (debug) Log.d(TAG,"IllegalArgumentException");
+ //if (debug) Log.d(TAG,"IllegalArgumentException");
}
}
if (debug) Log.d(TAG,"onResume()");
if (CategoryList.isSignedIn()==false) {
- saveState();
+ if (Passwords.isCryptoInitialized()) {
+ saveState();
+ }
startActivity(frontdoor);
return;
}
IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
registerReceiver(mIntentReceiver, filter);
+ Passwords.Initialize(this);
+
populateFields();
}
}
}
+ /**
+ * Get the text from an EditText field.
+ *
+ * @param e EditText to retrieve text from.
+ * @return The field's text. If e==null returns null.
+ */
+ private String getTextFromField(EditText e) {
+ if (e==null) {
+ return null;
+ }
+ return e.getText().toString();
+ }
+
@Override
public void onUserInteraction() {
super.onUserInteraction();
frontdoor = new Intent(this, FrontDoor.class);
frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
- if (CategoryList.isSignedIn()==false) {
- startActivity(frontdoor);
- }
restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
setContentView(R.layout.pass_gen);
- String title = getResources().getString(R.string.app_name) + " - Generate Password";
+ String title = getString(R.string.app_name) + " - " +
+ getString(R.string.generate_password);
setTitle(title);
pass_view = (EditText) findViewById(R.id.pass_view);
*/
public class PassList extends ListActivity {
- private static final boolean debug = false;
+ private static final boolean debug = true;
private static final String TAG = "PassList";
// Menu Item order
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) {
- return;
- }
- restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
+ if (debug) Log.d(TAG,"onCreate("+icicle+")");
- setContentView(R.layout.pass_list);
-
CategoryId = icicle != null ? icicle.getLong(CategoryList.KEY_ID) : null;
if (CategoryId == null) {
Bundle extras = getIntent().getExtras();
CategoryId = extras != null ? extras.getLong(CategoryList.KEY_ID) : null;
}
- if (CategoryId<1) {
- finish(); // no valid category less than one
+ if (debug) Log.d(TAG,"CategoryId="+CategoryId);
+ if ((CategoryId==null) || (CategoryId<1)) {
+ finish(); // no valid category
return;
}
-
- String categoryName=Passwords.getCategoryEntry(CategoryId).plainName;
- String title = getResources().getString(R.string.app_name) + " - " +
- getResources().getString(R.string.passwords) + " -" +
- categoryName;
- setTitle(title);
-// fillData();
+ frontdoor = new Intent(this, FrontDoor.class);
+ frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
+ restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
+
+ setContentView(R.layout.pass_list);
final ListView list = getListView();
list.setFocusable(true);
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
+ if (debug) Log.d(TAG,"onSaveInstanceState(): CategoryId="+CategoryId);
// remember which Category we're looking at
if (CategoryId != null) {
outState.putLong(CategoryList.KEY_ID, CategoryId);
try {
unregisterReceiver(mIntentReceiver);
} catch (IllegalArgumentException e) {
- if (debug) Log.d(TAG,"IllegalArgumentException");
+ //if (debug) Log.d(TAG,"IllegalArgumentException");
}
removeDialog(DECRYPT_PROGRESS_KEY);
}
IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
registerReceiver(mIntentReceiver, filter);
+ Passwords.Initialize(this);
+
+ String categoryName=Passwords.getCategoryEntry(CategoryId).plainName;
+ String title = getResources().getString(R.string.app_name) + " - " +
+ getResources().getString(R.string.passwords) + " -" +
+ categoryName;
+ setTitle(title);
+
ListAdapter la=getListAdapter();
if (la!=null) {
if (debug) Log.d(TAG,"onResume: count="+la.getCount());
fillerThread = new Thread(new Runnable() {
public void run(){
+ if (debug) Log.d(TAG,"CategoryId="+CategoryId);
rows=Passwords.getPassEntries(CategoryId, true, true);
passDescriptions.clear();
if (rows!=null) {
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;
*/
public class PassView extends Activity implements View.OnClickListener {
- private static boolean debug = false;
+ private static boolean debug = true;
private static String TAG = "PassView";
public static final int EDIT_PASSWORD_INDEX = Menu.FIRST;
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- if (debug) Log.d(TAG,"onCreate()");
+ if (debug) Log.d(TAG,"onCreate("+icicle+")");
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) + " - "
CategoryId = extras != null ? extras.getLong(PassList.KEY_CATEGORY_ID) : null;
}
- populateFields();
-
+ if ((RowId==null) || (CategoryId==null) ||
+ (RowId<1) || (CategoryId<1)) {
+ // invalid Row or Category
+ finish();
+ return;
+ }
goButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
String link = websiteText.getText().toString();
try {
unregisterReceiver(mIntentReceiver);
} catch (IllegalArgumentException e) {
- if (debug) Log.d(TAG,"IllegalArgumentException");
+ //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
}
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());
+
+ Passwords.Initialize(this);
+
+ populateFields();
}
@Override
import android.content.Context;
import android.util.Log;
+import android.widget.Toast;
/**
* Abstraction layer for storing encrypted and decrypted versions
*/
public class Passwords {
- private static final boolean debug = false;
+ private static final boolean debug = true;
private static final String TAG = "Passwords";
private static HashMap<Long, PassEntry> passEntries=null;
private static HashMap<Long, ArrayList<PackageAccessEntry>> packageAccessEntries=null;
private static CryptoHelper ch=null;
+ private static boolean cryptoInitialized=false;
+
private static DBHelper dbHelper=null;
public static void Initialize(Context ctx) {
if (ch==null) {
ch = new CryptoHelper();
}
+ if ((cryptoInitialized==false) &&
+ (CategoryList.getSalt()!=null) &&
+ (CategoryList.getMasterKey()!=null))
+ {
+ try {
+ Passwords.InitCrypto(CryptoHelper.EncryptionMedium,
+ CategoryList.getSalt(), CategoryList.getMasterKey());
+ cryptoInitialized=true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ Toast.makeText(ctx, "CategoryList: " + ctx.getString(R.string.crypto_error),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+
if (dbHelper==null) {
dbHelper = new DBHelper(ctx);
}
public static void InitCrypto(int strength, String salt, String masterKey)
throws Exception {
+ if (debug) Log.d(TAG,"InitCrypto("+strength+","+salt+","+masterKey);
try {
ch.init(strength,salt);
ch.setPassword(masterKey);
}
}
+ public static boolean isCryptoInitialized() {
+ return cryptoInitialized;
+ }
public static void deleteAll() {
dbHelper.deleteDatabase();
Reset();
}
public static List<PassEntry> getPassEntries(long categoryId, boolean decrypt, boolean descriptionOnly) {
+ if (debug) Log.d(TAG,"getPassEntries("+categoryId+","+decrypt+","+descriptionOnly+")");
Collection<PassEntry> passwords=passEntries.values();
List<PassEntry> passList=new ArrayList<PassEntry>();
Iterator<PassEntry> passIter=passwords.iterator();
frontdoor = new Intent(this, FrontDoor.class);
frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
- if (CategoryList.isSignedIn()==false) {
- startActivity(frontdoor);
- }
restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
// Load the preferences from an XML resource
try {
unregisterReceiver(mIntentReceiver);
} catch (IllegalArgumentException e) {
- if (debug) Log.d(TAG,"IllegalArgumentException");
+ //if (debug) Log.d(TAG,"IllegalArgumentException");
}
}
frontdoor = new Intent(this, FrontDoor.class);
frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
- if ((!firstTime) && (CategoryList.isSignedIn()==false)) {
- startActivity(frontdoor);
- return;
- }
restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
+ Passwords.Initialize(this);
+
setContentView(R.layout.restore);
String title = getResources().getString(R.string.app_name) + " - " +
getResources().getString(R.string.restore);
try {
unregisterReceiver(mIntentReceiver);
} catch (IllegalArgumentException e) {
- if (debug) Log.d(TAG,"IllegalArgumentException");
+ //if (debug) Log.d(TAG,"IllegalArgumentException");
}
}
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);
try {
unregisterReceiver(mIntentReceiver);
} catch (IllegalArgumentException e) {
- if (debug) Log.d(TAG,"IllegalArgumentException");
+ //if (debug) Log.d(TAG,"IllegalArgumentException");
}
}
}
IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
registerReceiver(mIntentReceiver, filter);
-
+
+ Passwords.Initialize(this);
}
protected void onListItemClick(ListView l, View v, int position, long id) {