-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat(settings): modernize AboutFragment using Jetpack Compose #10310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
30932e3
refactor(AboutFragment): convert about_title from MaterialTextView to…
shamim-emon 74dffac
refactor(AboutFragment): convert version related MaterialTextViews to…
shamim-emon 06e814d
refactor(AboutFragment): convert authors related MaterialTextViews to…
shamim-emon ba50fde
refactor(AboutFragment): convert licence related MaterialTextViews to…
shamim-emon bd4cb92
refactor(AboutFragment): convert aboutProjectTitle from MaterialTextV…
shamim-emon 5c88f63
refactor(AboutFragment): convert website related MaterialTextViews to…
shamim-emon d54eca5
refactor(AboutFragment): convert librariesTitle MaterialTextView and …
shamim-emon 096a030
refactor(AboutFragment): convert libraries recyclerView into ComposeView
shamim-emon 33ff186
refactor(AboutFragment): replace fragment's xml-layout with composable
shamim-emon e4f04ff
refactor(AboutFragment): removed unused fragment_about.xml
shamim-emon 4642e0b
refactor(AboutFragment): introduce UDF
shamim-emon 7b500da
test: add test coverage for AboutViewModel
shamim-emon df92e17
feat: add AboutScreen preview
shamim-emon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...common/src/main/kotlin/net/thunderbird/app/common/appVersion/DefaultAppVersionProvider.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package net.thunderbird.app.common.appVersion | ||
|
|
||
| import android.content.Context | ||
| import android.content.pm.PackageManager | ||
| import net.thunderbird.core.common.provider.AppVersionProvider | ||
| import net.thunderbird.core.logging.Logger | ||
|
|
||
| private const val TAG = "DefaultAppVersionProvider" | ||
|
|
||
| class DefaultAppVersionProvider( | ||
| private val context: Context, | ||
| private var logger: Logger, | ||
| ) : AppVersionProvider { | ||
| override fun getVersionNumber(): String { | ||
| try { | ||
| val packageInfo = context.packageManager.getPackageInfo(context.packageName, 0) | ||
| return packageInfo.versionName ?: "?" | ||
| } catch (e: PackageManager.NameNotFoundException) { | ||
| logger.error(TAG, e, { "Error getting PackageInfo" }) | ||
| return "?" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
core/common/src/commonMain/kotlin/net/thunderbird/core/common/provider/AppVersionProvider.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package net.thunderbird.core.common.provider | ||
| /** | ||
| * Provides the application version. | ||
| */ | ||
| interface AppVersionProvider { | ||
| fun getVersionNumber(): String | ||
| } |
44 changes: 44 additions & 0 deletions
44
legacy/ui/legacy/src/debug/kotlin/com/fsck/k9/ui/settings/AboutScreenPreview.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package com.fsck.k9.ui.settings | ||
|
|
||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.tooling.preview.PreviewLightDark | ||
| import app.k9mail.core.ui.compose.designsystem.PreviewWithThemesLightDark | ||
| import app.k9mail.core.ui.compose.theme2.k9mail.R | ||
| import kotlinx.collections.immutable.persistentListOf | ||
|
|
||
| @Composable | ||
| @PreviewLightDark | ||
| internal fun AboutScreenPreview() { | ||
| PreviewWithThemesLightDark { | ||
| AboutScreen( | ||
| aboutTitle = "About K-9 Mail", | ||
| projectTitle = "Open Source Project", | ||
| librariesTitle = "Libraries", | ||
| versionNumber = "17.0a1", | ||
| appLogoResId = R.drawable.core_ui_theme2_k9mail_logo, | ||
| libraries = fakeLibraryList, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| private val fakeLibraryList = persistentListOf( | ||
| Library( | ||
| "Android Jetpack libraries", | ||
| "https://developer.android.com/jetpack", | ||
| "Apache License, Version 2.0", | ||
| ), | ||
| Library( | ||
| "AndroidX Preference extended", | ||
| "https://github.com/takisoft/preferencex-android", | ||
| "Apache License, Version 2.0", | ||
| ), | ||
| Library("AppAuth for Android", "https://github.com/openid/AppAuth-Android", "Apache License, Version 2.0"), | ||
| Library("Apache HttpComponents", "https://hc.apache.org/", "Apache License, Version 2.0"), | ||
| Library("AutoValue", "https://github.com/google/auto", "Apache License, Version 2.0"), | ||
| Library("CircleImageView", "https://github.com/hdodenhof/CircleImageView", "Apache License, Version 2.0"), | ||
| Library("ckChangeLog", "https://github.com/cketti/ckChangeLog", "Apache License, Version 2.0"), | ||
| Library("Commons IO", "https://commons.apache.org/io/", "Apache License, Version 2.0"), | ||
| Library("ColorPicker", "https://github.com/gregkorossy/ColorPicker", "Apache License, Version 2.0"), | ||
| Library("DateTimePicker", "https://github.com/gregkorossy/DateTimePicker", "Apache License, Version 2.0"), | ||
| Library("Error Prone annotations", "https://github.com/google/error-prone", "Apache License, Version 2.0"), | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
legacy/ui/legacy/src/main/java/com/fsck/k9/ui/settings/AboutContract.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package com.fsck.k9.ui.settings | ||
|
|
||
| import androidx.compose.runtime.Stable | ||
| import app.k9mail.core.ui.compose.common.mvi.UnidirectionalViewModel | ||
| import kotlinx.collections.immutable.ImmutableList | ||
| import kotlinx.collections.immutable.persistentListOf | ||
|
|
||
| internal interface AboutContract { | ||
|
|
||
| interface ViewModel : | ||
| UnidirectionalViewModel<State, Event, Effect> | ||
|
|
||
| @Stable | ||
| data class State( | ||
| val version: String = "", | ||
| val libraries: ImmutableList<Library> = persistentListOf(), | ||
| ) | ||
|
|
||
| sealed interface Event { | ||
| data object OnChangeLogClick : Event | ||
| data class OnSectionContentClick(val url: String) : Event | ||
| data class OnLibraryClick(val library: Library) : Event | ||
| } | ||
|
|
||
| sealed interface Effect { | ||
| data class OpenUrl(val url: String) : Effect | ||
| data object OpenChangeLog : Effect | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.