-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* XML files * Basic structure * Review funtional implementation * Test case added * Test case added * Final ui * Nit changes * Configuration change test case added * Removed TopicReviewViewModel * Test cases updated * Nit changes * Glide library added * Nit changes * Test-case changes * Test-case changes * Linked to ConceptCardFragment * ImageBindingAdapter changes * Updated test-cases * Updated test-cases
- Loading branch information
Showing
16 changed files
with
339 additions
and
20 deletions.
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
48 changes: 48 additions & 0 deletions
48
app/src/main/java/org/oppia/app/databinding/ImageViewBindingAdapters.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,48 @@ | ||
package org.oppia.app.databinding | ||
|
||
import android.widget.ImageView | ||
import androidx.annotation.DrawableRes | ||
import androidx.databinding.BindingAdapter | ||
import com.bumptech.glide.request.RequestOptions | ||
import com.bumptech.glide.Glide | ||
import org.oppia.app.R | ||
import org.oppia.app.model.LessonThumbnailGraphic | ||
|
||
/** | ||
* Allows binding drawables to an [ImageView] via "android:src". Source: https://stackoverflow.com/a/35809319/3689782. | ||
*/ | ||
@BindingAdapter("android:src") | ||
fun setImageDrawable(imageView: ImageView, imageUrl: String) { | ||
val requestOptions = RequestOptions().placeholder(R.drawable.review_placeholder) | ||
|
||
Glide.with(imageView.context) | ||
.load(imageUrl) | ||
.apply(requestOptions) | ||
.into(imageView) | ||
} | ||
|
||
/** | ||
* Allows binding drawables to an [ImageView] via "android:src". Source: https://stackoverflow.com/a/35809319/3689782. | ||
*/ | ||
@BindingAdapter("android:src") | ||
fun setImageDrawable(imageView: ImageView, @DrawableRes drawableResourceId: Int) { | ||
imageView.setImageResource(drawableResourceId) | ||
} | ||
|
||
/** | ||
* Binds the specified [LessonThumbnailGraphic] as the source for the [ImageView]. The view should be specified to have | ||
* no width/height (when sized in a constraint layout), and use centerCrop for the image to appear correctly. | ||
*/ | ||
@BindingAdapter("android:src") | ||
fun setImageDrawable(imageView: ImageView, thumbnailGraphic: LessonThumbnailGraphic) { | ||
setImageDrawable(imageView, when (thumbnailGraphic) { | ||
LessonThumbnailGraphic.BAKER -> R.drawable.lesson_thumbnail_graphic_baker | ||
LessonThumbnailGraphic.CHILD_WITH_BOOK -> R.drawable.lesson_thumbnail_graphic_child_with_book | ||
LessonThumbnailGraphic.CHILD_WITH_CUPCAKES -> R.drawable.lesson_thumbnail_graphic_child_with_cupcakes | ||
LessonThumbnailGraphic.CHILD_WITH_FRACTIONS_HOMEWORK -> | ||
R.drawable.lesson_thumbnail_graphic_child_with_fractions_homework | ||
LessonThumbnailGraphic.DUCK_AND_CHICKEN -> R.drawable.lesson_thumbnail_graphic_duck_and_chicken | ||
LessonThumbnailGraphic.PERSON_WITH_PIE_CHART -> R.drawable.lesson_thumbnail_graphic_person_with_pie_chart | ||
else -> R.drawable.lesson_thumbnail_default | ||
}) | ||
} |
6 changes: 6 additions & 0 deletions
6
app/src/main/java/org/oppia/app/topic/RouteToConceptCardListener.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,6 @@ | ||
package org.oppia.app.topic | ||
|
||
/** Listener for when an [TopicActivity] should route to a [ConceptCardFragment]. */ | ||
interface RouteToConceptCardListener { | ||
fun routeToConceptCard(skillId: String) | ||
} |
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
49 changes: 49 additions & 0 deletions
49
app/src/main/java/org/oppia/app/topic/review/ReviewSkillSelectionAdapter.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,49 @@ | ||
package org.oppia.app.topic.review | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.databinding.DataBindingUtil | ||
import androidx.databinding.library.baseAdapters.BR | ||
import androidx.recyclerview.widget.RecyclerView | ||
import org.oppia.app.databinding.TopicReviewSummaryViewBinding | ||
import org.oppia.app.model.SkillSummary | ||
import org.oppia.app.R | ||
|
||
// TODO(#216): Make use of generic data-binding-enabled RecyclerView adapter. | ||
/** Adapter to bind skills to [RecyclerView] inside [TopicReviewFragment]. */ | ||
class ReviewSkillSelectionAdapter(private val reviewSkillSelector: ReviewSkillSelector) : | ||
RecyclerView.Adapter<ReviewSkillSelectionAdapter.SkillViewHolder>() { | ||
|
||
private var skillList: List<SkillSummary> = ArrayList() | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SkillViewHolder { | ||
val skillListItemBinding = DataBindingUtil.inflate<TopicReviewSummaryViewBinding>( | ||
LayoutInflater.from(parent.context), | ||
R.layout.topic_review_summary_view, parent, | ||
/* attachToRoot= */ false | ||
) | ||
return SkillViewHolder(skillListItemBinding) | ||
} | ||
|
||
override fun onBindViewHolder(skillViewHolder: SkillViewHolder, i: Int) { | ||
skillViewHolder.bind(skillList[i], i) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return skillList.size | ||
} | ||
|
||
fun setSkillList(skillList: List<SkillSummary>) { | ||
this.skillList = skillList | ||
notifyDataSetChanged() | ||
} | ||
|
||
inner class SkillViewHolder(val binding: TopicReviewSummaryViewBinding) : RecyclerView.ViewHolder(binding.root) { | ||
internal fun bind(skill: SkillSummary, @Suppress("UNUSED_PARAMETER") position: Int) { | ||
binding.setVariable(BR.skill, skill) | ||
binding.root.setOnClickListener { | ||
reviewSkillSelector.onTopicReviewSummaryClicked(skill) | ||
} | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/org/oppia/app/topic/review/ReviewSkillSelector.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,8 @@ | ||
package org.oppia.app.topic.review | ||
|
||
import org.oppia.app.model.SkillSummary | ||
|
||
/** Listener for when a skill is selected for review. */ | ||
interface ReviewSkillSelector { | ||
fun onTopicReviewSummaryClicked(skillSummary: SkillSummary) | ||
} |
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
9 changes: 9 additions & 0 deletions
9
app/src/main/java/org/oppia/app/topic/review/TopicReviewViewModel.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,9 @@ | ||
package org.oppia.app.topic.review | ||
|
||
import androidx.lifecycle.ViewModel | ||
import org.oppia.app.fragment.FragmentScope | ||
import javax.inject.Inject | ||
|
||
/** [ViewModel] for showing a list of topic review-skills. */ | ||
@FragmentScope | ||
class TopicReviewViewModel @Inject constructor() : ViewModel() |
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> | ||
<solid android:color="@color/colorPrimary" /> | ||
</shape> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<solid | ||
android:color="@color/white"/> | ||
<stroke | ||
android:width="2dp" | ||
android:color="@color/oppiaBrown"/> | ||
<corners | ||
android:radius="8dp"/> | ||
</shape> |
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 |
---|---|---|
@@ -1,18 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
<androidx.constraintlayout.widget.ConstraintLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<FrameLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
<TextView | ||
android:id="@+id/dummy_text_view" | ||
android:layout_width="wrap_content" | ||
android:layout_height="match_parent" | ||
android:background="@color/oppiaBackground"> | ||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/review_skill_recycler_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="This is dummy TextView for testing" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent"/> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
android:padding="16dp"/> | ||
</FrameLayout> | ||
</layout> |
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,48 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
<data> | ||
<variable | ||
name="skill" | ||
type="org.oppia.app.model.SkillSummary"/> | ||
</data> | ||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="180dp" | ||
android:layout_margin="16dp" | ||
android:background="@drawable/topic_review_item_border" | ||
android:clickable="true" | ||
android:focusable="true"> | ||
<ImageView | ||
android:id="@+id/skill_image_view" | ||
android:src="@{skill.thumbnailUrl}" | ||
android:layout_width="0dp" | ||
android:layout_height="105dp" | ||
android:importantForAccessibility="no" | ||
android:scaleType="centerCrop" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent"/> | ||
<View | ||
android:id="@+id/separator_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="2dp" | ||
android:background="@color/oppiaBrown" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/skill_image_view"/> | ||
<TextView | ||
android:id="@+id/skill_name" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:fontFamily="sans-serif-medium" | ||
android:padding="24dp" | ||
android:text="@{skill.description}" | ||
android:textColor="@color/oppiaPrimaryText" | ||
android:textSize="14sp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/separator_view"/> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</layout> |
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.