-
Notifications
You must be signed in to change notification settings - Fork 531
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
Changes from 2 commits
7addaed
ff88c01
77e122d
8e75c7f
77be534
804c7db
205bfe3
9dfb3e4
c5c763a
3c5dc75
15c6066
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,16 @@ | ||||||||||
package org.oppia.android.app.home.recentlyplayed | ||||||||||
|
||||||||||
import android.content.Context | ||||||||||
import androidx.annotation.StringRes | ||||||||||
import org.oppia.android.R | ||||||||||
|
||||||||||
/** 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Correct. Used |
||||||||||
STORIES_FOR_YOU(R.string.stories_for_you); | ||||||||||
|
||||||||||
/** Returns the string corresponding to this error's string resources, or null if there is none. */ | ||||||||||
fun getTitleFromStringRes(context: Context): String? { | ||||||||||
return title.let(context::getString) | ||||||||||
} | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
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 commentThe reason will be displayed to describe this comment to others. Learn more. Updated as per suggestion. |
||||||||||
} |
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,55 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/recently_played_fragment_placeholder" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".app.home.recentlyplayed.RecentlyPlayedActivity" /> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="@color/white"> | ||
|
||
<com.google.android.material.appbar.AppBarLayout | ||
android:id="@+id/recently_played_app_bar_layout" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent"> | ||
|
||
<androidx.appcompat.widget.Toolbar | ||
android:id="@+id/recently_played_toolbar" | ||
android:layout_width="match_parent" | ||
android:layout_height="?attr/actionBarSize" | ||
android:background="?attr/colorPrimary" | ||
android:fontFamily="sans-serif" | ||
android:minHeight="?attr/actionBarSize" | ||
app:navigationContentDescription="@string/navigate_up" | ||
app:navigationIcon="?attr/homeAsUpIndicator" | ||
app:title="@string/recently_played_activity_title" | ||
app:titleTextAppearance="@style/ToolbarTextAppearance" | ||
app:titleTextColor="@color/white" /> | ||
</com.google.android.material.appbar.AppBarLayout> | ||
|
||
<FrameLayout | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
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"> | ||
|
||
<FrameLayout | ||
android:id="@+id/recently_played_fragment_placeholder" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
|
||
<View | ||
android:layout_width="match_parent" | ||
android:layout_height="6dp" | ||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. These constraints are incorrect. Removed now. |
||
</FrameLayout> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</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.
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.RecentlyPlayedActivityIntentExtras
is a value insideDestinationScreen
which contains information about the destination activity as well as its intent extras.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.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?