diff options
author | Adithya Abraham Philip <adithyaphilip@gmail.com> | 2015-07-02 05:43:23 +0530 |
---|---|---|
committer | Adithya Abraham Philip <adithyaphilip@gmail.com> | 2015-07-02 05:43:55 +0530 |
commit | 7b5c35ee8787934d97d24f3d6f79fd6340ab8a4d (patch) | |
tree | d80d79f82b1689e15a1d308713a0d8909fe93a42 | |
parent | 3510275a7fd7bff005eccbb94895d645b12e7180 (diff) | |
download | open-keychain-7b5c35ee8787934d97d24f3d6f79fd6340ab8a4d.tar.gz open-keychain-7b5c35ee8787934d97d24f3d6f79fd6340ab8a4d.tar.bz2 open-keychain-7b5c35ee8787934d97d24f3d6f79fd6340ab8a4d.zip |
prevent deletion of last keyserver in preference
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsKeyserverFragment.java | 8 | ||||
-rw-r--r-- | OpenKeychain/src/main/res/values/strings.xml | 3 |
2 files changed, 8 insertions, 3 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsKeyserverFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsKeyserverFragment.java index 6578d06af..2ae64d90b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsKeyserverFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsKeyserverFragment.java @@ -45,7 +45,6 @@ import org.sufficientlysecure.keychain.ui.util.recyclerview.ItemTouchHelperViewH import org.sufficientlysecure.keychain.ui.util.recyclerview.ItemTouchHelperDragCallback; import org.sufficientlysecure.keychain.ui.util.Notify; import org.sufficientlysecure.keychain.ui.util.recyclerview.RecyclerItemClickListener; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Preferences; import java.util.ArrayList; @@ -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); diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 619c67ee3..c216cd869 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -685,7 +685,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> |