mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Solve dialogs bugs (checkboxes)
This commit is contained in:
@@ -28,11 +28,12 @@ import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -41,22 +42,27 @@ import com.keepassdroid.utils.UriUtil;
|
||||
import com.keepassdroid.view.KeyFileHelper;
|
||||
import com.kunzisoft.keepass.R;
|
||||
|
||||
public class AssignPasswordDialog extends DialogFragment {
|
||||
public class AssignMasterKeyDialog extends DialogFragment {
|
||||
|
||||
private String masterPassword;
|
||||
private Uri mKeyfile;
|
||||
|
||||
private View rootView;
|
||||
private CompoundButton passwordCheckBox;
|
||||
private TextView passView;
|
||||
private TextView passConfView;
|
||||
private CompoundButton keyfileCheckBox;
|
||||
private TextView keyfileView;
|
||||
|
||||
private AssignPasswordDialogListener mListener;
|
||||
|
||||
private KeyFileHelper keyFileHelper;
|
||||
|
||||
public interface AssignPasswordDialogListener {
|
||||
void onAssignKeyDialogPositiveClick(String masterPassword, Uri keyFile);
|
||||
void onAssignKeyDialogNegativeClick(String masterPassword, Uri keyFile);
|
||||
void onAssignKeyDialogPositiveClick(boolean masterPasswordChecked, String masterPassword,
|
||||
boolean keyFileChecked, Uri keyFile);
|
||||
void onAssignKeyDialogNegativeClick(boolean masterPasswordChecked, String masterPassword,
|
||||
boolean keyFileChecked, Uri keyFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,14 +97,41 @@ public class AssignPasswordDialog extends DialogFragment {
|
||||
});
|
||||
|
||||
passwordCheckBox = (CompoundButton) rootView.findViewById(R.id.password_checkbox);
|
||||
passView = (TextView) rootView.findViewById(R.id.pass_password);
|
||||
passView.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
passwordCheckBox.setChecked(true);
|
||||
}
|
||||
});
|
||||
passConfView = (TextView) rootView.findViewById(R.id.pass_conf_password);
|
||||
|
||||
keyfileCheckBox = (CompoundButton) rootView.findViewById(R.id.keyfile_checkox);
|
||||
keyfileView = (TextView) rootView.findViewById(R.id.pass_keyfile);
|
||||
keyfileView.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
keyfileCheckBox.setChecked(true);
|
||||
}
|
||||
});
|
||||
|
||||
keyFileHelper = new KeyFileHelper(this);
|
||||
rootView.findViewById(R.id.browse_button)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
keyfileCheckBox.setChecked(true);
|
||||
keyFileHelper.getOpenFileOnClickViewListener().onClick(view);
|
||||
}
|
||||
});
|
||||
@@ -116,44 +149,18 @@ public class AssignPasswordDialog extends DialogFragment {
|
||||
masterPassword = "";
|
||||
mKeyfile = null;
|
||||
|
||||
boolean error = false;
|
||||
boolean error = verifyPassword() || verifyFile();
|
||||
|
||||
// Assign password
|
||||
if (passwordCheckBox.isChecked()) {
|
||||
TextView passView = (TextView) rootView.findViewById(R.id.pass_password);
|
||||
masterPassword = passView.getText().toString();
|
||||
TextView passConfView = (TextView) rootView.findViewById(R.id.pass_conf_password);
|
||||
String confpass = passConfView.getText().toString();
|
||||
|
||||
// Verify that passwords match
|
||||
if (!masterPassword.equals(confpass)) {
|
||||
// Passwords do not match
|
||||
Toast.makeText(getContext(), R.string.error_pass_match, Toast.LENGTH_LONG).show();
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Assign keyfile
|
||||
if (keyfileCheckBox.isChecked()) {
|
||||
TextView keyfileView = (TextView) rootView.findViewById(R.id.pass_keyfile);
|
||||
Uri keyfile = UriUtil.parseDefaultFile(keyfileView.getText().toString());
|
||||
mKeyfile = keyfile;
|
||||
|
||||
// Verify that a keyfile is set
|
||||
if (EmptyUtils.isNullOrEmpty(keyfile)) {
|
||||
Toast.makeText(getContext(), R.string.error_nokeyfile, Toast.LENGTH_LONG).show();
|
||||
error = true;
|
||||
}
|
||||
if (!passwordCheckBox.isChecked() && !keyfileCheckBox.isChecked()) {
|
||||
error = true;
|
||||
showNoKeyConfirmationDialog();
|
||||
}
|
||||
|
||||
if (!error) {
|
||||
if (!keyfileCheckBox.isChecked() &&
|
||||
(masterPassword == null || masterPassword.isEmpty())) {
|
||||
showEmptyPasswordConfirmationDialog();
|
||||
} else {
|
||||
mListener.onAssignKeyDialogPositiveClick(masterPassword, mKeyfile);
|
||||
dismiss();
|
||||
}
|
||||
mListener.onAssignKeyDialogPositiveClick(
|
||||
passwordCheckBox.isChecked(), masterPassword,
|
||||
keyfileCheckBox.isChecked(), mKeyfile);
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -161,7 +168,9 @@ public class AssignPasswordDialog extends DialogFragment {
|
||||
negativeButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
mListener.onAssignKeyDialogNegativeClick(masterPassword, mKeyfile);
|
||||
mListener.onAssignKeyDialogNegativeClick(
|
||||
passwordCheckBox.isChecked(), masterPassword,
|
||||
keyfileCheckBox.isChecked(), mKeyfile);
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
@@ -172,19 +181,74 @@ public class AssignPasswordDialog extends DialogFragment {
|
||||
return dialog;
|
||||
}
|
||||
|
||||
private boolean verifyPassword() {
|
||||
boolean error = false;
|
||||
if (passwordCheckBox.isChecked()) {
|
||||
masterPassword = passView.getText().toString();
|
||||
String confpass = passConfView.getText().toString();
|
||||
|
||||
// Verify that passwords match
|
||||
if (!masterPassword.equals(confpass)) {
|
||||
error = true;
|
||||
// Passwords do not match
|
||||
Toast.makeText(getContext(), R.string.error_pass_match, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
if (masterPassword == null || masterPassword.isEmpty()) {
|
||||
error = true;
|
||||
showEmptyPasswordConfirmationDialog();
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
private boolean verifyFile() {
|
||||
boolean error = false;
|
||||
if (keyfileCheckBox.isChecked()) {
|
||||
Uri keyfile = UriUtil.parseDefaultFile(keyfileView.getText().toString());
|
||||
mKeyfile = keyfile;
|
||||
|
||||
// Verify that a keyfile is set
|
||||
if (EmptyUtils.isNullOrEmpty(keyfile)) {
|
||||
error = true;
|
||||
Toast.makeText(getContext(), R.string.error_nokeyfile, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
private void showEmptyPasswordConfirmationDialog() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setMessage(R.string.warning_empty_password)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
mListener.onAssignKeyDialogPositiveClick(masterPassword, mKeyfile);
|
||||
AssignPasswordDialog.this.dismiss();
|
||||
if (!verifyFile()) {
|
||||
mListener.onAssignKeyDialogPositiveClick(
|
||||
passwordCheckBox.isChecked(), masterPassword,
|
||||
keyfileCheckBox.isChecked(), mKeyfile);
|
||||
AssignMasterKeyDialog.this.dismiss();
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {}
|
||||
});
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
private void showNoKeyConfirmationDialog() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setMessage(R.string.warning_no_encryption_key)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
mListener.onAssignKeyDialogNegativeClick(masterPassword, mKeyfile);
|
||||
mListener.onAssignKeyDialogPositiveClick(
|
||||
passwordCheckBox.isChecked(), masterPassword,
|
||||
keyfileCheckBox.isChecked(), mKeyfile);
|
||||
AssignMasterKeyDialog.this.dismiss();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {}
|
||||
});
|
||||
builder.create().show();
|
||||
}
|
||||
@@ -196,12 +260,13 @@ public class AssignPasswordDialog extends DialogFragment {
|
||||
keyFileHelper.onActivityResultCallback(requestCode, resultCode, data,
|
||||
new KeyFileHelper.KeyFileCallback() {
|
||||
@Override
|
||||
public void onResultCallback(Uri uri) {
|
||||
public void onKeyFileResultCallback(Uri uri) {
|
||||
if(uri != null) {
|
||||
EditText keyFileView = (EditText) rootView.findViewById(R.id.pass_keyfile);
|
||||
Uri pathString = UriUtil.parseDefaultFile(uri.toString());
|
||||
if (pathString != null)
|
||||
keyFileView.setText(pathString.toString());
|
||||
if (pathString != null) {
|
||||
keyfileCheckBox.setChecked(true);
|
||||
keyfileView.setText(pathString.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -34,6 +34,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
|
||||
@@ -56,8 +57,8 @@ public class CreateFileDialog extends DialogFragment implements AdapterView.OnIt
|
||||
private Uri uriPath;
|
||||
|
||||
public interface DefinePathDialogListener {
|
||||
void onDefinePathDialogPositiveClick(Uri pathFile);
|
||||
void onDefinePathDialogNegativeClick(Uri pathFile);
|
||||
boolean onDefinePathDialogPositiveClick(Uri pathFile);
|
||||
boolean onDefinePathDialogNegativeClick(Uri pathFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,14 +84,10 @@ public class CreateFileDialog extends DialogFragment implements AdapterView.OnIt
|
||||
// Add action buttons
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
mListener.onDefinePathDialogPositiveClick(buildPath());
|
||||
}
|
||||
public void onClick(DialogInterface dialog, int id) {}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
mListener.onDefinePathDialogNegativeClick(buildPath());
|
||||
}
|
||||
public void onClick(DialogInterface dialog, int id) {}
|
||||
});
|
||||
|
||||
// Folder selection
|
||||
@@ -127,7 +124,31 @@ public class CreateFileDialog extends DialogFragment implements AdapterView.OnIt
|
||||
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
spinner.setAdapter(dataAdapter);
|
||||
|
||||
return builder.create();
|
||||
AlertDialog dialog = builder.create();
|
||||
|
||||
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||
@Override
|
||||
public void onShow(final DialogInterface dialog) {
|
||||
Button positiveButton = ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE);
|
||||
positiveButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
if(mListener.onDefinePathDialogPositiveClick(buildPath()))
|
||||
CreateFileDialog.this.dismiss();
|
||||
}
|
||||
});
|
||||
Button negativeButton = ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_NEGATIVE);
|
||||
negativeButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
if(mListener.onDefinePathDialogNegativeClick(buildPath()))
|
||||
CreateFileDialog.this.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -55,7 +55,7 @@ import com.kunzisoft.keepass.KeePass;
|
||||
import com.kunzisoft.keepass.R;
|
||||
|
||||
public abstract class GroupBaseActivity extends LockCloseListActivity
|
||||
implements AssignPasswordDialog.AssignPasswordDialogListener {
|
||||
implements AssignMasterKeyDialog.AssignPasswordDialogListener {
|
||||
protected ListView mList;
|
||||
protected ListAdapter mAdapter;
|
||||
|
||||
@@ -269,7 +269,9 @@ public abstract class GroupBaseActivity extends LockCloseListActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAssignKeyDialogPositiveClick(String masterPassword, Uri keyFile) {
|
||||
public void onAssignKeyDialogPositiveClick(
|
||||
boolean masterPasswordChecked, String masterPassword,
|
||||
boolean keyFileChecked, Uri keyFile) {
|
||||
|
||||
AssignPasswordHelper assignPasswordHelper =
|
||||
new AssignPasswordHelper(this,
|
||||
@@ -278,12 +280,14 @@ public abstract class GroupBaseActivity extends LockCloseListActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAssignKeyDialogNegativeClick(String masterPassword, Uri keyFile) {
|
||||
public void onAssignKeyDialogNegativeClick(
|
||||
boolean masterPasswordChecked, String masterPassword,
|
||||
boolean keyFileChecked, Uri keyFile) {
|
||||
|
||||
}
|
||||
|
||||
private void setPassword() {
|
||||
AssignPasswordDialog dialog = new AssignPasswordDialog();
|
||||
AssignMasterKeyDialog dialog = new AssignMasterKeyDialog();
|
||||
dialog.show(getSupportFragmentManager(), "passwordDialog");
|
||||
}
|
||||
|
||||
|
||||
@@ -88,13 +88,15 @@ public class PasswordActivity extends LockingActivity implements FingerPrintHelp
|
||||
private int mode;
|
||||
private static final String PREF_KEY_VALUE_PREFIX = "valueFor_"; // key is a combination of db file name and this prefix
|
||||
private static final String PREF_KEY_IV_PREFIX = "ivFor_"; // key is a combination of db file name and this prefix
|
||||
|
||||
private TextView filenameView;
|
||||
private View fingerprintView;
|
||||
private TextView confirmationView;
|
||||
private EditText passwordView;
|
||||
private EditText keyFileView;
|
||||
private Button confirmButton;
|
||||
private CheckBox checkboxPassword;
|
||||
private CheckBox checkboxKeyfile;
|
||||
private Button confirmButtonView;
|
||||
private CheckBox checkboxPasswordView;
|
||||
private CheckBox checkboxKeyfileView;
|
||||
|
||||
private KeyFileHelper keyFileHelper;
|
||||
|
||||
@@ -141,10 +143,9 @@ public class PasswordActivity extends LockingActivity implements FingerPrintHelp
|
||||
keyFileHelper.onActivityResultCallback(requestCode, resultCode, data,
|
||||
new KeyFileHelper.KeyFileCallback() {
|
||||
@Override
|
||||
public void onResultCallback(Uri uri) {
|
||||
public void onKeyFileResultCallback(Uri uri) {
|
||||
if(uri != null) {
|
||||
EditText fn = (EditText) findViewById(R.id.pass_keyfile);
|
||||
fn.setText(uri.toString());
|
||||
keyFileView.setText(uri.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -184,14 +185,39 @@ public class PasswordActivity extends LockingActivity implements FingerPrintHelp
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
|
||||
confirmButton = (Button) findViewById(R.id.pass_ok);
|
||||
filenameView = (TextView) findViewById(R.id.filename);
|
||||
confirmButtonView = (Button) findViewById(R.id.pass_ok);
|
||||
fingerprintView = findViewById(R.id.fingerprint);
|
||||
confirmationView = (TextView) findViewById(R.id.fingerprint_label);
|
||||
passwordView = (EditText) findViewById(R.id.password);
|
||||
keyFileView = (EditText) findViewById(R.id.pass_keyfile);
|
||||
checkboxPasswordView = (CheckBox) findViewById(R.id.password_checkbox);
|
||||
checkboxKeyfileView = (CheckBox) findViewById(R.id.keyfile_checkox);
|
||||
|
||||
checkboxPassword = (CheckBox) findViewById(R.id.password_checkbox);
|
||||
checkboxKeyfile = (CheckBox) findViewById(R.id.keyfile_checkox);
|
||||
passwordView.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
checkboxPasswordView.setChecked(true);
|
||||
}
|
||||
});
|
||||
keyFileView.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
checkboxKeyfileView.setChecked(true);
|
||||
}
|
||||
});
|
||||
|
||||
new InitTask().execute(i);
|
||||
}
|
||||
@@ -219,6 +245,8 @@ public class PasswordActivity extends LockingActivity implements FingerPrintHelp
|
||||
private void setEmptyViews() {
|
||||
passwordView.setText("");
|
||||
keyFileView.setText("");
|
||||
checkboxPasswordView.setChecked(false);
|
||||
checkboxKeyfileView.setChecked(false);
|
||||
}
|
||||
|
||||
private void retrieveSettings() {
|
||||
@@ -239,10 +267,12 @@ public class PasswordActivity extends LockingActivity implements FingerPrintHelp
|
||||
|
||||
private void populateView() {
|
||||
String db = (mDbUri == null) ? "" : mDbUri.toString();
|
||||
setEditText(R.id.filename, db);
|
||||
if (!db.isEmpty())
|
||||
filenameView.setText(db);
|
||||
|
||||
String key = (mKeyUri == null) ? "" : mKeyUri.toString();
|
||||
setEditText(R.id.pass_keyfile, key);
|
||||
if (!key.isEmpty())
|
||||
keyFileView.setText(key);
|
||||
}
|
||||
|
||||
// fingerprint related code here
|
||||
@@ -407,7 +437,7 @@ public class PasswordActivity extends LockingActivity implements FingerPrintHelp
|
||||
.putString(getPreferenceKeyIvSpec(), ivSpec)
|
||||
.apply();
|
||||
// and remove visual input to reset UI
|
||||
confirmButton.performClick();
|
||||
confirmButtonView.performClick();
|
||||
confirmationView.setText(R.string.encrypted_value_stored);
|
||||
}
|
||||
|
||||
@@ -415,7 +445,7 @@ public class PasswordActivity extends LockingActivity implements FingerPrintHelp
|
||||
public void handleDecryptedResult(final String value) {
|
||||
// on decrypt enter it for the purchase/login action
|
||||
passwordView.setText(value);
|
||||
confirmButton.performClick();
|
||||
confirmButtonView.performClick();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
@@ -462,8 +492,8 @@ public class PasswordActivity extends LockingActivity implements FingerPrintHelp
|
||||
private class OkClickHandler implements View.OnClickListener {
|
||||
|
||||
public void onClick(View view) {
|
||||
String pass = getEditText(R.id.password);
|
||||
String key = getEditText(R.id.pass_keyfile);
|
||||
String pass = passwordView.getText().toString();
|
||||
String key = keyFileView.getText().toString();
|
||||
loadDatabase(pass, key);
|
||||
}
|
||||
}
|
||||
@@ -485,10 +515,10 @@ public class PasswordActivity extends LockingActivity implements FingerPrintHelp
|
||||
// Clear the shutdown flag
|
||||
App.clearShutdown();
|
||||
|
||||
if (!checkboxPassword.isChecked()) {
|
||||
if (!checkboxPasswordView.isChecked()) {
|
||||
pass = "";
|
||||
}
|
||||
if (!checkboxKeyfile.isChecked()) {
|
||||
if (!checkboxKeyfileView.isChecked()) {
|
||||
keyfile = null;
|
||||
}
|
||||
|
||||
@@ -502,15 +532,6 @@ public class PasswordActivity extends LockingActivity implements FingerPrintHelp
|
||||
return Util.getEditText(this, resId);
|
||||
}
|
||||
|
||||
private void setEditText(
|
||||
int resId,
|
||||
String str) {
|
||||
TextView te = (TextView) findViewById(resId);
|
||||
if (te != null) {
|
||||
te.setText(str);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
|
||||
@@ -50,7 +50,7 @@ import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.keepassdroid.AssignPasswordDialog;
|
||||
import com.keepassdroid.AssignMasterKeyDialog;
|
||||
import com.keepassdroid.CreateFileDialog;
|
||||
import com.keepassdroid.GroupActivity;
|
||||
import com.keepassdroid.PasswordActivity;
|
||||
@@ -80,7 +80,7 @@ import java.net.URLDecoder;
|
||||
|
||||
public class FileSelectActivity extends StylishActivity implements
|
||||
CreateFileDialog.DefinePathDialogListener ,
|
||||
AssignPasswordDialog.AssignPasswordDialogListener {
|
||||
AssignMasterKeyDialog.AssignPasswordDialogListener {
|
||||
|
||||
private static final String TAG = "FileSelectActivity";
|
||||
|
||||
@@ -318,21 +318,26 @@ public class FileSelectActivity extends StylishActivity implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDefinePathDialogPositiveClick(Uri pathFile) {
|
||||
public boolean onDefinePathDialogPositiveClick(Uri pathFile) {
|
||||
databaseUri = pathFile;
|
||||
if(createDatabaseFile(pathFile)) {
|
||||
AssignPasswordDialog assignPasswordDialog = new AssignPasswordDialog();
|
||||
assignPasswordDialog.show(getSupportFragmentManager(), "passwordDialog");
|
||||
}
|
||||
AssignMasterKeyDialog assignMasterKeyDialog = new AssignMasterKeyDialog();
|
||||
assignMasterKeyDialog.show(getSupportFragmentManager(), "passwordDialog");
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDefinePathDialogNegativeClick(Uri pathFile) {
|
||||
|
||||
public boolean onDefinePathDialogNegativeClick(Uri pathFile) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAssignKeyDialogPositiveClick(String masterPassword, Uri keyFile) {
|
||||
public void onAssignKeyDialogPositiveClick(
|
||||
boolean masterPasswordChecked, String masterPassword,
|
||||
boolean keyFileChecked, Uri keyFile) {
|
||||
|
||||
String databaseFilename = databaseUri.getPath();
|
||||
|
||||
// Prep an object to collect a password once the database has
|
||||
@@ -356,7 +361,9 @@ public class FileSelectActivity extends StylishActivity implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAssignKeyDialogNegativeClick(String masterPassword, Uri keyFile) {
|
||||
public void onAssignKeyDialogNegativeClick(
|
||||
boolean masterPasswordChecked, String masterPassword,
|
||||
boolean keyFileChecked, Uri keyFile) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -19,12 +19,6 @@
|
||||
*/
|
||||
package com.keepassdroid.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import com.keepassdroid.database.exception.SamsungClipboardException;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
@@ -33,6 +27,12 @@ import android.net.Uri;
|
||||
import android.text.ClipboardManager;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.keepassdroid.database.exception.SamsungClipboardException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class Util {
|
||||
public static String getClipboard(Context context) {
|
||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
@@ -75,14 +75,6 @@ public class Util {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setEditText(Activity act, int resId, String str) {
|
||||
TextView te = (TextView) act.findViewById(resId);
|
||||
|
||||
if (te != null) {
|
||||
te.setText(str);
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyStream(InputStream in, OutputStream out) throws IOException {
|
||||
byte[] buf = new byte[1024];
|
||||
int read;
|
||||
|
||||
@@ -20,7 +20,9 @@ public class AssignPasswordHelper {
|
||||
private String masterPassword;
|
||||
private Uri keyfile;
|
||||
|
||||
public AssignPasswordHelper(Context context, String masterPassword, Uri keyfile) {
|
||||
public AssignPasswordHelper(Context context,
|
||||
String masterPassword,
|
||||
Uri keyfile) {
|
||||
this.context = context;
|
||||
this.masterPassword = masterPassword;
|
||||
this.keyfile = keyfile;
|
||||
|
||||
@@ -150,7 +150,7 @@ public class KeyFileHelper {
|
||||
keyUri = UriUtil.parseDefaultFile(filename);
|
||||
}
|
||||
if (keyFileCallback != null)
|
||||
keyFileCallback.onResultCallback(keyUri);
|
||||
keyFileCallback.onKeyFileResultCallback(keyUri);
|
||||
}
|
||||
break;
|
||||
case GET_CONTENT:
|
||||
@@ -163,7 +163,7 @@ public class KeyFileHelper {
|
||||
uri = UriUtil.translate(activity, uri);
|
||||
}
|
||||
if (keyFileCallback != null)
|
||||
keyFileCallback.onResultCallback(uri);
|
||||
keyFileCallback.onKeyFileResultCallback(uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,7 +172,7 @@ public class KeyFileHelper {
|
||||
}
|
||||
|
||||
public interface KeyFileCallback {
|
||||
void onResultCallback(Uri uri);
|
||||
void onKeyFileResultCallback(Uri uri);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -118,7 +118,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:checked="true"
|
||||
android:paddingBottom="20dp"
|
||||
android:gravity="center_vertical" />
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
android:layout_height="match_parent">
|
||||
<android.support.v7.widget.CardView
|
||||
android:id="@+id/card_view_master_password"
|
||||
android:layout_margin="4dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -39,7 +40,6 @@
|
||||
android:id="@+id/password_checkbox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:text="@string/password"/>
|
||||
|
||||
<!-- Password Input -->
|
||||
@@ -80,8 +80,7 @@
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:layout_margin="4dp"
|
||||
app:cardCornerRadius="4dp">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -192,6 +192,7 @@
|
||||
<string name="warning_read_only">Votre carte SD est actuellement en lecture seule. Vous ne pourrez pas enregistrer les changements dans la base de données.</string>
|
||||
<string name="warning_unmounted">Votre carte SD n\'est actuellement pas montée sur votre appareil. Vous ne pourrez pas charger ou créer votre base de données.</string>
|
||||
<string name="warning_empty_password">Voulez-vous vraiment utiliser une chaine de caractères vide comme mot de passe ?</string>
|
||||
<string name="warning_no_encryption_key">Etes-vous sûr de ne vouloir utiliser aucune clé de chiffrement.</string>
|
||||
<string name="version_label">Version\u00A0:</string>
|
||||
<string name="configure_fingerprint">Reconnaissance d\'empreinte digitale non configuré pour cet appareil</string>
|
||||
<string name="scanning_fingerprint">Attente d\'une reconnaissance d\'empreinte digitale</string>
|
||||
|
||||
@@ -192,6 +192,7 @@
|
||||
<string name="warning_read_only">Your sd card is currently read-only. You may not be able to save changes to your database.</string>
|
||||
<string name="warning_unmounted">Your sd card is not currently mounted on your device. You will not be able to load or create your database.</string>
|
||||
<string name="warning_empty_password">Do you really want to use an empty string as password ?</string>
|
||||
<string name="warning_no_encryption_key">Are you sure you do not want to use any encryption key ?</string>
|
||||
<string name="version_label">Version:</string>
|
||||
<string name="configure_fingerprint">Fingerprint supported but not configured for device</string>
|
||||
<string name="scanning_fingerprint">Listening for fingerprints</string>
|
||||
|
||||
@@ -238,7 +238,7 @@
|
||||
</style>
|
||||
|
||||
<!-- File Picker Theme -->
|
||||
<style name="KeepassDXStyle.FilePickerStyle.Night" parent="Theme.AppCompat.Dialog">
|
||||
<style name="KeepassDXStyle.FilePickerStyle.Night" parent="Theme.AppCompat.DialogWhenLarge">
|
||||
<!-- You can override this in your sub theme -->
|
||||
<item name="nnf_toolbarTheme">@style/ThemeOverlay.AppCompat.ActionBar</item>
|
||||
<item name="nnf_separator_color">@color/nnf_dark_separator_color</item>
|
||||
@@ -253,7 +253,7 @@
|
||||
<item name="colorAccent">@color/orange</item>
|
||||
</style>
|
||||
|
||||
<style name="KeepassDXStyle.FilePickerStyle.Light" parent="Theme.AppCompat.Light.Dialog">
|
||||
<style name="KeepassDXStyle.FilePickerStyle.Light" parent="Theme.AppCompat.Light.DialogWhenLarge">
|
||||
<item name="nnf_toolbarTheme">@style/ThemeOverlay.AppCompat.ActionBar</item>
|
||||
<item name="nnf_separator_color">@color/nnf_light_separator_color</item>
|
||||
<item name="nnf_save_icon_color">?attr/colorAccent</item>
|
||||
|
||||
Reference in New Issue
Block a user