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

Fixes #2824: [A11y] Add label for RecentlyPlayedActivity #3065

Closed
wants to merge 11 commits into from

Conversation

rt4914
Copy link
Contributor

@rt4914 rt4914 commented Apr 9, 2021

Explanation

Fixes #2824

For RecentlyPlayedActivity the label can be either Stories for you or Recently Played Stories.
This activity can be visited via two screens: (a.) Click on View All in HomeActivity and (b.) Click on View All in ProfileProgressActivity.

The main problem is that we need to send the string in advance via intent as we need it for screen readers. To do this I have created RecentlyPlayedTitleEnum enum which will send the correct title. But this was not working and even I found one bug with Toolbar too in current develop. The toolbar title fluctuates. Check this below gif and focus on toolbar.

bug1

Earlier we were using toolbar in fragment and we were fetching the content from domain layer and based on the content received we were setting the toolbar. Now because in the new implementation we already have the title we can shift this toolbar to activity so that the flakiness is removed and the screen readers can work properly.

Screenreader output on this branch

current_recently_played.mp4

Note to Reviewer

In this draft PR I am just confirming the approach and therefore I done following things which will be fixed in final PR:

  1. Removed all other layout files related to recently_played so that I don't have to worry about them.
  2. While calling the intent for RecentlyPlayed I am passing the hard-coded/fixed enum value if the approach is finalised this will be sent correctly.
  3. I am not updated the test cases which might be failing.

Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The PR explanation includes the words "Fixes #bugnum: ..." (or "Fixes part of #bugnum" if the PR only partially fixes an issue).
  • The PR follows the style guide.
  • The PR does not contain any unnecessary auto-generated code from Android Studio.
  • The PR is made from a branch that's not called "develop".
  • The PR is made from a branch that is up-to-date with "develop".
  • The PR's branch is based on "develop" and not on any other branch.
  • The PR is assigned to an appropriate reviewer in both the Assignees and the Reviewers sections.

@rt4914
Copy link
Contributor Author

rt4914 commented Apr 9, 2021

@BenHenning PTAL at approach.

@BenHenning
Copy link
Member

Apologies--will need to look at this tomorrow.

Copy link
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 @rt4914. Left some thoughts, but the overall approach seems good.

val intent = Intent(context, RecentlyPlayedActivity::class.java)
intent.putExtra(RECENTLY_PLAYED_ACTIVITY_INTERNAL_PROFILE_ID_KEY, internalProfileId)
intent.putExtra(RECENTLY_PLAYED_ACTIVITY_TITLE_ENUM_KEY, recentlyPlayedTitleEnum)
Copy link
Member

Choose a reason for hiding this comment

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

This seems reasonable to me, but I think we want to do a push toward using protos more aggressively for sending arguments & intent extras. Maybe just go ahead and define an intent extra proto for this activity & use that, instead? It means a less-clean enum but you could still create an extension function for getTitleFromStringRes to keep dependent code clean.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have tried to use protos. I am not sure if its correct so do let me know WDYT.

  1. DestinationScreen will helps to identify which activity to open and also with what intent extra values.
  2. For example for this implementation, RecentlyPlayedActivityIntentExtras is a value inside DestinationScreen which contains information about the destination activity as well as its intent extras.
  3. In activity package I have created ActivityRouter which will be injected to all activities / fragments from where we want to start the next activity. In this we will call routeToScreen with correct DestinationScreen and then this will decide which activity should be started.
  4. One added code clarity point: With this approach we can change RecentlyPlayedActivityIntentExtras proto anytime it will be very easy to make changes to code. For example in current develop as I had to send an enum I had to introduced a new key and change the createRecentlyPlayedActivityIntent function by introducing a new argument which in turn resulted in changes in all the instances where that function was getting called. But with this new approach these changes will be comparatively less.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I was just thinking that you could pass a RecentlyPlayedActivityIntentExtras proto here & proceed similarly. The router approach seems much nicer. Do you want to do that change as part of this PR or separately?

<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<androidx.constraintlayout.widget.ConstraintLayout
Copy link
Member

Choose a reason for hiding this comment

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

Did we ever need landscape-specific specialization for this layout or did you just noticed it wasn't needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually we do need other xml files too but if this approach gets approved the xml files will change a lot and therefore I thought to remove them directly for now, finish the implementation, then again add those files back with all the changes. That way i won't have to make changes to various versions of xml files again and again.

Comment on lines 49 to 52
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/recently_played_app_bar_layout" />
Copy link
Member

Choose a reason for hiding this comment

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

Is it value to have constraints when within a layout being constrained? Do we eve need these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These constraints are incorrect. Removed now.

Comment on lines 13 to 15
fun getTitleFromStringRes(context: Context): String? {
return title.let(context::getString)
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fun getTitleFromStringRes(context: Context): String? {
return title.let(context::getString)
}
fun getTitleFromStringRes(context: Context): String? = context.getString(title)

The scope function way seems less readable to me, but YMMV. I also changed this to an optional single-assignment syntax.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated as per suggestion.


/** Represents different titles for RecentlyPlayedActivity used by screen readers. */
enum class RecentlyPlayedTitleEnum(@StringRes private var title: Int) {
RECENTLY_PLAYED_STORIES(R.string.recently_played_stories),
Copy link
Member

Choose a reason for hiding this comment

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

Why isn't this using recently_played_activity_title?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. Used recently_played_activity_title

@BenHenning
Copy link
Member

Also just to check: is the bug in the first video with or without the intent approach? I wouldn't expect the flicker to happen with your current implementation--is that the case?

@BenHenning BenHenning assigned rt4914 and unassigned BenHenning Apr 9, 2021
@rt4914
Copy link
Contributor Author

rt4914 commented Apr 12, 2021

Also just to check: is the bug in the first video with or without the intent approach? I wouldn't expect the flicker to happen with your current implementation--is that the case?

The bug is without this approach, in current develop. With current implementation is it fixed.

Rajat Talesra added 2 commits April 12, 2021 12:35
@rt4914 rt4914 assigned BenHenning and unassigned rt4914 Apr 12, 2021
@BenHenning
Copy link
Member

@rt4914 I think the approach seems fine, though I do suggest going with protos instead (one way or another with regards to introducing a router or not--I'll defer to you on how/when you want to introduce that). I think the overall solution is actually quite nice, and am happy to see the bug get fixed.

@BenHenning BenHenning assigned rt4914 and unassigned BenHenning Apr 13, 2021

/** Checks the value of [DestinationScreen] and routes to different activities accordingly. */
fun routeToScreen(destinationScreen: DestinationScreen) {
if (destinationScreen.destinationScreenCase ==
Copy link
Member

Choose a reason for hiding this comment

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

Should this be a when statement, instead? Maybe also use 'return' to force it to be exhaustive.

val intent = Intent(context, RecentlyPlayedActivity::class.java)
intent.putExtra(RECENTLY_PLAYED_ACTIVITY_INTERNAL_PROFILE_ID_KEY, internalProfileId)
intent.putExtra(
Copy link
Member

Choose a reason for hiding this comment

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

}

// Intent extras for RecentlyPlayedActivity.
message RecentlyPlayedActivityIntentExtras{
Copy link
Member

Choose a reason for hiding this comment

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

Nit: space before {

@anandwana001 anandwana001 added the PR don't merge - NEEDS UPDATE Corresponds to PRs that need to be updated with the latest develop changes before they can be merged label May 7, 2021
@rt4914 rt4914 removed the PR don't merge - NEEDS UPDATE Corresponds to PRs that need to be updated with the latest develop changes before they can be merged label Jul 5, 2021
@oppiabot
Copy link

oppiabot bot commented Aug 14, 2021

Hi @rt4914, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 3 days, it will be automatically closed so that others can take up the issue.
If you are still working on this PR, please make a follow-up commit within 3 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you!

@oppiabot oppiabot bot added the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Aug 14, 2021
@oppiabot oppiabot bot closed this Aug 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Corresponds to items that haven't seen a recent update and may be automatically closed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[A11y] Add label for RecentlyPlayedActivity [Blocked on #3095]
3 participants