Skip to content

Commit

Permalink
added error message
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Apr 3, 2017
1 parent 257b6b6 commit cb3dcb8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions twidere/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit cb3dcb8

Please sign in to comment.