aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui
diff options
context:
space:
mode:
authorAshley Hughes <spirit.returned@gmail.com>2014-02-05 21:36:11 +0000
committerAshley Hughes <spirit.returned@gmail.com>2014-02-05 21:36:11 +0000
commit262425c6ad7cfa6509dc53150e592b3f6fd366c1 (patch)
tree357f936780e6bea0740a494dc8e8a2a3255767c5 /OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui
parent8d7cc6755349d06dcd9a2c28dc556c7adb71b8a4 (diff)
downloadopen-keychain-262425c6ad7cfa6509dc53150e592b3f6fd366c1.tar.gz
open-keychain-262425c6ad7cfa6509dc53150e592b3f6fd366c1.tar.bz2
open-keychain-262425c6ad7cfa6509dc53150e592b3f6fd366c1.zip
edit ui knows it it has been changed
Diffstat (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui')
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java5
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java22
2 files changed, 21 insertions, 6 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java
index 19926abd3..bf8a3f96b 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java
@@ -273,10 +273,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
UserIdEditor view = (UserIdEditor) mInflater.inflate(R.layout.edit_key_user_id_item,
mEditors, false);
view.setEditorListener(this);
- view.setValue(userId);
- if (mEditors.getChildCount() == 0) {
- view.setIsMainUserId(true);
- }
+ view.setValue(userId, mEditors.getChildCount() == 0);
view.setCanEdit(canEdit);
mEditors.addView(view);
}
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java
index a56340582..4cd1392c2 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java
@@ -38,8 +38,12 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
private BootstrapButton mDeleteButton;
private RadioButton mIsMainUserId;
private EditText mName;
+ private String mOriginalName;
private EditText mEmail;
+ private String mOriginalEmail;
private EditText mComment;
+ private String mOriginalComment;
+ private boolean mOriginallyMainUserID;
// see http://www.regular-expressions.info/email.html
// RFC 2822 if we omit the syntax using double quotes and square brackets
@@ -108,17 +112,22 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
super.onFinishInflate();
}
- public void setValue(String userId) {
+ public void setValue(String userId, boolean isMainID) {
mName.setText("");
mComment.setText("");
mEmail.setText("");
+ //TODO: update this file for blank email/name?
+
Pattern withComment = Pattern.compile("^(.*) [(](.*)[)] <(.*)>$");
Matcher matcher = withComment.matcher(userId);
if (matcher.matches()) {
mName.setText(matcher.group(1));
+ mOriginalName = matcher.group(1);
mComment.setText(matcher.group(2));
+ mOriginalComment = matcher.group(2);
mEmail.setText(matcher.group(3));
+ mOriginalEmail = matcher.group(3);
return;
}
@@ -126,9 +135,14 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
matcher = withoutComment.matcher(userId);
if (matcher.matches()) {
mName.setText(matcher.group(1));
+ mOriginalName = matcher.group(1);
mEmail.setText(matcher.group(2));
+ mOriginalEmail = matcher.group(2);
+ mOriginalComment = "";
return;
}
+ mOriginallyMainUserID = isMainID;
+ setIsMainUserId(isMainID);
}
public String getValue() throws NoNameException, NoEmailException, InvalidEmailException {
@@ -207,6 +221,10 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
@Override
public boolean needsSaving() {
- return false;
+ boolean retval = (mOriginallyMainUserID != isMainUserId());
+ retval |= (mOriginalName.equals( ("" + mName.getText()).trim() ) );
+ retval |= (mOriginalEmail.equals( ("" + mEmail.getText()).trim() ) );
+ retval |= (mOriginalComment.equals( ("" + mComment.getText()).trim() ) );
+ return retval;
}
}