added error message

This commit is contained in:
Mariotaku Lee 2017-04-04 00:29:03 +08:00
parent 257b6b6c88
commit cb3dcb8d6d
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
2 changed files with 12 additions and 2 deletions

View File

@ -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()

View File

@ -688,6 +688,8 @@
<string name="message_toast_notification_enabled_hint">Only available when streaming is on, and not 100% reliable.</string>
<string name="message_toast_press_again_to_close">Press again to close</string>
<string name="message_toast_profile_banner_image_updated">Profile banner image updated</string>
<string name="message_toast_qr_scan_link_not_supported">Link not supported</string>
<string name="message_toast_qr_scanner_not_supported">QR scanner not supported</string>
<string name="message_toast_retweet_cancelled">Retweet cancelled</string>
<string name="message_toast_save_media_no_storage_permission">Storage permission is needed to save media</string>
<string name="message_toast_saved_to_gallery">Saved to gallery</string>