prevent NaN dialog on import with no selected keys

This commit is contained in:
Adithya Abraham Philip 2015-05-31 02:36:45 +05:30
parent 3be44898db
commit cfeffef80d
2 changed files with 8 additions and 3 deletions

View File

@ -384,6 +384,13 @@ public class ImportKeysActivity extends BaseNfcActivity {
*/ */
public void importKeys() { public void importKeys() {
ImportKeysListFragment.LoaderState ls = mListFragment.getLoaderState(); ImportKeysListFragment.LoaderState ls = mListFragment.getLoaderState();
if (mListFragment.getSelectedEntries().size() == 0) {
Notify.create(this, R.string.error_nothing_import_selected, Notify.Style.ERROR)
.show((ViewGroup) findViewById(R.id.import_snackbar));
return;
}
if (ls instanceof ImportKeysListFragment.BytesLoaderState) { if (ls instanceof ImportKeysListFragment.BytesLoaderState) {
Log.d(Constants.TAG, "importKeys started"); Log.d(Constants.TAG, "importKeys started");
@ -488,9 +495,6 @@ public class ImportKeysActivity extends BaseNfcActivity {
// start service with intent // start service with intent
startService(intent); startService(intent);
} else {
Notify.create(this, R.string.error_nothing_import, Notify.Style.ERROR)
.show((ViewGroup) findViewById(R.id.import_snackbar));
} }
} }

View File

@ -281,6 +281,7 @@
<string name="error_nfc_needed">"NFC must be enabled!"</string> <string name="error_nfc_needed">"NFC must be enabled!"</string>
<string name="error_beam_needed">"Beam must be enabled!"</string> <string name="error_beam_needed">"Beam must be enabled!"</string>
<string name="error_nothing_import">"No keys found!"</string> <string name="error_nothing_import">"No keys found!"</string>
<string name="error_nothing_import_selected">"No keys selected for import!"</string>
<string name="error_contacts_key_id_missing">"Retrieving the key ID from contacts failed!"</string> <string name="error_contacts_key_id_missing">"Retrieving the key ID from contacts failed!"</string>
<string name="error_generic_report_bug">"A generic error occurred, please create a new bug report for OpenKeychain."</string> <string name="error_generic_report_bug">"A generic error occurred, please create a new bug report for OpenKeychain."</string>