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