mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Merge remote-tracking branch 'TwinProduction/master'
This commit is contained in:
@@ -35,14 +35,11 @@ public class KeePass extends Activity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
startFileSelect();
|
||||
}
|
||||
|
||||
|
||||
@@ -54,20 +54,15 @@ public class AboutDialog extends Dialog {
|
||||
|
||||
private void setVersion() {
|
||||
Context ctx = getContext();
|
||||
|
||||
String version;
|
||||
try {
|
||||
PackageInfo packageInfo = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0);
|
||||
version = packageInfo.versionName;
|
||||
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
version = "";
|
||||
}
|
||||
|
||||
TextView tv = (TextView) findViewById(R.id.version);
|
||||
tv.setText(version);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -107,7 +107,6 @@ public class Database {
|
||||
throw ContentFileNotFoundException.getInstance(keyfile);
|
||||
}
|
||||
LoadData(ctx, is, password, kfIs, status, debug);
|
||||
|
||||
}
|
||||
|
||||
public void LoadData(Context ctx, InputStream is, String password, InputStream kfIs, boolean debug) throws IOException, InvalidDBException {
|
||||
@@ -115,7 +114,6 @@ public class Database {
|
||||
}
|
||||
|
||||
public void LoadData(Context ctx, InputStream is, String password, InputStream kfIs, UpdateStatus status, boolean debug) throws IOException, InvalidDBException {
|
||||
|
||||
BufferedInputStream bis = new BufferedInputStream(is);
|
||||
|
||||
if ( ! bis.markSupported() ) {
|
||||
@@ -132,12 +130,9 @@ public class Database {
|
||||
pm = imp.openDatabase(bis, password, kfIs, status);
|
||||
if ( pm != null ) {
|
||||
PwGroup root = pm.rootGroup;
|
||||
|
||||
pm.populateGlobals(root);
|
||||
|
||||
LoadData(ctx, pm, password, kfIs, status);
|
||||
}
|
||||
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
@@ -145,19 +140,13 @@ public class Database {
|
||||
if ( pm != null ) {
|
||||
passwordEncodingError = !pm.validatePasswordEncoding(password);
|
||||
}
|
||||
|
||||
searchHelper = new SearchDbHelper(ctx);
|
||||
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
public PwGroup Search(String str) {
|
||||
if (searchHelper == null) { return null; }
|
||||
|
||||
PwGroup group = searchHelper.search(this, str);
|
||||
|
||||
return group;
|
||||
|
||||
return searchHelper.search(this, str);
|
||||
}
|
||||
|
||||
public void SaveData(Context ctx) throws IOException, PwDbOutputException {
|
||||
@@ -203,9 +192,7 @@ public class Database {
|
||||
pmo.output();
|
||||
os.close();
|
||||
}
|
||||
|
||||
mUri = uri;
|
||||
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
@@ -229,5 +216,4 @@ public class Database {
|
||||
dirty.add(pm.rootGroup);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -184,7 +184,6 @@ public abstract class GroupBaseActivity extends LockCloseListActivity {
|
||||
}
|
||||
|
||||
menu.findItem(R.id.menu_sort).setTitle(resId);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -261,7 +260,6 @@ public abstract class GroupBaseActivity extends LockCloseListActivity {
|
||||
|
||||
private void setPassword() {
|
||||
SetPasswordDialog dialog = new SetPasswordDialog(this);
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
@@ -295,7 +293,5 @@ public abstract class GroupBaseActivity extends LockCloseListActivity {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,11 +61,9 @@ public class ProgressTask implements Runnable {
|
||||
// Show process dialog
|
||||
mPd.show();
|
||||
|
||||
|
||||
// Start Thread to Run task
|
||||
Thread t = new Thread(mTask);
|
||||
t.start();
|
||||
|
||||
}
|
||||
|
||||
private class AfterTask extends OnFinish {
|
||||
@@ -77,10 +75,8 @@ public class ProgressTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
|
||||
// Remove the progress dialog
|
||||
mHandler.post(new CloseProcessDialog());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,7 +49,6 @@ public class SetPasswordDialog extends CancelDialog {
|
||||
|
||||
public SetPasswordDialog(Context context, FileOnFinish finish) {
|
||||
super(context);
|
||||
|
||||
mFinish = finish;
|
||||
}
|
||||
|
||||
@@ -144,10 +143,7 @@ public class SetPasswordDialog extends CancelDialog {
|
||||
} else {
|
||||
displayMessage(getContext());
|
||||
}
|
||||
|
||||
super.run();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,9 +39,5 @@ public class UIToastTask implements Runnable {
|
||||
|
||||
public void run() {
|
||||
Toast.makeText(mCtx, mText, Toast.LENGTH_LONG).show();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -26,14 +26,15 @@ import android.content.Context;
|
||||
import com.android.keepass.R;
|
||||
|
||||
public class PasswordGenerator {
|
||||
private static final String upperCaseChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
private static final String lowerCaseChars = "abcdefghijklmnopqrstuvwxyz";
|
||||
private static final String digitChars = "0123456789";
|
||||
private static final String minusChars = "-";
|
||||
private static final String underlineChars = "_";
|
||||
private static final String spaceChars = " ";
|
||||
private static final String specialChars = "!\"#$%&'*+,./:;=?@\\^`";
|
||||
private static final String bracketChars = "[]{}()<>";
|
||||
private static final String UPPERCASE_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
private static final String LOWERCASE_CHARS = "abcdefghijklmnopqrstuvwxyz";
|
||||
private static final String DIGIT_CHARS = "0123456789";
|
||||
private static final String MINUS_CHAR = "-";
|
||||
private static final String UNDERLINE_CHAR = "_";
|
||||
private static final String SPACE_CHAR = " ";
|
||||
private static final String SPECIAL_CHARS = "!\"#$%&'*+,./:;=?@\\^`";
|
||||
private static final String BRACKET_CHARS = "[]{}()<>";
|
||||
|
||||
|
||||
private Context cxt;
|
||||
|
||||
@@ -42,11 +43,15 @@ public class PasswordGenerator {
|
||||
}
|
||||
|
||||
public String generatePassword(int length, boolean upperCase, boolean lowerCase, boolean digits, boolean minus, boolean underline, boolean space, boolean specials, boolean brackets) throws IllegalArgumentException{
|
||||
if (length <= 0)
|
||||
// Desired password length is 0 or less
|
||||
if (length <= 0) {
|
||||
throw new IllegalArgumentException(cxt.getString(R.string.error_wrong_length));
|
||||
}
|
||||
|
||||
if (!upperCase && !lowerCase && !digits && !minus && !underline && !space && !specials && !brackets)
|
||||
// No option has been checked
|
||||
if (!upperCase && !lowerCase && !digits && !minus && !underline && !space && !specials && !brackets) {
|
||||
throw new IllegalArgumentException(cxt.getString(R.string.error_pass_gen_type));
|
||||
}
|
||||
|
||||
String characterSet = getCharacterSet(upperCase, lowerCase, digits, minus, underline, space, specials, brackets);
|
||||
|
||||
@@ -56,43 +61,48 @@ public class PasswordGenerator {
|
||||
|
||||
SecureRandom random = new SecureRandom(); // use more secure variant of Random!
|
||||
if (size > 0) {
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
char c = characterSet.charAt((char) random.nextInt(size));
|
||||
|
||||
buffer.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
public String getCharacterSet(boolean upperCase, boolean lowerCase, boolean digits, boolean minus, boolean underline, boolean space, boolean specials, boolean brackets) {
|
||||
StringBuffer charSet = new StringBuffer();
|
||||
|
||||
if (upperCase)
|
||||
charSet.append(upperCaseChars);
|
||||
if (upperCase) {
|
||||
charSet.append(UPPERCASE_CHARS);
|
||||
}
|
||||
|
||||
if (lowerCase)
|
||||
charSet.append(lowerCaseChars);
|
||||
if (lowerCase) {
|
||||
charSet.append(LOWERCASE_CHARS);
|
||||
}
|
||||
|
||||
if (digits)
|
||||
charSet.append(digitChars);
|
||||
if (digits) {
|
||||
charSet.append(DIGIT_CHARS);
|
||||
}
|
||||
|
||||
if (minus)
|
||||
charSet.append(minusChars);
|
||||
if (minus) {
|
||||
charSet.append(MINUS_CHAR);
|
||||
}
|
||||
|
||||
if (underline)
|
||||
charSet.append(underlineChars);
|
||||
if (underline) {
|
||||
charSet.append(UNDERLINE_CHAR);
|
||||
}
|
||||
|
||||
if (space)
|
||||
charSet.append(spaceChars);
|
||||
if (space) {
|
||||
charSet.append(SPACE_CHAR);
|
||||
}
|
||||
|
||||
if (specials)
|
||||
charSet.append(specialChars);
|
||||
if (specials) {
|
||||
charSet.append(SPECIAL_CHARS);
|
||||
}
|
||||
|
||||
if (brackets)
|
||||
charSet.append(bracketChars);
|
||||
if (brackets) {
|
||||
charSet.append(BRACKET_CHARS);
|
||||
}
|
||||
|
||||
return charSet.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user