Merge pull request #3207 from element-hq/feature/bma/openSourceLicenses
Add generated screen to show open source licenses in Gplay variant
This commit is contained in:
commit
5e6ac6fa57
23 changed files with 450 additions and 5 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
12
app/src/gplay/AndroidManifest.xml
Normal file
12
app/src/gplay/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
|
||||
android:theme="@style/Theme.OssLicenses" />
|
||||
<activity
|
||||
android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
|
||||
android:theme="@style/Theme.OssLicenses" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
25
app/src/gplay/res/values-night-v27/themes.xml
Normal file
25
app/src/gplay/res/values-night-v27/themes.xml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<style name="Theme.OssLicenses.v27" parent="Base.Theme.OssLicenses">
|
||||
<item name="android:windowLightNavigationBar">false</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.OssLicenses" parent="Theme.OssLicenses.v27"/>
|
||||
|
||||
</resources>
|
||||
45
app/src/gplay/res/values-night/themes.xml
Normal file
45
app/src/gplay/res/values-night/themes.xml
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<!-- Use a few colors from compoundColorsLight -->
|
||||
<!-- DarkColorTokens.colorThemeBg -->
|
||||
<color name="colorThemeBg">#FF101317</color>
|
||||
<!-- DarkColorTokens.colorGray1400 -->
|
||||
<color name="textPrimary">#FFEBEEF2</color>
|
||||
<!-- DarkColorTokens.colorGray900 -->
|
||||
<color name="textSecondary">#ff808994</color>
|
||||
|
||||
<style name="Base.Theme.OssLicenses" parent="Theme.MaterialComponents">
|
||||
<!-- Background of title bar -->
|
||||
<item name="colorPrimary">@color/colorThemeBg</item>
|
||||
<!-- Background of the screen -->
|
||||
<item name="android:colorBackground">@color/colorThemeBg</item>
|
||||
<!-- Text of the licenses -->
|
||||
<item name="android:textColor">@color/textSecondary</item>
|
||||
<!-- Title, back button and license item text color -->
|
||||
<item name="android:textColorPrimary">@color/textPrimary</item>
|
||||
<!-- Background of status bar -->
|
||||
<item name="android:statusBarColor">@color/colorThemeBg</item>
|
||||
<item name="android:windowLightStatusBar">false</item>
|
||||
<!-- Background of navigation bar -->
|
||||
<item name="android:navigationBarColor">@color/colorThemeBg</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.OssLicenses" parent="Base.Theme.OssLicenses" />
|
||||
|
||||
</resources>
|
||||
25
app/src/gplay/res/values-v27/themes.xml
Normal file
25
app/src/gplay/res/values-v27/themes.xml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<style name="Theme.OssLicenses.Light.v27" parent="Base.Theme.OssLicenses.Light">
|
||||
<item name="android:windowLightNavigationBar">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.OssLicenses" parent="Theme.OssLicenses.Light.v27"/>
|
||||
|
||||
</resources>
|
||||
23
app/src/gplay/res/values/styles.xml
Normal file
23
app/src/gplay/res/values/styles.xml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<style name="NoElevationToolbar" parent="Widget.MaterialComponents.Toolbar">
|
||||
<item name="android:elevation">0dp</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
47
app/src/gplay/res/values/themes.xml
Normal file
47
app/src/gplay/res/values/themes.xml
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<!-- Use a few colors from compoundColorsLight -->
|
||||
<!-- LightColorTokens.colorThemeBg -->
|
||||
<color name="colorThemeBg">#FFFFFFFF</color>
|
||||
<!-- LightColorTokens.colorGray1400 -->
|
||||
<color name="textPrimary">#FF1B1D22</color>
|
||||
<!-- LightColorTokens.colorGray900 -->
|
||||
<color name="textSecondary">#FF656D77</color>
|
||||
|
||||
<style name="Base.Theme.OssLicenses.Light" parent="Theme.MaterialComponents.Light">
|
||||
<!-- Background of title bar -->
|
||||
<item name="colorPrimary">@color/colorThemeBg</item>
|
||||
<!-- Background of the screen -->
|
||||
<item name="android:colorBackground">@color/colorThemeBg</item>
|
||||
<!-- Text of the licenses -->
|
||||
<item name="android:textColor">@color/textSecondary</item>
|
||||
<!-- Title, back button and license item text color -->
|
||||
<item name="android:textColorPrimary">@color/textPrimary</item>
|
||||
<!-- Background of status bar -->
|
||||
<item name="android:statusBarColor">@color/colorThemeBg</item>
|
||||
<item name="android:windowLightStatusBar">true</item>
|
||||
<!-- Background of navigation bar -->
|
||||
<item name="android:navigationBarColor">@color/colorThemeBg</item>
|
||||
<!-- Try to remove Toolbar elevation, but it does not work :/ -->
|
||||
<item name="toolbarStyle">@style/NoElevationToolbar</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.OssLicenses" parent="Base.Theme.OssLicenses.Light" />
|
||||
|
||||
</resources>
|
||||
|
|
@ -5,6 +5,7 @@ buildscript {
|
|||
dependencies {
|
||||
classpath(libs.kotlin.gradle.plugin)
|
||||
classpath(libs.gms.google.services)
|
||||
classpath(libs.oss.licenses.plugin)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -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<Plugin>,
|
||||
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
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<AboutState> {
|
||||
class AboutPresenter @Inject constructor(
|
||||
private val openSourceLicensesProvider: OpenSourceLicensesProvider,
|
||||
) : Presenter<AboutState> {
|
||||
@Composable
|
||||
override fun present(): AboutState {
|
||||
return AboutState(
|
||||
elementLegals = getAllLegals(),
|
||||
hasOpenSourcesLicenses = openSourceLicensesProvider.hasOpenSourceLicenses,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<ElementLegal>,
|
||||
val hasOpenSourcesLicenses: Boolean,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -21,10 +21,14 @@ import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
|||
open class AboutStateProvider : PreviewParameterProvider<AboutState> {
|
||||
override val values: Sequence<AboutState>
|
||||
get() = sequenceOf(
|
||||
aAboutState(),
|
||||
anAboutState(),
|
||||
anAboutState(hasOpenSourcesLicenses = true),
|
||||
)
|
||||
}
|
||||
|
||||
fun aAboutState() = AboutState(
|
||||
fun anAboutState(
|
||||
hasOpenSourcesLicenses: Boolean = false,
|
||||
) = AboutState(
|
||||
elementLegals = getAllLegals(),
|
||||
hasOpenSourcesLicenses = hasOpenSourcesLicenses,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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 = {},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<ComponentActivity>()
|
||||
|
||||
@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 <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.setAboutView(
|
||||
state: AboutState,
|
||||
onElementLegalClick: (ElementLegal) -> Unit = EnsureNeverCalledWithParam(),
|
||||
onOpenSourceLicensesClick: () -> Unit = EnsureNeverCalled(),
|
||||
onBackClick: () -> Unit = EnsureNeverCalled(),
|
||||
) {
|
||||
setContent {
|
||||
AboutView(
|
||||
state = state,
|
||||
onElementLegalClick = onElementLegalClick,
|
||||
onOpenSourceLicensesClick = onOpenSourceLicensesClick,
|
||||
onBackClick = onBackClick,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -113,10 +113,12 @@ class KonsistClassNameTest {
|
|||
"Default",
|
||||
"DataStore",
|
||||
"Enterprise",
|
||||
"Fdroid",
|
||||
"FileExtensionExtractor",
|
||||
"KeyStore",
|
||||
"Matrix",
|
||||
"Noop",
|
||||
"Oss",
|
||||
"Preferences",
|
||||
"Rust",
|
||||
"SharedPreferences",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:af0cf33a8f40d66441e9f0e05120c181d2c0fe046cc12c5c1008c905e2a42a46
|
||||
size 19774
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1c8a5c260e3ed883a808e5c0c1573a322220dd723f06856bad230f55c829a435
|
||||
size 19171
|
||||
Loading…
Add table
Add a link
Reference in a new issue