Skip to content

Hilt migration: Add AppInitializer#16055

Merged
ravishanker merged 6 commits intofeature/dagger-to-hiltfrom
feature/app-initializer
Mar 21, 2022
Merged

Hilt migration: Add AppInitializer#16055
ravishanker merged 6 commits intofeature/dagger-to-hiltfrom
feature/app-initializer

Conversation

@irfano
Copy link
Copy Markdown
Member

@irfano irfano commented Mar 6, 2022

This PR is preparation for Hilt migration. Hilt migration is implemented in #15653 but it's a big PR and a bit outdated. This PR is a small part of #15653.

Basically, this PR includes only adding AppInitializer without adding Hilt dependency.

Why will we need AppInitializer?
After Hilt is added, the UI test structure will change completely. Hilt will use a test application different from real application. The main reason is that Hilt will inject components at different times in test and real applications. By using AppInitializer we'll be able to control initializing by just deciding when to call AppInitilizer's init() function.

Even though we don't add Hilt in this PR, it's still better to handle initialization in a separate class rather than WordPress class.

To test:
There shouldn't be any user-facing change. It can be smoke tested.

Regression Notes

  1. Potential unintended areas of impact
    Login, logout functions, notifications. Since the logic from the core is moved to another class, most of the features can be affected.

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    I smoke tested the app, it's working as expected.

  3. What automated tests I added (or what prevented me from doing so)
    No tests are added since no new feature is added.

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

irfano added 2 commits March 6, 2022 18:33
WellSqlInitializer is added for debug and release variants. It'll be used in AppInitializer.
AppInitializer is created, and all initializing stuff is moved to AppInitializer from WordPress.
@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented Mar 6, 2022

Warnings
⚠️ PR has more than 300 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS

Copy link
Copy Markdown
Member

@hichamboushaba hichamboushaba left a comment

Choose a reason for hiding this comment

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

Sorry for the late review, the code looks good to me, nice work, and thanks @irfano for working on this 👍.

I didn't approve just to give @renanferrari and @ravishanker a chance to review too, and test the app before merging.

androidx.work.Configuration config =
(new androidx.work.Configuration.Builder()).setWorkerFactory(mWordPressWorkerFactory).build();
WorkManager.initialize(this, config);
return AppInitializer.Companion.getBitmapCache();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

np, since we have the annotation @JvmStatic on the function, we can access it without passing by the companion object.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch! 👍🏻
I'm removing @JvmStatic annotation from functions instead of removing Companion. Because we won't need @JvmStatic when we convert WordPress to Kotlin.

@irfano irfano changed the base branch from trunk to feature/dagger-to-hilt March 18, 2022 14:23
@irfano
Copy link
Copy Markdown
Member Author

irfano commented Mar 18, 2022

I changed the base from trunk to feature/dagger-to-hilt. I decided to manage the migration from feature/dagger-to-hilt branch.

Copy link
Copy Markdown
Contributor

@ravishanker ravishanker left a comment

Choose a reason for hiding this comment

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

It's a good plan to collate all this effort into a separate branch before merging it into trunk. Make sure to pull in trunk from time to time to avoid having to resolve conflicts.

LGTM 👍

@ravishanker ravishanker merged commit c19b8e1 into feature/dagger-to-hilt Mar 21, 2022
@ravishanker ravishanker deleted the feature/app-initializer branch March 21, 2022 00:44
@irfano irfano mentioned this pull request Apr 18, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants