Cleaned up code, better random password generation

pull/14/head
Sam Bosley 13 years ago
parent bbdc745731
commit 61434b7b74

@ -301,13 +301,32 @@ public class ActFmLoginActivity extends Activity implements AuthListener {
private String generateRandomPassword() {
String acceptable = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),."; //$NON-NLS-1$
char[] chars = new char[8];
char last = 'a';
for (int i = 0; i < chars.length; i++) {
char r = acceptable.charAt(rand.nextInt(acceptable.length()));
while (checkSimilar(last, r))
r = acceptable.charAt(rand.nextInt(acceptable.length()));
last = r;
chars[i] = r;
}
return new String(chars);
}
@SuppressWarnings("nls")
private boolean checkSimilar(char last, char check) {
String iSimilar = "ijl1!";
String oSimilar = "oO0";
String puncSimilar = ".,";
boolean match = (iSimilar.indexOf(last) > 0 && iSimilar.indexOf(check) > 0)
|| (oSimilar.indexOf(last) > 0 && oSimilar.indexOf(check) > 0)
|| (puncSimilar.indexOf(last) > 0 && puncSimilar.indexOf(check) > 0);
if (match)
return false;
return true;
}
private EditText addEditField(LinearLayout body, int hint) {
TextView label = new TextView(ActFmLoginActivity.this);
label.setText(hint);

@ -32,6 +32,7 @@ public class MoveListRequest extends PushRequest {
@Override
protected void recover() {
//If there's a good way to recover, put it here
//Since MoveListRequest isn't actually used at the moment, it's probably fine for now
}
private void transferProperties(Task local) {

@ -22,7 +22,7 @@ public class UpdateRequest extends PushRequest {
@Override
protected void recover() {
//If there's a good way to recover, put it here
//Figure out a good way to recover!
}
}

@ -169,14 +169,4 @@ public class ABOptions {
//Calls to addOption go here
}
// Declare AB options like this:
// public static final String AB_OPTION_FIRST_ACTIVITY = "ab_first_activity";
// private static final int[] AB_OPTION_FIRST_ACTIVITY_PROBS = { 9, 1 };
// private static final String[] AB_OPTION_FIRST_ACTIVITY_DESCRIPTIONS = { "ab-show-tasks-first", "ab-show-lists-first" };
// private static final String[] AB_OPTION_FIRST_ACTIVITY_RELEVANT_EVENTS = { StatisticsConstants.CREATE_TASK,
// StatisticsConstants.TASK_CREATED_TASKLIST,
// StatisticsConstants.USER_FIRST_TASK,
// StatisticsConstants.ACTFM_LIST_SHARED,
// StatisticsConstants.ACTFM_NEW_USER };//*/
}

Loading…
Cancel
Save