mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Change password generator as DialogFragment
This commit is contained in:
@@ -84,16 +84,20 @@
|
|||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name="com.keepassdroid.EntryActivity"
|
android:name="com.keepassdroid.EntryActivity"
|
||||||
android:configChanges="orientation|keyboardHidden" />
|
android:configChanges="orientation|keyboardHidden"
|
||||||
|
android:windowSoftInputMode="stateHidden" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.keepassdroid.EntryActivityV4"
|
android:name="com.keepassdroid.EntryActivityV4"
|
||||||
android:configChanges="orientation|keyboardHidden" />
|
android:configChanges="orientation|keyboardHidden"
|
||||||
|
android:windowSoftInputMode="stateHidden" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.keepassdroid.EntryEditActivityV3"
|
android:name="com.keepassdroid.EntryEditActivityV3"
|
||||||
android:configChanges="orientation|keyboardHidden" />
|
android:configChanges="orientation|keyboardHidden"
|
||||||
|
android:windowSoftInputMode="stateHidden" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.keepassdroid.EntryEditActivityV4"
|
android:name="com.keepassdroid.EntryEditActivityV4"
|
||||||
android:configChanges="orientation|keyboardHidden" />
|
android:configChanges="orientation|keyboardHidden"
|
||||||
|
android:windowSoftInputMode="stateHidden" />
|
||||||
<activity android:name="com.keepassdroid.search.SearchResults" android:launchMode="standard">
|
<activity android:name="com.keepassdroid.search.SearchResults" android:launchMode="standard">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.SEARCH" />
|
<action android:name="android.intent.action.SEARCH" />
|
||||||
@@ -102,7 +106,6 @@
|
|||||||
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
|
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="com.keepassdroid.settings.SettingsActivity" />
|
<activity android:name="com.keepassdroid.settings.SettingsActivity" />
|
||||||
<activity android:name="com.keepassdroid.GeneratePasswordActivity" />
|
|
||||||
|
|
||||||
<service android:name="com.keepassdroid.services.TimeoutService" />
|
<service android:name="com.keepassdroid.services.TimeoutService" />
|
||||||
<meta-data android:name="com.a0soft.gphone.aTrackDog.webURL" android:value="http://keepassdroid.com" />
|
<meta-data android:name="com.a0soft.gphone.aTrackDog.webURL" android:value="http://keepassdroid.com" />
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ import java.util.Date;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public abstract class EntryEditActivity extends LockCloseHideActivity
|
public abstract class EntryEditActivity extends LockCloseHideActivity
|
||||||
implements IconPickerFragment.IconPickerListener {
|
implements IconPickerFragment.IconPickerListener,
|
||||||
|
GeneratePasswordFragment.GeneratePasswordListener {
|
||||||
public static final String KEY_ENTRY = "entry";
|
public static final String KEY_ENTRY = "entry";
|
||||||
public static final String KEY_PARENT = "parent";
|
public static final String KEY_PARENT = "parent";
|
||||||
|
|
||||||
@@ -170,7 +171,8 @@ public abstract class EntryEditActivity extends LockCloseHideActivity
|
|||||||
generatePassword.setOnClickListener(new OnClickListener() {
|
generatePassword.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
GeneratePasswordActivity.Launch(EntryEditActivity.this);
|
GeneratePasswordFragment generatePasswordFragment = new GeneratePasswordFragment();
|
||||||
|
generatePasswordFragment.show(getSupportFragmentManager(), "PasswordGeneratorFragment");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -268,26 +270,6 @@ public abstract class EntryEditActivity extends LockCloseHideActivity
|
|||||||
|
|
||||||
return newEntry;
|
return newEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
|
||||||
{
|
|
||||||
switch (resultCode)
|
|
||||||
{
|
|
||||||
case RESULT_OK_PASSWORD_GENERATOR:
|
|
||||||
String generatedPassword = data.getStringExtra("com.keepassdroid.password.generated_password");
|
|
||||||
EditText password = (EditText) findViewById(R.id.entry_password);
|
|
||||||
EditText confPassword = (EditText) findViewById(R.id.entry_confpassword);
|
|
||||||
|
|
||||||
password.setText(generatedPassword);
|
|
||||||
confPassword.setText(generatedPassword);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case Activity.RESULT_CANCELED:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
@@ -313,6 +295,7 @@ public abstract class EntryEditActivity extends LockCloseHideActivity
|
|||||||
switch ( item.getItemId() ) {
|
switch ( item.getItemId() ) {
|
||||||
case R.id.menu_donate:
|
case R.id.menu_donate:
|
||||||
try {
|
try {
|
||||||
|
// TODO Encapsulate
|
||||||
Util.gotoUrl(this, R.string.donate_url);
|
Util.gotoUrl(this, R.string.donate_url);
|
||||||
} catch (ActivityNotFoundException e) {
|
} catch (ActivityNotFoundException e) {
|
||||||
Toast.makeText(this, R.string.error_failed_to_launch_link, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, R.string.error_failed_to_launch_link, Toast.LENGTH_LONG).show();
|
||||||
@@ -360,7 +343,7 @@ public abstract class EntryEditActivity extends LockCloseHideActivity
|
|||||||
populateText(R.id.entry_user_name, mEntry.getUsername());
|
populateText(R.id.entry_user_name, mEntry.getUsername());
|
||||||
populateText(R.id.entry_url, mEntry.getUrl());
|
populateText(R.id.entry_url, mEntry.getUrl());
|
||||||
|
|
||||||
String password = new String(mEntry.getPassword());
|
String password = mEntry.getPassword();
|
||||||
populateText(R.id.entry_password, password);
|
populateText(R.id.entry_password, password);
|
||||||
populateText(R.id.entry_confpassword, password);
|
populateText(R.id.entry_confpassword, password);
|
||||||
setPasswordStyle();
|
setPasswordStyle();
|
||||||
@@ -380,7 +363,22 @@ public abstract class EntryEditActivity extends LockCloseHideActivity
|
|||||||
currIconButton.setImageResource(Icons.iconToResId(mSelectedIconID));
|
currIconButton.setImageResource(Icons.iconToResId(mSelectedIconID));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class AfterSave extends OnFinish {
|
@Override
|
||||||
|
public void acceptPassword(Bundle bundle) {
|
||||||
|
String generatedPassword = bundle.getString(GeneratePasswordFragment.KEY_PASSWORD_ID);
|
||||||
|
EditText password = (EditText) findViewById(R.id.entry_password);
|
||||||
|
EditText confPassword = (EditText) findViewById(R.id.entry_confpassword);
|
||||||
|
|
||||||
|
password.setText(generatedPassword);
|
||||||
|
confPassword.setText(generatedPassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancelPassword(Bundle bundle) {
|
||||||
|
// Do nothing here
|
||||||
|
}
|
||||||
|
|
||||||
|
private final class AfterSave extends OnFinish {
|
||||||
|
|
||||||
public AfterSave(Handler handler) {
|
public AfterSave(Handler handler) {
|
||||||
super(handler);
|
super(handler);
|
||||||
|
|||||||
@@ -19,12 +19,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.keepassdroid;
|
package com.keepassdroid;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -32,9 +26,7 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@@ -51,6 +43,12 @@ import com.keepassdroid.database.security.ProtectedString;
|
|||||||
import com.keepassdroid.utils.Types;
|
import com.keepassdroid.utils.Types;
|
||||||
import com.keepassdroid.view.EntryEditSection;
|
import com.keepassdroid.view.EntryEditSection;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class EntryEditActivityV4 extends EntryEditActivity {
|
public class EntryEditActivityV4 extends EntryEditActivity {
|
||||||
|
|
||||||
private ScrollView scroll;
|
private ScrollView scroll;
|
||||||
|
|||||||
@@ -1,133 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017 Brian Pellin, Jeremy Jamet / Kunzisoft.
|
|
||||||
*
|
|
||||||
* This file is part of KeePass DX.
|
|
||||||
*
|
|
||||||
* KeePass DX is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* KeePass DX is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package com.keepassdroid;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.android.keepass.KeePass;
|
|
||||||
import com.android.keepass.R;
|
|
||||||
import com.keepassdroid.password.PasswordGenerator;
|
|
||||||
|
|
||||||
public class GeneratePasswordActivity extends LockCloseActivity {
|
|
||||||
private static final int[] BUTTON_IDS = new int [] {R.id.btn_length6, R.id.btn_length8, R.id.btn_length12, R.id.btn_length16};
|
|
||||||
|
|
||||||
public static void Launch(Activity act) {
|
|
||||||
Intent i = new Intent(act, GeneratePasswordActivity.class);
|
|
||||||
|
|
||||||
act.startActivityForResult(i, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private OnClickListener lengthButtonsListener = new OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
Button button = (Button) v;
|
|
||||||
|
|
||||||
EditText editText = (EditText) findViewById(R.id.length);
|
|
||||||
editText.setText(button.getText());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.generate_password);
|
|
||||||
setResult(KeePass.EXIT_NORMAL);
|
|
||||||
|
|
||||||
for (int id : BUTTON_IDS) {
|
|
||||||
Button button = (Button) findViewById(id);
|
|
||||||
button.setOnClickListener(lengthButtonsListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
Button genPassButton = (Button) findViewById(R.id.generate_password_button);
|
|
||||||
genPassButton.setOnClickListener(new OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
fillPassword();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Button acceptButton = (Button) findViewById(R.id.accept_button);
|
|
||||||
acceptButton.setOnClickListener(new OnClickListener() {
|
|
||||||
|
|
||||||
public void onClick(View v) {
|
|
||||||
EditText password = (EditText) findViewById(R.id.password);
|
|
||||||
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.putExtra("com.keepassdroid.password.generated_password", password.getText().toString());
|
|
||||||
|
|
||||||
setResult(EntryEditActivity.RESULT_OK_PASSWORD_GENERATOR, intent);
|
|
||||||
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Button cancelButton = (Button) findViewById(R.id.cancel_button);
|
|
||||||
cancelButton.setOnClickListener(new OnClickListener() {
|
|
||||||
|
|
||||||
public void onClick(View v) {
|
|
||||||
setResult(RESULT_CANCELED);
|
|
||||||
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Pre-populate a password to possibly save the user a few clicks
|
|
||||||
fillPassword();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fillPassword() {
|
|
||||||
EditText txtPassword = (EditText) findViewById(R.id.password);
|
|
||||||
txtPassword.setText(generatePassword());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String generatePassword() {
|
|
||||||
String password = "";
|
|
||||||
|
|
||||||
try {
|
|
||||||
int length = Integer.valueOf(((EditText) findViewById(R.id.length)).getText().toString());
|
|
||||||
|
|
||||||
((CheckBox) findViewById(R.id.cb_uppercase)).isChecked();
|
|
||||||
|
|
||||||
PasswordGenerator generator = new PasswordGenerator(this);
|
|
||||||
|
|
||||||
password = generator.generatePassword(length,
|
|
||||||
((CheckBox) findViewById(R.id.cb_uppercase)).isChecked(),
|
|
||||||
((CheckBox) findViewById(R.id.cb_lowercase)).isChecked(),
|
|
||||||
((CheckBox) findViewById(R.id.cb_digits)).isChecked(),
|
|
||||||
((CheckBox) findViewById(R.id.cb_minus)).isChecked(),
|
|
||||||
((CheckBox) findViewById(R.id.cb_underline)).isChecked(),
|
|
||||||
((CheckBox) findViewById(R.id.cb_space)).isChecked(),
|
|
||||||
((CheckBox) findViewById(R.id.cb_specials)).isChecked(),
|
|
||||||
((CheckBox) findViewById(R.id.cb_brackets)).isChecked());
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
Toast.makeText(this, R.string.error_wrong_length, Toast.LENGTH_LONG).show();
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
154
app/src/main/java/com/keepassdroid/GeneratePasswordFragment.java
Normal file
154
app/src/main/java/com/keepassdroid/GeneratePasswordFragment.java
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Brian Pellin, Jeremy Jamet / Kunzisoft.
|
||||||
|
*
|
||||||
|
* This file is part of KeePass DX.
|
||||||
|
*
|
||||||
|
* KeePass DX is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* KeePass DX is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.keepassdroid;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.SeekBar;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.android.keepass.R;
|
||||||
|
import com.keepassdroid.password.PasswordGenerator;
|
||||||
|
|
||||||
|
public class GeneratePasswordFragment extends DialogFragment {
|
||||||
|
|
||||||
|
public static final String KEY_PASSWORD_ID = "KEY_PASSWORD_ID";
|
||||||
|
|
||||||
|
private GeneratePasswordListener mListener;
|
||||||
|
private View root;
|
||||||
|
private EditText lengthTextView;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
try {
|
||||||
|
mListener = (GeneratePasswordListener) context;
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
throw new ClassCastException(context.toString()
|
||||||
|
+ " must implement " + GeneratePasswordListener.class.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
|
root = inflater.inflate(R.layout.generate_password, null);
|
||||||
|
|
||||||
|
lengthTextView = (EditText) root.findViewById(R.id.length);
|
||||||
|
|
||||||
|
SeekBar seekBar = (SeekBar) root.findViewById(R.id.seekbar_length);
|
||||||
|
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
|
lengthTextView.setText(String.valueOf(progress));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStartTrackingTouch(SeekBar seekBar) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStopTrackingTouch(SeekBar seekBar) {}
|
||||||
|
});
|
||||||
|
|
||||||
|
Button genPassButton = (Button) root.findViewById(R.id.generate_password_button);
|
||||||
|
genPassButton.setOnClickListener(new OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
fillPassword();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.setView(root)
|
||||||
|
.setPositiveButton(R.string.accept, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
EditText password = (EditText) root.findViewById(R.id.password);
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString(KEY_PASSWORD_ID, password.getText().toString());
|
||||||
|
mListener.acceptPassword(bundle);
|
||||||
|
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
mListener.cancelPassword(bundle);
|
||||||
|
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Pre-populate a password to possibly save the user a few clicks
|
||||||
|
fillPassword();
|
||||||
|
|
||||||
|
return builder.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillPassword() {
|
||||||
|
EditText txtPassword = (EditText) root.findViewById(R.id.password);
|
||||||
|
txtPassword.setText(generatePassword());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String generatePassword() {
|
||||||
|
String password = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
int length = Integer.valueOf(((EditText) root.findViewById(R.id.length)).getText().toString());
|
||||||
|
|
||||||
|
((CheckBox) root.findViewById(R.id.cb_uppercase)).isChecked();
|
||||||
|
|
||||||
|
PasswordGenerator generator = new PasswordGenerator(getActivity());
|
||||||
|
|
||||||
|
password = generator.generatePassword(length,
|
||||||
|
((CheckBox) root.findViewById(R.id.cb_uppercase)).isChecked(),
|
||||||
|
((CheckBox) root.findViewById(R.id.cb_lowercase)).isChecked(),
|
||||||
|
((CheckBox) root.findViewById(R.id.cb_digits)).isChecked(),
|
||||||
|
((CheckBox) root.findViewById(R.id.cb_minus)).isChecked(),
|
||||||
|
((CheckBox) root.findViewById(R.id.cb_underline)).isChecked(),
|
||||||
|
((CheckBox) root.findViewById(R.id.cb_space)).isChecked(),
|
||||||
|
((CheckBox) root.findViewById(R.id.cb_specials)).isChecked(),
|
||||||
|
((CheckBox) root.findViewById(R.id.cb_brackets)).isChecked());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
Toast.makeText(getContext(), R.string.error_wrong_length, Toast.LENGTH_LONG).show();
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface GeneratePasswordListener {
|
||||||
|
void acceptPassword(Bundle bundle);
|
||||||
|
void cancelPassword(Bundle bundle);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -104,6 +104,7 @@
|
|||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
<android.support.design.widget.TextInputLayout
|
||||||
|
android:id="@+id/container_entry_password"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
@@ -120,30 +121,36 @@
|
|||||||
android:hint="@string/entry_password" />
|
android:hint="@string/entry_password" />
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatImageView android:id="@+id/generate_button"
|
<!-- Confirm Password -->
|
||||||
android:layout_width="wrap_content"
|
<android.support.design.widget.TextInputLayout
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:src="@drawable/ic_mode_edit_white_24dp"
|
|
||||||
android:tint="@color/colorAccent"
|
|
||||||
android:layout_margin="8dp"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_alignParentEnd="true"/>
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Confirm Password -->
|
|
||||||
<android.support.design.widget.TextInputLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatEditText
|
|
||||||
android:id="@+id/entry_confpassword"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:inputType="textPassword"
|
android:layout_alignParentLeft="true"
|
||||||
android:maxLines="1"
|
android:layout_alignParentStart="true"
|
||||||
android:hint="@string/entry_confpassword" />
|
android:layout_toLeftOf="@+id/generate_button"
|
||||||
</android.support.design.widget.TextInputLayout>
|
android:layout_toStartOf="@+id/generate_button"
|
||||||
|
android:layout_below="@+id/container_entry_password">
|
||||||
|
|
||||||
|
<android.support.v7.widget.AppCompatEditText
|
||||||
|
android:id="@+id/entry_confpassword"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="textPassword"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:hint="@string/entry_confpassword" />
|
||||||
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
|
<android.support.v7.widget.AppCompatImageView
|
||||||
|
android:id="@+id/generate_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:src="@drawable/ic_key_white_24dp"
|
||||||
|
android:tint="@color/colorAccent" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<!-- Comment -->
|
<!-- Comment -->
|
||||||
<android.support.design.widget.TextInputLayout
|
<android.support.design.widget.TextInputLayout
|
||||||
|
|||||||
@@ -17,133 +17,124 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_margin="@dimen/default_margin"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_height="match_parent">
|
android:orientation="vertical"
|
||||||
<Button android:id="@+id/accept_button"
|
android:layout_width="wrap_content"
|
||||||
android:layout_margin="@dimen/button_margin"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:padding="@dimen/default_margin">
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:text="@string/accept"
|
<LinearLayout
|
||||||
android:layout_alignParentBottom="true" />
|
android:layout_width="match_parent"
|
||||||
<Button android:id="@+id/cancel_button"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="@dimen/button_margin"
|
android:orientation="vertical">
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
<EditText android:id="@+id/password"
|
||||||
android:text="@string/cancel"
|
android:layout_width="match_parent"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_height="wrap_content"
|
||||||
android:layout_toRightOf="@id/accept_button"
|
android:ems="10"
|
||||||
android:layout_toEndOf="@id/accept_button" />
|
android:hint="@string/hint_generated_password" />
|
||||||
<ScrollView android:id="@+id/ScrollView"
|
|
||||||
android:layout_width="wrap_content"
|
<Button android:id="@+id/generate_password_button"
|
||||||
android:layout_height="wrap_content"
|
android:layout_margin="@dimen/button_margin"
|
||||||
android:layout_above="@id/cancel_button">
|
android:layout_width="match_parent"
|
||||||
<RelativeLayout android:id="@+id/RelativeLayout"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:text="@string/generate_password" />
|
||||||
android:layout_width="wrap_content">
|
</LinearLayout>
|
||||||
<EditText android:id="@+id/password"
|
|
||||||
android:layout_width="match_parent"
|
<ScrollView android:id="@+id/ScrollView"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:ems="10"
|
android:layout_height="wrap_content">
|
||||||
android:maxLines="1"
|
|
||||||
android:hint="@string/hint_generated_password" />
|
<LinearLayout
|
||||||
<Button android:id="@+id/generate_password_button"
|
android:layout_width="match_parent"
|
||||||
android:layout_margin="@dimen/button_margin"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="match_parent"
|
android:orientation="vertical">
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@id/password"
|
<RelativeLayout
|
||||||
android:text="@string/generate_password" />
|
android:layout_width="wrap_content"
|
||||||
<TextView android:id="@+id/length_label"
|
android:layout_height="wrap_content">
|
||||||
android:text="@string/length"
|
|
||||||
android:layout_height="match_parent"
|
<TextView android:id="@+id/length_label"
|
||||||
android:layout_width="match_parent"
|
android:text="@string/length"
|
||||||
android:layout_below="@id/generate_password_button" />
|
android:layout_height="match_parent"
|
||||||
<Button android:id="@+id/btn_length16"
|
android:layout_width="match_parent" />
|
||||||
android:text="@string/generate_16"
|
|
||||||
android:layout_alignParentRight="true"
|
<EditText android:id="@+id/length"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_width="60dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_width="wrap_content"
|
android:layout_alignParentStart="true"
|
||||||
android:minWidth="60dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/length_label" />
|
android:layout_below="@+id/length_label"
|
||||||
<Button android:id="@+id/btn_length12"
|
android:maxLines="1"
|
||||||
android:text="@string/generate_12"
|
android:inputType="number"
|
||||||
android:layout_toLeftOf="@id/btn_length16"
|
android:text="@integer/default_password_length"
|
||||||
android:layout_toStartOf="@id/btn_length16"
|
android:hint="@string/hint_length"/>
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
<android.support.v7.widget.AppCompatSeekBar android:id="@+id/seekbar_length"
|
||||||
android:minWidth="60dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_alignTop="@id/btn_length16" />
|
android:layout_height="wrap_content"
|
||||||
<Button android:id="@+id/btn_length8"
|
android:layout_alignBottom="@+id/length"
|
||||||
android:text="@string/generate_8"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_toLeftOf="@id/btn_length12"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_toStartOf="@id/btn_length12"
|
android:layout_alignTop="@+id/length"
|
||||||
android:layout_height="wrap_content"
|
android:layout_toEndOf="@+id/length"
|
||||||
android:layout_width="wrap_content"
|
android:layout_toRightOf="@+id/length"
|
||||||
android:minWidth="60dp"
|
app:min="1"
|
||||||
android:layout_alignTop="@id/btn_length16" />
|
android:progress="@integer/default_password_length"
|
||||||
<Button android:id="@+id/btn_length6"
|
android:max="64"/>
|
||||||
android:text="@string/generate_6"
|
|
||||||
android:layout_toLeftOf="@id/btn_length8"
|
</RelativeLayout>
|
||||||
android:layout_toStartOf="@id/btn_length8"
|
|
||||||
android:layout_height="wrap_content"
|
<LinearLayout android:id="@+id/RelativeLayout"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minWidth="60dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_alignTop="@id/btn_length16" />
|
android:orientation="vertical">
|
||||||
<EditText android:id="@+id/length"
|
|
||||||
android:layout_width="match_parent"
|
<CheckBox android:id="@+id/cb_uppercase"
|
||||||
android:layout_toLeftOf="@id/btn_length6"
|
android:layout_width="wrap_content"
|
||||||
android:layout_toStartOf="@id/btn_length6"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:text="@string/uppercase"
|
||||||
android:layout_alignTop="@id/btn_length16"
|
android:checked="true" />
|
||||||
android:maxLines="1"
|
|
||||||
android:inputType="number"
|
<CheckBox android:id="@+id/cb_lowercase"
|
||||||
android:text="@string/generate_8"
|
android:layout_width="wrap_content"
|
||||||
android:hint="@string/hint_length"/>
|
android:layout_height="wrap_content"
|
||||||
<CheckBox android:id="@+id/cb_uppercase"
|
android:text="@string/lowercase"
|
||||||
android:layout_width="wrap_content"
|
android:checked="true" />
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/uppercase"
|
<CheckBox android:id="@+id/cb_digits"
|
||||||
android:checked="true"
|
android:layout_width="wrap_content"
|
||||||
android:layout_below="@id/length" />
|
android:layout_height="wrap_content"
|
||||||
<CheckBox android:id="@+id/cb_lowercase"
|
android:text="@string/digits"
|
||||||
android:layout_width="wrap_content"
|
android:checked="true" />
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/lowercase"
|
<CheckBox android:id="@+id/cb_minus"
|
||||||
android:checked="true"
|
android:layout_width="wrap_content"
|
||||||
android:layout_below="@id/cb_uppercase" />
|
android:layout_height="wrap_content"
|
||||||
<CheckBox android:id="@+id/cb_digits"
|
android:text="@string/minus" />
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
<CheckBox android:id="@+id/cb_underline"
|
||||||
android:text="@string/digits"
|
android:layout_width="wrap_content"
|
||||||
android:checked="true"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/cb_lowercase" />
|
android:text="@string/underline" />
|
||||||
<CheckBox android:id="@+id/cb_minus"
|
|
||||||
android:layout_width="wrap_content"
|
<CheckBox android:id="@+id/cb_space"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:text="@string/minus"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/cb_digits" />
|
android:text="@string/space" />
|
||||||
<CheckBox android:id="@+id/cb_underline"
|
|
||||||
android:layout_width="wrap_content"
|
<CheckBox android:id="@+id/cb_specials"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:text="@string/underline"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/cb_minus" />
|
android:text="@string/special" />
|
||||||
<CheckBox android:id="@+id/cb_space"
|
|
||||||
android:layout_width="wrap_content"
|
<CheckBox android:id="@+id/cb_brackets"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:text="@string/space"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/cb_underline" />
|
android:text="@string/brackets" />
|
||||||
<CheckBox android:id="@+id/cb_specials"
|
</LinearLayout>
|
||||||
android:layout_width="wrap_content"
|
</LinearLayout>
|
||||||
android:layout_height="wrap_content"
|
</ScrollView>
|
||||||
android:text="@string/special"
|
</LinearLayout>
|
||||||
android:layout_below="@id/cb_space" />
|
|
||||||
<CheckBox android:id="@+id/cb_brackets"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/brackets"
|
|
||||||
android:layout_below="@id/cb_specials" />
|
|
||||||
</RelativeLayout>
|
|
||||||
</ScrollView>
|
|
||||||
</RelativeLayout>
|
|
||||||
@@ -28,10 +28,7 @@
|
|||||||
<string name="oi_filemanager_web">https://openintents.googlecode.com/files/FileManager-2.0.2.apk</string>
|
<string name="oi_filemanager_web">https://openintents.googlecode.com/files/FileManager-2.0.2.apk</string>
|
||||||
|
|
||||||
<!-- Password generator -->
|
<!-- Password generator -->
|
||||||
<string name="generate_6">6</string>
|
<integer name="default_password_length">8</integer>
|
||||||
<string name="generate_8">8</string>
|
|
||||||
<string name="generate_12">12</string>
|
|
||||||
<string name="generate_16">16</string>
|
|
||||||
|
|
||||||
<!-- Preference settings -->
|
<!-- Preference settings -->
|
||||||
<string name="algorithm_key">algorithm</string>
|
<string name="algorithm_key">algorithm</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user