mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 18:35:40 +03:00
Legals: Move the 3 element links to the new legal screen
This commit is contained in:
parent
e1fc7cfaba
commit
e91e26ebfb
6 changed files with 58 additions and 51 deletions
|
@ -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_LOGGED_IN_PREFERENCE_KEY = "SETTINGS_LOGGED_IN_PREFERENCE_KEY"
|
||||||
const val SETTINGS_HOME_SERVER_PREFERENCE_KEY = "SETTINGS_HOME_SERVER_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_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_DISCOVERY_PREFERENCE_KEY = "SETTINGS_DISCOVERY_PREFERENCE_KEY"
|
||||||
|
|
||||||
const val SETTINGS_THIRD_PARTY_NOTICES_PREFERENCE_KEY = "SETTINGS_THIRD_PARTY_NOTICES_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_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_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_CLEAR_MEDIA_CACHE_PREFERENCE_KEY = "SETTINGS_CLEAR_MEDIA_CACHE_PREFERENCE_KEY"
|
||||||
const val SETTINGS_USER_SETTINGS_PREFERENCE_KEY = "SETTINGS_USER_SETTINGS_PREFERENCE_KEY"
|
const val SETTINGS_USER_SETTINGS_PREFERENCE_KEY = "SETTINGS_USER_SETTINGS_PREFERENCE_KEY"
|
||||||
|
|
|
@ -24,7 +24,6 @@ import im.vector.app.core.utils.FirstThrottler
|
||||||
import im.vector.app.core.utils.copyToClipboard
|
import im.vector.app.core.utils.copyToClipboard
|
||||||
import im.vector.app.core.utils.displayInWebView
|
import im.vector.app.core.utils.displayInWebView
|
||||||
import im.vector.app.core.utils.openAppSettingsPage
|
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.features.version.VersionProvider
|
||||||
import im.vector.app.openOssLicensesMenuActivity
|
import im.vector.app.openOssLicensesMenuActivity
|
||||||
import org.matrix.android.sdk.api.Matrix
|
import org.matrix.android.sdk.api.Matrix
|
||||||
|
@ -77,27 +76,6 @@ class VectorSettingsHelpAboutFragment @Inject constructor(
|
||||||
findPreference<VectorPreference>(VectorPreferences.SETTINGS_OLM_VERSION_PREFERENCE_KEY)!!
|
findPreference<VectorPreference>(VectorPreferences.SETTINGS_OLM_VERSION_PREFERENCE_KEY)!!
|
||||||
.summary = session.cryptoService().getCryptoVersion(requireContext(), false)
|
.summary = session.cryptoService().getCryptoVersion(requireContext(), false)
|
||||||
|
|
||||||
// copyright
|
|
||||||
findPreference<VectorPreference>(VectorPreferences.SETTINGS_COPYRIGHT_PREFERENCE_KEY)!!
|
|
||||||
.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
|
||||||
openUrlInChromeCustomTab(requireContext(), null, VectorSettingsUrls.COPYRIGHT)
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
// terms & conditions
|
|
||||||
findPreference<VectorPreference>(VectorPreferences.SETTINGS_APP_TERM_CONDITIONS_PREFERENCE_KEY)!!
|
|
||||||
.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
|
||||||
openUrlInChromeCustomTab(requireContext(), null, VectorSettingsUrls.TAC)
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
// privacy policy
|
|
||||||
findPreference<VectorPreference>(VectorPreferences.SETTINGS_PRIVACY_POLICY_PREFERENCE_KEY)!!
|
|
||||||
.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
|
||||||
openUrlInChromeCustomTab(requireContext(), null, VectorSettingsUrls.PRIVACY_POLICY)
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
// third party notice
|
// third party notice
|
||||||
findPreference<VectorPreference>(VectorPreferences.SETTINGS_THIRD_PARTY_NOTICES_PREFERENCE_KEY)!!
|
findPreference<VectorPreference>(VectorPreferences.SETTINGS_THIRD_PARTY_NOTICES_PREFERENCE_KEY)!!
|
||||||
.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package im.vector.app.features.settings
|
package im.vector.app.features.settings
|
||||||
|
|
||||||
object VectorSettingsUrls {
|
object VectorSettingsUrls {
|
||||||
|
|
||||||
const val COPYRIGHT = "https://element.io/copyright"
|
const val COPYRIGHT = "https://element.io/copyright"
|
||||||
const val TAC = "https://element.io/terms-of-service"
|
const val TAC = "https://element.io/terms-of-service"
|
||||||
const val PRIVACY_POLICY = "https://element.io/privacy"
|
const val PRIVACY_POLICY = "https://element.io/privacy"
|
||||||
|
|
|
@ -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<ServerPolicy> {
|
||||||
|
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)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,8 +26,8 @@ import im.vector.app.core.epoxy.errorWithRetryItem
|
||||||
import im.vector.app.core.epoxy.loadingItem
|
import im.vector.app.core.epoxy.loadingItem
|
||||||
import im.vector.app.core.error.ErrorFormatter
|
import im.vector.app.core.error.ErrorFormatter
|
||||||
import im.vector.app.core.resources.StringProvider
|
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.ServerAndPolicies
|
||||||
|
import im.vector.app.features.discovery.ServerPolicy
|
||||||
import im.vector.app.features.discovery.discoveryPolicyItem
|
import im.vector.app.features.discovery.discoveryPolicyItem
|
||||||
import im.vector.app.features.discovery.settingsInfoItem
|
import im.vector.app.features.discovery.settingsInfoItem
|
||||||
import im.vector.app.features.discovery.settingsSectionTitleItem
|
import im.vector.app.features.discovery.settingsSectionTitleItem
|
||||||
|
@ -35,6 +35,7 @@ import javax.inject.Inject
|
||||||
|
|
||||||
class LegalsController @Inject constructor(
|
class LegalsController @Inject constructor(
|
||||||
private val stringProvider: StringProvider,
|
private val stringProvider: StringProvider,
|
||||||
|
private val elementLegals: ElementLegals,
|
||||||
private val errorFormatter: ErrorFormatter
|
private val errorFormatter: ErrorFormatter
|
||||||
) : TypedEpoxyController<LegalsState>() {
|
) : TypedEpoxyController<LegalsState>() {
|
||||||
|
|
||||||
|
@ -52,7 +53,7 @@ class LegalsController @Inject constructor(
|
||||||
titleResId(R.string.legals_application_title)
|
titleResId(R.string.legals_application_title)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
buildPolicies("el", elementLegals.getData())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildHomeserverSection(data: LegalsState) {
|
private fun buildHomeserverSection(data: LegalsState) {
|
||||||
|
@ -61,7 +62,7 @@ class LegalsController @Inject constructor(
|
||||||
titleResId(R.string.legals_home_server_title)
|
titleResId(R.string.legals_home_server_title)
|
||||||
}
|
}
|
||||||
|
|
||||||
buildPolicy("hs", data.homeServer)
|
buildPolicyAsync("hs", data.homeServer)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildIdentityServerSection(data: LegalsState) {
|
private fun buildIdentityServerSection(data: LegalsState) {
|
||||||
|
@ -71,11 +72,11 @@ class LegalsController @Inject constructor(
|
||||||
titleResId(R.string.legals_identity_server_title)
|
titleResId(R.string.legals_identity_server_title)
|
||||||
}
|
}
|
||||||
|
|
||||||
buildPolicy("is", data.identityServer)
|
buildPolicyAsync("is", data.identityServer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildPolicy(tag: String, serverAndPolicies: Async<ServerAndPolicies?>) {
|
private fun buildPolicyAsync(tag: String, serverAndPolicies: Async<ServerAndPolicies?>) {
|
||||||
val host = this
|
val host = this
|
||||||
|
|
||||||
when (serverAndPolicies) {
|
when (serverAndPolicies) {
|
||||||
|
@ -91,14 +92,7 @@ class LegalsController @Inject constructor(
|
||||||
helperText(host.stringProvider.getString(R.string.legals_no_policy_provided))
|
helperText(host.stringProvider.getString(R.string.legals_no_policy_provided))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
policies.forEach { policy ->
|
buildPolicies(tag, policies)
|
||||||
discoveryPolicyItem {
|
|
||||||
id(policy.url)
|
|
||||||
name(policy.name)
|
|
||||||
url(policy.url)
|
|
||||||
clickListener { host.listener?.openPolicy(policy) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is Fail -> {
|
is Fail -> {
|
||||||
|
@ -111,6 +105,19 @@ class LegalsController @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun buildPolicies(tag: String, policies: List<ServerPolicy>) {
|
||||||
|
val host = this
|
||||||
|
|
||||||
|
policies.forEach { policy ->
|
||||||
|
discoveryPolicyItem {
|
||||||
|
id(tag + policy.url)
|
||||||
|
name(policy.name)
|
||||||
|
url(policy.url)
|
||||||
|
clickListener { host.listener?.openPolicy(policy) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interface Listener {
|
interface Listener {
|
||||||
fun onTapRetry()
|
fun onTapRetry()
|
||||||
fun openPolicy(policy: ServerPolicy)
|
fun openPolicy(policy: ServerPolicy)
|
||||||
|
|
|
@ -23,18 +23,6 @@
|
||||||
android:title="@string/settings_olm_version"
|
android:title="@string/settings_olm_version"
|
||||||
tools:summary="7.8.9" />
|
tools:summary="7.8.9" />
|
||||||
|
|
||||||
<im.vector.app.core.preference.VectorPreference
|
|
||||||
android:key="SETTINGS_COPYRIGHT_PREFERENCE_KEY"
|
|
||||||
android:title="@string/settings_copyright" />
|
|
||||||
|
|
||||||
<im.vector.app.core.preference.VectorPreference
|
|
||||||
android:key="SETTINGS_APP_TERM_CONDITIONS_PREFERENCE_KEY"
|
|
||||||
android:title="@string/settings_app_term_conditions" />
|
|
||||||
|
|
||||||
<im.vector.app.core.preference.VectorPreference
|
|
||||||
android:key="SETTINGS_PRIVACY_POLICY_PREFERENCE_KEY"
|
|
||||||
android:title="@string/settings_privacy_policy" />
|
|
||||||
|
|
||||||
<im.vector.app.core.preference.VectorPreference
|
<im.vector.app.core.preference.VectorPreference
|
||||||
android:key="SETTINGS_THIRD_PARTY_NOTICES_PREFERENCE_KEY"
|
android:key="SETTINGS_THIRD_PARTY_NOTICES_PREFERENCE_KEY"
|
||||||
android:title="@string/settings_third_party_notices" />
|
android:title="@string/settings_third_party_notices" />
|
||||||
|
|
Loading…
Reference in a new issue