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(