diff options
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt index 03dbb9fb..f3c81578 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt @@ -32,7 +32,7 @@ import com.pitchedapps.frost.prefs.Prefs /** * Created by Allan Wang on 2017-07-07. */ -fun Context.showWebContextMenu(wc: WebContext, fbCookie: FbCookie) { +fun Context.showWebContextMenu(wc: WebContext, fbCookie: FbCookie, prefs: Prefs) { if (wc.isEmpty) return var title = wc.url ?: string(R.string.menu) title = @@ -45,7 +45,7 @@ fun Context.showWebContextMenu(wc: WebContext, fbCookie: FbCookie) { materialDialog { title(text = title) listItems(items = menuItems.map { string(it.textId) }) { _, position, _ -> - menuItems[position].onClick(this@showWebContextMenu, wc, fbCookie) + menuItems[position].onClick(this@showWebContextMenu, wc, fbCookie, prefs) } onDismiss { // showing the dialog interrupts the touch down event, so we must ensure that the viewpager's swipe is enabled @@ -67,15 +67,16 @@ class WebContext(val unformattedUrl: String?, val text: String?) { enum class WebContextType( val textId: Int, val constraint: (wc: WebContext) -> Boolean, - val onClick: (c: Context, wc: WebContext, fc: FbCookie) -> Unit + val onClick: (c: Context, wc: WebContext, fc: FbCookie, prefs: Prefs) -> Unit ) { OPEN_LINK( R.string.open_link, { it.hasUrl }, - { c, wc, fc -> c.launchWebOverlay(wc.url!!, fc, Prefs.get()) }), - COPY_LINK(R.string.copy_link, { it.hasUrl }, { c, wc, _ -> c.copyToClipboard(wc.url) }), - COPY_TEXT(R.string.copy_text, { it.hasText }, { c, wc, _ -> c.copyToClipboard(wc.text) }), - SHARE_LINK(R.string.share_link, { it.hasUrl }, { c, wc, _ -> c.shareText(wc.url) }) + { c, wc, fc, prefs -> c.launchWebOverlay(wc.url!!, fc, prefs) } + ), + COPY_LINK(R.string.copy_link, { it.hasUrl }, { c, wc, _, _ -> c.copyToClipboard(wc.url) }), + COPY_TEXT(R.string.copy_text, { it.hasText }, { c, wc, _, _ -> c.copyToClipboard(wc.text) }), + SHARE_LINK(R.string.share_link, { it.hasUrl }, { c, wc, _, _ -> c.shareText(wc.url) }) ; companion object { |