diff options
Diffstat (limited to 'OpenPGP-Keychain/src/main/java')
4 files changed, 30 insertions, 11 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index a0186f08c..edf980773 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -600,8 +600,6 @@ public class EditKeyActivity extends ActionBarActivity { } catch (UserIdEditor.NoEmailException e) { throw new PgpGeneralException( this.getString(R.string.error_user_id_needs_an_email_address)); - } catch (UserIdEditor.InvalidEmailException e) { - throw new PgpGeneralException(e.getMessage()); } if (userId.equals("")) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java index 16776e121..0f05af447 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java @@ -152,6 +152,7 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> { } LinearLayout ll = (LinearLayout) convertView.findViewById(R.id.list); + ll.removeAllViews(); if (entry.userIds.size() == 1) { ll.setVisibility(View.GONE); } else { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListServerLoader.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListServerLoader.java index 1e96606a6..a4dd06e40 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListServerLoader.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListServerLoader.java @@ -89,6 +89,7 @@ public class ImportKeysListServerLoader try { ArrayList<ImportKeysListEntry> searchResult = server.search(query); + mEntryList.clear(); // add result to data mEntryList.addAll(searchResult); mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, null); 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 + ")"; |