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

Fix #936 & #2297 : Oppia Android Promoted Stories App Layer. #2320

Merged
merged 517 commits into from
Feb 13, 2021
Merged

Fix #936 & #2297 : Oppia Android Promoted Stories App Layer. #2320

merged 517 commits into from
Feb 13, 2021

Conversation

veena14cs
Copy link
Contributor

@veena14cs veena14cs commented Dec 26, 2020

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

  • 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.

@veena14cs veena14cs requested a review from rt4914 as a code owner December 26, 2020 11:50
@veena14cs veena14cs changed the base branch from develop to refactor-topic-list-adapter-to-use-bindable-adapter-veena December 26, 2020 18:48
Copy link
Contributor

@rt4914 rt4914 left a 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

Copy link
Contributor

@anandwana001 anandwana001 left a 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

@veena14cs
Copy link
Contributor Author

veena14cs commented Dec 30, 2020

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

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.

Copy link
Contributor

@anandwana001 anandwana001 left a comment

Choose a reason for hiding this comment

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

  1. add ComingSoonTopicListViewModel ComingSoonTopicsViewModel to

    VIEW_MODELS = [

  2. add ComingSoonTopicsListView to

    VIEWS = [

  3. Tests are failing, let me know if we can fix it together and save time as the number of test cases is big.

Screenshot 2020-12-31 at 10 10 06
Screenshot 2020-12-31 at 10 09 21
Screenshot 2020-12-31 at 10 06 11
Screenshot 2020-12-31 at 10 02 13
Screenshot 2020-12-31 at 09 53 06
Screenshot 2020-12-31 at 09 46 03

* (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.
Copy link
Contributor

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.

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 would defer this to @rt4914 and @BenHenning.

Copy link
Contributor

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.

Copy link
Contributor Author

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 -> {
Copy link
Contributor

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

Copy link
Contributor Author

@veena14cs veena14cs Dec 31, 2020

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.

Copy link
Member

@BenHenning BenHenning Jan 9, 2021

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.

/** 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 {
Copy link
Contributor

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.

Copy link
Contributor Author

@veena14cs veena14cs Jan 6, 2021

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.

Copy link
Contributor

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)
        }
      }
    }

Copy link
Contributor

@aggarwalpulkit596 aggarwalpulkit596 Jan 6, 2021

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 ?

Copy link
Contributor Author

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! :)

type="org.oppia.android.app.home.promotedlist.ComingSoonTopicListViewModel" />
</data>

<LinearLayout
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@anandwana001
Copy link
Contributor

@veena14cs Looks like tests are failing.
One example

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"

@anandwana001 anandwana001 removed their assignment Jan 4, 2021
Copy link
Contributor

@rt4914 rt4914 left a 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?

app/BUILD.bazel Outdated Show resolved Hide resolved
app/BUILD.bazel 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.
Copy link
Contributor

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.

type="org.oppia.android.app.home.promotedlist.ComingSoonTopicListViewModel" />
</data>

<LinearLayout
Copy link
Contributor

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

@rt4914 rt4914 removed their assignment Jan 4, 2021
Copy link
Contributor

@FareesHussain FareesHussain left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.
All the tests in HomeActivityTest are passing for tablet now.
image

@FareesHussain FareesHussain removed their assignment Feb 12, 2021
@veena14cs
Copy link
Contributor Author

LGTM, thanks.
All the tests in HomeActivityTest are passing for tablet now.
image

Thanks @FareesHussain .

@veena14cs
Copy link
Contributor Author

@anandwana001 I have addressed all your comments. PTAL.

Copy link
Contributor

@anandwana001 anandwana001 left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks @veena14cs

@anandwana001 anandwana001 removed their assignment Feb 12, 2021
@BenHenning
Copy link
Member

@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.

@veena14cs veena14cs mentioned this pull request Feb 12, 2021
8 tasks
@veena14cs veena14cs requested a review from BenHenning February 12, 2021 19:50
@veena14cs veena14cs assigned BenHenning and unassigned veena14cs Feb 12, 2021
@BenHenning BenHenning enabled auto-merge (squash) February 13, 2021 03:23
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 @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).

@BenHenning BenHenning dismissed aggarwalpulkit596’s stale review February 13, 2021 03:25

Dismissing as a non-required reviewer & this is a time-sensitive PR.

@BenHenning
Copy link
Member

@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.

@BenHenning
Copy link
Member

(Cancelled the Bazel tests sort of accidentally due to cancelling other workflows to free up CI resources, but it should be fine).

@BenHenning BenHenning merged commit d2d5501 into oppia:develop Feb 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants