SS-75 Added 'Copied' toast when the user copies a URL in the Open URL dialog

This commit is contained in:
alansley 2024-08-22 09:55:14 +10:00
parent 59b4805b8b
commit 9766c3fd0b

View File

@ -22,6 +22,7 @@ import android.widget.RelativeLayout
import android.widget.ScrollView import android.widget.ScrollView
import android.widget.Space import android.widget.Space
import android.widget.TextView import android.widget.TextView
import android.widget.Toast
import androidx.annotation.AttrRes import androidx.annotation.AttrRes
import androidx.annotation.LayoutRes import androidx.annotation.LayoutRes
import androidx.annotation.StringRes import androidx.annotation.StringRes
@ -202,8 +203,6 @@ public fun Context.copyURLToClipboard(url: String) {
fun Context.showOpenUrlDialog(url: String, showCloseButton: Boolean = true): AlertDialog { fun Context.showOpenUrlDialog(url: String, showCloseButton: Boolean = true): AlertDialog {
return SessionDialogBuilder(this).apply { return SessionDialogBuilder(this).apply {
// If we're not showing a close button we can just use a simple title.. // If we're not showing a close button we can just use a simple title..
if (!showCloseButton) { if (!showCloseButton) {
title(R.string.urlOpen) title(R.string.urlOpen)
@ -311,7 +310,10 @@ fun Context.showOpenUrlDialog(url: String, showCloseButton: Boolean = true): Ale
// Note: The text and contentDescription are set on the `copyUrlButton` by the function. // Note: The text and contentDescription are set on the `copyUrlButton` by the function.
contentView.addView(scrollView) contentView.addView(scrollView)
dangerButton(R.string.open, R.string.AccessibilityId_urlOpenBrowser) { openUrl(url) } dangerButton(R.string.open, R.string.AccessibilityId_urlOpenBrowser) { openUrl(url) }
copyUrlButton { context.copyURLToClipboard(url) } copyUrlButton {
context.copyURLToClipboard(url)
Toast.makeText(context, R.string.copied, Toast.LENGTH_SHORT).show()
}
}.show() }.show()
} }