1
0
Fork 0

For #3371: Show snackbar message when share fails with crash (#5210)

master
Mihai Adrian 2019-09-12 19:26:24 +03:00 committed by Yeon Taek Jeong
parent fcb0448fa5
commit bc16061939
2 changed files with 15 additions and 1 deletions

View File

@ -13,11 +13,14 @@ import androidx.annotation.VisibleForTesting
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.navigation.NavController import androidx.navigation.NavController
import com.google.android.material.snackbar.Snackbar
import mozilla.components.concept.sync.Device import mozilla.components.concept.sync.Device
import mozilla.components.concept.sync.TabData import mozilla.components.concept.sync.TabData
import mozilla.components.feature.sendtab.SendTabUseCases import mozilla.components.feature.sendtab.SendTabUseCases
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.getRootView
import org.mozilla.fenix.ext.metrics import org.mozilla.fenix.ext.metrics
import org.mozilla.fenix.ext.nav import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.share.listadapters.AppShareOption import org.mozilla.fenix.share.listadapters.AppShareOption
@ -71,7 +74,16 @@ class DefaultShareController(
flags = FLAG_ACTIVITY_NEW_TASK flags = FLAG_ACTIVITY_NEW_TASK
setClassName(app.packageName, app.activityName) setClassName(app.packageName, app.activityName)
} }
fragment.startActivity(intent)
try {
fragment.startActivity(intent)
} catch (e: SecurityException) {
context.getRootView()?.let {
FenixSnackbar.make(it, Snackbar.LENGTH_LONG)
.setText(context.getString(R.string.share_error_snackbar))
.show()
}
}
dismiss() dismiss()
} }

View File

@ -593,6 +593,8 @@
<string name="sync_connect_device_dialog">To send a tab, sign in to Firefox on at least one other device.</string> <string name="sync_connect_device_dialog">To send a tab, sign in to Firefox on at least one other device.</string>
<!-- Confirmation dialog button --> <!-- Confirmation dialog button -->
<string name="sync_confirmation_button">Got it</string> <string name="sync_confirmation_button">Got it</string>
<!-- Share error message -->
<string name="share_error_snackbar">Cannot share to this app</string>
<!-- Notifications --> <!-- Notifications -->
<!-- The user visible name of the "notification channel" (Android 8+ feature) for the ongoing notification shown while a browsing session is active. --> <!-- The user visible name of the "notification channel" (Android 8+ feature) for the ongoing notification shown while a browsing session is active. -->