Replace OSS licenses plugin with Licensee and some manually done UI.
This should fix both configuration cache and reproducible F-droid builds. Cleanup and remove gplay/fdroid diff on open source licenses. Co-authored by @jmartinesp
This commit is contained in:
parent
941c762cff
commit
965e445d04
38 changed files with 983 additions and 309 deletions
|
|
@ -29,6 +29,7 @@ import com.bumble.appyx.navmodel.backstack.operation.push
|
|||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedInject
|
||||
import io.element.android.anvilannotations.ContributesNode
|
||||
import io.element.android.features.licenses.api.OpenSourceLicensesEntryPoint
|
||||
import io.element.android.features.lockscreen.api.LockScreenEntryPoint
|
||||
import io.element.android.features.logout.api.LogoutEntryPoint
|
||||
import io.element.android.features.preferences.api.PreferencesEntryPoint
|
||||
|
|
@ -59,6 +60,7 @@ class PreferencesFlowNode @AssistedInject constructor(
|
|||
private val lockScreenEntryPoint: LockScreenEntryPoint,
|
||||
private val notificationTroubleShootEntryPoint: NotificationTroubleShootEntryPoint,
|
||||
private val logoutEntryPoint: LogoutEntryPoint,
|
||||
private val openSourceLicensesEntryPoint: OpenSourceLicensesEntryPoint,
|
||||
) : BaseFlowNode<PreferencesFlowNode.NavTarget>(
|
||||
backstack = BackStack(
|
||||
initialElement = plugins.filterIsInstance<PreferencesEntryPoint.Params>().first().initialElement.toNavTarget(),
|
||||
|
|
@ -106,6 +108,9 @@ class PreferencesFlowNode @AssistedInject constructor(
|
|||
|
||||
@Parcelize
|
||||
data object SignOut : NavTarget
|
||||
|
||||
@Parcelize
|
||||
data object OssLicenses : NavTarget
|
||||
}
|
||||
|
||||
override fun resolve(navTarget: NavTarget, buildContext: BuildContext): Node {
|
||||
|
|
@ -170,7 +175,12 @@ class PreferencesFlowNode @AssistedInject constructor(
|
|||
createNode<ConfigureTracingNode>(buildContext)
|
||||
}
|
||||
NavTarget.About -> {
|
||||
createNode<AboutNode>(buildContext)
|
||||
val callback = object : AboutNode.Callback {
|
||||
override fun openOssLicenses() {
|
||||
backstack.push(NavTarget.OssLicenses)
|
||||
}
|
||||
}
|
||||
createNode<AboutNode>(buildContext, listOf(callback))
|
||||
}
|
||||
NavTarget.AnalyticsSettings -> {
|
||||
createNode<AnalyticsSettingsNode>(buildContext)
|
||||
|
|
@ -232,6 +242,9 @@ class PreferencesFlowNode @AssistedInject constructor(
|
|||
.callback(callBack)
|
||||
.build()
|
||||
}
|
||||
is NavTarget.OssLicenses -> {
|
||||
openSourceLicensesEntryPoint.getNode(this, buildContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ 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
|
||||
|
||||
|
|
@ -36,8 +35,11 @@ class AboutNode @AssistedInject constructor(
|
|||
@Assisted buildContext: BuildContext,
|
||||
@Assisted plugins: List<Plugin>,
|
||||
private val presenter: AboutPresenter,
|
||||
private val openSourceLicensesProvider: OpenSourceLicensesProvider,
|
||||
) : Node(buildContext, plugins = plugins) {
|
||||
interface Callback : Plugin {
|
||||
fun openOssLicenses()
|
||||
}
|
||||
|
||||
private fun onElementLegalClick(
|
||||
activity: Activity,
|
||||
darkTheme: Boolean,
|
||||
|
|
@ -58,7 +60,7 @@ class AboutNode @AssistedInject constructor(
|
|||
onElementLegalClick(activity, isDark, elementLegal)
|
||||
},
|
||||
onOpenSourceLicensesClick = {
|
||||
openSourceLicensesProvider.navigateToOpenSourceLicenses(activity)
|
||||
plugins.filterIsInstance<Callback>().forEach { it.openOssLicenses() }
|
||||
},
|
||||
modifier = modifier
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,18 +17,14 @@
|
|||
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(
|
||||
private val openSourceLicensesProvider: OpenSourceLicensesProvider,
|
||||
) : Presenter<AboutState> {
|
||||
class AboutPresenter @Inject constructor() : Presenter<AboutState> {
|
||||
@Composable
|
||||
override fun present(): AboutState {
|
||||
return AboutState(
|
||||
elementLegals = getAllLegals(),
|
||||
hasOpenSourcesLicenses = openSourceLicensesProvider.hasOpenSourceLicenses,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,5 +18,4 @@ package io.element.android.features.preferences.impl.about
|
|||
|
||||
data class AboutState(
|
||||
val elementLegals: List<ElementLegal>,
|
||||
val hasOpenSourcesLicenses: Boolean,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -22,13 +22,11 @@ open class AboutStateProvider : PreviewParameterProvider<AboutState> {
|
|||
override val values: Sequence<AboutState>
|
||||
get() = sequenceOf(
|
||||
anAboutState(),
|
||||
anAboutState(hasOpenSourcesLicenses = true),
|
||||
)
|
||||
}
|
||||
|
||||
fun anAboutState(
|
||||
hasOpenSourcesLicenses: Boolean = false,
|
||||
elementLegals: List<ElementLegal> = getAllLegals(),
|
||||
) = AboutState(
|
||||
elementLegals = getAllLegals(),
|
||||
hasOpenSourcesLicenses = hasOpenSourcesLicenses,
|
||||
elementLegals = elementLegals,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -45,12 +45,10 @@ fun AboutView(
|
|||
onClick = { onElementLegalClick(elementLegal) }
|
||||
)
|
||||
}
|
||||
if (state.hasOpenSourcesLicenses) {
|
||||
PreferenceText(
|
||||
title = stringResource(id = CommonStrings.common_open_source_licenses),
|
||||
onClick = onOpenSourceLicensesClick,
|
||||
)
|
||||
}
|
||||
PreferenceText(
|
||||
title = stringResource(id = CommonStrings.common_open_source_licenses),
|
||||
onClick = onOpenSourceLicensesClick,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,25 +31,12 @@ class AboutPresenterTest {
|
|||
|
||||
@Test
|
||||
fun `present - initial state`() = runTest {
|
||||
val presenter = AboutPresenter(FakeOpenSourceLicensesProvider(hasOpenSourceLicenses = true))
|
||||
val presenter = AboutPresenter()
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ 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
|
||||
|
|
@ -61,21 +60,10 @@ class AboutViewTest {
|
|||
}
|
||||
|
||||
@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`() {
|
||||
fun `clicking on the open source licenses invokes the expected callback`() {
|
||||
ensureCalledOnce { callback ->
|
||||
rule.setAboutView(
|
||||
anAboutState(
|
||||
hasOpenSourcesLicenses = true,
|
||||
),
|
||||
anAboutState(),
|
||||
onOpenSourceLicensesClick = callback,
|
||||
)
|
||||
rule.clickOn(CommonStrings.common_open_source_licenses)
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue