diff options
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysListFragment.java')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysListFragment.java | 65 |
1 files changed, 39 insertions, 26 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysListFragment.java index 16ebd6aca..ad50ecd3d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysListFragment.java @@ -31,6 +31,7 @@ import android.widget.ListView; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.service.results.GetKeyResult; import org.sufficientlysecure.keychain.util.ParcelableFileCache.IteratorWithSize; import org.sufficientlysecure.keychain.util.Preferences; import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry; @@ -285,48 +286,60 @@ public class ImportKeysListFragment extends ListFragment implements setListShownNoAnimation(true); } - Exception error = data.getError(); - // free old cached key data mCachedKeyData = null; + GetKeyResult getKeyResult = (GetKeyResult) data.getOperationResult(); switch (loader.getId()) { case LOADER_ID_BYTES: - if (error == null) { + if (getKeyResult.success()) { // No error mCachedKeyData = ((ImportKeysListLoader) loader).getParcelableRings(); - } else if (error instanceof ImportKeysListLoader.NoValidKeysException) { - Notify.showNotify(getActivity(), R.string.error_import_no_valid_keys, Notify.Style.ERROR); - } else if (error instanceof ImportKeysListLoader.NonPgpPartException) { - Notify.showNotify(getActivity(), - ((ImportKeysListLoader.NonPgpPartException) error).getCount() + " " + getResources(). - getQuantityString(R.plurals.error_import_non_pgp_part, - ((ImportKeysListLoader.NonPgpPartException) error).getCount()), - Notify.Style.OK - ); } else { - Notify.showNotify(getActivity(), R.string.error_generic_report_bug, Notify.Style.ERROR); + getKeyResult.createNotify(getActivity()).show(); } +// if (error == null) { +// // No error +// mCachedKeyData = ((ImportKeysListLoader) loader).getParcelableRings(); +// } else if (error instanceof ImportKeysListLoader.NoValidKeysException) { +// Notify.showNotify(getActivity(), R.string.error_import_no_valid_keys, Notify.Style.ERROR); +// } else if (error instanceof ImportKeysListLoader.NonPgpPartException) { +// Notify.showNotify(getActivity(), +// ((ImportKeysListLoader.NonPgpPartException) error).getCount() + " " + getResources(). +// getQuantityString(R.plurals.error_import_non_pgp_part, +// ((ImportKeysListLoader.NonPgpPartException) error).getCount()), +// Notify.Style.OK +// ); +// } else { +// Notify.showNotify(getActivity(), R.string.error_generic_report_bug, Notify.Style.ERROR); +// } break; case LOADER_ID_CLOUD: - if (error == null) { + if (getKeyResult.success()) { // No error - } else if (error instanceof Keyserver.QueryTooShortException) { - Notify.showNotify(getActivity(), R.string.error_query_too_short, Notify.Style.ERROR); - } else if (error instanceof Keyserver.TooManyResponsesException) { - Notify.showNotify(getActivity(), R.string.error_too_many_responses, Notify.Style.ERROR); - } else if (error instanceof Keyserver.QueryTooShortOrTooManyResponsesException) { - Notify.showNotify(getActivity(), R.string.error_too_short_or_too_many_responses, Notify.Style.ERROR); - } else if (error instanceof Keyserver.QueryFailedException) { - Log.d(Constants.TAG, - "Unrecoverable keyserver query error: " + error.getLocalizedMessage()); - String alert = getActivity().getString(R.string.error_searching_keys); - alert = alert + " (" + error.getLocalizedMessage() + ")"; - Notify.showNotify(getActivity(), alert, Notify.Style.ERROR); + } else { + getKeyResult.createNotify(getActivity()).show(); } + + +// if (error == null) { +// // No error +// } else if (error instanceof Keyserver.QueryTooShortException) { +// Notify.showNotify(getActivity(), R.string.error_query_too_short, Notify.Style.ERROR); +// } else if (error instanceof Keyserver.TooManyResponsesException) { +// Notify.showNotify(getActivity(), R.string.error_too_many_responses, Notify.Style.ERROR); +// } else if (error instanceof Keyserver.QueryTooShortOrTooManyResponsesException) { +// Notify.showNotify(getActivity(), R.string.error_too_short_or_too_many_responses, Notify.Style.ERROR); +// } else if (error instanceof Keyserver.QueryFailedException) { +// Log.d(Constants.TAG, +// "Unrecoverable keyserver query error: " + error.getLocalizedMessage()); +// String alert = getActivity().getString(R.string.error_searching_keys); +// alert = alert + " (" + error.getLocalizedMessage() + ")"; +// Notify.showNotify(getActivity(), alert, Notify.Style.ERROR); +// } break; default: |