mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Add generated screen to show open source licenses.
For Google Play variant only
This commit is contained in:
committed by
Benoit Marty
parent
f5e866e18c
commit
766ae389ce
+5
@@ -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
|
||||
)
|
||||
}
|
||||
|
||||
+5
-1
@@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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,
|
||||
)
|
||||
|
||||
+6
-2
@@ -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,
|
||||
)
|
||||
|
||||
+8
@@ -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 = {},
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user