From f6827152928f8f717b050122570be739d0d100ae Mon Sep 17 00:00:00 2001 From: alperozturk Date: Mon, 4 Nov 2024 15:47:44 +0100 Subject: [PATCH] add disableClipboard Signed-off-by: alperozturk --- .../java/com/owncloud/android/utils/ClipboardUtil.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/java/com/owncloud/android/utils/ClipboardUtil.kt b/app/src/main/java/com/owncloud/android/utils/ClipboardUtil.kt index da2f4b65d7..e9bed2ae52 100644 --- a/app/src/main/java/com/owncloud/android/utils/ClipboardUtil.kt +++ b/app/src/main/java/com/owncloud/android/utils/ClipboardUtil.kt @@ -10,10 +10,13 @@ import android.app.Activity import android.content.ClipData import android.content.ClipboardManager import android.content.Context +import android.content.RestrictionsManager import android.text.TextUtils import android.widget.Toast +import com.nextcloud.utils.extensions.getRestriction import com.owncloud.android.R 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. @@ -25,6 +28,15 @@ object ClipboardUtil { @JvmOverloads @Suppress("TooGenericExceptionCaught") 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)) { try { val clip = ClipData.newPlainText(