Преглед на файлове

Add base url config, is_branded_plus, remove enterprise reporter

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk преди 1 година
родител
ревизия
b727fc364c

+ 0 - 3
app/build.gradle

@@ -274,9 +274,6 @@ dependencies {
         exclude group: 'org.ogce', module: 'xpp3' // unused in Android and brings wrong Junit version
     }
 
-    // Enterprise Feedback for AppConfig
-    implementation "androidx.enterprise:enterprise-feedback:1.1.0"
-
     // Jetpack Compose
     implementation(platform("androidx.compose:compose-bom:2024.05.00"))
     implementation("androidx.compose.ui:ui")

+ 8 - 1
app/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java

@@ -111,6 +111,7 @@ import com.owncloud.android.utils.DisplayUtils;
 import com.owncloud.android.utils.ErrorMessageAdapter;
 import com.owncloud.android.utils.PermissionUtil;
 import com.owncloud.android.utils.WebViewUtil;
+import com.owncloud.android.utils.appConfig.AppConfigManager;
 import com.owncloud.android.utils.theme.CapabilityUtils;
 import com.owncloud.android.utils.theme.ViewThemeUtils;
 
@@ -320,7 +321,13 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
 
         String webloginUrl = null;
         boolean webViewLoginMethod;
-        if (getIntent().getBooleanExtra(EXTRA_USE_PROVIDER_AS_WEBLOGIN, false)) {
+
+        AppConfigManager appConfigManager = new AppConfigManager(this);
+
+        if (getResources().getBoolean(R.bool.is_branded_plus_client)) {
+            webViewLoginMethod = true;
+            webloginUrl = appConfigManager.getBaseUrl();
+        } else if (getIntent().getBooleanExtra(EXTRA_USE_PROVIDER_AS_WEBLOGIN, false)) {
             webViewLoginMethod = true;
             webloginUrl = getString(R.string.provider_registration_server);
         } else {

+ 1 - 0
app/src/main/java/com/owncloud/android/utils/appConfig/AppConfigKeys.kt

@@ -11,6 +11,7 @@ package com.owncloud.android.utils.appConfig
  * These keys are connected to app_config.xml
  */
 enum class AppConfigKeys(val key: String) {
+    BaseUrl("base_url"),
     ProxyHost("proxy_host"),
     ProxyPort("proxy_port")
 }

+ 18 - 10
app/src/main/java/com/owncloud/android/utils/appConfig/AppConfigManager.kt

@@ -13,17 +13,23 @@ import android.content.res.Resources
 import com.owncloud.android.R
 import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
 import com.owncloud.android.lib.common.utils.Log_OC
-import com.owncloud.android.utils.enterpriseReporter.enterpriseFeedback
 
 class AppConfigManager(private val context: Context) {
 
     private val restrictionsManager =
         context.getSystemService(Context.RESTRICTIONS_SERVICE) as RestrictionsManager
 
+    private val appRestrictions = restrictionsManager.applicationRestrictions
+
     private val tag = "AppConfigManager"
 
     fun setProxyConfig() {
-        val appRestrictions = restrictionsManager.applicationRestrictions
+        if (!context.resources.getBoolean(R.bool.is_branded_client) ||
+            !context.resources.getBoolean(R.bool.is_branded_plus_client)
+        ) {
+            Log_OC.d(tag, "Proxy configuration cannot be set. Client is not branded.")
+            return
+        }
 
         val host = if (appRestrictions.containsKey(AppConfigKeys.ProxyHost.key)) {
             appRestrictions.getString(AppConfigKeys.ProxyHost.key)
@@ -38,10 +44,7 @@ class AppConfigManager(private val context: Context) {
         }
 
         if (host == null) {
-            context.enterpriseFeedback(
-                AppConfigKeys.ProxyHost,
-                R.string.app_config_proxy_config_cannot_be_found_message
-            )
+            Log_OC.d(tag, "Proxy configuration cannot be found")
             return
         }
 
@@ -51,11 +54,16 @@ class AppConfigManager(private val context: Context) {
 
             Log_OC.d(tag, "Proxy configuration successfully set")
         } catch (e: Resources.NotFoundException) {
-            context.run {
-                enterpriseFeedback(AppConfigKeys.ProxyHost, R.string.app_config_proxy_config_cannot_be_set_message)
-                enterpriseFeedback(AppConfigKeys.ProxyPort, R.string.app_config_proxy_config_cannot_be_set_message)
-            }
             Log_OC.e(tag, "Proxy config cannot able to set due to: $e")
         }
     }
+
+    fun getBaseUrl(): String? {
+        return if (appRestrictions.containsKey(AppConfigKeys.BaseUrl.key)) {
+            appRestrictions.getString(AppConfigKeys.BaseUrl.key)
+        } else {
+            Log_OC.d(tag, "BaseUrl configuration cannot be found")
+            null
+        }
+    }
 }

+ 0 - 57
app/src/main/java/com/owncloud/android/utils/enterpriseReporter/EnterpriseReporter.kt

@@ -1,57 +0,0 @@
-/*
- * Nextcloud - Android Client
- *
- * SPDX-FileCopyrightText: 2024 Your Name <your@email.com>
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
-
-package com.owncloud.android.utils.enterpriseReporter
-
-import android.content.Context
-import androidx.enterprise.feedback.KeyedAppState
-import androidx.enterprise.feedback.KeyedAppStatesCallback
-import androidx.enterprise.feedback.KeyedAppStatesCallback.STATUS_EXCEEDED_BUFFER_ERROR
-import androidx.enterprise.feedback.KeyedAppStatesCallback.STATUS_SUCCESS
-import androidx.enterprise.feedback.KeyedAppStatesCallback.STATUS_TRANSACTION_TOO_LARGE_ERROR
-import androidx.enterprise.feedback.KeyedAppStatesCallback.STATUS_UNKNOWN_ERROR
-import androidx.enterprise.feedback.KeyedAppStatesReporter
-import com.owncloud.android.lib.common.utils.Log_OC
-import com.owncloud.android.utils.appConfig.AppConfigKeys
-
-@Suppress("TooGenericExceptionCaught")
-fun Context.enterpriseFeedback(
-    appConfig: AppConfigKeys,
-    messageId: Int,
-    severity: Int = KeyedAppState.SEVERITY_ERROR
-) {
-    try {
-        val keyedAppStatesReporter = KeyedAppStatesReporter.create(this)
-        val keyedAppStateMessage = KeyedAppState.builder()
-            .setKey(appConfig.key)
-            .setSeverity(severity)
-            .setMessage(getString(messageId))
-            .build()
-        val list: MutableList<KeyedAppState> = ArrayList()
-        list.add(keyedAppStateMessage)
-        keyedAppStatesReporter.setStates(list, Callback())
-    } catch (e: Exception) {
-        Log_OC.d("EnterpriseFeedback", "Feedback cannot sent to the enterprise: $e")
-    }
-}
-
-internal class Callback : KeyedAppStatesCallback {
-    override fun onResult(state: Int, throwable: Throwable?) {
-        when (state) {
-            STATUS_SUCCESS ->
-                Log_OC.i("ErrorReporter", "KeyedAppStatesCallback status: SUCCESS ")
-            STATUS_UNKNOWN_ERROR ->
-                Log_OC.i("ErrorReporter", "KeyedAppStatesCallback status: UNKNOWN_ERROR ")
-            STATUS_TRANSACTION_TOO_LARGE_ERROR ->
-                Log_OC.i("ErrorReporter", "KeyedAppStatesCallback status: TRANSACTION_TOO_LARGE_ERROR ")
-            STATUS_EXCEEDED_BUFFER_ERROR ->
-                Log_OC.i("ErrorReporter", "KeyedAppStatesCallback status: EXCEEDED_BUFFER_ERROR ")
-            else ->
-                Log_OC.i("ErrorReporter", "KeyedAppStatesCallback status: $state ")
-        }
-    }
-}

+ 1 - 0
app/src/main/res/values/setup.xml

@@ -43,6 +43,7 @@
     <bool name="show_external_links">true</bool>
     <bool name="show_outdated_server_warning">true</bool>
     <bool name="is_branded_client">false</bool>
+    <bool name="is_branded_plus_client">false</bool>
 
     <!-- Calendar & Contacts backup -->
     <string name="contacts_backup_folder">/.Contacts-Backup</string>

+ 0 - 3
app/src/main/res/values/strings.xml

@@ -29,9 +29,6 @@
     <string name="app_config_proxy_host_title">Proxy Host Name</string>
     <string name="app_config_proxy_port_title">Proxy Port</string>
 
-    <string name="app_config_proxy_config_cannot_be_found_message">Proxy configuration cannot be found</string>
-    <string name="app_config_proxy_config_cannot_be_set_message">Proxy configuration cannot be set</string>
-
     <string name="assistant_screen_task_types_error_state_message">Unable to fetch task types, please check your internet connection.</string>
     <string name="assistant_screen_task_list_error_state_message">Unable to fetch task list, please check your internet connection.</string>
 

+ 1 - 1
app/src/main/res/xml/app_config.xml

@@ -15,7 +15,7 @@
 
     <restriction
         android:key="proxy_port"
-        android:defaultValue="0"
+        android:defaultValue="-1"
         android:restrictionType="integer"
         android:title="@string/app_config_proxy_port_title" />