diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-10-02 11:32:10 +0200 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-10-02 11:32:10 +0200 |
commit | 8f616bcf0c064ad9523d3d228bd4686127333056 (patch) | |
tree | a6d0da2145650d99658b5c9e3c0f1b1b7d1b9b01 /OpenKeychain | |
parent | 17e45d94a827e97b1f276c483035f2903423740d (diff) | |
download | open-keychain-8f616bcf0c064ad9523d3d228bd4686127333056.tar.gz open-keychain-8f616bcf0c064ad9523d3d228bd4686127333056.tar.bz2 open-keychain-8f616bcf0c064ad9523d3d228bd4686127333056.zip |
Add null check when retrieving key ids from contacts api
Diffstat (limited to 'OpenKeychain')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java | 7 | ||||
-rw-r--r-- | OpenKeychain/src/main/res/values/strings.xml | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index 2bced3c8f..eff1f7d46 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -45,6 +45,7 @@ import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; +import android.widget.Toast; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; @@ -151,6 +152,12 @@ public class ViewKeyActivity extends ActionBarActivity implements } if (mDataUri.getHost().equals(ContactsContract.AUTHORITY)) { mDataUri = ContactHelper.dataUriFromContactUri(this, mDataUri); + if (mDataUri == null) { + Log.e(Constants.TAG, "Contact Data missing. Should be uri of key!"); + Toast.makeText(this, R.string.error_contacts_key_id_missing, Toast.LENGTH_LONG).show(); + finish(); + return; + } } Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index b04db2fa8..a44aaf2a6 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -261,6 +261,7 @@ <string name="error_searching_keys">"An error occurred when searching for keys."</string> <string name="error_too_many_responses">"Key search query returned too many candidates. Please refine your query!"</string> <string name="error_too_short_or_too_many_responses">"Either no keys or too many have been found. Please improve your query!"</string> + <string name="error_contacts_key_id_missing">"Retrieving the key ID from contacts failed!"</string> <string name="error_import_no_valid_keys">"No valid keys found in File/Clipboard!"</string> <string name="error_generic_report_bug">"A generic error occurred, please create a new bug report for OpenKeychain."</string> |