mirror of
https://github.com/moparisthebest/keepass2android
synced 2024-12-23 07:28:48 -05:00
Allow to enter password only once in Entry Edit Activity
This commit is contained in:
parent
a26f908bd8
commit
d7b6490c2f
@ -242,13 +242,15 @@ namespace keepass2android
|
||||
};
|
||||
|
||||
// Respect mask password setting
|
||||
if (State.ShowPassword) {
|
||||
EditText pass = (EditText) FindViewById(Resource.Id.entry_password);
|
||||
EditText conf = (EditText) FindViewById(Resource.Id.entry_confpassword);
|
||||
|
||||
pass.InputType = InputTypes.ClassText | InputTypes.TextVariationVisiblePassword;
|
||||
conf.InputType = InputTypes.ClassText | InputTypes.TextVariationVisiblePassword;
|
||||
}
|
||||
MakePasswordVisibleOrHidden();
|
||||
|
||||
ImageButton btnTogglePassword = (ImageButton)FindViewById(Resource.Id.toggle_password);
|
||||
btnTogglePassword.Click += (sender, e) =>
|
||||
{
|
||||
State.ShowPassword = !State.ShowPassword;
|
||||
MakePasswordVisibleOrHidden();
|
||||
};
|
||||
|
||||
|
||||
Button addButton = (Button) FindViewById(Resource.Id.add_advanced);
|
||||
addButton.Visibility = ViewStates.Visible;
|
||||
@ -283,6 +285,22 @@ namespace keepass2android
|
||||
|
||||
}
|
||||
|
||||
private void MakePasswordVisibleOrHidden()
|
||||
{
|
||||
TextView password = (TextView) FindViewById(Resource.Id.entry_password);
|
||||
TextView confpassword = (TextView) FindViewById(Resource.Id.entry_confpassword);
|
||||
if (State.ShowPassword)
|
||||
{
|
||||
password.InputType = InputTypes.ClassText | InputTypes.TextVariationVisiblePassword;
|
||||
confpassword.Visibility = ViewStates.Gone;
|
||||
}
|
||||
else
|
||||
{
|
||||
password.InputType = InputTypes.ClassText | InputTypes.TextVariationPassword;
|
||||
confpassword.Visibility = ViewStates.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
void SaveEntry()
|
||||
{
|
||||
Database db = App.Kp2a.GetDb();
|
||||
@ -685,13 +703,6 @@ namespace keepass2android
|
||||
inflater.Inflate(Resource.Menu.entry_edit, menu);
|
||||
|
||||
|
||||
IMenuItem togglePassword = menu.FindItem(Resource.Id.menu_toggle_pass);
|
||||
if ( State.ShowPassword ) {
|
||||
togglePassword.SetTitle(Resource.String.menu_hide_password);
|
||||
} else {
|
||||
togglePassword.SetTitle(Resource.String.show_password);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -705,16 +716,6 @@ namespace keepass2android
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
case Resource.Id.menu_toggle_pass:
|
||||
if ( State.ShowPassword ) {
|
||||
item.SetTitle(Resource.String.show_password);
|
||||
State.ShowPassword = false;
|
||||
} else {
|
||||
item.SetTitle(Resource.String.menu_hide_password);
|
||||
State.ShowPassword = true;
|
||||
}
|
||||
SetPasswordStyle();
|
||||
return true;
|
||||
case Resource.Id.menu_cancel_edit:
|
||||
Finish();
|
||||
@ -748,19 +749,6 @@ namespace keepass2android
|
||||
return base.OnOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void SetPasswordStyle() {
|
||||
TextView password = (TextView) FindViewById(Resource.Id.entry_password);
|
||||
TextView confpassword = (TextView) FindViewById(Resource.Id.entry_confpassword);
|
||||
|
||||
if ( State.ShowPassword ) {
|
||||
password.InputType = InputTypes.ClassText | InputTypes.TextVariationVisiblePassword;
|
||||
confpassword.InputType = InputTypes.ClassText | InputTypes.TextVariationVisiblePassword;
|
||||
|
||||
} else {
|
||||
password.InputType = InputTypes.ClassText | InputTypes.TextVariationPassword;
|
||||
confpassword.InputType = InputTypes.ClassText | InputTypes.TextVariationPassword;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateExpires()
|
||||
{
|
||||
@ -862,7 +850,6 @@ namespace keepass2android
|
||||
String password = State.Entry.Strings.ReadSafe(PwDefs.PasswordField);
|
||||
PopulateText(Resource.Id.entry_password, password);
|
||||
PopulateText(Resource.Id.entry_confpassword, password);
|
||||
SetPasswordStyle();
|
||||
|
||||
PopulateText(Resource.Id.entry_comment, State.Entry.Strings.ReadSafe (PwDefs.NotesField));
|
||||
|
||||
@ -913,13 +900,18 @@ namespace keepass2android
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate password
|
||||
String pass = Util.GetEditText(this, Resource.Id.entry_password);
|
||||
String conf = Util.GetEditText(this, Resource.Id.entry_confpassword);
|
||||
if ( ! pass.Equals(conf) ) {
|
||||
Toast.MakeText(this, Resource.String.error_pass_match, ToastLength.Long).Show();
|
||||
return false;
|
||||
if (!State.ShowPassword)
|
||||
{
|
||||
// Validate password
|
||||
String pass = Util.GetEditText(this, Resource.Id.entry_password);
|
||||
String conf = Util.GetEditText(this, Resource.Id.entry_confpassword);
|
||||
if (!pass.Equals(conf))
|
||||
{
|
||||
Toast.MakeText(this, Resource.String.error_pass_match, ToastLength.Long).Show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Validate expiry date
|
||||
DateTime newExpiry = new DateTime();
|
||||
|
@ -57,49 +57,57 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/entry_url"
|
||||
android:text="@string/entry_password" />
|
||||
<Button
|
||||
android:id="@+id/generate_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@id/entry_password_label"
|
||||
android:text="@string/ellipsis" />
|
||||
<EditText
|
||||
android:id="@+id/entry_password"
|
||||
style="@style/TextAppearance_EditEntry_Value"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/generate_button"
|
||||
android:layout_toLeftOf="@id/generate_button"
|
||||
android:hint="@string/hint_pass"
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"
|
||||
android:typeface="monospace" />
|
||||
<!-- Confirm Password -->
|
||||
<TextView
|
||||
android:id="@+id/entry_confpassword_label"
|
||||
style="@style/TextAppearance_EditEntry_LabelSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/entry_password"
|
||||
android:text="@string/entry_confpassword" />
|
||||
<EditText
|
||||
android:id="@+id/entry_confpassword"
|
||||
style="@style/TextAppearance_EditEntry_Value"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/entry_confpassword_label"
|
||||
android:hint="@string/hint_conf_pass"
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"
|
||||
android:typeface="monospace" />
|
||||
<RelativeLayout
|
||||
android:id="@+id/password_section"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/entry_password_label">
|
||||
|
||||
<Button
|
||||
android:id="@+id/generate_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:text="@string/ellipsis" />
|
||||
<ImageButton
|
||||
android:id="@+id/toggle_password"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_menu_view"
|
||||
android:layout_alignTop="@id/generate_button"
|
||||
android:layout_toLeftOf="@id/generate_button"
|
||||
/>
|
||||
<EditText
|
||||
android:id="@+id/entry_password"
|
||||
style="@style/TextAppearance_EditEntry_Value"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/generate_button"
|
||||
android:layout_toLeftOf="@id/toggle_password"
|
||||
android:hint="@string/hint_pass"
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"
|
||||
android:typeface="monospace" />
|
||||
<!-- Confirm Password -->
|
||||
<EditText
|
||||
android:id="@+id/entry_confpassword"
|
||||
style="@style/TextAppearance_EditEntry_Value"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/entry_password"
|
||||
android:hint="@string/hint_conf_pass"
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"
|
||||
android:typeface="monospace" />
|
||||
|
||||
</RelativeLayout>
|
||||
<!-- Comment -->
|
||||
<TextView
|
||||
android:id="@+id/entry_comment_label"
|
||||
style="@style/TextAppearance_EditEntry_LabelSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/entry_confpassword"
|
||||
android:layout_below="@id/password_section"
|
||||
android:text="@string/entry_comment" />
|
||||
<EditText
|
||||
android:id="@+id/entry_comment"
|
||||
|
@ -95,45 +95,56 @@
|
||||
android:layout_below="@id/entry_url"
|
||||
style="@style/EntryFieldHeader"
|
||||
android:text="@string/entry_password" />
|
||||
<Button
|
||||
android:id="@+id/generate_button"
|
||||
android:layout_below="@id/entry_password_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/ellipsis"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true" />
|
||||
<EditText
|
||||
android:id="@+id/entry_password"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textPassword"
|
||||
android:typeface="monospace"
|
||||
android:singleLine="true"
|
||||
android:layout_toLeftOf="@id/generate_button"
|
||||
android:hint="@string/hint_pass"
|
||||
android:layout_alignTop="@id/generate_button" />
|
||||
<!-- Confirm Password -->
|
||||
<TextView
|
||||
android:id="@+id/entry_confpassword_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/entry_password"
|
||||
android:text="@string/entry_confpassword" />
|
||||
<EditText
|
||||
android:id="@+id/entry_confpassword"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textPassword"
|
||||
android:typeface="monospace"
|
||||
android:singleLine="true"
|
||||
android:layout_below="@id/entry_confpassword_label"
|
||||
android:hint="@string/hint_conf_pass" />
|
||||
<RelativeLayout
|
||||
android:id="@+id/password_section"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/entry_password_label">
|
||||
|
||||
<Button
|
||||
android:id="@+id/generate_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:text="@string/ellipsis" />
|
||||
<ImageButton
|
||||
android:id="@+id/toggle_password"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_menu_view"
|
||||
android:layout_alignTop="@id/generate_button"
|
||||
android:layout_toLeftOf="@id/generate_button"
|
||||
/>
|
||||
<EditText
|
||||
android:id="@+id/entry_password"
|
||||
style="@style/TextAppearance_EditEntry_Value"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/generate_button"
|
||||
android:layout_toLeftOf="@id/toggle_password"
|
||||
android:hint="@string/hint_pass"
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"
|
||||
android:typeface="monospace" />
|
||||
<!-- Confirm Password -->
|
||||
<EditText
|
||||
android:id="@+id/entry_confpassword"
|
||||
style="@style/TextAppearance_EditEntry_Value"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/entry_password"
|
||||
android:hint="@string/hint_conf_pass"
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"
|
||||
android:typeface="monospace" />
|
||||
|
||||
</RelativeLayout>
|
||||
<!-- Comment -->
|
||||
<TextView
|
||||
android:id="@+id/entry_comment_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/entry_confpassword"
|
||||
android:layout_below="@id/password_section"
|
||||
style="@style/EntryFieldHeader"
|
||||
android:text="@string/entry_comment" />
|
||||
<EditText
|
||||
|
@ -16,11 +16,6 @@
|
||||
along with Keepass2Android. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/menu_toggle_pass"
|
||||
android:title="@string/show_password"
|
||||
android:icon="@android:drawable/ic_menu_view"
|
||||
android:showAsAction="ifRoom"
|
||||
/>
|
||||
<item android:id="@+id/menu_donate"
|
||||
android:title="@string/menu_donate"
|
||||
android:showAsAction="ifRoom"
|
||||
|
@ -17,10 +17,6 @@
|
||||
along with Keepass2Android. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/menu_toggle_pass"
|
||||
android:icon="@android:drawable/ic_menu_view"
|
||||
android:title="@string/show_password"
|
||||
/>
|
||||
<item android:id="@+id/menu_cancel_edit"
|
||||
android:title="@string/entry_cancel"
|
||||
/>
|
||||
|
Loading…
Reference in New Issue
Block a user