diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 3f5618b208..7778a3246e 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -36,6 +36,7 @@ plugins {
id(libs.plugins.firebaseAppDistribution.get().pluginId)
alias(libs.plugins.knit)
id("kotlin-parcelize")
+ id("com.google.android.gms.oss-licenses-plugin")
// To be able to update the firebase.xml files, uncomment and build the project
// id("com.google.gms.google-services")
}
@@ -250,6 +251,7 @@ dependencies {
implementation(projects.anvilannotations)
implementation(projects.appnav)
implementation(projects.appconfig)
+ implementation(projects.libraries.uiStrings)
anvil(projects.anvilcodegen)
// Comment to not include firebase in the project
@@ -257,6 +259,8 @@ dependencies {
// Comment to not include unified push in the project
implementation(projects.libraries.pushproviders.unifiedpush)
+ "gplayImplementation"(libs.play.services.oss.licenses)
+
implementation(libs.appyx.core)
implementation(libs.androidx.splash)
implementation(libs.androidx.core)
diff --git a/app/src/fdroid/kotlin/io/element/android/x/licenses/FdroidOpenSourceLicensesProvider.kt b/app/src/fdroid/kotlin/io/element/android/x/licenses/FdroidOpenSourceLicensesProvider.kt
new file mode 100644
index 0000000000..2e926f487e
--- /dev/null
+++ b/app/src/fdroid/kotlin/io/element/android/x/licenses/FdroidOpenSourceLicensesProvider.kt
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2024 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
+ *
+ * https://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 io.element.android.x.licenses
+
+import android.app.Activity
+import com.squareup.anvil.annotations.ContributesBinding
+import io.element.android.features.preferences.api.OpenSourceLicensesProvider
+import io.element.android.libraries.di.AppScope
+import javax.inject.Inject
+
+@ContributesBinding(AppScope::class)
+class FdroidOpenSourceLicensesProvider @Inject constructor() : OpenSourceLicensesProvider {
+ override val hasOpenSourceLicenses: Boolean = false
+
+ override fun navigateToOpenSourceLicenses(activity: Activity) {
+ error("Not supported, please ensure that hasOpenSourcesLicenses is true before calling this method")
+ }
+}
diff --git a/app/src/gplay/AndroidManifest.xml b/app/src/gplay/AndroidManifest.xml
new file mode 100644
index 0000000000..234003d953
--- /dev/null
+++ b/app/src/gplay/AndroidManifest.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/gplay/kotlin/io/element/android/x/licenses/OssOpenSourcesLicensesProvider.kt b/app/src/gplay/kotlin/io/element/android/x/licenses/OssOpenSourcesLicensesProvider.kt
new file mode 100644
index 0000000000..93848c438d
--- /dev/null
+++ b/app/src/gplay/kotlin/io/element/android/x/licenses/OssOpenSourcesLicensesProvider.kt
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2024 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
+ *
+ * https://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 io.element.android.x.licenses
+
+import android.app.Activity
+import android.content.Intent
+import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
+import com.squareup.anvil.annotations.ContributesBinding
+import io.element.android.features.preferences.api.OpenSourceLicensesProvider
+import io.element.android.libraries.di.AppScope
+import io.element.android.libraries.ui.strings.CommonStrings
+import javax.inject.Inject
+
+@ContributesBinding(AppScope::class)
+class OssOpenSourcesLicensesProvider @Inject constructor() : OpenSourceLicensesProvider {
+ override val hasOpenSourceLicenses: Boolean = true
+
+ override fun navigateToOpenSourceLicenses(activity: Activity) {
+ val title = activity.getString(CommonStrings.common_open_source_licenses)
+ OssLicensesMenuActivity.setActivityTitle(title)
+ activity.startActivity(Intent(activity, OssLicensesMenuActivity::class.java))
+ }
+}
diff --git a/app/src/gplay/res/values-night-v27/themes.xml b/app/src/gplay/res/values-night-v27/themes.xml
new file mode 100644
index 0000000000..b1b00d7205
--- /dev/null
+++ b/app/src/gplay/res/values-night-v27/themes.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/src/gplay/res/values-night/themes.xml b/app/src/gplay/res/values-night/themes.xml
new file mode 100644
index 0000000000..ddba043ac2
--- /dev/null
+++ b/app/src/gplay/res/values-night/themes.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+ #FF101317
+
+ #FFEBEEF2
+
+ #ff808994
+
+
+
+
+
+
diff --git a/app/src/gplay/res/values-v27/themes.xml b/app/src/gplay/res/values-v27/themes.xml
new file mode 100644
index 0000000000..6ee828f6d2
--- /dev/null
+++ b/app/src/gplay/res/values-v27/themes.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/src/gplay/res/values/styles.xml b/app/src/gplay/res/values/styles.xml
new file mode 100644
index 0000000000..1e8c836919
--- /dev/null
+++ b/app/src/gplay/res/values/styles.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
diff --git a/app/src/gplay/res/values/themes.xml b/app/src/gplay/res/values/themes.xml
new file mode 100644
index 0000000000..ab93c3743d
--- /dev/null
+++ b/app/src/gplay/res/values/themes.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+ #FFFFFFFF
+
+ #FF1B1D22
+
+ #FF656D77
+
+
+
+
+
+
diff --git a/build.gradle.kts b/build.gradle.kts
index ff5d46ab12..8139ed6eb8 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -5,6 +5,7 @@ buildscript {
dependencies {
classpath(libs.kotlin.gradle.plugin)
classpath(libs.gms.google.services)
+ classpath(libs.oss.licenses.plugin)
}
}
diff --git a/features/preferences/api/src/main/kotlin/io/element/android/features/preferences/api/OpenSourceLicensesProvider.kt b/features/preferences/api/src/main/kotlin/io/element/android/features/preferences/api/OpenSourceLicensesProvider.kt
new file mode 100644
index 0000000000..561ad6add0
--- /dev/null
+++ b/features/preferences/api/src/main/kotlin/io/element/android/features/preferences/api/OpenSourceLicensesProvider.kt
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2024 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
+ *
+ * https://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 io.element.android.features.preferences.api
+
+import android.app.Activity
+
+interface OpenSourceLicensesProvider {
+ val hasOpenSourceLicenses: Boolean
+ fun navigateToOpenSourceLicenses(activity: Activity)
+}
diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutNode.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutNode.kt
index bc2ff7894b..691bb09ae5 100644
--- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutNode.kt
+++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutNode.kt
@@ -27,6 +27,7 @@ import dagger.assisted.Assisted
import dagger.assisted.AssistedInject
import io.element.android.anvilannotations.ContributesNode
import io.element.android.compound.theme.ElementTheme
+import io.element.android.features.preferences.api.OpenSourceLicensesProvider
import io.element.android.libraries.androidutils.browser.openUrlInChromeCustomTab
import io.element.android.libraries.di.SessionScope
@@ -35,6 +36,7 @@ class AboutNode @AssistedInject constructor(
@Assisted buildContext: BuildContext,
@Assisted plugins: List,
private val presenter: AboutPresenter,
+ private val openSourceLicensesProvider: OpenSourceLicensesProvider,
) : Node(buildContext, plugins = plugins) {
private fun onElementLegalClick(
activity: Activity,
@@ -55,6 +57,9 @@ class AboutNode @AssistedInject constructor(
onElementLegalClick = { elementLegal ->
onElementLegalClick(activity, isDark, elementLegal)
},
+ onOpenSourceLicensesClick = {
+ openSourceLicensesProvider.navigateToOpenSourceLicenses(activity)
+ },
modifier = modifier
)
}
diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutPresenter.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutPresenter.kt
index 76c3054f61..60395784d4 100644
--- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutPresenter.kt
+++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutPresenter.kt
@@ -17,14 +17,18 @@
package io.element.android.features.preferences.impl.about
import androidx.compose.runtime.Composable
+import io.element.android.features.preferences.api.OpenSourceLicensesProvider
import io.element.android.libraries.architecture.Presenter
import javax.inject.Inject
-class AboutPresenter @Inject constructor() : Presenter {
+class AboutPresenter @Inject constructor(
+ private val openSourceLicensesProvider: OpenSourceLicensesProvider,
+) : Presenter {
@Composable
override fun present(): AboutState {
return AboutState(
elementLegals = getAllLegals(),
+ hasOpenSourcesLicenses = openSourceLicensesProvider.hasOpenSourceLicenses,
)
}
}
diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutState.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutState.kt
index cd361bd4b0..a058f3c138 100644
--- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutState.kt
+++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutState.kt
@@ -16,7 +16,7 @@
package io.element.android.features.preferences.impl.about
-// Do not use default value, so no member get forgotten in the presenters.
data class AboutState(
val elementLegals: List,
+ val hasOpenSourcesLicenses: Boolean,
)
diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutStateProvider.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutStateProvider.kt
index 5775cbe48c..75dbad1fd2 100644
--- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutStateProvider.kt
+++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutStateProvider.kt
@@ -21,10 +21,14 @@ import androidx.compose.ui.tooling.preview.PreviewParameterProvider
open class AboutStateProvider : PreviewParameterProvider {
override val values: Sequence
get() = sequenceOf(
- aAboutState(),
+ anAboutState(),
+ anAboutState(hasOpenSourcesLicenses = true),
)
}
-fun aAboutState() = AboutState(
+fun anAboutState(
+ hasOpenSourcesLicenses: Boolean = false,
+) = AboutState(
elementLegals = getAllLegals(),
+ hasOpenSourcesLicenses = hasOpenSourcesLicenses,
)
diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutView.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutView.kt
index 4a55217275..413ecb6df9 100644
--- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutView.kt
+++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/about/AboutView.kt
@@ -30,6 +30,7 @@ import io.element.android.libraries.ui.strings.CommonStrings
fun AboutView(
state: AboutState,
onElementLegalClick: (ElementLegal) -> Unit,
+ onOpenSourceLicensesClick: () -> Unit,
onBackClick: () -> Unit,
modifier: Modifier = Modifier,
) {
@@ -44,6 +45,12 @@ fun AboutView(
onClick = { onElementLegalClick(elementLegal) }
)
}
+ if (state.hasOpenSourcesLicenses) {
+ PreferenceText(
+ title = stringResource(id = CommonStrings.common_open_source_licenses),
+ onClick = onOpenSourceLicensesClick,
+ )
+ }
}
}
@@ -53,6 +60,7 @@ internal fun AboutViewPreview(@PreviewParameter(AboutStateProvider::class) state
AboutView(
state = state,
onElementLegalClick = {},
+ onOpenSourceLicensesClick = {},
onBackClick = {},
)
}
diff --git a/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/about/AboutPresenterTest.kt b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/about/AboutPresenterTest.kt
index be2742c80e..64a209dd9e 100644
--- a/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/about/AboutPresenterTest.kt
+++ b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/about/AboutPresenterTest.kt
@@ -31,12 +31,25 @@ class AboutPresenterTest {
@Test
fun `present - initial state`() = runTest {
- val presenter = AboutPresenter()
+ val presenter = AboutPresenter(FakeOpenSourceLicensesProvider(hasOpenSourceLicenses = true))
moleculeFlow(RecompositionMode.Immediate) {
presenter.present()
}.test {
val initialState = awaitItem()
assertThat(initialState.elementLegals).isEqualTo(getAllLegals())
+ assertThat(initialState.hasOpenSourcesLicenses).isTrue()
+ }
+ }
+
+ @Test
+ fun `present - initial state, no open source licenses`() = runTest {
+ val presenter = AboutPresenter(FakeOpenSourceLicensesProvider(hasOpenSourceLicenses = false))
+ moleculeFlow(RecompositionMode.Immediate) {
+ presenter.present()
+ }.test {
+ val initialState = awaitItem()
+ assertThat(initialState.elementLegals).isEqualTo(getAllLegals())
+ assertThat(initialState.hasOpenSourcesLicenses).isFalse()
}
}
}
diff --git a/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/about/AboutViewTest.kt b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/about/AboutViewTest.kt
new file mode 100644
index 0000000000..851fcdd8e9
--- /dev/null
+++ b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/about/AboutViewTest.kt
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2024 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
+ *
+ * https://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 io.element.android.features.preferences.impl.about
+
+import androidx.activity.ComponentActivity
+import androidx.compose.ui.test.junit4.AndroidComposeTestRule
+import androidx.compose.ui.test.junit4.createAndroidComposeRule
+import androidx.compose.ui.test.onNodeWithText
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import io.element.android.libraries.ui.strings.CommonStrings
+import io.element.android.tests.testutils.EnsureNeverCalled
+import io.element.android.tests.testutils.EnsureNeverCalledWithParam
+import io.element.android.tests.testutils.clickOn
+import io.element.android.tests.testutils.ensureCalledOnce
+import io.element.android.tests.testutils.ensureCalledOnceWithParam
+import io.element.android.tests.testutils.pressBack
+import org.junit.Rule
+import org.junit.Test
+import org.junit.rules.TestRule
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class AboutViewTest {
+ @get:Rule val rule = createAndroidComposeRule()
+
+ @Test
+ fun `clicking on back invokes back callback`() {
+ ensureCalledOnce { callback ->
+ rule.setAboutView(
+ anAboutState(),
+ onBackClick = callback,
+ )
+ rule.pressBack()
+ }
+ }
+
+ @Test
+ fun `clicking on an item invokes the expected callback`() {
+ val state = anAboutState()
+ ensureCalledOnceWithParam(state.elementLegals.first()) { callback ->
+ rule.setAboutView(
+ state,
+ onElementLegalClick = callback,
+ )
+ rule.clickOn(state.elementLegals.first().titleRes)
+ }
+ }
+
+ @Test
+ fun `if open source licenses are not available, the entry is not displayed`() {
+ rule.setAboutView(
+ anAboutState(),
+ )
+ val text = rule.activity.getString(CommonStrings.common_open_source_licenses)
+ rule.onNodeWithText(text).assertDoesNotExist()
+ }
+
+ @Test
+ fun `if open source licenses are available, clicking on the entry invokes the expected callback`() {
+ ensureCalledOnce { callback ->
+ rule.setAboutView(
+ anAboutState(
+ hasOpenSourcesLicenses = true,
+ ),
+ onOpenSourceLicensesClick = callback,
+ )
+ rule.clickOn(CommonStrings.common_open_source_licenses)
+ }
+ }
+}
+
+private fun AndroidComposeTestRule.setAboutView(
+ state: AboutState,
+ onElementLegalClick: (ElementLegal) -> Unit = EnsureNeverCalledWithParam(),
+ onOpenSourceLicensesClick: () -> Unit = EnsureNeverCalled(),
+ onBackClick: () -> Unit = EnsureNeverCalled(),
+) {
+ setContent {
+ AboutView(
+ state = state,
+ onElementLegalClick = onElementLegalClick,
+ onOpenSourceLicensesClick = onOpenSourceLicensesClick,
+ onBackClick = onBackClick,
+ )
+ }
+}
diff --git a/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/about/FakeOpenSourceLicensesProvider.kt b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/about/FakeOpenSourceLicensesProvider.kt
new file mode 100644
index 0000000000..c7f1c25a33
--- /dev/null
+++ b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/about/FakeOpenSourceLicensesProvider.kt
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2024 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
+ *
+ * https://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 io.element.android.features.preferences.impl.about
+
+import android.app.Activity
+import io.element.android.features.preferences.api.OpenSourceLicensesProvider
+
+class FakeOpenSourceLicensesProvider(
+ override val hasOpenSourceLicenses: Boolean,
+) : OpenSourceLicensesProvider {
+ override fun navigateToOpenSourceLicenses(activity: Activity) = Unit
+}
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 30a0e381cb..ffbf984e6d 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -70,6 +70,7 @@ gms_google_services = "com.google.gms:google-services:4.4.2"
google_firebase_bom = "com.google.firebase:firebase-bom:33.1.2"
firebase_appdistribution_gradle = { module = "com.google.firebase:firebase-appdistribution-gradle", version.ref = "firebaseAppDistribution" }
autonomousapps_dependencyanalysis_plugin = { module = "com.autonomousapps:dependency-analysis-gradle-plugin", version.ref = "dependencyAnalysis" }
+oss_licenses_plugin = "com.google.android.gms:oss-licenses-plugin:0.10.6"
# AndroidX
androidx_core = { module = "androidx.core:core", version.ref = "core" }
@@ -182,6 +183,7 @@ maplibre_annotation = "org.maplibre.gl:android-plugin-annotation-v9:3.0.0"
opusencoder = "io.element.android:opusencoder:1.1.0"
kotlinpoet = "com.squareup:kotlinpoet:1.18.1"
zxing_cpp = "io.github.zxing-cpp:android:2.2.0"
+play_services_oss_licenses = "com.google.android.gms:play-services-oss-licenses:17.1.0"
# Analytics
posthog = "com.posthog:posthog-android:3.4.2"