Merge branch 'master' of github.com:open-keychain/open-keychain
@@ -21,6 +21,8 @@ import android.app.Activity;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
import android.text.method.HideReturnsTransformationMethod;
|
import android.text.method.HideReturnsTransformationMethod;
|
||||||
import android.text.method.PasswordTransformationMethod;
|
import android.text.method.PasswordTransformationMethod;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -79,19 +81,10 @@ public class CreateKeyPassphraseFragment extends Fragment {
|
|||||||
return output;
|
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 p1 = new Passphrase(editText1);
|
||||||
Passphrase p2 = new Passphrase(editText2);
|
Passphrase p2 = new Passphrase(editText2);
|
||||||
boolean output = (p1.equals(p2));
|
return (p1.equals(p2));
|
||||||
|
|
||||||
if (!output) {
|
|
||||||
editText2.setError(context.getString(R.string.create_key_passphrases_not_equal));
|
|
||||||
editText2.requestFocus();
|
|
||||||
} else {
|
|
||||||
editText2.setError(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
return view;
|
||||||
}
|
}
|
||||||
@@ -153,9 +175,15 @@ public class CreateKeyPassphraseFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void nextClicked() {
|
private void nextClicked() {
|
||||||
if (isEditTextNotEmpty(getActivity(), mPassphraseEdit)
|
if (isEditTextNotEmpty(getActivity(), mPassphraseEdit)) {
|
||||||
&& areEditTextsEqual(getActivity(), mPassphraseEdit, mPassphraseEditAgain)) {
|
|
||||||
|
|
||||||
|
if (!areEditTextsEqual(mPassphraseEdit, mPassphraseEditAgain)) {
|
||||||
|
mPassphraseEditAgain.setError(getActivity().getApplicationContext().getString(R.string.create_key_passphrases_not_equal));
|
||||||
|
mPassphraseEditAgain.requestFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mPassphraseEditAgain.setError(null);
|
||||||
// save state
|
// save state
|
||||||
mCreateKeyActivity.mPassphrase = new Passphrase(mPassphraseEdit);
|
mCreateKeyActivity.mPassphrase = new Passphrase(mPassphraseEdit);
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ public class SettingsKeyserverFragment extends Fragment implements RecyclerItemC
|
|||||||
|
|
||||||
String keyservers[] = getArguments().getStringArray(ARG_KEYSERVER_ARRAY);
|
String keyservers[] = getArguments().getStringArray(ARG_KEYSERVER_ARRAY);
|
||||||
mKeyservers = new ArrayList<>(Arrays.asList(keyservers));
|
mKeyservers = new ArrayList<>(Arrays.asList(keyservers));
|
||||||
saveKeyserverList(); // in case user does not make any changes
|
|
||||||
|
|
||||||
mAdapter = new KeyserverListAdapter(mKeyservers);
|
mAdapter = new KeyserverListAdapter(mKeyservers);
|
||||||
|
|
||||||
@@ -146,7 +145,7 @@ public class SettingsKeyserverFragment extends Fragment implements RecyclerItemC
|
|||||||
if (deleted) {
|
if (deleted) {
|
||||||
Notify.create(getActivity(),
|
Notify.create(getActivity(),
|
||||||
getActivity().getString(
|
getActivity().getString(
|
||||||
R.string.keyserver_deleted, mKeyservers.get(position)),
|
R.string.keyserver_preference_deleted, mKeyservers.get(position)),
|
||||||
Notify.Style.OK)
|
Notify.Style.OK)
|
||||||
.show();
|
.show();
|
||||||
deleteKeyserver(position);
|
deleteKeyserver(position);
|
||||||
@@ -222,6 +221,11 @@ public class SettingsKeyserverFragment extends Fragment implements RecyclerItemC
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void deleteKeyserver(int position) {
|
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);
|
mKeyservers.remove(position);
|
||||||
// we use this
|
// we use this
|
||||||
mAdapter.notifyItemRemoved(position);
|
mAdapter.notifyItemRemoved(position);
|
||||||
|
|||||||
@@ -75,10 +75,10 @@ public class EmailEditText extends AppCompatAutoCompleteTextView {
|
|||||||
Matcher emailMatcher = Patterns.EMAIL_ADDRESS.matcher(email);
|
Matcher emailMatcher = Patterns.EMAIL_ADDRESS.matcher(email);
|
||||||
if (emailMatcher.matches()) {
|
if (emailMatcher.matches()) {
|
||||||
EmailEditText.this.setCompoundDrawablesWithIntrinsicBounds(0, 0,
|
EmailEditText.this.setCompoundDrawablesWithIntrinsicBounds(0, 0,
|
||||||
R.drawable.uid_mail_ok, 0);
|
R.drawable.ic_stat_retyped_ok, 0);
|
||||||
} else {
|
} else {
|
||||||
EmailEditText.this.setCompoundDrawablesWithIntrinsicBounds(0, 0,
|
EmailEditText.this.setCompoundDrawablesWithIntrinsicBounds(0, 0,
|
||||||
R.drawable.uid_mail_bad, 0);
|
R.drawable.ic_stat_retyped_bad, 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// remove drawable if email is empty
|
// remove drawable if email is empty
|
||||||
|
|||||||
@@ -138,6 +138,9 @@ public class Preferences {
|
|||||||
public String[] getKeyServers() {
|
public String[] getKeyServers() {
|
||||||
String rawData = mSharedPreferences.getString(Constants.Pref.KEY_SERVERS,
|
String rawData = mSharedPreferences.getString(Constants.Pref.KEY_SERVERS,
|
||||||
Constants.Defaults.KEY_SERVERS);
|
Constants.Defaults.KEY_SERVERS);
|
||||||
|
if (rawData.equals("")) {
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
Vector<String> servers = new Vector<>();
|
Vector<String> servers = new Vector<>();
|
||||||
String chunks[] = rawData.split(",");
|
String chunks[] = rawData.split(",");
|
||||||
for (String c : chunks) {
|
for (String c : chunks) {
|
||||||
@@ -150,7 +153,8 @@ public class Preferences {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getPreferredKeyserver() {
|
public String getPreferredKeyserver() {
|
||||||
return getKeyServers()[0];
|
String[] keyservers = getKeyServers();
|
||||||
|
return keyservers.length == 0 ? null : keyservers[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeyServers(String[] value) {
|
public void setKeyServers(String[] value) {
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 942 B After Width: | Height: | Size: 942 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 647 B After Width: | Height: | Size: 647 B |
|
Before Width: | Height: | Size: 862 B After Width: | Height: | Size: 862 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
@@ -687,7 +687,8 @@
|
|||||||
<string name="add_keyserver_without_verification">"Keyserver added without verification."</string>
|
<string name="add_keyserver_without_verification">"Keyserver added without verification."</string>
|
||||||
<string name="add_keyserver_invalid_url">"Invalid URL!"</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="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 -->
|
<!-- Navigation Drawer -->
|
||||||
<string name="nav_keys">"Keys"</string>
|
<string name="nav_keys">"Keys"</string>
|
||||||
|
|||||||