-
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
Closed
Closed
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7addaed
Approach for RecentlyPlayed label
ff88c01
Nit fix
77e122d
Merge remote-tracking branch 'upstream/develop' into a11y-recenly-played
8e75c7f
Nit fix
77be534
Draft impl of proto based intents
804c7db
Nit fix and documentation
205bfe3
Proto fix
9dfb3e4
Nit fix
c5c763a
Merge remote-tracking branch 'upstream/develop' into a11y-recenly-played
3c5dc75
Merged with develop
15c6066
Merge remote-tracking branch 'upstream/develop' into a11y-recenly-played
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app/src/main/java/org/oppia/android/app/activity/ActivityRouter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.oppia.android.app.activity | ||
|
||
import androidx.appcompat.app.AppCompatActivity | ||
import org.oppia.android.app.home.recentlyplayed.RecentlyPlayedActivity | ||
import org.oppia.android.app.model.DestinationScreen | ||
import org.oppia.android.app.model.RecentlyPlayedActivityIntentExtras | ||
import javax.inject.Inject | ||
|
||
/** Central utility to manage routing to different activities. */ | ||
class ActivityRouter @Inject constructor(private val activity: AppCompatActivity) { | ||
|
||
/** Checks the value of [DestinationScreen] and routes to different activities accordingly. */ | ||
fun routeToScreen(destinationScreen: DestinationScreen) { | ||
if (destinationScreen.destinationScreenCase == | ||
DestinationScreen.DestinationScreenCase.RECENTLY_PLAYED_ACTIVITY_INTENT_EXTRAS | ||
) { | ||
openRecentlyPlayedActivity(destinationScreen.recentlyPlayedActivityIntentExtras) | ||
} | ||
} | ||
|
||
private fun openRecentlyPlayedActivity( | ||
recentlyPlayedActivityIntentExtras: RecentlyPlayedActivityIntentExtras | ||
) { | ||
activity.startActivity( | ||
RecentlyPlayedActivity.createRecentlyPlayedActivityIntent( | ||
activity, | ||
recentlyPlayedActivityIntentExtras | ||
) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import android.content.Intent | |
import android.os.Bundle | ||
import org.oppia.android.app.activity.InjectableAppCompatActivity | ||
import org.oppia.android.app.home.RouteToExplorationListener | ||
import org.oppia.android.app.model.RecentlyPlayedActivityIntentExtras | ||
import org.oppia.android.app.player.exploration.ExplorationActivity | ||
import javax.inject.Inject | ||
|
||
|
@@ -17,22 +18,27 @@ class RecentlyPlayedActivity : InjectableAppCompatActivity(), RouteToExploration | |
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
activityComponent.inject(this) | ||
val internalProfileId = intent.getIntExtra( | ||
RECENTLY_PLAYED_ACTIVITY_INTERNAL_PROFILE_ID_KEY, | ||
-1 | ||
val recentlyPlayedActivityIntentExtras = RecentlyPlayedActivityIntentExtras.parseFrom( | ||
intent.getByteArrayExtra(RECENTLY_PLAYED_ACTIVITY_INTENT_EXTRAS) | ||
) | ||
recentlyPlayedActivityPresenter.handleOnCreate(internalProfileId) | ||
|
||
recentlyPlayedActivityPresenter.handleOnCreate(recentlyPlayedActivityIntentExtras) | ||
} | ||
|
||
companion object { | ||
// TODO(#1655): Re-restrict access to fields in tests post-Gradle. | ||
const val RECENTLY_PLAYED_ACTIVITY_INTERNAL_PROFILE_ID_KEY = | ||
"RecentlyPlayedActivity.internal_profile_id" | ||
const val RECENTLY_PLAYED_ACTIVITY_INTENT_EXTRAS = "RecentlyPlayedActivity.intent_extras" | ||
|
||
/** Returns a new [Intent] to route to [RecentlyPlayedActivity]. */ | ||
fun createRecentlyPlayedActivityIntent(context: Context, internalProfileId: Int): Intent { | ||
fun createRecentlyPlayedActivityIntent( | ||
context: Context, | ||
recentlyPlayedActivityIntentExtras: RecentlyPlayedActivityIntentExtras | ||
): Intent { | ||
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 commentThe 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. |
||
RECENTLY_PLAYED_ACTIVITY_INTENT_EXTRAS, | ||
recentlyPlayedActivityIntentExtras.toByteArray() | ||
) | ||
return intent | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.