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

Add global context.cacheDir provider. #1606

Merged
merged 2 commits into from
Oct 19, 2023

Conversation

julioromano
Copy link
Contributor

@julioromano julioromano commented Oct 19, 2023

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Dagger now provides the app's cacheDir when requesting a @CacheDirectory File type.

Motivation and context

To support some upcoming code that needs the cacheDir to be changed during tests.

@julioromano julioromano self-assigned this Oct 19, 2023
@julioromano julioromano requested a review from a team as a code owner October 19, 2023 10:00
@julioromano julioromano requested review from bmarty and removed request for a team October 19, 2023 10:00
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!


import javax.inject.Qualifier

@Qualifier annotation class CacheDir
Copy link
Member

Choose a reason for hiding this comment

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

FTR this is what we had in EA: https://github.com/vector-im/element-android/blob/develop/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/di/FileQualifiers.kt#L31

@Qualifier
@Retention(AnnotationRetention.RUNTIME)
internal annotation class CacheDirectory

Maybe use the same name CacheDirectory. Also @Retention default value is AnnotationRetention.RUNTIME , so I think it's fine not to include it, but maybe @ganfra can confirm this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just copied whatever we already had from @ApplicationContext.
As per the naming: I found it more "mnemonic" to have @CacheDir private val cacheDir: File and know that it will point to context.cacheDir.
But I'm open to better suggeestions.

Copy link
Member

Choose a reason for hiding this comment

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

OK, it's fine. The PR is approved, you can merge it :)

@github-actions
Copy link
Contributor

github-actions bot commented Oct 19, 2023

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/hV44uz

@codecov
Copy link

codecov bot commented Oct 19, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (79d2941) 58.96% compared to head (a7f8da3) 58.96%.
Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1606      +/-   ##
===========================================
- Coverage    58.96%   58.96%   -0.01%     
===========================================
  Files         1199     1199              
  Lines        30965    30966       +1     
  Branches      6343     6343              
===========================================
  Hits         18259    18259              
- Misses        9959     9960       +1     
  Partials      2747     2747              
Files Coverage Δ
...c/main/kotlin/io/element/android/x/di/AppModule.kt 0.00% <0.00%> (ø)
...d/libraries/matrix/impl/RustMatrixClientFactory.kt 0.00% <0.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@julioromano
Copy link
Contributor Author

Renamed it and added docs to all existing qualifiers.

@sonarcloud
Copy link

sonarcloud bot commented Oct 19, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@julioromano julioromano merged commit 33f5c8e into develop Oct 19, 2023
13 of 15 checks passed
@julioromano julioromano deleted the julioromano/cacheDir_provider branch October 19, 2023 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants