|
|
@@ -1,25 +1,24 @@
|
|
|
package info.knacki.pass.generator.ui;
|
|
|
|
|
|
import android.content.Context;
|
|
|
-import android.support.v7.widget.AppCompatCheckBox;
|
|
|
import android.support.v7.widget.AppCompatSpinner;
|
|
|
import android.view.View;
|
|
|
import android.widget.AdapterView;
|
|
|
import android.widget.ArrayAdapter;
|
|
|
-import android.widget.CompoundButton;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.NumberPicker;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import info.knacki.pass.R;
|
|
|
import info.knacki.pass.generator.PasswordGenerator;
|
|
|
+import info.knacki.pass.ui.widget.Checkbox;
|
|
|
|
|
|
public class PasswordGeneratorWizard extends LinearLayout implements PasswordGenerator.PasswordGeneratorParams {
|
|
|
public final AppCompatSpinner fDifficulty;
|
|
|
- public final AppCompatCheckBox fAlpha;
|
|
|
- public final AppCompatCheckBox fCapitalize;
|
|
|
- public final AppCompatCheckBox fNum;
|
|
|
- public final AppCompatCheckBox fSpecial;
|
|
|
+ public final Checkbox fAlpha;
|
|
|
+ public final Checkbox fCapitalize;
|
|
|
+ public final Checkbox fNum;
|
|
|
+ public final Checkbox fSpecial;
|
|
|
public final NumberPicker fLength;
|
|
|
|
|
|
public static final int PRESET_NUM =0;
|
|
|
@@ -52,11 +51,11 @@ public class PasswordGeneratorWizard extends LinearLayout implements PasswordGen
|
|
|
return fLength.getValue();
|
|
|
}
|
|
|
|
|
|
- private class ChangeListener implements CompoundButton.OnCheckedChangeListener, NumberPicker.OnValueChangeListener {
|
|
|
+ private class ChangeListener implements Checkbox.OnCheckedChangeListener, NumberPicker.OnValueChangeListener {
|
|
|
private boolean locked = true;
|
|
|
|
|
|
@Override
|
|
|
- public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
|
|
+ public void onCheckedChanged(Checkbox checkbox, boolean b) {
|
|
|
if (!locked)
|
|
|
fDifficulty.setSelection(4, true);
|
|
|
}
|
|
|
@@ -76,7 +75,6 @@ public class PasswordGeneratorWizard extends LinearLayout implements PasswordGen
|
|
|
public PasswordGeneratorWizard(Context c) {
|
|
|
super(c);
|
|
|
|
|
|
-
|
|
|
LinearLayout difficultyLayout = new LinearLayout(c);
|
|
|
ArrayAdapter fDifficultyAdapter = new ArrayAdapter<>(c, android.R.layout.simple_spinner_item, c.getResources().getStringArray(R.array.fDifficulty));
|
|
|
fDifficultyAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
|
|
@@ -97,22 +95,10 @@ public class PasswordGeneratorWizard extends LinearLayout implements PasswordGen
|
|
|
difficultyLayout.addView(tv);
|
|
|
difficultyLayout.addView(fDifficulty);
|
|
|
addView(difficultyLayout);
|
|
|
- fNum = new AppCompatCheckBox(c);
|
|
|
- fNum.setText(R.string.generate_number);
|
|
|
- fNum.setOnCheckedChangeListener(fChangeListener);
|
|
|
- addView(fNum);
|
|
|
- fAlpha = new AppCompatCheckBox(c);
|
|
|
- fAlpha.setText(R.string.generate_alpha);
|
|
|
- fAlpha.setOnCheckedChangeListener(fChangeListener);
|
|
|
- addView(fAlpha);
|
|
|
- fCapitalize = new AppCompatCheckBox(c);
|
|
|
- fCapitalize.setText(R.string.generate_capitalize);
|
|
|
- fCapitalize.setOnCheckedChangeListener(fChangeListener);
|
|
|
- addView(fCapitalize);
|
|
|
- fSpecial = new AppCompatCheckBox(c);
|
|
|
- fSpecial.setText(R.string.generate_special);
|
|
|
- fSpecial.setOnCheckedChangeListener(fChangeListener);
|
|
|
- addView(fSpecial);
|
|
|
+ fNum = new Checkbox(c, R.string.generate_number, fChangeListener, this);
|
|
|
+ fAlpha = new Checkbox(c, R.string.generate_alpha, fChangeListener, this);
|
|
|
+ fCapitalize = new Checkbox(c, R.string.generate_capitalize, fChangeListener, this);
|
|
|
+ fSpecial = new Checkbox(c, R.string.generate_special, fChangeListener, this);
|
|
|
fLength = new NumberPicker(c);
|
|
|
fLength.setMinValue(4);
|
|
|
fLength.setMaxValue(21);
|