From cb3dcb8d6dab0725d97a440a636b16e2ff1fe78d Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Tue, 4 Apr 2017 00:29:03 +0800 Subject: [PATCH] added error message --- .../twidere/activity/QuickSearchBarActivity.kt | 12 ++++++++++-- twidere/src/main/res/values/strings.xml | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/QuickSearchBarActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/QuickSearchBarActivity.kt index 75e2846c4..a64e281ed 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/QuickSearchBarActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/QuickSearchBarActivity.kt @@ -199,12 +199,20 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks< when (requestCode) { REQUEST_SCAN_QR -> { if (resultCode == Activity.RESULT_OK && data != null) { - val scanResult = data.getStringExtra(EXTRA_ZXING_SCAN_RESULT) + val scanResult = data.getStringExtra(EXTRA_ZXING_SCAN_RESULT) ?: run { + Toast.makeText(this, R.string.message_toast_qr_scanner_not_supported, + Toast.LENGTH_SHORT).show() + return + } val viewIntent = Intent(Intent.ACTION_VIEW, Uri.parse(scanResult)).apply { `package` = BuildConfig.APPLICATION_ID putExtra(EXTRA_ACCOUNT_KEY, selectedAccountDetails?.key) } - val componentName = viewIntent.resolveActivity(packageManager) ?: return + val componentName = viewIntent.resolveActivity(packageManager) ?: run { + Toast.makeText(this, R.string.message_toast_qr_scan_link_not_supported, + Toast.LENGTH_SHORT).show() + return + } viewIntent.component = componentName startActivity(viewIntent) finish() diff --git a/twidere/src/main/res/values/strings.xml b/twidere/src/main/res/values/strings.xml index 96b2325b7..620fc6be0 100644 --- a/twidere/src/main/res/values/strings.xml +++ b/twidere/src/main/res/values/strings.xml @@ -688,6 +688,8 @@ Only available when streaming is on, and not 100% reliable. Press again to close Profile banner image updated + Link not supported + QR scanner not supported Retweet cancelled Storage permission is needed to save media Saved to gallery