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 part of #632: Refactor topic list adapter to use bindable adapter #2246

Merged
Merged
Show file tree
Hide file tree
Changes from 154 commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
a979440
Use BindableAdapter for displaying Welcome layout, still updating Pro…
jcqli Dec 8, 2020
6573b73
Merge branch 'develop' into refactor-topic-list-adapter-to-use-bindab…
jcqli Dec 8, 2020
f51498e
Refactor PromotedStoryListViewModel to update using BindableAdapter
jcqli Dec 8, 2020
4a1b0b4
Migrate TopicListViewHolder logic
jcqli Dec 8, 2020
1ddbe5a
Bind TopicSummary padding and HomeItemList
jcqli Dec 9, 2020
f5d87d9
Compute margins and bind to layout in topic summary view
jcqli Dec 9, 2020
0a9246d
Add databinding for topic summary margins
jcqli Dec 9, 2020
41e5bb9
Pushing latest changes to compare
jcqli Dec 9, 2020
38043a3
Return int to layout margins
jcqli Dec 9, 2020
e3f4a55
Clean up commented code
jcqli Dec 9, 2020
4c9d0bf
Use app-defined margin layouts for data binding
jcqli Dec 9, 2020
87bcf61
Add binding to HomeViewModel
jcqli Dec 10, 2020
34ad3eb
Remove use of ViewModelProvider in HomeFragmentPresenter
jcqli Dec 10, 2020
dd87309
Bind PromotedStoryList layout values
jcqli Dec 10, 2020
95ad08c
Add data binding for sotry & layout of PromotedStory card
jcqli Dec 10, 2020
721beea
Merge remote-tracking branch 'upstream/develop' into refactor-topic-l…
jcqli Dec 10, 2020
269204e
Add BindingAdapter for layout height
jcqli Dec 10, 2020
ace1354
Create custom recycler view for PromotedStoryList
jcqli Dec 11, 2020
c1912f0
Remove unused imports & TopicListAdapter
jcqli Dec 11, 2020
c891f7a
Construct adapter in custom view
jcqli Dec 11, 2020
89a947b
Debugging layout data binding
jcqli Dec 11, 2020
efa6a2a
Add PromotedStoryCard to custom promoted story list view
jcqli Dec 11, 2020
4447d1b
Remove unused imports
jcqli Dec 11, 2020
2f4f2e7
Set topic summary position to start at 1
jcqli Dec 11, 2020
1384358
Set adapter in initializer
jcqli Dec 11, 2020
fd9e418
Refactor to process TopicList later
jcqli Dec 11, 2020
9078a9b
Merge branch 'develop' into refactor-topic-list-adapter-to-use-bindab…
jcqli Dec 11, 2020
340f71b
Revert "Refactor to process TopicList later"
jcqli Dec 11, 2020
bb4d302
Process welcome in home view model
jcqli Dec 12, 2020
fd0d431
Move processing logic for all view models to home
jcqli Dec 12, 2020
7bf14b3
Add model for home fragment data to combine data providers
jcqli Dec 14, 2020
870ec2c
Apply patch for combining home view model data and adjust topic list …
jcqli Dec 15, 2020
b9c2d4d
Add orientation to tablet layouts
jcqli Dec 15, 2020
45b9462
Use promoted story list for itemCount
jcqli Dec 15, 2020
41d3af4
Bind list of ChapterSummaryViewModel instead of ChapterSummary to fix…
jcqli Dec 15, 2020
14fb58c
Fix linter errors & remove PromotedStoryListAdapter
jcqli Dec 15, 2020
f090330
Add viewmodels to bazel build
jcqli Dec 15, 2020
798bc4c
Fix more linter errors
jcqli Dec 15, 2020
801d4e1
Fix more linter errors
jcqli Dec 15, 2020
46ca860
Merge branch 'refactor-topic-list-adapter-to-use-bindable-adapter' of…
jcqli Dec 15, 2020
7dd9fb0
Revert "Add viewmodels to bazel build"
jcqli Dec 15, 2020
b9b226b
Apply test changes from #2253
jcqli Dec 15, 2020
0097bfa
Address review comments
jcqli Dec 16, 2020
594d8c0
Resolve conflicts
jcqli Dec 16, 2020
9c6ea9f
Fix linter errors
jcqli Dec 16, 2020
27f878f
Fix linter errors
jcqli Dec 16, 2020
435270a
Add view models to bazel build file
jcqli Dec 17, 2020
5f93d32
Refactor all topics list to return empty list if no topics
jcqli Dec 17, 2020
b184d1e
Remove duplicated HomeViewModel in bazel build
jcqli Dec 17, 2020
cec345d
Fix linter error & filepath for AllTopicsViewModel in bazel build
jcqli Dec 17, 2020
859fd4a
Merge remote-tracking branch 'upstream/develop' into refactor-topic-l…
jcqli Dec 17, 2020
0026e36
Remove test helper for home fragment
jcqli Dec 17, 2020
a264442
Add completing all topics to story progress test helper
jcqli Dec 18, 2020
95d0af9
Add tests for no promtoed stories on home fragment and all topics com…
jcqli Dec 18, 2020
2570dde
Address review comments
jcqli Dec 18, 2020
5633194
Set View All button visiblity in view model
jcqli Dec 18, 2020
f906d0d
Fix linter issues
jcqli Dec 18, 2020
d971e13
Add comment to explain test topic exploration progress in test helper
jcqli Dec 18, 2020
31a9d8b
Merge remote-tracking branch 'upstream/develop' into refactor-topic-l…
jcqli Dec 21, 2020
01c3653
Address review comments
jcqli Dec 22, 2020
f347994
Set routing / listeners in home activity
jcqli Dec 22, 2020
26b082c
More review comments
jcqli Dec 22, 2020
92b6bed
Address review comments
jcqli Dec 22, 2020
e304b63
Fix linter issues
jcqli Dec 22, 2020
ac7a029
Fix linter errors
jcqli Dec 22, 2020
8e5d5af
Fix test errors (linter & bazel)
jcqli Dec 22, 2020
03f6887
Fix bazel errors and add tests for no user progress case
jcqli Dec 22, 2020
2e87b69
Remove double declaration of TopicSummaryViewModel
jcqli Dec 22, 2020
c845113
Move PromotedStoryViewModel to be declared with resources
jcqli Dec 22, 2020
ca30f39
Remove curly brace on padding dimensions in promotedstorylistview
jcqli Dec 22, 2020
9a4c82c
Remove Int type from padding value
jcqli Dec 23, 2020
28b60a2
Address review comments
jcqli Dec 23, 2020
3f23dbb
Add BindingAdapter for padding end
jcqli Dec 23, 2020
9566c62
Remove unused import
jcqli Dec 23, 2020
b37f624
Fix comments
jcqli Dec 23, 2020
5cc9b28
Use int in BindingAdapter
jcqli Dec 23, 2020
b527e16
Rename BindingAdapter?
jcqli Dec 23, 2020
f67afed
Refactor BindingAdapter naming
jcqli Dec 23, 2020
c7fc75b
Add view to bazel build
jcqli Dec 23, 2020
4f48b76
Add SnapHelper to build
jcqli Dec 23, 2020
51311b2
Create HomeFragmentView to handle layout
jcqli Dec 23, 2020
1ad8e52
Handle layout in presenter again
jcqli Dec 24, 2020
11fa3c1
Fix linter errors
jcqli Dec 24, 2020
0df343e
Add recyclerview to snap helper in build
jcqli Dec 24, 2020
f9e9494
Add databidning dependency
jcqli Dec 24, 2020
7d94895
WOrk on bazel errors
jcqli Dec 24, 2020
8a0bc4a
WOrk on bazel errors
jcqli Dec 24, 2020
6de46c3
WOrk on bazel errors
jcqli Dec 24, 2020
55a4597
Enable data-binding in build?
jcqli Dec 24, 2020
a308621
Remove enable data binding for snap helper
jcqli Dec 24, 2020
94e9f3b
Add custom package?
jcqli Dec 24, 2020
aa5656a
Use shim for bindings in PromotedStoryListView
jcqli Dec 24, 2020
666de4d
Address review comments
jcqli Dec 24, 2020
6fc5312
Attach to window and use view component
jcqli Dec 24, 2020
19c98a2
Use application injection in PromotedStoryListView, add bounds check …
jcqli Dec 24, 2020
057f937
Fix linter errors
jcqli Dec 24, 2020
ed5b3de
Merge remote-tracking branch 'upstream/develop' into refactor-topic-l…
jcqli Jan 4, 2021
f455660
Merge remote-tracking branch 'upstream/develop' into refactor-topic-l…
jcqli Jan 5, 2021
9b23ee7
Use fragment injection in custom recycler view, override equals in vi…
jcqli Jan 5, 2021
206bc41
Shorten error message
jcqli Jan 5, 2021
7c23c9f
Shorten error message
jcqli Jan 5, 2021
8f37116
Merge branch 'refactor-topic-list-adapter-to-use-bindable-adapter' of…
jcqli Jan 5, 2021
a1bb425
Merge remote-tracking branch 'upstream/develop' into refactor-topic-l…
jcqli Jan 6, 2021
7e71d54
Add hashcode to view models and address review comments
jcqli Jan 6, 2021
cfa1d49
Start tests for view model equals
jcqli Jan 6, 2021
11fb309
Merge remote-tracking branch 'upstream/develop' into refactor-topic-l…
jcqli Jan 7, 2021
def4ae3
Add view model tests
jcqli Jan 7, 2021
86224fa
Use test activity to get fragment
jcqli Jan 8, 2021
4faf7e7
Create intent in test activity
jcqli Jan 8, 2021
92b2389
Add test for WelcomeViewModel
jcqli Jan 8, 2021
d1bcc2d
Clarify test names and start PromotedStoryListViewModel
jcqli Jan 8, 2021
f11e530
Add tests for equals definition and hashcode of WelcomeViewModel and …
jcqli Jan 8, 2021
23c816b
Add tests for PromotedStoryListViewModel
jcqli Jan 8, 2021
e9e0d52
Add tests for TopicSummaryViewModel
jcqli Jan 8, 2021
57abbea
Shorten comment
jcqli Jan 8, 2021
502a6f7
Address review comments
jcqli Jan 8, 2021
e05ba31
Separate WelcomeViewModel into own test
jcqli Jan 8, 2021
dc1c8af
Separate PromotedStoryViewModel test
jcqli Jan 8, 2021
8dae244
Separate PromotedStoryListViewModel tests
jcqli Jan 8, 2021
e7576c9
Separate TopicSummaryViewModel tests
jcqli Jan 8, 2021
401ddb0
Remove combined ViewModel tests
jcqli Jan 8, 2021
a8818ba
Fix lint errors
jcqli Jan 8, 2021
fc8d16f
Create fragment in view model test
jcqli Jan 8, 2021
c004111
Remove fragment transaction from test activity
jcqli Jan 8, 2021
01d96cb
Fix linter errors
jcqli Jan 8, 2021
a8e47a8
Use helpers and improve readability of promoted story list view model…
jcqli Jan 9, 2021
c89b077
Improve readability for WelcomeViewModel tests
jcqli Jan 9, 2021
b2c6bcf
Simplilfy promtoed story view model and welcome view model tests
jcqli Jan 9, 2021
3bc2364
Simplify topic summary and promtoed story view models
jcqli Jan 9, 2021
a15141c
Clarify test names
jcqli Jan 9, 2021
c073c8d
Move test helpers beneath test cases
jcqli Jan 11, 2021
805efcd
Address review comments
jcqli Jan 11, 2021
411a67a
Merge remote-tracking branch 'upstream/develop' into refactor-topic-l…
jcqli Jan 11, 2021
ccac3da
Address comments for HomeActivityTest
jcqli Jan 12, 2021
1d66248
Import ActivityScenario.launch for view model tests
jcqli Jan 12, 2021
65173e2
Use named parameters in StoryProgressTestHelperTest
jcqli Jan 12, 2021
83c99b1
Clarify new user used for no story progress in ProfileTestHelpr
jcqli Jan 12, 2021
1f25997
Order view model alphabetically
jcqli Jan 12, 2021
356e03e
Add readability fixes from review
jcqli Jan 12, 2021
0641c8e
Fix comments
jcqli Jan 12, 2021
0d08d9a
Resolve merge conflicts
jcqli Jan 12, 2021
86a2a36
Add dummy data in promoted story list view to appropriately initiate …
jcqli Jan 13, 2021
b0b5045
Merge remote-tracking branch 'upstream/develop' into refactor-topic-l…
jcqli Jan 13, 2021
346fc10
Use BindingAdapter on the data list of promtoed stories
jcqli Jan 13, 2021
67eb418
Remove static binding adapter for data-binding in promoted story list…
jcqli Jan 14, 2021
e1e0703
Address review comments
jcqli Jan 14, 2021
60c9cfc
Remove extra space in layout
jcqli Jan 14, 2021
00f32a7
Improve test readability
jcqli Jan 14, 2021
8183f21
Check column count before testing span in HomeActivityTest
jcqli Jan 14, 2021
9391b14
Add test for promoted story list view bug
jcqli Jan 14, 2021
effb20a
Rename tag for clarity
jcqli Jan 14, 2021
2fc8c44
Comments for test
jcqli Jan 14, 2021
7235ede
Merge remote-tracking branch 'upstream/develop' into refactor-topic-l…
jcqli Jan 14, 2021
4e0cdbc
Address review comments
jcqli Jan 15, 2021
e8822fc
Address review comments
jcqli Jan 15, 2021
5967065
Fix linter errors
jcqli Jan 15, 2021
a2d460f
Fix linter errors
jcqli Jan 15, 2021
f31bea9
Add test to check correct max number of promoted stories shown
jcqli Jan 15, 2021
f5fbbc3
Delete home view model test
jcqli Jan 15, 2021
e71d5a4
Fix import
jcqli Jan 15, 2021
b476636
Address review comments
jcqli Jan 15, 2021
cc39506
Change function name
jcqli Jan 15, 2021
9e04a1c
Add null check for promoted story list data
jcqli Jan 15, 2021
7fa1b71
Fix typo
jcqli Jan 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ VIEW_MODELS_WITH_RESOURCE_IMPORTS = [
"src/main/java/org/oppia/android/app/help/HelpItemViewModel.kt",
"src/main/java/org/oppia/android/app/help/HelpListViewModel.kt",
"src/main/java/org/oppia/android/app/help/faq/FAQListViewModel.kt",
"src/main/java/org/oppia/android/app/home/HomeViewModel.kt",
"src/main/java/org/oppia/android/app/home/promotedlist/PromotedStoryListViewModel.kt",
"src/main/java/org/oppia/android/app/home/promotedlist/PromotedStoryViewModel.kt",
"src/main/java/org/oppia/android/app/home/topiclist/TopicSummaryViewModel.kt",
"src/main/java/org/oppia/android/app/onboarding/OnboadingSlideViewModel.kt",
"src/main/java/org/oppia/android/app/onboarding/OnboardingViewModel.kt",
"src/main/java/org/oppia/android/app/parser/StringToFractionParser.kt",
Expand Down Expand Up @@ -168,9 +172,6 @@ VIEW_MODELS = [
"src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedItemViewModel.kt",
"src/main/java/org/oppia/android/app/home/recentlyplayed/SectionTitleViewModel.kt",
"src/main/java/org/oppia/android/app/home/topiclist/AllTopicsViewModel.kt",
"src/main/java/org/oppia/android/app/home/topiclist/PromotedStoryListViewModel.kt",
"src/main/java/org/oppia/android/app/home/topiclist/PromotedStoryViewModel.kt",
"src/main/java/org/oppia/android/app/home/topiclist/TopicSummaryViewModel.kt",
"src/main/java/org/oppia/android/app/home/UserAppHistoryViewModel.kt",
"src/main/java/org/oppia/android/app/home/WelcomeViewModel.kt",
"src/main/java/org/oppia/android/app/onboarding/OnboardingSlideFinalViewModel.kt",
Expand Down Expand Up @@ -312,6 +313,7 @@ VIEWS = [
"src/main/java/org/oppia/android/app/customview/interaction/NumericInputInteractionView.kt",
"src/main/java/org/oppia/android/app/customview/interaction/TextInputInteractionView.kt",
"src/main/java/org/oppia/android/app/customview/interaction/RatioInputInteractionView.kt",
"src/main/java/org/oppia/android/app/home/promotedlist/PromotedStoryListView.kt",
"src/main/java/org/oppia/android/app/player/state/DragDropSortInteractionView.kt",
"src/main/java/org/oppia/android/app/player/state/ImageRegionSelectionInteractionView.kt",
"src/main/java/org/oppia/android/app/player/state/SelectionInteractionView.kt",
Expand Down Expand Up @@ -405,6 +407,8 @@ in order to keep Gradle building.
""",
) for file in BINDING_ADAPTERS_WITH_RESOURCE_IMPORTS]

SNAP_HELPER = ["src/main/java/org/oppia/android/app/recyclerview/StartSnapHelper.kt"]

"""
Files to be excluded from the source list for the app library. This list includes all the files
built by the following libraries:
Expand All @@ -415,7 +419,7 @@ built by the following libraries:
- binding_adapters
"""

EXCLUDED_APP_LIB_FILES = VIEW_MODELS + VIEW_MODELS_WITH_RESOURCE_IMPORTS + VIEWS + VIEWS_WITH_RESOURCE_IMPORTS + BINDING_ADAPTERS + BINDING_ADAPTERS_WITH_RESOURCE_IMPORTS + LISTENERS + ANNOTATIONS
EXCLUDED_APP_LIB_FILES = VIEW_MODELS + VIEW_MODELS_WITH_RESOURCE_IMPORTS + VIEWS + VIEWS_WITH_RESOURCE_IMPORTS + BINDING_ADAPTERS + BINDING_ADAPTERS_WITH_RESOURCE_IMPORTS + LISTENERS + ANNOTATIONS + SNAP_HELPER

"""
Files to be built by the app library. All of these files are assumed to have resource imports and
Expand Down Expand Up @@ -530,6 +534,7 @@ kt_android_library(
":listeners",
":resources",
":view_models",
":snap_helper",
"//model",
"@circularimageview//circularimageview:circular_image_view",
artifact("androidx.appcompat:appcompat"),
Expand Down Expand Up @@ -572,6 +577,14 @@ kt_android_library(
],
)

# Library for snap helper used to build views.
kt_android_library(
name = "snap_helper",
srcs = SNAP_HELPER,
custom_package = "org.oppia.android.app.recyclerview",
deps = [artifact("androidx.recyclerview:recyclerview:1.0.0"),],
)

# TODO(#1639): Translate binding adapters back to Kotlin post-Bazel modularization.
# Library for all custom data-binding adapters under org/oppia/android/app/databinding.
android_library(
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
<activity
android:name=".app.testing.TestFontScaleConfigurationUtilActivity"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity android:name=".app.testing.HomeFragmentTestActivity" />
<activity android:name=".app.testing.HomeInjectionActivity" />
<activity android:name=".app.testing.HtmlParserTestActivity" />
<activity android:name=".app.testing.HomeTestActivity" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import org.oppia.android.app.testing.ConceptCardFragmentTestActivity
import org.oppia.android.app.testing.DragDropTestActivity
import org.oppia.android.app.testing.ExplorationInjectionActivity
import org.oppia.android.app.testing.ExplorationTestActivity
import org.oppia.android.app.testing.HomeFragmentTestActivity
import org.oppia.android.app.testing.HomeInjectionActivity
import org.oppia.android.app.testing.HomeTestActivity
import org.oppia.android.app.testing.HtmlParserTestActivity
Expand Down Expand Up @@ -90,6 +91,7 @@ interface ActivityComponent {
fun inject(testFontScaleConfigurationUtilActivity: TestFontScaleConfigurationUtilActivity)
fun inject(helpActivity: HelpActivity)
fun inject(homeActivity: HomeActivity)
fun inject(homeFragmentTestActivity: HomeFragmentTestActivity)
fun inject(homeInjectionActivity: HomeInjectionActivity)
fun inject(homeTestActivity: HomeTestActivity)
fun inject(htmlParserTestActivity: HtmlParserTestActivity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
public final class ViewBindingAdapters {

/**
* BindingAdapter to set the height of a View.
* BindingAdapter to set the height of a View. If this value is calculated in data fetching, the
* layout will require a default value since binding adapters aren't called until after initial
* view measurements and layouts are formatted.
*/
@BindingAdapter("android:layout_height")
public static void setLayoutHeight(@NonNull View view, float height) {
Expand All @@ -21,6 +23,18 @@ public static void setLayoutHeight(@NonNull View view, float height) {
view.setLayoutParams(layoutParams);
}

/**
* BindingAdapter to set the width of a View. If this value is calculated in data fetching, the
* layout will require a default value since binding adapters aren't called until after initial
* view measurements and layouts are formatted.
*/
@BindingAdapter("android:layout_width")
public static void setLayoutWidth(@NonNull View view, float width) {
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
layoutParams.width = (int) width;
view.setLayoutParams(layoutParams);
}

@BindingAdapter(
value = {
"app:isRotationAnimationClockwise",
Expand Down
27 changes: 26 additions & 1 deletion app/src/main/java/org/oppia/android/app/home/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ import org.oppia.android.app.activity.InjectableAppCompatActivity
import org.oppia.android.app.drawer.ExitProfileDialogFragment
import org.oppia.android.app.drawer.KEY_NAVIGATION_PROFILE_ID
import org.oppia.android.app.drawer.TAG_SWITCH_PROFILE_DIALOG
import org.oppia.android.app.home.recentlyplayed.RecentlyPlayedActivity
import org.oppia.android.app.topic.TopicActivity
import javax.inject.Inject

/** The central activity for all users entering the app. */
class HomeActivity : InjectableAppCompatActivity(), RouteToTopicListener {
class HomeActivity :
InjectableAppCompatActivity(),
RouteToTopicListener,
RouteToTopicPlayStoryListener,
RouteToRecentlyPlayedListener {
@Inject
lateinit var homeActivityPresenter: HomeActivityPresenter
private var internalProfileId: Int = -1
Expand Down Expand Up @@ -47,4 +52,24 @@ class HomeActivity : InjectableAppCompatActivity(), RouteToTopicListener {
.newInstance(isFromNavigationDrawer = false)
dialogFragment.showNow(supportFragmentManager, TAG_SWITCH_PROFILE_DIALOG)
}

override fun routeToTopicPlayStory(internalProfileId: Int, topicId: String, storyId: String) {
startActivity(
TopicActivity.createTopicPlayStoryActivityIntent(
this,
internalProfileId,
topicId,
storyId
)
)
}

override fun routeToRecentlyPlayed() {
startActivity(
RecentlyPlayedActivity.createRecentlyPlayedActivityIntent(
this,
internalProfileId
)
)
}
}
Loading