-
Notifications
You must be signed in to change notification settings - Fork 528
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
Conversation
@BenHenning PTAL at approach. |
Apologies--will need to look at this tomorrow. |
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.
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) |
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.
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.
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 have tried to use protos. I am not sure if its correct so do let me know WDYT.
DestinationScreen
will helps to identify which activity to open and also with what intent extra values.- For example for this implementation,
RecentlyPlayedActivityIntentExtras
is a value insideDestinationScreen
which contains information about the destination activity as well as its intent extras. - In
activity
package I have createdActivityRouter
which will be injected to all activities / fragments from where we want to start the next activity. In this we will callrouteToScreen
with correctDestinationScreen
and then this will decide which activity should be started. - 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 thecreateRecentlyPlayedActivityIntent
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.
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.
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 |
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.
Did we ever need landscape-specific specialization for this layout or did you just noticed it wasn't needed?
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.
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.
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" /> |
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.
Is it value to have constraints when within a layout being constrained? Do we eve need these?
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.
These constraints are incorrect. Removed now.
fun getTitleFromStringRes(context: Context): String? { | ||
return title.let(context::getString) | ||
} |
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.
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.
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.
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), |
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.
Why isn't this using recently_played_activity_title?
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.
Correct. Used recently_played_activity_title
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. |
@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. |
|
||
/** Checks the value of [DestinationScreen] and routes to different activities accordingly. */ | ||
fun routeToScreen(destinationScreen: DestinationScreen) { | ||
if (destinationScreen.destinationScreenCase == |
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.
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( |
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.
Prefer using this utility instead: https://github.com/oppia/oppia-android/blob/develop/utility/src/main/java/org/oppia/android/util/extensions/BundleExtensions.kt#L13.
} | ||
|
||
// Intent extras for RecentlyPlayedActivity. | ||
message RecentlyPlayedActivityIntentExtras{ |
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.
Nit: space before {
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. |
Explanation
Fixes #2824
For
RecentlyPlayedActivity
the label can be eitherStories for you
orRecently Played Stories
.This activity can be visited via two screens: (a.) Click on
View All
inHomeActivity
and (b.) Click onView All
inProfileProgressActivity
.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.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:
recently_played
so that I don't have to worry about them.RecentlyPlayed
I am passing the hard-coded/fixed enum value if the approach is finalised this will be sent correctly.Checklist