Fix nullpointer in ImportKeysActivity

This commit is contained in:
Dominik Schürmann 2015-01-27 13:15:24 +01:00
parent 3b23a71209
commit 5a1187b781

View File

@ -115,6 +115,12 @@ public class ImportKeysActivity extends BaseActivity {
extras = new Bundle(); extras = new Bundle();
} }
if (action == null) {
startCloudFragment(savedInstanceState, null, false);
startListFragment(savedInstanceState, null, null, null);
return;
}
if (Intent.ACTION_VIEW.equals(action)) { if (Intent.ACTION_VIEW.equals(action)) {
// Android's Action when opening file associated to Keychain (see AndroidManifest.xml) // Android's Action when opening file associated to Keychain (see AndroidManifest.xml)
// delegate action to ACTION_IMPORT_KEY // delegate action to ACTION_IMPORT_KEY
@ -122,8 +128,8 @@ public class ImportKeysActivity extends BaseActivity {
} }
switch (action) { switch (action) {
case ACTION_IMPORT_KEY: case ACTION_IMPORT_KEY: {
/* Keychain's own Actions */ /* Keychain's own Actions */
startFileFragment(savedInstanceState); startFileFragment(savedInstanceState);
if (dataUri != null) { if (dataUri != null) {
@ -136,16 +142,17 @@ public class ImportKeysActivity extends BaseActivity {
startListFragment(savedInstanceState, importData, null, null); startListFragment(savedInstanceState, importData, null, null);
} }
break; break;
}
case ACTION_IMPORT_KEY_FROM_KEYSERVER: case ACTION_IMPORT_KEY_FROM_KEYSERVER:
case ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_TO_SERVICE: case ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_TO_SERVICE:
case ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT: case ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT: {
// only used for OpenPgpService // only used for OpenPgpService
if (extras.containsKey(EXTRA_PENDING_INTENT_DATA)) { if (extras.containsKey(EXTRA_PENDING_INTENT_DATA)) {
mPendingIntentData = extras.getParcelable(EXTRA_PENDING_INTENT_DATA); mPendingIntentData = extras.getParcelable(EXTRA_PENDING_INTENT_DATA);
} }
if (extras.containsKey(EXTRA_QUERY) || extras.containsKey(EXTRA_KEY_ID)) { if (extras.containsKey(EXTRA_QUERY) || extras.containsKey(EXTRA_KEY_ID)) {
/* simple search based on query or key id */ /* simple search based on query or key id */
String query = null; String query = null;
if (extras.containsKey(EXTRA_QUERY)) { if (extras.containsKey(EXTRA_QUERY)) {
@ -168,10 +175,10 @@ public class ImportKeysActivity extends BaseActivity {
return; return;
} }
} else if (extras.containsKey(EXTRA_FINGERPRINT)) { } else if (extras.containsKey(EXTRA_FINGERPRINT)) {
/* /*
* search based on fingerprint, here we can enforce a check in the end * search based on fingerprint, here we can enforce a check in the end
* if the right key has been downloaded * if the right key has been downloaded
*/ */
String fingerprint = extras.getString(EXTRA_FINGERPRINT); String fingerprint = extras.getString(EXTRA_FINGERPRINT);
if (isFingerprintValid(fingerprint)) { if (isFingerprintValid(fingerprint)) {
@ -191,21 +198,24 @@ public class ImportKeysActivity extends BaseActivity {
return; return;
} }
break; break;
case ACTION_IMPORT_KEY_FROM_FILE: }
case ACTION_IMPORT_KEY_FROM_FILE: {
// NOTE: this only displays the appropriate fragment, no actions are taken // NOTE: this only displays the appropriate fragment, no actions are taken
startFileFragment(savedInstanceState); startFileFragment(savedInstanceState);
// no immediate actions! // no immediate actions!
startListFragment(savedInstanceState, null, null, null); startListFragment(savedInstanceState, null, null, null);
break; break;
case ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN: }
case ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN: {
// NOTE: this only displays the appropriate fragment, no actions are taken // NOTE: this only displays the appropriate fragment, no actions are taken
startFileFragment(savedInstanceState); startFileFragment(savedInstanceState);
// no immediate actions! // no immediate actions!
startListFragment(savedInstanceState, null, null, null); startListFragment(savedInstanceState, null, null, null);
break; break;
case ACTION_IMPORT_KEY_FROM_NFC: }
case ACTION_IMPORT_KEY_FROM_NFC: {
// NOTE: this only displays the appropriate fragment, no actions are taken // NOTE: this only displays the appropriate fragment, no actions are taken
startFileFragment(savedInstanceState); startFileFragment(savedInstanceState);
// TODO!!!!! // TODO!!!!!
@ -213,14 +223,15 @@ public class ImportKeysActivity extends BaseActivity {
// no immediate actions! // no immediate actions!
startListFragment(savedInstanceState, null, null, null); startListFragment(savedInstanceState, null, null, null);
break; break;
default: }
default: {
startCloudFragment(savedInstanceState, null, false); startCloudFragment(savedInstanceState, null, false);
startListFragment(savedInstanceState, null, null, null); startListFragment(savedInstanceState, null, null, null);
break; break;
}
} }
} }
private void startListFragment(Bundle savedInstanceState, byte[] bytes, Uri dataUri, String serverQuery) { private void startListFragment(Bundle savedInstanceState, byte[] bytes, Uri dataUri, String serverQuery) {
// However, if we're being restored from a previous state, // However, if we're being restored from a previous state,
// then we don't need to do anything and should return or else // then we don't need to do anything and should return or else