Skip to content
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

[Android] Enable to get version name from BuildConfig on AboutScreen #1113

Merged

Conversation

syarihu
Copy link
Contributor

@syarihu syarihu commented Sep 7, 2023

Issue

  • No issue

Overview (Required)

  • Enable to get the version name from BuildConfig on AboutScreen. This eliminates the need to get the version name from Context

Detail

  • Create a BuildConfigProvider interface to enable provision of BuildConfig values
  • Create an AppModule to get the app version name from BuildConfig and pass it to BuildConfigProvider
  • Added version name to AboutScreenUiState, which was unused, and made UiState available
  • Added process to ViewModel to get app version name from BuildConfigProvider and set it to UiState
  • Replaced the part of getting the app version name from Context with getting it from UiState
  • The function to get the version name from Context is no longer needed, so it was removed

Links

  • Nothing

Screenshot (Optional if screenshot test is present or unrelated to UI)

  • Ensure results remain the same
Before After

@syarihu syarihu requested a review from a team as a code owner September 7, 2023 13:35
@syarihu syarihu requested a review from mhidaka September 7, 2023 13:35
@github-actions
Copy link

github-actions bot commented Sep 7, 2023

Hi @syarihu! Codes seem to be unformatted. To resolve this issue, please run ./gradlew detekt --auto-correct and fix the results of ./gradlew lintDebug.. Thank you for your contribution.

@takahirom
Copy link
Member

We've attempted this. However, there's an issue where the tests can't recognize the Dagger Module of the app-android module. I believe the tests will fail. 😭
#782

@github-actions github-actions bot temporarily deployed to deploygate-distribution September 7, 2023 16:24 Inactive
…rovider. Then, overwrite the provider with android-app module so that both testing module and android-app module can handle BuildConfigProvider
@syarihu syarihu force-pushed the fix_method_of_getting_version_names branch from 1913a99 to 6e95950 Compare September 7, 2023 19:58
@syarihu
Copy link
Contributor Author

syarihu commented Sep 7, 2023

@takahirom
Thanks for sharing about your previous issues.
I have created a BuildConfigProviderModule that provides an empty BuildConfigProvider that can override the Provider using BindsOptionalOf in the data module.
Then, by overriding that setting in the AppModule, app-android was able to return values from BuildConfig while providing an empty BuildConfigProvider in the test.
I think this also makes all the test code PASS. In my environment, I passed all of them.
What do you think of this?

@github-actions
Copy link

github-actions bot commented Sep 8, 2023

@github-actions
Copy link

github-actions bot commented Sep 8, 2023

Test Results

211 tests   211 ✔️  7m 49s ⏱️
  11 suites      0 💤
  11 files        0

Results for commit 4db99a1.

@github-actions github-actions bot temporarily deployed to deploygate-distribution September 8, 2023 00:31 Inactive
val uiState = MutableStateFlow(
AboutScreenUiState(),
).asStateFlow()
val uiState: StateFlow<AboutScreenUiState> = buildUiState(versionNameStateFlow) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@takahirom
Copy link
Member

@matsumo0922 For your reference, the issue is fixed now! 👍

Copy link
Member

@takahirom takahirom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have never used the BindsOptionalOf! Thanks

@takahirom takahirom merged commit ba2622f into DroidKaigi:main Sep 8, 2023
8 checks passed
@syarihu
Copy link
Contributor Author

syarihu commented Sep 8, 2023

Thanks for your review and merge!

@syarihu syarihu deleted the fix_method_of_getting_version_names branch September 8, 2023 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants