mirror of
https://github.com/nextcloud/android.git
synced 2024-11-25 22:55:46 +03:00
add disableClipboard
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
3134ab1936
commit
f682715292
1 changed files with 12 additions and 0 deletions
|
@ -10,10 +10,13 @@ import android.app.Activity
|
||||||
import android.content.ClipData
|
import android.content.ClipData
|
||||||
import android.content.ClipboardManager
|
import android.content.ClipboardManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.RestrictionsManager
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import com.nextcloud.utils.extensions.getRestriction
|
||||||
import com.owncloud.android.R
|
import com.owncloud.android.R
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC
|
import com.owncloud.android.lib.common.utils.Log_OC
|
||||||
|
import com.owncloud.android.utils.appConfig.AppConfigKeys
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper implementation to copy a string into the system clipboard.
|
* Helper implementation to copy a string into the system clipboard.
|
||||||
|
@ -25,6 +28,15 @@ object ClipboardUtil {
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
@Suppress("TooGenericExceptionCaught")
|
@Suppress("TooGenericExceptionCaught")
|
||||||
fun copyToClipboard(activity: Activity, text: String?, showToast: Boolean = true) {
|
fun copyToClipboard(activity: Activity, text: String?, showToast: Boolean = true) {
|
||||||
|
val restrictionsManager = activity.getSystemService(Context.RESTRICTIONS_SERVICE) as RestrictionsManager
|
||||||
|
val disableClipboard = restrictionsManager.getRestriction(
|
||||||
|
AppConfigKeys.DisableClipboard.key,
|
||||||
|
activity.resources.getBoolean(R.bool.disable_clipboard)
|
||||||
|
)
|
||||||
|
if (disableClipboard) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(text)) {
|
if (!TextUtils.isEmpty(text)) {
|
||||||
try {
|
try {
|
||||||
val clip = ClipData.newPlainText(
|
val clip = ClipData.newPlainText(
|
||||||
|
|
Loading…
Reference in a new issue