From 90902f51940c82ba003f648d5e75a77651f90612 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Tue, 5 Nov 2024 12:19:17 +0100 Subject: [PATCH] add showIntro configs to the MDM Signed-off-by: alperozturk --- .../nextcloud/client/onboarding/FirstRunActivity.kt | 12 ++++-------- .../client/onboarding/OnboardingServiceImpl.kt | 9 +++------ .../main/java/com/nextcloud/utils/mdm/MDMConfig.kt | 8 ++++++++ .../owncloud/android/ui/activity/DrawerActivity.java | 8 +------- .../owncloud/android/ui/adapter/UserListAdapter.java | 9 ++------- 5 files changed, 18 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/onboarding/FirstRunActivity.kt b/app/src/main/java/com/nextcloud/client/onboarding/FirstRunActivity.kt index e811b81664..5f9e872464 100644 --- a/app/src/main/java/com/nextcloud/client/onboarding/FirstRunActivity.kt +++ b/app/src/main/java/com/nextcloud/client/onboarding/FirstRunActivity.kt @@ -24,7 +24,7 @@ import com.nextcloud.client.account.UserAccountManager import com.nextcloud.client.appinfo.AppInfo import com.nextcloud.client.di.Injectable import com.nextcloud.client.preferences.AppPreferences -import com.nextcloud.utils.extensions.getRestriction +import com.nextcloud.utils.mdm.MDMConfig import com.owncloud.android.BuildConfig import com.owncloud.android.R import com.owncloud.android.authentication.AuthenticatorActivity @@ -34,7 +34,6 @@ import com.owncloud.android.ui.activity.BaseActivity import com.owncloud.android.ui.activity.FileDisplayActivity import com.owncloud.android.ui.adapter.FeaturesViewAdapter import com.owncloud.android.utils.DisplayUtils -import com.owncloud.android.utils.appConfig.AppConfigKeys import com.owncloud.android.utils.theme.ViewThemeUtils import javax.inject.Inject @@ -78,14 +77,12 @@ class FirstRunActivity : BaseActivity(), Injectable { binding = FirstRunActivityBinding.inflate(layoutInflater) setContentView(binding.root) - val disableIntroViaMDM = getRestriction(AppConfigKeys.DisableIntro, resources.getBoolean(R.bool.disable_intro)) - val isProviderOrOwnInstallationVisible = resources.getBoolean(R.bool.show_provider_or_own_installation) setSlideshowSize(resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) registerActivityResult() setupLoginButton() - setupSignupButton(isProviderOrOwnInstallationVisible && !disableIntroViaMDM) - setupHostOwnServerTextView(isProviderOrOwnInstallationVisible && !disableIntroViaMDM) + setupSignupButton(MDMConfig.showIntro(this)) + setupHostOwnServerTextView(MDMConfig.showIntro(this)) deleteAccountAtFirstLaunch() setupFeaturesViewAdapter() handleOnBackPressed() @@ -210,10 +207,9 @@ class FirstRunActivity : BaseActivity(), Injectable { } private fun setSlideshowSize(isLandscape: Boolean) { - val isProviderOrOwnInstallationVisible = resources.getBoolean(R.bool.show_provider_or_own_installation) binding.buttonLayout.orientation = if (isLandscape) LinearLayout.HORIZONTAL else LinearLayout.VERTICAL - val layoutParams: LinearLayout.LayoutParams = if (isProviderOrOwnInstallationVisible) { + val layoutParams: LinearLayout.LayoutParams = if (MDMConfig.showIntro(this)) { LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT diff --git a/app/src/main/java/com/nextcloud/client/onboarding/OnboardingServiceImpl.kt b/app/src/main/java/com/nextcloud/client/onboarding/OnboardingServiceImpl.kt index b928c7b172..e121d32d02 100644 --- a/app/src/main/java/com/nextcloud/client/onboarding/OnboardingServiceImpl.kt +++ b/app/src/main/java/com/nextcloud/client/onboarding/OnboardingServiceImpl.kt @@ -13,13 +13,12 @@ import android.content.Intent import android.content.res.Resources import com.nextcloud.client.account.CurrentAccountProvider import com.nextcloud.client.preferences.AppPreferences -import com.nextcloud.utils.extensions.getRestriction +import com.nextcloud.utils.mdm.MDMConfig import com.owncloud.android.BuildConfig import com.owncloud.android.R import com.owncloud.android.authentication.AuthenticatorActivity import com.owncloud.android.features.FeatureItem import com.owncloud.android.ui.activity.PassCodeActivity -import com.owncloud.android.utils.appConfig.AppConfigKeys internal class OnboardingServiceImpl( private val resources: Resources, @@ -63,10 +62,8 @@ internal class OnboardingServiceImpl( } override fun launchFirstRunIfNeeded(activity: Activity): Boolean { - val disableIntroViaMDM = activity.getRestriction(AppConfigKeys.DisableIntro, resources.getBoolean(R.bool.disable_intro)) - val isProviderOrOwnInstallationVisible = resources.getBoolean(R.bool.show_provider_or_own_installation) - val canLaunch = isProviderOrOwnInstallationVisible && isFirstRun && activity is AuthenticatorActivity - if (canLaunch && !disableIntroViaMDM) { + val canLaunch = MDMConfig.showIntro(activity) && isFirstRun && activity is AuthenticatorActivity + if (canLaunch) { val intent = Intent(activity, FirstRunActivity::class.java) activity.startActivityForResult(intent, AuthenticatorActivity.REQUEST_CODE_FIRST_RUN) } diff --git a/app/src/main/java/com/nextcloud/utils/mdm/MDMConfig.kt b/app/src/main/java/com/nextcloud/utils/mdm/MDMConfig.kt index 872980d39a..b315201b4a 100644 --- a/app/src/main/java/com/nextcloud/utils/mdm/MDMConfig.kt +++ b/app/src/main/java/com/nextcloud/utils/mdm/MDMConfig.kt @@ -65,4 +65,12 @@ object MDMConfig { return showExternalLinks && !disableMoreExternalSiteViaMDM } + + fun showIntro(context: Context): Boolean { + val disableIntroViaMDM = + context.getRestriction(AppConfigKeys.DisableIntro, context.resources.getBoolean(R.bool.disable_intro)) + val isProviderOrOwnInstallationVisible = context.resources.getBoolean(R.bool.show_provider_or_own_installation) + + return isProviderOrOwnInstallationVisible && !disableIntroViaMDM + } } diff --git a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java index 410b39bee4..98658dbf06 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java @@ -59,7 +59,6 @@ import com.nextcloud.common.NextcloudClient; import com.nextcloud.ui.ChooseAccountDialogFragment; import com.nextcloud.ui.composeActivity.ComposeActivity; import com.nextcloud.ui.composeActivity.ComposeDestination; -import com.nextcloud.utils.extensions.ContextExtensionsKt; import com.nextcloud.utils.mdm.MDMConfig; import com.owncloud.android.MainApp; import com.owncloud.android.R; @@ -97,7 +96,6 @@ import com.owncloud.android.utils.BitmapUtils; import com.owncloud.android.utils.DisplayUtils; import com.owncloud.android.utils.DrawerMenuUtil; import com.owncloud.android.utils.FilesSyncHelper; -import com.owncloud.android.utils.appConfig.AppConfigKeys; import com.owncloud.android.utils.svg.MenuSimpleTarget; import com.owncloud.android.utils.svg.SVGorImage; import com.owncloud.android.utils.svg.SvgOrImageBitmapTranscoder; @@ -605,11 +603,7 @@ public abstract class DrawerActivity extends ToolbarActivity } public void openAddAccount() { - boolean disableIntroViaMDM = ContextExtensionsKt.getRestriction(this, AppConfigKeys.DisableIntro, getResources().getBoolean(R.bool.disable_intro)); - boolean isProviderOrOwnInstallationVisible = getResources() - .getBoolean(R.bool.show_provider_or_own_installation); - - if (isProviderOrOwnInstallationVisible && !disableIntroViaMDM) { + if (MDMConfig.INSTANCE.showIntro(this)) { Intent firstRunIntent = new Intent(getApplicationContext(), FirstRunActivity.class); firstRunIntent.putExtra(FirstRunActivity.EXTRA_ALLOW_CLOSE, true); startActivity(firstRunIntent); diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/UserListAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/UserListAdapter.java index 5603afb6eb..8353353bd2 100644 --- a/app/src/main/java/com/owncloud/android/ui/adapter/UserListAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/UserListAdapter.java @@ -22,14 +22,13 @@ import android.widget.ImageView; import com.nextcloud.client.account.User; import com.nextcloud.client.account.UserAccountManager; -import com.nextcloud.utils.extensions.ContextExtensionsKt; +import com.nextcloud.utils.mdm.MDMConfig; import com.owncloud.android.R; import com.owncloud.android.databinding.AccountActionBinding; import com.owncloud.android.databinding.AccountItemBinding; import com.owncloud.android.lib.common.OwnCloudAccount; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.utils.DisplayUtils; -import com.owncloud.android.utils.appConfig.AppConfigKeys; import com.owncloud.android.utils.theme.ViewThemeUtils; import java.util.ArrayList; @@ -320,11 +319,7 @@ public class UserListAdapter extends RecyclerView.Adapter accountListAdapterListener.showFirstRunActivity()); } else { itemView.setOnClickListener(v -> accountListAdapterListener.startAccountCreation());