mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-17 06:15:15 -05:00
Merge pull request #417 from uberspot/master
Make email address less restrictive and fix double user ids
This commit is contained in:
commit
efab1d27ac
@ -600,8 +600,6 @@ public class EditKeyActivity extends ActionBarActivity {
|
|||||||
} catch (UserIdEditor.NoEmailException e) {
|
} catch (UserIdEditor.NoEmailException e) {
|
||||||
throw new PgpGeneralException(
|
throw new PgpGeneralException(
|
||||||
this.getString(R.string.error_user_id_needs_an_email_address));
|
this.getString(R.string.error_user_id_needs_an_email_address));
|
||||||
} catch (UserIdEditor.InvalidEmailException e) {
|
|
||||||
throw new PgpGeneralException(e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userId.equals("")) {
|
if (userId.equals("")) {
|
||||||
|
@ -152,6 +152,7 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LinearLayout ll = (LinearLayout) convertView.findViewById(R.id.list);
|
LinearLayout ll = (LinearLayout) convertView.findViewById(R.id.list);
|
||||||
|
ll.removeAllViews();
|
||||||
if (entry.userIds.size() == 1) {
|
if (entry.userIds.size() == 1) {
|
||||||
ll.setVisibility(View.GONE);
|
ll.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
|
@ -89,6 +89,7 @@ public class ImportKeysListServerLoader
|
|||||||
try {
|
try {
|
||||||
ArrayList<ImportKeysListEntry> searchResult = server.search(query);
|
ArrayList<ImportKeysListEntry> searchResult = server.search(query);
|
||||||
|
|
||||||
|
mEntryList.clear();
|
||||||
// add result to data
|
// add result to data
|
||||||
mEntryList.addAll(searchResult);
|
mEntryList.addAll(searchResult);
|
||||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, null);
|
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, null);
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
package org.sufficientlysecure.keychain.ui.widget;
|
package org.sufficientlysecure.keychain.ui.widget;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Patterns;
|
import android.util.Patterns;
|
||||||
import android.view.View;
|
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,
|
(this.getContext(), android.R.layout.simple_dropdown_item_1line,
|
||||||
ContactHelper.getMailAccounts(getContext())
|
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();
|
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 name = ("" + mName.getText()).trim();
|
||||||
String email = ("" + mEmail.getText()).trim();
|
String email = ("" + mEmail.getText()).trim();
|
||||||
String comment = ("" + mComment.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;
|
String userId = name;
|
||||||
if (comment.length() > 0) {
|
if (comment.length() > 0) {
|
||||||
userId += " (" + comment + ")";
|
userId += " (" + comment + ")";
|
||||||
|
Loading…
Reference in New Issue
Block a user