diff options
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java | 97 |
1 files changed, 18 insertions, 79 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java index 81061501e..0d8c8233a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java @@ -65,6 +65,8 @@ public class ImportKeysActivity extends ActionBarActivity { + "IMPORT_KEY_FROM_QR_CODE"; public static final String ACTION_IMPORT_KEY_FROM_KEYSERVER = Constants.INTENT_PREFIX + "IMPORT_KEY_FROM_KEYSERVER"; + public static final String ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT = + Constants.INTENT_PREFIX + "IMPORT_KEY_FROM_KEY_SERVER_AND_RETURN_RESULT"; public static final String ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN = Constants.INTENT_PREFIX + "IMPORT_KEY_FROM_KEY_SERVER_AND_RETURN"; public static final String ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN = Constants.INTENT_PREFIX @@ -78,6 +80,8 @@ public class ImportKeysActivity extends ActionBarActivity { public static final String ACTION_IMPORT_KEY_FROM_NFC = Constants.INTENT_PREFIX + "IMPORT_KEY_FROM_NFC"; + public static final String EXTRA_RESULT = "result"; + // only used by ACTION_IMPORT_KEY public static final String EXTRA_KEY_BYTES = "key_bytes"; @@ -168,7 +172,8 @@ public class ImportKeysActivity extends ActionBarActivity { startListFragment(savedInstanceState, importData, null, null); } } else if (ACTION_IMPORT_KEY_FROM_KEYSERVER.equals(action) - || ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN.equals(action)) { + || ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN.equals(action) + || ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT.equals(action)) { // only used for OpenPgpService if (extras.containsKey(EXTRA_PENDING_INTENT_DATA)) { @@ -436,92 +441,26 @@ public class ImportKeysActivity extends ActionBarActivity { if (result == null) { return; } - int resultType = result.getResult(); - - String str; - int duration, color; - - // Not an overall failure - if ((resultType & ImportResult.RESULT_ERROR) == 0) { - String withWarnings; - - // Any warnings? - if ((resultType & ImportResult.RESULT_WITH_WARNINGS) > 0) { - duration = 0; - color = Style.ORANGE; - withWarnings = getResources().getString(R.string.import_with_warnings); - } else { - duration = SuperToast.Duration.LONG; - color = Style.GREEN; - withWarnings = ""; - } - - // New and updated keys - if (result.isOkBoth()) { - str = getResources().getQuantityString( - R.plurals.import_keys_added_and_updated_1, result.mNewKeys, result.mNewKeys); - str += getResources().getQuantityString( - R.plurals.import_keys_added_and_updated_2, result.mUpdatedKeys, result.mUpdatedKeys, withWarnings); - } else if (result.isOkUpdated()) { - str = getResources().getQuantityString( - R.plurals.import_keys_updated, result.mUpdatedKeys, result.mUpdatedKeys, withWarnings); - } else if (result.isOkNew()) { - str = getResources().getQuantityString( - R.plurals.import_keys_added, result.mNewKeys, result.mNewKeys, withWarnings); - } else { - duration = 0; - color = Style.RED; - str = "internal error"; - } - - } else { - duration = 0; - color = Style.RED; - if (result.isFailNothing()) { - str = getString(R.string.import_error_nothing); - } else { - str = getString(R.string.import_error); - } - } - SuperCardToast toast = new SuperCardToast(ImportKeysActivity.this, - SuperToast.Type.BUTTON, Style.getStyle(color, SuperToast.Animations.POPUP)); - toast.setText(str); - toast.setDuration(duration); - toast.setIndeterminate(duration == 0); - toast.setSwipeToDismiss(true); - toast.setButtonIcon(R.drawable.ic_action_view_as_list, - getResources().getString(R.string.import_view_log)); - toast.setButtonTextColor(getResources().getColor(R.color.black)); - toast.setTextColor(getResources().getColor(R.color.black)); - toast.setOnClickWrapper(new OnClickWrapper("supercardtoast", - new SuperToast.OnClickListener() { - @Override - public void onClick(View view, Parcelable token) { - Intent intent = new Intent( - ImportKeysActivity.this, LogDisplayActivity.class); - intent.putExtra(LogDisplayFragment.EXTRA_RESULT, result); - startActivity(intent); - } - } - )); - toast.show(); - - /* - if (bad > 0) { - BadImportKeyDialogFragment badImportKeyDialogFragment = - BadImportKeyDialogFragment.newInstance(bad); - badImportKeyDialogFragment.show(getSupportFragmentManager(), "badKeyDialog"); + if (ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT.equals(getIntent().getAction())) { + Intent intent = new Intent(); + intent.putExtra(EXTRA_RESULT, result); + ImportKeysActivity.this.setResult(RESULT_OK, intent); + ImportKeysActivity.this.finish(); + return; } - */ - if (ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN.equals(getIntent().getAction())) { ImportKeysActivity.this.setResult(RESULT_OK, mPendingIntentData); ImportKeysActivity.this.finish(); - } else if (ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN.equals(getIntent().getAction())) { + return; + } + if (ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN.equals(getIntent().getAction())) { ImportKeysActivity.this.setResult(RESULT_OK); ImportKeysActivity.this.finish(); + return; } + + result.displayToast(ImportKeysActivity.this); } } }; |