mirror of
https://github.com/moparisthebest/keepass2android
synced 2024-11-22 09:12:17 -05:00
ask for comfirmation when leaving edit entry with back buttom after making changes
This commit is contained in:
parent
5370e73639
commit
6ba4068a28
@ -52,6 +52,8 @@ namespace keepass2android
|
|||||||
private PwIcon mSelectedIconID;
|
private PwIcon mSelectedIconID;
|
||||||
private PwUuid mSelectedCustomIconID = PwUuid.Zero;
|
private PwUuid mSelectedCustomIconID = PwUuid.Zero;
|
||||||
private bool mSelectedIcon = false;
|
private bool mSelectedIcon = false;
|
||||||
|
|
||||||
|
bool mEntryModified;
|
||||||
|
|
||||||
public static void Launch(Activity act, PwEntry pw) {
|
public static void Launch(Activity act, PwEntry pw) {
|
||||||
Intent i = new Intent(act, typeof(EntryEditActivity));
|
Intent i = new Intent(act, typeof(EntryEditActivity));
|
||||||
@ -145,6 +147,7 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
mIsNew = true;
|
mIsNew = true;
|
||||||
|
mEntryModified = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -356,7 +359,9 @@ namespace keepass2android
|
|||||||
ees.setData("", new ProtectedString(false, ""));
|
ees.setData("", new ProtectedString(false, ""));
|
||||||
ees.getDeleteButton().Click += (senderEes, eEes) => deleteAdvancedString((View)senderEes);
|
ees.getDeleteButton().Click += (senderEes, eEes) => deleteAdvancedString((View)senderEes);
|
||||||
container.AddView(ees);
|
container.AddView(ees);
|
||||||
|
|
||||||
|
mEntryModified = true;
|
||||||
|
|
||||||
// Scroll bottom
|
// Scroll bottom
|
||||||
scroll.Post(() => {
|
scroll.Post(() => {
|
||||||
scroll.FullScroll(FocusSearchDirection.Down);
|
scroll.FullScroll(FocusSearchDirection.Down);
|
||||||
@ -374,7 +379,7 @@ namespace keepass2android
|
|||||||
mEntry.ExpiryTime = DateTime.Now;
|
mEntry.ExpiryTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
updateExpires();
|
updateExpires();
|
||||||
|
mEntryModified = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -446,8 +451,39 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
Toast.MakeText(this, GetString(Resource.String.AttachFailed)+" "+exAttach.Message, ToastLength.Long).Show();
|
Toast.MakeText(this, GetString(Resource.String.AttachFailed)+" "+exAttach.Message, ToastLength.Long).Show();
|
||||||
}
|
}
|
||||||
|
mEntryModified = true;
|
||||||
populateBinaries();
|
populateBinaries();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnBackPressed()
|
||||||
|
{
|
||||||
|
if (mEntryModified == false)
|
||||||
|
{
|
||||||
|
base.OnBackPressed();
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.SetTitle(GetString(Resource.String.AskDiscardChanges_title));
|
||||||
|
|
||||||
|
builder.SetMessage(GetString(Resource.String.AskDiscardChanges));
|
||||||
|
|
||||||
|
builder.SetPositiveButton(GetString(Android.Resource.String.Yes), new EventHandler<DialogClickEventArgs>((dlgSender, dlgEvt) =>
|
||||||
|
{
|
||||||
|
Finish();
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
|
builder.SetNegativeButton(GetString(Android.Resource.String.No), new EventHandler<DialogClickEventArgs>((dlgSender, dlgEvt) =>
|
||||||
|
{
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
Dialog dialog = builder.Create();
|
||||||
|
dialog.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
|
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
|
||||||
{
|
{
|
||||||
@ -463,6 +499,7 @@ namespace keepass2android
|
|||||||
ImageButton currIconButton = (ImageButton) FindViewById(Resource.Id.icon_button);
|
ImageButton currIconButton = (ImageButton) FindViewById(Resource.Id.icon_button);
|
||||||
//TODO: custom image
|
//TODO: custom image
|
||||||
currIconButton.SetImageResource(Icons.iconToResId(mSelectedIconID));
|
currIconButton.SetImageResource(Icons.iconToResId(mSelectedIconID));
|
||||||
|
mEntryModified = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RESULT_OK_PASSWORD_GENERATOR:
|
case RESULT_OK_PASSWORD_GENERATOR:
|
||||||
@ -472,7 +509,7 @@ namespace keepass2android
|
|||||||
|
|
||||||
password.Text = generatedPassword;
|
password.Text = generatedPassword;
|
||||||
confPassword.Text = generatedPassword;
|
confPassword.Text = generatedPassword;
|
||||||
|
mEntryModified = true;
|
||||||
break;
|
break;
|
||||||
case (int)Result.Ok:
|
case (int)Result.Ok:
|
||||||
if (requestCode == Intents.REQUEST_CODE_FILE_BROWSE)
|
if (requestCode == Intents.REQUEST_CODE_FILE_BROWSE)
|
||||||
@ -511,6 +548,7 @@ namespace keepass2android
|
|||||||
binaryButton.SetCompoundDrawablesWithIntrinsicBounds( Resources.GetDrawable(Android.Resource.Drawable.IcMenuDelete),null, null, null);
|
binaryButton.SetCompoundDrawablesWithIntrinsicBounds( Resources.GetDrawable(Android.Resource.Drawable.IcMenuDelete),null, null, null);
|
||||||
binaryButton.Click += (object sender, EventArgs e) =>
|
binaryButton.Click += (object sender, EventArgs e) =>
|
||||||
{
|
{
|
||||||
|
mEntryModified = true;
|
||||||
Button btnSender = (Button)(sender);
|
Button btnSender = (Button)(sender);
|
||||||
mEntry.Binaries.Remove(key);
|
mEntry.Binaries.Remove(key);
|
||||||
populateBinaries();
|
populateBinaries();
|
||||||
@ -632,6 +670,7 @@ namespace keepass2android
|
|||||||
if (!PwDefs.IsStandardField(key)) {
|
if (!PwDefs.IsStandardField(key)) {
|
||||||
EntryEditSection ees = (EntryEditSection) LayoutInflater.Inflate(Resource.Layout.entry_edit_section, null);
|
EntryEditSection ees = (EntryEditSection) LayoutInflater.Inflate(Resource.Layout.entry_edit_section, null);
|
||||||
ees.setData(key, pair.Value);
|
ees.setData(key, pair.Value);
|
||||||
|
ees.ContentChanged += (sender, e) => {mEntryModified=true;};
|
||||||
ees.getDeleteButton().Click += (sender, e) => deleteAdvancedString((View)sender);
|
ees.getDeleteButton().Click += (sender, e) => deleteAdvancedString((View)sender);
|
||||||
container.AddView(ees);
|
container.AddView(ees);
|
||||||
}
|
}
|
||||||
@ -652,7 +691,7 @@ namespace keepass2android
|
|||||||
public void deleteAdvancedString(View view) {
|
public void deleteAdvancedString(View view) {
|
||||||
EntryEditSection section = (EntryEditSection) view.Parent;
|
EntryEditSection section = (EntryEditSection) view.Parent;
|
||||||
LinearLayout container = (LinearLayout) FindViewById(Resource.Id.advanced_container);
|
LinearLayout container = (LinearLayout) FindViewById(Resource.Id.advanced_container);
|
||||||
|
mEntryModified = true;
|
||||||
for (int i = 0; i < container.ChildCount; i++) {
|
for (int i = 0; i < container.ChildCount; i++) {
|
||||||
EntryEditSection ees = (EntryEditSection) container.GetChildAt(i);
|
EntryEditSection ees = (EntryEditSection) container.GetChildAt(i);
|
||||||
if (ees == section) {
|
if (ees == section) {
|
||||||
@ -714,6 +753,7 @@ namespace keepass2android
|
|||||||
private void populateText(int viewId, String text) {
|
private void populateText(int viewId, String text) {
|
||||||
TextView tv = (TextView) FindViewById(viewId);
|
TextView tv = (TextView) FindViewById(viewId);
|
||||||
tv.Text = text;
|
tv.Text = text;
|
||||||
|
tv.TextChanged += (sender, e) => {mEntryModified = true;};
|
||||||
}
|
}
|
||||||
|
|
||||||
private class AfterSave : OnFinish {
|
private class AfterSave : OnFinish {
|
||||||
|
@ -1009,6 +1009,12 @@ namespace keepass2android
|
|||||||
// aapt resource value: 0x7f0500f1
|
// aapt resource value: 0x7f0500f1
|
||||||
public const int AskDeletePermanently_title = 2131034353;
|
public const int AskDeletePermanently_title = 2131034353;
|
||||||
|
|
||||||
|
// aapt resource value: 0x7f0500f4
|
||||||
|
public const int AskDiscardChanges = 2131034356;
|
||||||
|
|
||||||
|
// aapt resource value: 0x7f0500f5
|
||||||
|
public const int AskDiscardChanges_title = 2131034357;
|
||||||
|
|
||||||
// aapt resource value: 0x7f0500e9
|
// aapt resource value: 0x7f0500e9
|
||||||
public const int AskOverwriteBinary = 2131034345;
|
public const int AskOverwriteBinary = 2131034345;
|
||||||
|
|
||||||
|
@ -214,6 +214,8 @@
|
|||||||
<string name="AskDeletePermanently_title">Delete permanently?</string>
|
<string name="AskDeletePermanently_title">Delete permanently?</string>
|
||||||
<string name="AskReloadFile_title">Reload file?</string>
|
<string name="AskReloadFile_title">Reload file?</string>
|
||||||
<string name="AskReloadFile">The file which is currently open was changed by another program. Do you want to reload it?</string>
|
<string name="AskReloadFile">The file which is currently open was changed by another program. Do you want to reload it?</string>
|
||||||
|
<string name="AskDiscardChanges">Do you really want to discard the changes made? (The Save button is at the top of the form.)</string>
|
||||||
|
<string name="AskDiscardChanges_title">Discard changes?</string>
|
||||||
<string-array name="clipboard_timeout_options">
|
<string-array name="clipboard_timeout_options">
|
||||||
<item>30 seconds</item>
|
<item>30 seconds</item>
|
||||||
<item>1 minute</item>
|
<item>1 minute</item>
|
||||||
|
@ -33,6 +33,8 @@ namespace keepass2android.view
|
|||||||
{
|
{
|
||||||
public class EntryEditSection : RelativeLayout
|
public class EntryEditSection : RelativeLayout
|
||||||
{
|
{
|
||||||
|
public event EventHandler ContentChanged;
|
||||||
|
|
||||||
public EntryEditSection (IntPtr javaReference, JniHandleOwnership transfer)
|
public EntryEditSection (IntPtr javaReference, JniHandleOwnership transfer)
|
||||||
: base(javaReference, transfer)
|
: base(javaReference, transfer)
|
||||||
{
|
{
|
||||||
@ -62,6 +64,9 @@ namespace keepass2android.view
|
|||||||
|
|
||||||
CheckBox cb = (CheckBox) FindViewById(Resource.Id.protection);
|
CheckBox cb = (CheckBox) FindViewById(Resource.Id.protection);
|
||||||
cb.Checked = value.IsProtected;
|
cb.Checked = value.IsProtected;
|
||||||
|
cb.CheckedChange += (sender, e) => {if (ContentChanged != null)
|
||||||
|
ContentChanged(this, new EventArgs());
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageButton getDeleteButton()
|
public ImageButton getDeleteButton()
|
||||||
@ -73,8 +78,12 @@ namespace keepass2android.view
|
|||||||
{
|
{
|
||||||
if (str != null)
|
if (str != null)
|
||||||
{
|
{
|
||||||
TextView tvTitle = (TextView)FindViewById(resId);
|
TextView tv = (TextView)FindViewById(resId);
|
||||||
tvTitle.Text = str;
|
tv.Text = str;
|
||||||
|
tv.TextChanged += (sender, e) => {
|
||||||
|
if (ContentChanged != null)
|
||||||
|
ContentChanged(this, new EventArgs());
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user