Skip to content

Jetpack Mobile: Scan Introduce UiState#13578

Merged
malinajirka merged 18 commits intodevelopfrom
issue/13326-scan-introduce-ui-states
Dec 17, 2020
Merged

Jetpack Mobile: Scan Introduce UiState#13578
malinajirka merged 18 commits intodevelopfrom
issue/13326-scan-introduce-ui-states

Conversation

@ashiagr
Copy link
Copy Markdown
Contributor

@ashiagr ashiagr commented Dec 10, 2020

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

  • introduces recycler view + adapter to the ScanFragment
  • introduces Content UiState to the ScanViewModel
  • populates basic elements (scan state icon, title) on the screen using the state received from the scan service.

I 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.

  • Select a site with scan capability on the My Site tab
  • Notice that scan menu is displayed
  • Click scan menu item
  • Notice that basic elements (icon, title) are displayed on the Scan screen from the service.

device-2020-12-10-170621

Note

  • Used placeholder icons, texts. Ignore all stying.
  • ScanListItemState has to be fine tuned. I'll pickup and fine tune different view types (with their states) in the upcoming PRs.
  • I'll create a separate FluxC PR for storing/ retrieving threats into/ from db.

Merge Instructions

  1. Make sure Jetpack Mobile: Scan menu #13555 is merged
  2. Remove "Not ready for merge" label
  3. Merge this PR to develop

PR submission checklist:

  • I have considered adding unit tests where possible.
  • 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.

@ashiagr ashiagr added this to the 16.5 milestone Dec 10, 2020
@ashiagr ashiagr self-assigned this Dec 10, 2020
@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented Dec 10, 2020

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented Dec 10, 2020

You can test the changes on this Pull Request by downloading the APK here.

@ashiagr ashiagr mentioned this pull request Dec 10, 2020
67 tasks
val nonNullActivity = requireActivity()
(nonNullActivity.application as WordPress).component()?.inject(this)

val site = if (savedInstanceState == null) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we can update FluxC code to just use siteId. We can eliminate this passing and retrieval of the entire site model. Lmkwyt.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👋 @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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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. 🤔

Copy link
Copy Markdown
Contributor

@ParaskP7 ParaskP7 left a comment

Choose a reason for hiding this comment

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

Good job and thanks for including me in this PR @ashiagr ! 🌟

I have few comments, but very minor ones and most of them are kind of question related.

PS: The testing part will be done on a separate commit or on another PR?

private fun setupObservers() {
viewModel.uiState.observe(
viewLifecycleOwner,
Observer { uiState ->
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

@ashiagr ashiagr Dec 11, 2020

Choose a reason for hiding this comment

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

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
}

Copy link
Copy Markdown
Contributor

@ParaskP7 ParaskP7 Dec 11, 2020

Choose a reason for hiding this comment

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

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?

@ashiagr
Copy link
Copy Markdown
Contributor Author

ashiagr commented Dec 11, 2020

I have few comments, but very minor ones and most of them are kind of question related.

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.

PS: The testing part will be done on a separate commit or on another PR?

They will be covered in a separate PR once UiStates are fine-tuned.

Ready for another round 🙇‍♀️.

@ParaskP7
Copy link
Copy Markdown
Contributor

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.

Thank YOU Ashita for addressing all of them and so gracefully!

They will be covered in a separate PR once UiStates are fine-tuned.

Perfect, I was sure of that, just trying to make sure I am not missing something.

Ready for another round 🙇‍♀️.

All good from my side! I just kept one comment unresolved just to trigger a short discussion for anyone interested! 😊

@ashiagr ashiagr marked this pull request as ready for review December 15, 2020 10:44
@malinajirka malinajirka self-assigned this Dec 15, 2020
Copy link
Copy Markdown
Contributor

@malinajirka malinajirka left a comment

Choose a reason for hiding this comment

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

Thank you @ashiagr, great job! ;) I've left some comments. Let me know what you think.

@ashiagr
Copy link
Copy Markdown
Contributor Author

ashiagr commented Dec 15, 2020

Thanks for the review @malinajirka !

For this one:

⚠️ Should we replace "7 hours" with a parameter?

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.

⚠️ We usually name the resources ic_[NAME]_[WIDTH]dp.xml. I think it'd be good to update the names to keep the consistency. Thanks!

⚠️ : We might want to use a resources from colors.xml. If it doesn't exist there, we might want ask Chris if there is any similar color or if we should really introduce a new color.

@malinajirka
Copy link
Copy Markdown
Contributor

Thanks @ashiagr! All LGTM ;)

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.

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
Base automatically changed from issue/13326-scan-menu to develop December 17, 2020 08:06
@ashiagr
Copy link
Copy Markdown
Contributor Author

ashiagr commented Dec 17, 2020

One thing we might want to consider is adding checkboxes to the parent issue (#13326) so we don't forget about it.

Checkbox added under Scan - Polish the UI:

Fine-tune icons: include dp width in the icon file names, color resources from colors.xml.

Merging is blocked after base change. Re-requesting approval.

@ashiagr ashiagr requested a review from malinajirka December 17, 2020 09:41
Copy link
Copy Markdown
Contributor

@malinajirka malinajirka 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!

@malinajirka malinajirka merged commit af3f269 into develop Dec 17, 2020
@malinajirka malinajirka deleted the issue/13326-scan-introduce-ui-states branch December 17, 2020 10:27
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.

3 participants