diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt index 47c9af3168..5bdd961277 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt @@ -42,13 +42,10 @@ class VectorPreferences @Inject constructor(private val context: Context) { const val SETTINGS_LOGGED_IN_PREFERENCE_KEY = "SETTINGS_LOGGED_IN_PREFERENCE_KEY" const val SETTINGS_HOME_SERVER_PREFERENCE_KEY = "SETTINGS_HOME_SERVER_PREFERENCE_KEY" const val SETTINGS_IDENTITY_SERVER_PREFERENCE_KEY = "SETTINGS_IDENTITY_SERVER_PREFERENCE_KEY" - const val SETTINGS_APP_TERM_CONDITIONS_PREFERENCE_KEY = "SETTINGS_APP_TERM_CONDITIONS_PREFERENCE_KEY" - const val SETTINGS_PRIVACY_POLICY_PREFERENCE_KEY = "SETTINGS_PRIVACY_POLICY_PREFERENCE_KEY" const val SETTINGS_DISCOVERY_PREFERENCE_KEY = "SETTINGS_DISCOVERY_PREFERENCE_KEY" const val SETTINGS_THIRD_PARTY_NOTICES_PREFERENCE_KEY = "SETTINGS_THIRD_PARTY_NOTICES_PREFERENCE_KEY" const val SETTINGS_OTHER_THIRD_PARTY_NOTICES_PREFERENCE_KEY = "SETTINGS_OTHER_THIRD_PARTY_NOTICES_PREFERENCE_KEY" - const val SETTINGS_COPYRIGHT_PREFERENCE_KEY = "SETTINGS_COPYRIGHT_PREFERENCE_KEY" const val SETTINGS_CLEAR_CACHE_PREFERENCE_KEY = "SETTINGS_CLEAR_CACHE_PREFERENCE_KEY" const val SETTINGS_CLEAR_MEDIA_CACHE_PREFERENCE_KEY = "SETTINGS_CLEAR_MEDIA_CACHE_PREFERENCE_KEY" const val SETTINGS_USER_SETTINGS_PREFERENCE_KEY = "SETTINGS_USER_SETTINGS_PREFERENCE_KEY" diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt index 03b7c16274..43325b6623 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt @@ -24,7 +24,6 @@ import im.vector.app.core.utils.FirstThrottler import im.vector.app.core.utils.copyToClipboard import im.vector.app.core.utils.displayInWebView import im.vector.app.core.utils.openAppSettingsPage -import im.vector.app.core.utils.openUrlInChromeCustomTab import im.vector.app.features.version.VersionProvider import im.vector.app.openOssLicensesMenuActivity import org.matrix.android.sdk.api.Matrix @@ -77,27 +76,6 @@ class VectorSettingsHelpAboutFragment @Inject constructor( findPreference(VectorPreferences.SETTINGS_OLM_VERSION_PREFERENCE_KEY)!! .summary = session.cryptoService().getCryptoVersion(requireContext(), false) - // copyright - findPreference(VectorPreferences.SETTINGS_COPYRIGHT_PREFERENCE_KEY)!! - .onPreferenceClickListener = Preference.OnPreferenceClickListener { - openUrlInChromeCustomTab(requireContext(), null, VectorSettingsUrls.COPYRIGHT) - false - } - - // terms & conditions - findPreference(VectorPreferences.SETTINGS_APP_TERM_CONDITIONS_PREFERENCE_KEY)!! - .onPreferenceClickListener = Preference.OnPreferenceClickListener { - openUrlInChromeCustomTab(requireContext(), null, VectorSettingsUrls.TAC) - false - } - - // privacy policy - findPreference(VectorPreferences.SETTINGS_PRIVACY_POLICY_PREFERENCE_KEY)!! - .onPreferenceClickListener = Preference.OnPreferenceClickListener { - openUrlInChromeCustomTab(requireContext(), null, VectorSettingsUrls.PRIVACY_POLICY) - false - } - // third party notice findPreference(VectorPreferences.SETTINGS_THIRD_PARTY_NOTICES_PREFERENCE_KEY)!! .onPreferenceClickListener = Preference.OnPreferenceClickListener { diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsUrls.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsUrls.kt index c5088aac6d..b3925c32dc 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsUrls.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsUrls.kt @@ -17,7 +17,6 @@ package im.vector.app.features.settings object VectorSettingsUrls { - const val COPYRIGHT = "https://element.io/copyright" const val TAC = "https://element.io/terms-of-service" const val PRIVACY_POLICY = "https://element.io/privacy" diff --git a/vector/src/main/java/im/vector/app/features/settings/legals/ElementLegals.kt b/vector/src/main/java/im/vector/app/features/settings/legals/ElementLegals.kt new file mode 100644 index 0000000000..de59f36604 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/legals/ElementLegals.kt @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.settings.legals + +import im.vector.app.R +import im.vector.app.core.resources.StringProvider +import im.vector.app.features.discovery.ServerPolicy +import im.vector.app.features.settings.VectorSettingsUrls +import javax.inject.Inject + +class ElementLegals @Inject constructor( + private val stringProvider: StringProvider +) { + /** + * Use ServerPolicy model + */ + fun getData(): List { + return listOf( + ServerPolicy(stringProvider.getString(R.string.settings_copyright), VectorSettingsUrls.COPYRIGHT), + ServerPolicy(stringProvider.getString(R.string.settings_app_term_conditions), VectorSettingsUrls.TAC), + ServerPolicy(stringProvider.getString(R.string.settings_privacy_policy), VectorSettingsUrls.PRIVACY_POLICY) + ) + } +} diff --git a/vector/src/main/java/im/vector/app/features/settings/legals/LegalsController.kt b/vector/src/main/java/im/vector/app/features/settings/legals/LegalsController.kt index 9bfbea6a42..5470bb3ace 100644 --- a/vector/src/main/java/im/vector/app/features/settings/legals/LegalsController.kt +++ b/vector/src/main/java/im/vector/app/features/settings/legals/LegalsController.kt @@ -26,8 +26,8 @@ import im.vector.app.core.epoxy.errorWithRetryItem import im.vector.app.core.epoxy.loadingItem import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.resources.StringProvider -import im.vector.app.features.discovery.ServerPolicy import im.vector.app.features.discovery.ServerAndPolicies +import im.vector.app.features.discovery.ServerPolicy import im.vector.app.features.discovery.discoveryPolicyItem import im.vector.app.features.discovery.settingsInfoItem import im.vector.app.features.discovery.settingsSectionTitleItem @@ -35,6 +35,7 @@ import javax.inject.Inject class LegalsController @Inject constructor( private val stringProvider: StringProvider, + private val elementLegals: ElementLegals, private val errorFormatter: ErrorFormatter ) : TypedEpoxyController() { @@ -52,7 +53,7 @@ class LegalsController @Inject constructor( titleResId(R.string.legals_application_title) } - // TODO + buildPolicies("el", elementLegals.getData()) } private fun buildHomeserverSection(data: LegalsState) { @@ -61,7 +62,7 @@ class LegalsController @Inject constructor( titleResId(R.string.legals_home_server_title) } - buildPolicy("hs", data.homeServer) + buildPolicyAsync("hs", data.homeServer) } private fun buildIdentityServerSection(data: LegalsState) { @@ -71,11 +72,11 @@ class LegalsController @Inject constructor( titleResId(R.string.legals_identity_server_title) } - buildPolicy("is", data.identityServer) + buildPolicyAsync("is", data.identityServer) } } - private fun buildPolicy(tag: String, serverAndPolicies: Async) { + private fun buildPolicyAsync(tag: String, serverAndPolicies: Async) { val host = this when (serverAndPolicies) { @@ -91,14 +92,7 @@ class LegalsController @Inject constructor( helperText(host.stringProvider.getString(R.string.legals_no_policy_provided)) } } else { - policies.forEach { policy -> - discoveryPolicyItem { - id(policy.url) - name(policy.name) - url(policy.url) - clickListener { host.listener?.openPolicy(policy) } - } - } + buildPolicies(tag, policies) } } is Fail -> { @@ -111,6 +105,19 @@ class LegalsController @Inject constructor( } } + private fun buildPolicies(tag: String, policies: List) { + val host = this + + policies.forEach { policy -> + discoveryPolicyItem { + id(tag + policy.url) + name(policy.name) + url(policy.url) + clickListener { host.listener?.openPolicy(policy) } + } + } + } + interface Listener { fun onTapRetry() fun openPolicy(policy: ServerPolicy) diff --git a/vector/src/main/res/xml/vector_settings_help_about.xml b/vector/src/main/res/xml/vector_settings_help_about.xml index b36fba05c2..9171d1e6fe 100644 --- a/vector/src/main/res/xml/vector_settings_help_about.xml +++ b/vector/src/main/res/xml/vector_settings_help_about.xml @@ -23,18 +23,6 @@ android:title="@string/settings_olm_version" tools:summary="7.8.9" /> - - - - - -