Skip to content

Commit

Permalink
add share configs to the MDM
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Nov 5, 2024
1 parent 68fca14 commit 01675b7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
39 changes: 29 additions & 10 deletions app/src/main/java/com/nextcloud/utils/mdm/MDMConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,37 @@ package com.nextcloud.utils.mdm

import android.content.Context
import com.nextcloud.utils.extensions.getRestriction
import com.owncloud.android.MainApp
import com.owncloud.android.R
import com.owncloud.android.utils.appConfig.AppConfigKeys

object MDMConfig {
fun multiAccountSupport(context: Context): Boolean {
val multiAccountSupport = context.resources.getBoolean(R.bool.multiaccount_support)
val disableMultiAccountViaMDM = context.getRestriction(
AppConfigKeys.DisableMultiAccount,
MainApp.getAppContext().resources.getBoolean(R.bool.disable_multiaccount)
)

return multiAccountSupport && !disableMultiAccountViaMDM
}
fun multiAccountSupport(context: Context): Boolean {
val multiAccountSupport = context.resources.getBoolean(R.bool.multiaccount_support)
val disableMultiAccountViaMDM = context.getRestriction(
AppConfigKeys.DisableMultiAccount,
context.resources.getBoolean(R.bool.disable_multiaccount)
)

return multiAccountSupport && !disableMultiAccountViaMDM
}

fun shareViaLink(context: Context): Boolean {
val disableShareViaMDM = context.getRestriction(
AppConfigKeys.DisableSharing,
context.resources.getBoolean(R.bool.disable_sharing)
)
val shareViaLink = context.resources.getBoolean(R.bool.share_via_link_feature)

return shareViaLink && disableShareViaMDM
}

fun shareViaUser(context: Context): Boolean {
val disableShareViaMDM = context.getRestriction(
AppConfigKeys.DisableSharing,
context.resources.getBoolean(R.bool.disable_sharing)
)
val shareViaUsers = context.resources.getBoolean(R.bool.share_with_users_feature)

return shareViaUsers && disableShareViaMDM
}
}
10 changes: 4 additions & 6 deletions app/src/main/java/com/owncloud/android/files/FileMenuFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.nextcloud.client.jobs.upload.FileUploadHelper;
import com.nextcloud.utils.EditorUtils;
import com.nextcloud.utils.extensions.ContextExtensionsKt;
import com.nextcloud.utils.mdm.MDMConfig;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
Expand All @@ -45,6 +46,7 @@

import androidx.annotation.IdRes;
import androidx.core.content.pm.ShortcutManagerCompat;
import androidx.media3.common.C;

/**
* Filters out the file actions available in a given {@link Menu} for a given {@link OCFile}
Expand Down Expand Up @@ -428,15 +430,11 @@ private boolean isShareApiEnabled(OCCapability capability) {
}

private boolean isShareWithUsersAllowed() {
return context != null &&
context.getResources().getBoolean(R.bool.share_with_users_feature) &&
!ContextExtensionsKt.getRestriction(context, AppConfigKeys.DisableSharing, context.getResources().getBoolean(R.bool.disable_sharing));
return context != null && MDMConfig.INSTANCE.shareViaUser(context);
}

private boolean isShareViaLinkAllowed() {
return context != null &&
context.getResources().getBoolean(R.bool.share_via_link_feature) &&
!ContextExtensionsKt.getRestriction(context, AppConfigKeys.DisableSharing, context.getResources().getBoolean(R.bool.disable_sharing));
return context != null && MDMConfig.INSTANCE.shareViaLink(context);
}

private boolean isSingleSelection() {
Expand Down

0 comments on commit 01675b7

Please sign in to comment.