-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Show the site selector and set up my site screen after the application password login #21968
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
Show the site selector and set up my site screen after the application password login #21968
Conversation
…eStore.kt Co-authored-by: Copilot <[email protected]>
…-the-site-selector-and-set-up-MySite-screen-after-the-Application-Login # Conflicts: # WordPress/src/main/java/org/wordpress/android/ui/accounts/applicationpassword/ApplicationPasswordLoginActivity.kt # WordPress/src/main/java/org/wordpress/android/ui/accounts/applicationpassword/ApplicationPasswordLoginViewModel.kt
Generated by 🚫 Danger |
|
App Name | ![]() |
|
Flavor | Jalapeno | |
Build Type | Debug | |
Version | pr21968-495bc0c | |
Commit | 495bc0c | |
Direct Download | jetpack-prototype-build-pr21968-495bc0c.apk |
|
App Name | ![]() |
|
Flavor | Jalapeno | |
Build Type | Debug | |
Version | pr21968-495bc0c | |
Commit | 495bc0c | |
Direct Download | wordpress-prototype-build-pr21968-495bc0c.apk |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## trunk #21968 +/- ##
=======================================
Coverage 39.10% 39.10%
=======================================
Files 2150 2150
Lines 101026 101026
Branches 15521 15521
=======================================
Hits 39504 39504
Misses 58034 58034
Partials 3488 3488 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enables a new flow after application password login by displaying the site selector or post-signup interstitial, depending on various credential and site configuration outcomes. Key changes include:
- Updates to the ApplicationPasswordLoginViewModel to support different navigation outcomes through a NavigationActionData object.
- Refactoring of test cases in ApplicationPasswordLoginViewModelTest for improved clarity and naming.
- Adjustments to the ApplicationPasswordLoginHelper and ApplicationPasswordLoginActivity to support the new site selection and profile fetching flow.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
WordPress/src/test/java/org/wordpress/android/ui/accounts/applicationpassword/ApplicationPasswordLoginViewModelTest.kt | Updated test names and assertions to use NavigationActionData and variable renaming from uriLogin to urlLogin |
WordPress/src/main/java/org/wordpress/android/ui/accounts/login/ApplicationPasswordLoginHelper.kt | Introduced URL normalization before comparing sites |
WordPress/src/main/java/org/wordpress/android/ui/accounts/applicationpassword/ApplicationPasswordLoginViewModel.kt | Reworked setupSite flow, error handling, and added EventBus subscribers for site changes and profile fetches |
WordPress/src/main/java/org/wordpress/android/ui/accounts/applicationpassword/ApplicationPasswordLoginActivity.kt | Refactored navigation logic in openMainActivity to handle different navigation actions |
Comments suppressed due to low confidence (2)
WordPress/src/main/java/org/wordpress/android/ui/accounts/applicationpassword/ApplicationPasswordLoginViewModel.kt:138
- In the fetchSites function's catch block, the logged message 'Error storing credentials' is misleading because the function is responsible for fetching sites. Consider updating the log message to 'Error fetching sites' to clearly indicate the operation in error.
}
WordPress/src/main/java/org/wordpress/android/ui/accounts/applicationpassword/ApplicationPasswordLoginViewModel.kt:125
- In the fetchSites function, the error log 'Cannot store credentials: rawData is empty' should be rephrased to reflect the actual context. A message like 'Insufficient login data for fetching sites' would more accurately describe the error condition.
emitErrorFetching(urlLogin)
…set-up-MySite-screen-after-the-Application-Login
/** | ||
* This method is called to set up the site with the provided raw data. | ||
* | ||
* @param rawData The raw data containing the callback data from the application password login. | ||
*/ | ||
fun setupSite(rawData: String) { | ||
viewModelScope.launch { | ||
if (rawData.isEmpty()) { | ||
Log.e(TAG, "Cannot store credentials: rawData is empty") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NP: I think we want to use appLogWrapper
for logging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity: what's the purpose of using that wrapper? I don't see it taking any extra action like sending the log to crashlytics or similar, plus I see a couple of disadvantages:
- We need to use a set of predefined tags. Which is ok, but creates a big logs scope when debugging
- We can not include a stacktrace as an extra argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, I don't have any context about this class other than it seems to have been created to enable mocking for tests. Including a stack trace would be simple to add.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, related question: do we have any logger to send the logs to crashlytics or sentry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure AppLog
does this. It also enables users to view the app log if needed via AppLogViewerActivity
(Me > Help & Support > Logs).
val isError: Boolean | ||
) | ||
|
||
class AppPrefsWrapper @Inject constructor() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused by this. We already have an AppPrefsWrapper
class with shouldShowPostSignupInterstitial
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, I didn't realise there was already a wrapper. I created a new internal one to be able to inject it in tests instead of using the static access to the Android sdk
Done: 4dab50b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adalpari This tested fine and overall looks good, but I think we'll want to address the AppPrefsWrapper
issue.
…e-screen-after-the-Application-Login' of https://github.com/wordpress-mobile/WordPress-Android into feature/CMM-519-Show-the-site-selector-and-set-up-MySite-screen-after-the-Application-Login
…set-up-MySite-screen-after-the-Application-Login
…set-up-MySite-screen-after-the-Application-Login
…e-screen-after-the-Application-Login' of https://github.com/wordpress-mobile/WordPress-Android into feature/CMM-519-Show-the-site-selector-and-set-up-MySite-screen-after-the-Application-Login
…set-up-MySite-screen-after-the-Application-Login
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good!
Description
This PR is showing the site selector screen after the user log into the app by using the Application Password flow
Testing instructions
Regular login
ExperimentalFeatures.isEnabled()
as follows to force the login in a new installationScreen.Recording.2025-06-23.at.16.42.46.mov