mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
Merge pull request #6966 from Bnyro/master
feat: show toast message after version text copied
This commit is contained in:
commit
1476c12594
@ -3,12 +3,23 @@ package com.github.libretube.helpers
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.getSystemService
|
||||
import com.github.libretube.R
|
||||
|
||||
object ClipboardHelper {
|
||||
fun save(context: Context, label: String = context.getString(R.string.copied), text: String) {
|
||||
fun save(
|
||||
context: Context,
|
||||
label: String = context.getString(R.string.copied),
|
||||
text: String,
|
||||
notify: Boolean = false
|
||||
) {
|
||||
val clip = ClipData.newPlainText(label, text)
|
||||
context.getSystemService<ClipboardManager>()!!.setPrimaryClip(clip)
|
||||
|
||||
if (notify && Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
|
||||
Toast.makeText(context, context.getString(R.string.copied), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class AboutActivity : BaseActivity() {
|
||||
val versionText = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})"
|
||||
binding.versionTv.text = versionText
|
||||
binding.versionCard.setOnClickListener {
|
||||
ClipboardHelper.save(this, text = versionText)
|
||||
ClipboardHelper.save(this, text = versionText, notify = true)
|
||||
}
|
||||
|
||||
setupCard(binding.donate, DONATE_URL)
|
||||
|
@ -3,7 +3,6 @@ package com.github.libretube.ui.adapters
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.text.method.LinkMovementMethodCompat
|
||||
@ -127,9 +126,9 @@ class CommentPagingAdapter(
|
||||
root.setOnLongClickListener {
|
||||
ClipboardHelper.save(
|
||||
root.context,
|
||||
text = comment.commentText.orEmpty().parseAsHtml().toString()
|
||||
text = comment.commentText.orEmpty().parseAsHtml().toString(),
|
||||
notify = true
|
||||
)
|
||||
Toast.makeText(root.context, R.string.copied, Toast.LENGTH_SHORT).show()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package com.github.libretube.ui.dialogs
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.helpers.ClipboardHelper
|
||||
@ -22,8 +21,7 @@ class ErrorDialog : DialogFragment() {
|
||||
.setMessage(errorLog)
|
||||
.setNegativeButton(R.string.okay, null)
|
||||
.setPositiveButton(androidx.preference.R.string.copy) { _, _ ->
|
||||
ClipboardHelper.save(requireContext(), text = errorLog)
|
||||
Toast.makeText(context, R.string.copied, Toast.LENGTH_SHORT).show()
|
||||
ClipboardHelper.save(requireContext(), text = errorLog, notify = true)
|
||||
}
|
||||
.show()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user