Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #3371 Show snackbar message when share fails with crash
Browse files Browse the repository at this point in the history
Caught SecurityException and show message that sharing to that app failed
Added share_error_snackbar string
  • Loading branch information
mcarare committed Sep 12, 2019
1 parent 9e83edc commit 09cd735
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/src/main/java/org/mozilla/fenix/share/ShareController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ import androidx.annotation.VisibleForTesting
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment
import androidx.navigation.NavController
import com.google.android.material.snackbar.Snackbar
import mozilla.components.concept.sync.Device
import mozilla.components.concept.sync.TabData
import mozilla.components.feature.sendtab.SendTabUseCases
import org.mozilla.fenix.R
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.getRootView
import org.mozilla.fenix.ext.metrics
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.share.listadapters.AppShareOption
Expand Down Expand Up @@ -64,7 +67,16 @@ class DefaultShareController(
flags = FLAG_ACTIVITY_NEW_TASK
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()
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
<!-- Confirmation dialog button -->
<string name="sync_confirmation_button">Got it</string>
<!-- Share error message -->
<string name="share_error_snackbar">Cannot share to this app</string>

<!-- Notifications -->
<!-- The user visible name of the "notification channel" (Android 8+ feature) for the ongoing notification shown while a browsing session is active. -->
Expand Down

0 comments on commit 09cd735

Please sign in to comment.