-
Notifications
You must be signed in to change notification settings - Fork 529
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 #936 & #2297 : Oppia Android Promoted Stories App Layer. #2320
Conversation
app/src/main/java/org/oppia/android/app/home/promotedlist/ComingSoonTopicsListView.kt
Show resolved
Hide resolved
app/src/main/java/org/oppia/android/app/home/promotedlist/PromotedStoryListViewModel.kt
Outdated
Show resolved
Hide resolved
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.
@veena14cs I did the very initial pass but there are lots of nit changes and lint issues. I suggest doing a self-PR-Review or solving the lint-test fail errors, so that it becomes easy to review and more focused towards implementation.
The initial implementation approach looks good and works correctly too.
Thanks @veena14cs
domain/src/main/java/org/oppia/android/domain/topic/StoryProgressTestHelper.kt
Outdated
Show resolved
Hide resolved
domain/src/main/java/org/oppia/android/domain/topic/StoryProgressTestHelper.kt
Outdated
Show resolved
Hide resolved
domain/src/main/java/org/oppia/android/domain/topic/StoryProgressTestHelper.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/android/app/home/promotedlist/PromotedStoryListViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/android/app/home/promotedlist/PromotedStoryListViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/android/app/home/promotedlist/PromotedStoryListViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/android/app/home/promotedlist/ComingSoonTopicsViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/android/app/home/promotedlist/ComingSoonTopicsViewModel.kt
Outdated
Show resolved
Hide resolved
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 review on few files.
Tried running app but didn't see the list item.
Aalso for bazel, you need to add any new listener, viewmodel to app/BUILD.bazel file
app/src/main/java/org/oppia/android/app/home/HomeFragmentPresenter.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/android/app/home/HomeItemViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/android/app/home/promotedlist/ComingSoonTopicsViewModel.kt
Outdated
Show resolved
Hide resolved
Did you try playing any of the explorations. Initially, we don't have any learner history we don't no what topics to recommend , so when user selects any topic and plays, based on this selection we recommend him next topic's first chapter. |
app/src/main/java/org/oppia/android/app/home/promotedlist/PromotedStoryListViewModel.kt
Outdated
Show resolved
Hide resolved
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.
app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedFragmentPresenter.kt
Show resolved
Hide resolved
app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedFragmentPresenter.kt
Show resolved
Hide resolved
app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt
Outdated
Show resolved
Hide resolved
* (see [PromotedStoryListViewModel]), or null if this profile does not have any promoted stories. | ||
* Promoted stories are determined by any recent stories started by this profile. | ||
* Returns a [HomeItemViewModel] corresponding to the promoted stories[PromotedStoryListViewModel] and Upcoming topics | ||
* [ComingSoonTopicListViewModel] to be displayed for this learner or null if this profile does not have any promoted 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.
Can we change the context to recommended here instead of using keywords like promoted i was a bit confused at first seeing promoted and recommended both.
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 would defer this to @rt4914 and @BenHenning.
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.
Recommended and Promoted have different meanings.
Promoted
simply meaning anything which is getting promoted to home-screen carousel. It can be either a Recommended Story
, RecentlyPlayed Story
or Upcoming Topic
.
Recommended
, means we are suggesting user something which will be the best logical step for them.
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 for making this clear.
) | ||
} else null | ||
when (recommendedActivityList.recommendationTypeCase) { | ||
RecommendedActivityList.RecommendationTypeCase.RECOMMENDED_STORY_LIST -> { |
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 RecommendationTypeCase is an enum ? if yes then we don't need to handle the else case here
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.
Its not an enum but oneOf at most one field will be set at the same time. There can be field called TYPE_NOT_SET. To handle this I have added else case.
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.
Protobuf enum can always, unfortunately, be unspecified so we can't rely on exhaustive when statements. :( Hopefully this gets addressed when there's a Kotlin-compatible protobuf compiler.
app/src/main/java/org/oppia/android/app/home/promotedlist/ComingSoonTopicsListView.kt
Show resolved
Hide resolved
/** Returns the padding placed at the end of the promoted stories list based on the number of promoted stories. */ | ||
val endPadding = | ||
if (promotedStoryList.size > 1) | ||
activity.resources.getDimensionPixelSize(R.dimen.home_padding_end) | ||
else activity.resources.getDimensionPixelSize(R.dimen.home_padding_start) | ||
|
||
/** Determines and returns the visibility for the "View All" button. */ | ||
fun getHeader(): String { | ||
recommendedActivityList.recommendedStoryList.let { |
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.
Oh instead of using let we could with
as that would be more appropriate here and elsewhere as it is an scope function which would change the scope and then we won't require to write even it
.
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.
@aggarwalpulkit596 can you please suggest me how I can use with
here instead of let
.
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.
with(recommendedActivityList.recommendedStoryList) {
return when {
suggestedStoryList.isNotEmpty() -> {
if (recentlyPlayedStoryList.isNotEmpty() || olderPlayedStoryList.isNotEmpty()) {
activity.getString(R.string.stories_for_you)
} else
activity.getString(R.string.recommended_stories)
}
recentlyPlayedStoryList.isNotEmpty() -> {
activity.getString(R.string.recently_played_stories)
}
else -> {
activity.getString(R.string.last_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.
with
changes the current scope to the object so here this
is referring to recommendedActivityList.recommendedStoryList
and since it is implicitly applied here we don't have to write this here. Does that make sense ?
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.
Yes, got it done. Thanks Pulkit! :)
app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedFragmentPresenter.kt
Outdated
Show resolved
Hide resolved
type="org.oppia.android.app.home.promotedlist.ComingSoonTopicListViewModel" /> | ||
</data> | ||
|
||
<LinearLayout |
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.
Just for consistency, we should use constraint layout @rt4914 @BenHenning
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.
Deferring it to @rt4914 @BenHenning
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.
@aggarwalpulkit596 Makes sense. @veena14cs Can you update this and other files to use 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.
Done.
@veena14cs Looks like tests are failing. fun testHomeActivity_recyclerViewIndex4_topicSummary_configurationChange_lessonCountIsCorrect() androidx.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: 'with text: a string containing "1 Lesson"' doesn't match the selected view.
Expected: with text: a string containing "1 Lesson" |
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.
@veena14cs the base branch of this PR should be promoted-story
right?
* (see [PromotedStoryListViewModel]), or null if this profile does not have any promoted stories. | ||
* Promoted stories are determined by any recent stories started by this profile. | ||
* Returns a [HomeItemViewModel] corresponding to the promoted stories[PromotedStoryListViewModel] and Upcoming topics | ||
* [ComingSoonTopicListViewModel] to be displayed for this learner or null if this profile does not have any promoted 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.
Recommended and Promoted have different meanings.
Promoted
simply meaning anything which is getting promoted to home-screen carousel. It can be either a Recommended Story
, RecentlyPlayed Story
or Upcoming Topic
.
Recommended
, means we are suggesting user something which will be the best logical step for them.
app/src/main/java/org/oppia/android/app/home/promotedlist/ComingSoonTopicListViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/android/app/home/promotedlist/PromotedStoryListViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedFragmentPresenter.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedFragmentPresenter.kt
Outdated
Show resolved
Hide resolved
type="org.oppia.android.app.home.promotedlist.ComingSoonTopicListViewModel" /> | ||
</data> | ||
|
||
<LinearLayout |
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.
@aggarwalpulkit596 Makes sense. @veena14cs Can you update this and other files to use 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.
Thanks @FareesHussain . |
@anandwana001 I have addressed all your comments. PTAL. |
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.
LGTM, Thanks @veena14cs
app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt
Outdated
Show resolved
Hide resolved
app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt
Outdated
Show resolved
Hide resolved
app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt
Outdated
Show resolved
Hide resolved
…yTest.kt Co-authored-by: Ben Henning <[email protected]>
@veena14cs just a few comments left, plus we need to update this after #2707 is merged in. Note that we can ignore the non-required failing Bazel tests & merge it once the Bazel build workflow is passing again. |
…yTest.kt Co-authored-by: Ben Henning <[email protected]>
…yTest.kt Co-authored-by: Ben Henning <[email protected]>
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 @veena14cs! PR LGTM, and the latest changes are passing. I needed to update the branch to develop, but it seems solid. Will ensure this gets merged quickly (since the Bazel tests aren't required yet).
Dismissing as a non-required reviewer & this is a time-sensitive PR.
@aggarwalpulkit596 FYI I cleared your review since you were requesting changes & this PR is a bit time sensitive. Please follow up with an issue for any additional changes you think are needed here. |
(Cancelled the Bazel tests sort of accidentally due to cancelling other workflows to free up CI resources, but it should be fine). |
Explanation
This PR is the app layer implementation of promoted stories and coming soon topics on the home screen. This PR fixes issues #936 & #2297 .
Design Document
https://docs.google.com/document/d/1o7hOz1rP-hJaKn1f5x6LV6ms0bzhyCpsTifJQY5crCc/edit?ts=5f9fc81b#heading=h.ovlu0iazlug6
Mock Links
Checklist