Add generated screen to show open source licenses.
For Google Play variant only
This commit is contained in:
parent
a6b6d2ab7a
commit
c2c7f6b755
20 changed files with 442 additions and 5 deletions
|
|
@ -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 = {},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue