aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget
diff options
context:
space:
mode:
authoruberspot <onexemailx@gmail.com>2014-03-13 23:52:21 +0200
committeruberspot <onexemailx@gmail.com>2014-03-14 00:02:31 +0200
commitb12392594f54cac1ef8812c80decc315f70866db (patch)
treedd8049a48c79e9f204e7c4df9a09040f1c76d24b /OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget
parentc737f01a727b9a6f074e88b31a025cd273f0a632 (diff)
downloadopen-keychain-b12392594f54cac1ef8812c80decc315f70866db.tar.gz
open-keychain-b12392594f54cac1ef8812c80decc315f70866db.tar.bz2
open-keychain-b12392594f54cac1ef8812c80decc315f70866db.zip
Make email address less restrictive and add icon to show when it's correct
Diffstat (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget')
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java37
1 files changed, 28 insertions, 9 deletions
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 d3c6f02fe..ed81b162e 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
@@ -17,6 +17,8 @@
package org.sufficientlysecure.keychain.ui.widget;
import android.content.Context;
+import android.text.Editable;
+import android.text.TextWatcher;
import android.util.AttributeSet;
import android.util.Patterns;
import android.view.View;
@@ -102,6 +104,31 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
(this.getContext(), android.R.layout.simple_dropdown_item_1line,
ContactHelper.getMailAccounts(getContext())
));
+ mEmail.addTextChangedListener(new TextWatcher(){
+ @Override
+ public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { }
+
+ @Override
+ public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { }
+
+ @Override
+ public void afterTextChanged(Editable editable) {
+ String email = editable.toString();
+ if (email.length() > 0) {
+ Matcher emailMatcher = Patterns.EMAIL_ADDRESS.matcher(email);
+ if (emailMatcher.matches()) {
+ mEmail.setCompoundDrawablesWithIntrinsicBounds(0, 0,
+ android.R.drawable.presence_online, 0);
+ } else {
+ mEmail.setCompoundDrawablesWithIntrinsicBounds(0, 0,
+ android.R.drawable.presence_offline, 0);
+ }
+ } else {
+ // remove drawable if email is empty
+ mEmail.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
+ }
+ }
+ });
super.onFinishInflate();
}
@@ -129,19 +156,11 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
}
}
- public String getValue() throws NoNameException, NoEmailException, InvalidEmailException {
+ public String getValue() throws NoNameException, NoEmailException {
String name = ("" + mName.getText()).trim();
String email = ("" + mEmail.getText()).trim();
String comment = ("" + mComment.getText()).trim();
- if (email.length() > 0) {
- Matcher emailMatcher = Patterns.EMAIL_ADDRESS.matcher(email);
- if (!emailMatcher.matches()) {
- throw new InvalidEmailException(getContext().getString(R.string.error_invalid_email,
- email));
- }
- }
-
String userId = name;
if (comment.length() > 0) {
userId += " (" + comment + ")";