Merge branch 'master' of github.com:open-keychain/open-keychain
This commit is contained in:
commit
0454c57431
13 files changed
+56
-19
No files matched your search
+41
-13
@@ -21,6 +21,8 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.HideReturnsTransformationMethod;
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -79,19 +81,10 @@ public class CreateKeyPassphraseFragment extends Fragment {
|
||||
return output;
|
||||
}
|
||||
|
||||
private static boolean areEditTextsEqual(Context context, EditText editText1, EditText editText2) {
|
||||
private static boolean areEditTextsEqual(EditText editText1, EditText editText2) {
|
||||
Passphrase p1 = new Passphrase(editText1);
|
||||
Passphrase p2 = new Passphrase(editText2);
|
||||
boolean output = (p1.equals(p2));
|
||||
|
||||
if (!output) {
|
||||
editText2.setError(context.getString(R.string.create_key_passphrases_not_equal));
|
||||
editText2.requestFocus();
|
||||
} else {
|
||||
editText2.setError(null);
|
||||
}
|
||||
|
||||
return output;
|
||||
return (p1.equals(p2));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,6 +130,35 @@ public class CreateKeyPassphraseFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
TextWatcher textWatcher = new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
if (!isEditTextNotEmpty(getActivity(), mPassphraseEdit)) {
|
||||
mPassphraseEditAgain.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (areEditTextsEqual(mPassphraseEdit, mPassphraseEditAgain)) {
|
||||
mPassphraseEditAgain.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_stat_retyped_ok, 0);
|
||||
} else {
|
||||
mPassphraseEditAgain.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_stat_retyped_bad, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
mPassphraseEdit.addTextChangedListener(textWatcher);
|
||||
mPassphraseEditAgain.addTextChangedListener(textWatcher);
|
||||
|
||||
return view;
|
||||
}
|
||||
@@ -153,9 +175,15 @@ public class CreateKeyPassphraseFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void nextClicked() {
|
||||
if (isEditTextNotEmpty(getActivity(), mPassphraseEdit)
|
||||
&& areEditTextsEqual(getActivity(), mPassphraseEdit, mPassphraseEditAgain)) {
|
||||
if (isEditTextNotEmpty(getActivity(), mPassphraseEdit)) {
|
||||
|
||||
if (!areEditTextsEqual(mPassphraseEdit, mPassphraseEditAgain)) {
|
||||
mPassphraseEditAgain.setError(getActivity().getApplicationContext().getString(R.string.create_key_passphrases_not_equal));
|
||||
mPassphraseEditAgain.requestFocus();
|
||||
return;
|
||||
}
|
||||
|
||||
mPassphraseEditAgain.setError(null);
|
||||
// save state
|
||||
mCreateKeyActivity.mPassphrase = new Passphrase(mPassphraseEdit);
|
||||
|
||||
|
||||
+6
-2
@@ -83,7 +83,6 @@ public class SettingsKeyserverFragment extends Fragment implements RecyclerItemC
|
||||
|
||||
String keyservers[] = getArguments().getStringArray(ARG_KEYSERVER_ARRAY);
|
||||
mKeyservers = new ArrayList<>(Arrays.asList(keyservers));
|
||||
saveKeyserverList(); // in case user does not make any changes
|
||||
|
||||
mAdapter = new KeyserverListAdapter(mKeyservers);
|
||||
|
||||
@@ -146,7 +145,7 @@ public class SettingsKeyserverFragment extends Fragment implements RecyclerItemC
|
||||
if (deleted) {
|
||||
Notify.create(getActivity(),
|
||||
getActivity().getString(
|
||||
R.string.keyserver_deleted, mKeyservers.get(position)),
|
||||
R.string.keyserver_preference_deleted, mKeyservers.get(position)),
|
||||
Notify.Style.OK)
|
||||
.show();
|
||||
deleteKeyserver(position);
|
||||
@@ -222,6 +221,11 @@ public class SettingsKeyserverFragment extends Fragment implements RecyclerItemC
|
||||
}
|
||||
|
||||
private void deleteKeyserver(int position) {
|
||||
if (mKeyservers.size() == 1) {
|
||||
Notify.create(getActivity(), R.string.keyserver_preference_cannot_delete_last,
|
||||
Notify.Style.ERROR).show();
|
||||
return;
|
||||
}
|
||||
mKeyservers.remove(position);
|
||||
// we use this
|
||||
mAdapter.notifyItemRemoved(position);
|
||||
|
||||
+2
-2
@@ -75,10 +75,10 @@ public class EmailEditText extends AppCompatAutoCompleteTextView {
|
||||
Matcher emailMatcher = Patterns.EMAIL_ADDRESS.matcher(email);
|
||||
if (emailMatcher.matches()) {
|
||||
EmailEditText.this.setCompoundDrawablesWithIntrinsicBounds(0, 0,
|
||||
R.drawable.uid_mail_ok, 0);
|
||||
R.drawable.ic_stat_retyped_ok, 0);
|
||||
} else {
|
||||
EmailEditText.this.setCompoundDrawablesWithIntrinsicBounds(0, 0,
|
||||
R.drawable.uid_mail_bad, 0);
|
||||
R.drawable.ic_stat_retyped_bad, 0);
|
||||
}
|
||||
} else {
|
||||
// remove drawable if email is empty
|
||||
|
||||
@@ -138,6 +138,9 @@ public class Preferences {
|
||||
public String[] getKeyServers() {
|
||||
String rawData = mSharedPreferences.getString(Constants.Pref.KEY_SERVERS,
|
||||
Constants.Defaults.KEY_SERVERS);
|
||||
if (rawData.equals("")) {
|
||||
return new String[0];
|
||||
}
|
||||
Vector<String> servers = new Vector<>();
|
||||
String chunks[] = rawData.split(",");
|
||||
for (String c : chunks) {
|
||||
@@ -150,7 +153,8 @@ public class Preferences {
|
||||
}
|
||||
|
||||
public String getPreferredKeyserver() {
|
||||
return getKeyServers()[0];
|
||||
String[] keyservers = getKeyServers();
|
||||
return keyservers.length == 0 ? null : keyservers[0];
|
||||
}
|
||||
|
||||
public void setKeyServers(String[] value) {
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -687,7 +687,8 @@
|
||||
<string name="add_keyserver_without_verification">"Keyserver added without verification."</string>
|
||||
<string name="add_keyserver_invalid_url">"Invalid URL!"</string>
|
||||
<string name="add_keyserver_connection_failed">"Failed to connect to keyserver. Please check the URL and your internet connection."</string>
|
||||
<string name="keyserver_deleted">"%s deleted"</string>
|
||||
<string name="keyserver_preference_deleted">"%s deleted"</string>
|
||||
<string name="keyserver_preference_cannot_delete_last">"Cannot delete last keyserver. At least one is required!"</string>
|
||||
|
||||
<!-- Navigation Drawer -->
|
||||
<string name="nav_keys">"Keys"</string>
|
||||
|
||||
Reference in new issue
Block a user