|
|
|
@ -4,25 +4,25 @@
|
|
|
|
|
|
|
|
|
|
package org.mozilla.fenix.utils
|
|
|
|
|
|
|
|
|
|
import android.app.Activity
|
|
|
|
|
import android.content.Context
|
|
|
|
|
import android.view.View
|
|
|
|
|
import com.google.android.material.snackbar.Snackbar
|
|
|
|
|
import org.mozilla.fenix.ext.asActivity
|
|
|
|
|
import org.mozilla.fenix.ext.components
|
|
|
|
|
|
|
|
|
|
class ItsNotBrokenSnack(val context: Context) {
|
|
|
|
|
fun getSnackbar(issueNumber: String, view: View): Snackbar {
|
|
|
|
|
val snackbar = Snackbar.make(view, message.replace("%", issueNumber), Snackbar.LENGTH_SHORT)
|
|
|
|
|
snackbar.setAction("Add Tab to Issue", {
|
|
|
|
|
context.components.useCases.tabsUseCases.addTab
|
|
|
|
|
.invoke(issues + issueNumber)
|
|
|
|
|
})
|
|
|
|
|
return snackbar
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun showSnackbar(issueNumber: String, activity: Activity) {
|
|
|
|
|
val rootView = activity.window.decorView.findViewById<View>(android.R.id.content)
|
|
|
|
|
getSnackbar(issueNumber, rootView).show()
|
|
|
|
|
fun showSnackbar(issueNumber: String) {
|
|
|
|
|
val rootView = context.asActivity()?.window?.decorView?.findViewById<View>(android.R.id.content)
|
|
|
|
|
rootView?.let {
|
|
|
|
|
Snackbar.make(rootView, message.replace("%", issueNumber), Snackbar.LENGTH_SHORT).apply {
|
|
|
|
|
setAction("Add Tab to Issue") {
|
|
|
|
|
context.components.useCases.tabsUseCases.addTab
|
|
|
|
|
.invoke(issues + issueNumber)
|
|
|
|
|
}
|
|
|
|
|
show()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
|