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

Fix part of #632: Move PromotedStoryListAdapter to BindableAdater #4874

Merged

Conversation

masclot
Copy link
Collaborator

@masclot masclot commented Feb 8, 2023

Explanation

Fixes part of #632: Reimplementation of PromotedStoryListAdapter as BindableAdater
Espresso tests are failing, but they were already failing. The errors with the new adapter are the same. The same tests pass when using gradle.

There was an error in MarginBindingAdapter which I'm also fixing in this cl: MarginBindingAdapter was replacing start/end margin changes for left/right margin changes. However, this replacement relied on getting the layout direction from the View being changed. When the direction is inherited and the View is not attached to a parent (recursively until top level View), the direction defaults to LTR, no matter the Locale/language. This situation happens for example in item Views within RecyclerView. The change does not replace start/end any more, but sets them through MarginLayoutParamsCompat so that it is compatible with api < 17.

Essential Checklist

  • The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • Any changes to scripts/assets files have their rationale included in the PR explanation.
  • The PR follows the style guide.
  • The PR does not contain any unnecessary code changes from Android Studio (reference).
  • The PR is made from a branch that's not called "develop" and is up-to-date with "develop".
  • The PR is assigned to the appropriate reviewers (reference).
Current new
bindable_adapter_current bindable_adapter_new

Unit tests:
recently_played_span_test

Espresso Tests. The run for the new version has an extra error, but it is due to timings. In other runs it passes.
recently_played_espresso_tests_current_vs_new

@rt4914 PTAL

@masclot
Copy link
Collaborator Author

masclot commented Feb 8, 2023

@rt4914 PTAL

Copy link
Sponsor Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @masclot! Took a first pass--PTAL. Also, I think there are CI checks failing that should be fixed.

@BenHenning BenHenning assigned masclot and unassigned BenHenning Feb 8, 2023
@BenHenning
Copy link
Sponsor Member

Also, please make sure to include the 'Fixes part of #632' within the PR description.

…a factory.

Turn some dependencies from AppCompatActivity to Context, so that unit tests do not require bringing up an activity/fragment.
Add Robolectric unit tests for RecentlyPlayedViewModel.kt
@masclot
Copy link
Collaborator Author

masclot commented Feb 10, 2023

I added unit tests
@BenHenning PTAL

@oppiabot oppiabot bot assigned BenHenning and unassigned masclot Feb 10, 2023
@seanlip
Copy link
Member

seanlip commented Mar 29, 2023

Ah, for the first one, scroll up the page further and click "Load more". Here's the start of that thread: #4874 (comment) -- you can reply there.

If the comment box says Pending, that means that you have draft comments that haven't been submitted. Go to the "Files Changed" tab, and submit them using the green button in the top right.

@masclot
Copy link
Collaborator Author

masclot commented Mar 29, 2023

Thanks! I thought that big green button was for reviewers, not for replies to review-comments. I also don't understand why some of my comments went through without clicking that button.
Anyway, there are no more pending labels and hopefully no more unreplied comments.

@seanlip
Copy link
Member

seanlip commented Mar 29, 2023

Ah ok, great, thanks @masclot! Not sure about why some of the comments went through, that seems odd.

Also just wondering, do you have any improvements to suggest to the docs here that would have made the process clearer? If so, would you be up for making a PR to update them? (Now that the wiki docs are stored in the main repo, that should hopefully be straightforward.)

Thanks!

@adhiamboperes
Copy link
Collaborator

adhiamboperes commented Mar 29, 2023

Ah ok, great, thanks @masclot! Not sure about why some of the comments went through, that seems odd.

Also just wondering, do you have any improvements to suggest to the docs here that would have made the process clearer? If so, would you be up for making a PR to update them? (Now that the wiki docs are stored in the main repo, that should hopefully be straightforward.)

Thanks!

cc @seanlip. @masclot, I believe what happened here was: in some cases you replied from the conversation view, which adds a single comment, and in a later instance, you chose to
start a review, from the Files changed tab.

This
Screenshot 2023-03-29 at 14 03 47

vs

Screenshot 2023-03-29 at 14 03 08

Copy link
Sponsor Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @masclot! This LGTM!

@BenHenning
Copy link
Sponsor Member

Syncing with develop & enabling auto-merge.

@BenHenning BenHenning enabled auto-merge (squash) March 30, 2023 04:06
@BenHenning BenHenning removed the request for review from rt4914 March 30, 2023 04:07
@oppiabot
Copy link

oppiabot bot commented Mar 30, 2023

Unassigning @BenHenning since they have already approved the PR.

@oppiabot oppiabot bot added the PR: LGTM label Mar 30, 2023
@oppiabot
Copy link

oppiabot bot commented Mar 30, 2023

Hi @masclot, this PR is ready to be merged. Please address any remaining comments prior to merging, and feel free to ask someone to merge your PR once the CI checks pass and you're happy with it. Thanks!

@BenHenning BenHenning merged commit 7fd290d into oppia:develop Mar 30, 2023
@masclot
Copy link
Collaborator Author

masclot commented Mar 31, 2023

cc @seanlip. @masclot, I believe what happened here was: in some cases you replied from the conversation view, which adds a single comment, and in a later instance, you chose to
start a review, from the Files changed tab.

Thant makes sense, thanks

@masclot
Copy link
Collaborator Author

masclot commented Mar 31, 2023

Also just wondering, do you have any improvements to suggest to the docs here that would have made the process clearer? If so, would you be up for making a PR to update them? (Now that the wiki docs are stored in the main repo, that should hopefully be straightforward.)

I'll try to compile a list of things I had trouble with. The documentation as a whole is big; I'm sure it has answers to at least some of my troubles, but I just could not remember the solution when I faced them.

@seanlip
Copy link
Member

seanlip commented Mar 31, 2023

@masclot Sounds good, thanks a lot -- appreciate it!

/cc @MohitGupta121 too, who is doing some work to update the wiki to make it easier to follow.

@MohitGupta121
Copy link
Member

Thanks @seanlip, Yes @masclot glad to help and collaborate with you in wiki contribution.

Uticodes pushed a commit to Uticodes/oppia-android that referenced this pull request Apr 4, 2023
oppia#4874)

<!-- READ ME FIRST: Please fill in the explanation section below and
check off every point from the Essential Checklist! -->
## Explanation
<!--
- Explain what your PR does. If this PR fixes an existing bug, please
include
- "Fixes #bugnum:" in the explanation so that GitHub can auto-close the
issue
  - when this PR is merged.
  -->

Fixes part of oppia#632: Reimplementation of PromotedStoryListAdapter as
BindableAdater
Espresso tests are failing, but they were already failing. The errors
with the new adapter are the same. The same tests pass when using
gradle.

There was an error in MarginBindingAdapter which I'm also fixing in this
cl: MarginBindingAdapter was replacing start/end margin changes for
left/right margin changes. However, this replacement relied on getting
the layout direction from the View being changed. When the direction is
inherited and the View is not attached to a parent (recursively until
top level View), the direction defaults to LTR, no matter the
Locale/language. This situation happens for example in item Views within
RecyclerView. The change does not replace start/end any more, but sets
them through MarginLayoutParamsCompat so that it is compatible with api
< 17.

## Essential Checklist
<!-- Please tick the relevant boxes by putting an "x" in them. -->
- [x] The PR title and explanation each start with "Fix #bugnum: " (If
this PR fixes part of an issue, prefix the title with "Fix part of
#bugnum: ...".)
- [X] Any changes to
[scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets)
files have their rationale included in the PR explanation.
- [X] The PR follows the [style
guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide).
- [X] The PR does not contain any unnecessary code changes from Android
Studio
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)).
- [X] The PR is made from a branch that's **not** called "develop" and
is up-to-date with "develop".
- [x] The PR is **assigned** to the appropriate reviewers
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)).

| Current | new |
|-|-|
|
![bindable_adapter_current](https://user-images.githubusercontent.com/103062089/217546850-30d59ac3-d996-4856-9a55-43a61e533eb2.png)
|
![bindable_adapter_new](https://user-images.githubusercontent.com/103062089/217546857-224a287d-b55a-4af9-8b05-e4855d78bd44.png)
|

Unit tests:

![recently_played_span_test](https://user-images.githubusercontent.com/103062089/217547368-f86fa7c4-c915-4257-948c-90a8e73c3ab6.png)

Espresso Tests. The run for the new version has an extra error, but it
is due to timings. In other runs it passes.

![recently_played_espresso_tests_current_vs_new](https://user-images.githubusercontent.com/103062089/217548889-21e0599e-e8b0-463d-a3f6-eeaaa93e674a.png)

@rt4914 PTAL

---------

Co-authored-by: Ben Henning <ben@oppia.org>
adhiamboperes added a commit that referenced this pull request Apr 18, 2023
BenHenning pushed a commit that referenced this pull request Apr 21, 2023
…dableAdapter" (#4951)

This reverts commit `7fd290d68f0440d926f2d443dbd7bfb28ab20547`, fixing
part of #2116.

While testing #2116, we found that the UI for default profile view does
not display correctly, and traced the change to #4874 in [this
discusson](#2116 (comment)).

#4874 introduces a change to `MarginBindingAdapters` which utilizes
`MarginLayoutParamsCompat` to compute the margins of a layout before
drawing it. I suspect that this works for the `Promoted Story` and
`Topic Summary` because we compute the start and end margins of each
item relative to grid columns laid out on the HomeActivity, but no such
implementation exists for the Profile Chooser view. We need to do some
further investigation into this, hence the decision to revert.

We will need to test all the associated screens to make sure they still
look as expected:

![Screenshot 2023-04-19 at 18 01
28](https://user-images.githubusercontent.com/59600948/233117952-8c981fa2-2d0c-45cc-80ff-651862c1fd96.png)


## Essential Checklist
<!-- Please tick the relevant boxes by putting an "x" in them. -->
- [x] The PR title and explanation each start with "Fix #bugnum: " (If
this PR fixes part of an issue, prefix the title with "Fix part of
#bugnum: ...".)
- [x] Any changes to
[scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets)
files have their rationale included in the PR explanation.
- [x] The PR follows the [style
guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide).
- [x] The PR does not contain any unnecessary code changes from Android
Studio
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)).
- [x] The PR is made from a branch that's **not** called "develop" and
is up-to-date with "develop".
- [x] The PR is **assigned** to the appropriate reviewers
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)).

## For UI-specific PRs only
This was mainly a re-implimentation per #632, and the UI did not change.
Please refer to #4874 for screenshots.

The Affected screen displays okay with this revert:


![Screenshot_1681916915](https://user-images.githubusercontent.com/59600948/233125096-2242fb7e-eb9f-4b78-8db0-c22abb6b5cc3.png)

Other screens:
|   |   |
|---|---|

|![Screenshot_1681917117](https://user-images.githubusercontent.com/59600948/233126283-45a860c7-26ac-47f6-8b38-e54b1ee7cb1f.png)|![Screenshot_1681917190](https://user-images.githubusercontent.com/59600948/233126350-08033853-4434-462d-9bf3-98040ff2356d.png)|
adhiamboperes added a commit that referenced this pull request Jun 24, 2023
…es. Fix #2116: UI misalignment due to not resetting the layout. (#4965)

## Explanation

Fix #2116:
Fix part of #632:

Simplify MarginBindingAdapters.

The code is mostly the same as in PR #4874, which was reverted. This PR
fixes the bug that caused the rollback.
The rest of the reverted changes in PR #4874 will be included in a
separate PR.

The fix consists of resetting the layout params after changing the top
and bottom margins, by calling View.setLayoutParams(), as explained in
the [layout params
documentation](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#bottomMargin).
The same call is not needed when calling a method instead of setting a
property.

It also fixes an RTL issue: if the view is not attached yet, there is no
layout direction information available, making the old implementation
render in LTR always.

Some screenshots:

|new|current|
|-|-|

|![home_rtl](https://user-images.githubusercontent.com/103062089/236451422-13843234-5f6c-4ed3-997a-e4b0459c3641.png)
|
![home_rtl_current](https://user-images.githubusercontent.com/103062089/236451614-55595920-ed58-4329-8d7d-7bdbc0487688.png)|

|![profile_chooser_landscape](https://user-images.githubusercontent.com/103062089/236451425-6766ed39-4a6b-4918-bf62-28bff5d05565.png)|![profile_chooser_landscape_current](https://user-images.githubusercontent.com/103062089/236451616-6979857b-f431-45cf-82c1-8db2a7618669.png)|

|![profile_chooser_portrait](https://user-images.githubusercontent.com/103062089/236451427-ba5cc671-ff03-4718-ae45-9e3cc924efeb.png)|![profile_chooser_portrait_current](https://user-images.githubusercontent.com/103062089/236451621-058ec5b9-0cdb-4713-931e-c49bd9a5edba.png)|

|![recently_played_rtl](https://user-images.githubusercontent.com/103062089/236451431-01e65a32-b448-422d-88a1-efb5326d5ab9.png)|![recently_played_rtl_current](https://user-images.githubusercontent.com/103062089/236451622-57a5cc80-f0d9-400d-8003-e9ff9735950b.png)|

Test results:
![Test
results](https://user-images.githubusercontent.com/103062089/236451433-d5a0e34f-75c0-4a6d-aeb5-88012913796f.png)


## Essential Checklist
<!-- Please tick the relevant boxes by putting an "x" in them. -->
- [x] The PR title and explanation each start with "Fix #bugnum: " (If
this PR fixes part of an issue, prefix the title with "Fix part of
#bugnum: ...".)
- [x] Any changes to
[scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets)
files have their rationale included in the PR explanation.
- [x] The PR follows the [style
guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide).
- [x] The PR does not contain any unnecessary code changes from Android
Studio
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)).
- [x] The PR is made from a branch that's **not** called "develop" and
is up-to-date with "develop".
- [ ] The PR is **assigned** to the appropriate reviewers
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)).

## For UI-specific PRs only
<!-- Delete these section if this PR does not include UI-related
changes. -->
If your PR includes UI-related changes, then:
- Add screenshots for portrait/landscape for both a tablet & phone of
the before & after UI changes
- For the screenshots above, include both English and pseudo-localized
(RTL) screenshots (see [RTL
guide](https://github.com/oppia/oppia-android/wiki/RTL-Guidelines))
- Add a video showing the full UX flow with a screen reader enabled (see
[accessibility
guide](https://github.com/oppia/oppia-android/wiki/Accessibility-A11y-Guide))
- Add a screenshot demonstrating that you ran affected Espresso tests
locally & that they're passing

---------

Co-authored-by: Adhiambo Peres <59600948+adhiamboperes@users.noreply.github.com>
adhiamboperes added a commit that referenced this pull request Jul 11, 2023
Fix #632: Move PromotedStoryListAdapter to BindableAdater

This change reverts partially #4951, which in turn reverted #4874 due to
a bug.
It is a partial revert because the bug was fixed independently in the
previous PR #4965.

I added RecentlyPlayedViewModel.kt to the list of classes not needing
tests, as is usual for ViewModels. This was also part of the original
PR.

| current | new |
|- | - |

|![recently_played_ltr_current](https://github.com/oppia/oppia-android/assets/103062089/179e56c1-6548-4be0-ac03-a0b7252c3a4a)|
![recently_played_ltr_new](https://github.com/oppia/oppia-android/assets/103062089/468d13e2-f6c8-48f0-a36c-2483f6dbe728)|

|![recently_played_rtl_current](https://github.com/oppia/oppia-android/assets/103062089/cf78dd4b-4fef-4311-accb-bd03d28345d6)|
![recently_played_rtl_new](https://github.com/oppia/oppia-android/assets/103062089/90a489b4-7e2a-49b3-9cbc-1eebd6dfe491)
|

|![recently_played_ltr_landscape_current](https://github.com/oppia/oppia-android/assets/103062089/92b12fa4-54c4-4be5-8c4f-1c73e90e9cb1)|![recently_played_ltr_landscape_new](https://github.com/oppia/oppia-android/assets/103062089/39833703-9cbd-4b63-b882-5950d3154316)|

|![recently_played_rtl_landscape_current](https://github.com/oppia/oppia-android/assets/103062089/46545cf6-40aa-4f24-a977-a0a586b46445)|![recently_played_rtl_landscape_new](https://github.com/oppia/oppia-android/assets/103062089/89c6a842-e876-4dc3-8861-c2c47a938183)|

## Essential Checklist
<!-- Please tick the relevant boxes by putting an "x" in them. -->
- [x] The PR title and explanation each start with "Fix #bugnum: " (If
this PR fixes part of an issue, prefix the title with "Fix part of
#bugnum: ...".)
- [x] Any changes to
[scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets)
files have their rationale included in the PR explanation.
- [x] The PR follows the [style
guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide).
- [x] The PR does not contain any unnecessary code changes from Android
Studio
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)).
- [x] The PR is made from a branch that's **not** called "develop" and
is up-to-date with "develop".
- [x] The PR is **assigned** to the appropriate reviewers
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)).

## For UI-specific PRs only
<!-- Delete these section if this PR does not include UI-related
changes. -->
If your PR includes UI-related changes, then:
- Add screenshots for portrait/landscape for both a tablet & phone of
the before & after UI changes
- For the screenshots above, include both English and pseudo-localized
(RTL) screenshots (see [RTL
guide](https://github.com/oppia/oppia-android/wiki/RTL-Guidelines))
- Add a video showing the full UX flow with a screen reader enabled (see
[accessibility guide](https://github.com/op
pia/oppia-android/wiki/Accessibility-A11y-Guide))
- Add a screenshot demonstrating that you ran affected Espresso tests
locally & that they're passing

---------

Co-authored-by: Adhiambo Peres <59600948+adhiamboperes@users.noreply.github.com>
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.

None yet

6 participants