Jetpack Mobile: Scan Introduce UiState#13578
Conversation
…ew items ScanListItemState will be structured similar to ActivityLogListItem
|
You can trigger optional UI/connected tests for these changes by visiting CircleCI here. |
|
You can test the changes on this Pull Request by downloading the APK here. |
| val nonNullActivity = requireActivity() | ||
| (nonNullActivity.application as WordPress).component()?.inject(this) | ||
|
|
||
| val site = if (savedInstanceState == null) { |
There was a problem hiding this comment.
I think we can update FluxC code to just use siteId. We can eliminate this passing and retrieval of the entire site model. Lmkwyt.
There was a problem hiding this comment.
👋 @ashiagr !
I think you are right and I agree. Since only siteId is the only property needed and considering that no other property from the entire site model will be used in the future, I believe the best course of action is to replace site with siteId.
IMHO, the main gain from doing something like that is to make it explicit to the reader that this is the only thing needed, so they know straight away and can score the feature down a bit. Obviously, there is a performance optimization as well, but to be honest this will not save us much.
There was a problem hiding this comment.
I wanted a second opinion if we should be doing it, thanks for sharing your thoughts 🙏. I'll not make any changes as of now, may be just add "nice to have" in the backlog.
There was a problem hiding this comment.
Yeap, definitely! But, on the other hand, it might be decided and for a good reason to keep using whole models instead, confronting my argument above, so I keep my mind open, as it indeed can help not having to make two PRs every time you want to add an extra property from the model or the whole model next time you needs more from it. 🤔
WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanStatusService.kt
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/adapters/ScanAdapter.kt
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanFragment.kt
Outdated
Show resolved
Hide resolved
| private fun setupObservers() { | ||
| viewModel.uiState.observe( | ||
| viewLifecycleOwner, | ||
| Observer { uiState -> |
There was a problem hiding this comment.
Question (❓ ): Does your IDE also suggests that this redundant SAM-constructor can be removed?
Minor (🔍 ): In the end I can make this code look like the below:
viewModel.uiState.observe(viewLifecycleOwner, { uiState ->
if (uiState is Content) refreshContentScreen(uiState)
})
PS: Usually, in Kotlin, I tend to keep simple, not complex, if statements, a one-liner. Thus, the suggestion above. If I can recall correctly this is also something that is suggested in the official Android Kotlin style guide.
There was a problem hiding this comment.
Does your IDE also suggests that this redundant SAM-constructor can be removed?
My IDE highlights it as well. It is for this reason mentioned in another PR review that I included it:
we're not removing them yet in the code for compatibility with older AS versions, right?
I tend to keep simple, not complex, if statements, a one-liner.
I just followed existing code convention in the VMs which use braces around if:
if (isStarted) {
return
}
There was a problem hiding this comment.
My IDE highlights it as well. It is for this reason mentioned in another PR review that I included it:
Interesting, thanks for sharing Ashita! I have left the below comment there and quoting it here.
Hmmm... Is this due to compatibility reason with AS version or Kotlin versions? I am thinking the later, right? And if that is the case, I suggest having every develop be forced to update the AS Kotlin plugin to at least the Gradle's Kotlin version, currently 1.4.10, as specified by our build files. This will make sure everyone is on the same boat. Wdyt?
WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanListItemState.kt
Outdated
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanStatusService.kt
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanViewModel.kt
Outdated
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanViewModel.kt
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanViewModel.kt
Outdated
Show resolved
Hide resolved
Thanks so much for a thorough review @ParaskP7! 🌟. I've addressed your comments and answered questions. Let me know if any thing is not clear.
They will be covered in a separate PR once UiStates are fine-tuned. Ready for another round 🙇♀️. |
Thank YOU Ashita for addressing all of them and so gracefully!
Perfect, I was sure of that, just trying to make sure I am not missing something.
All good from my side! I just kept one comment unresolved just to trigger a short discussion for anyone interested! 😊 |
malinajirka
left a comment
There was a problem hiding this comment.
Thank you @ashiagr, great job! ;) I've left some comments. Let me know what you think.
WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanFragment.kt
Outdated
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanFragment.kt
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanStatusService.kt
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanViewModel.kt
Outdated
Show resolved
Hide resolved
.../main/java/org/wordpress/android/ui/jetpack/scan/adapters/viewholders/ScanStateViewHolder.kt
Outdated
Show resolved
Hide resolved
|
Thanks for the review @malinajirka ! For this one: I've already covered some of the dynamic texts in the next PR #13605. I mentioned in the PR description that I've used placeholder icons and texts but thanks so much for noticing it 🌟. Regarding below warnings, Android scan screen specs are not yet ready. I can add temporary dp width for now. Ideally I'd wait for the first set of specs to be shared with us before I start making these refinements. Lmkwyt. |
|
Thanks @ashiagr! All LGTM ;)
Sounds good to me. One thing we might want to consider is adding checkboxes to the parent issue (#13326) so we don't forget about it. Feel free to merge this PR. |
…ui-states # Conflicts: # WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanStatusService.kt
Checkbox added under Scan - Polish the UI:
Merging is blocked after base change. Re-requesting approval. |
Parent #13326
This is a small preparatory PR with a scope to just link things (Service, VM, Fragment, ViewHolder) together for the Scan screen UI. It
ScanFragmentScanViewModelI plan to use (in the upcoming PRs) different view types - scan state (with icon, title, description, action buttons), progress, threat header, threat items e.t.c. inside a RecyclerView so that entire screen is scrollable .
To test
Prerequisite: Make sure both Scan feature flag and MySiteImprovements flag are set on in the App settings.
Note
ScanListItemStatehas to be fine tuned. I'll pickup and fine tune different view types (with their states) in the upcoming PRs.Merge Instructions
PR submission checklist:
RELEASE-NOTES.txtif necessary.