diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 3618a9bbbfe..c86ff811456 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -64,7 +64,7 @@
-
+
diff --git a/app/src/main/java/org/oppia/app/activity/ActivityComponent.kt b/app/src/main/java/org/oppia/app/activity/ActivityComponent.kt
index 7cf88bd3dcd..8eeac18d9bb 100644
--- a/app/src/main/java/org/oppia/app/activity/ActivityComponent.kt
+++ b/app/src/main/java/org/oppia/app/activity/ActivityComponent.kt
@@ -21,7 +21,7 @@ import org.oppia.app.testing.HtmlParserTestActivity
import org.oppia.app.testing.TopicTestActivity
import org.oppia.app.testing.TopicTestActivityForStory
import org.oppia.app.topic.TopicActivity
-import org.oppia.app.topic.conceptcard.testing.ConceptCardFragmentTestActivity
+import org.oppia.app.testing.ConceptCardFragmentTestActivity
import org.oppia.app.topic.questionplayer.QuestionPlayerActivity
import javax.inject.Provider
diff --git a/app/src/main/java/org/oppia/app/topic/conceptcard/testing/ConceptCardFragmentTestActivity.kt b/app/src/main/java/org/oppia/app/testing/ConceptCardFragmentTestActivity.kt
similarity index 51%
rename from app/src/main/java/org/oppia/app/topic/conceptcard/testing/ConceptCardFragmentTestActivity.kt
rename to app/src/main/java/org/oppia/app/testing/ConceptCardFragmentTestActivity.kt
index 24b6055970c..244d4e32e53 100644
--- a/app/src/main/java/org/oppia/app/topic/conceptcard/testing/ConceptCardFragmentTestActivity.kt
+++ b/app/src/main/java/org/oppia/app/testing/ConceptCardFragmentTestActivity.kt
@@ -1,11 +1,13 @@
-package org.oppia.app.topic.conceptcard.testing
+package org.oppia.app.testing
import android.os.Bundle
import org.oppia.app.activity.InjectableAppCompatActivity
+import org.oppia.app.topic.conceptcard.ConceptCardFragment
+import org.oppia.app.topic.conceptcard.ConceptCardListener
import javax.inject.Inject
/** Test Activity used for testing ConceptCardFragment */
-class ConceptCardFragmentTestActivity : InjectableAppCompatActivity() {
+class ConceptCardFragmentTestActivity : InjectableAppCompatActivity(), ConceptCardListener {
@Inject lateinit var conceptCardFragmentTestActivityController: ConceptCardFragmentTestActivityPresenter
@@ -14,4 +16,16 @@ class ConceptCardFragmentTestActivity : InjectableAppCompatActivity() {
activityComponent.inject(this)
conceptCardFragmentTestActivityController.handleOnCreate()
}
+
+ override fun dismiss() {
+ getConceptCardFragment()?.dismiss()
+ }
+
+ private fun getConceptCardFragment(): ConceptCardFragment? {
+ return supportFragmentManager.findFragmentByTag(TAG_CONCEPT_CARD_DIALOG) as ConceptCardFragment?
+ }
+
+ companion object {
+ internal const val TAG_CONCEPT_CARD_DIALOG = "CONCEPT_CARD_DIALOG"
+ }
}
diff --git a/app/src/main/java/org/oppia/app/topic/conceptcard/testing/ConceptCardFragmentTestActivityPresenter.kt b/app/src/main/java/org/oppia/app/testing/ConceptCardFragmentTestActivityPresenter.kt
similarity index 74%
rename from app/src/main/java/org/oppia/app/topic/conceptcard/testing/ConceptCardFragmentTestActivityPresenter.kt
rename to app/src/main/java/org/oppia/app/testing/ConceptCardFragmentTestActivityPresenter.kt
index 68d16f32bf4..9dacd589cf9 100644
--- a/app/src/main/java/org/oppia/app/topic/conceptcard/testing/ConceptCardFragmentTestActivityPresenter.kt
+++ b/app/src/main/java/org/oppia/app/testing/ConceptCardFragmentTestActivityPresenter.kt
@@ -1,25 +1,24 @@
-package org.oppia.app.topic.conceptcard.testing
+package org.oppia.app.testing
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.concept_card_fragment_test_activity.*
import org.oppia.app.R
+import org.oppia.app.testing.ConceptCardFragmentTestActivity.Companion.TAG_CONCEPT_CARD_DIALOG
import org.oppia.app.topic.conceptcard.ConceptCardFragment
+import org.oppia.domain.topic.TEST_SKILL_ID_0
import org.oppia.domain.topic.TEST_SKILL_ID_1
-import org.oppia.domain.topic.TEST_SKILL_ID_2
import javax.inject.Inject
-private const val TAG_CONCEPT_CARD_DIALOG = "CONCEPT_CARD_DIALOG"
-
/** The presenter for [ConceptCardFragmentTestActivity] */
class ConceptCardFragmentTestActivityPresenter @Inject constructor(private val activity: AppCompatActivity) {
fun handleOnCreate() {
activity.setContentView(R.layout.concept_card_fragment_test_activity)
- activity.open_dialog_1.setOnClickListener {
- val frag = ConceptCardFragment.newInstance(TEST_SKILL_ID_1)
+ activity.open_dialog_0.setOnClickListener {
+ val frag = ConceptCardFragment.newInstance(TEST_SKILL_ID_0)
frag.showNow(activity.supportFragmentManager, TAG_CONCEPT_CARD_DIALOG)
}
- activity.open_dialog_2.setOnClickListener {
- val frag = ConceptCardFragment.newInstance(TEST_SKILL_ID_2)
+ activity.open_dialog_1.setOnClickListener {
+ val frag = ConceptCardFragment.newInstance(TEST_SKILL_ID_1)
frag.showNow(activity.supportFragmentManager, TAG_CONCEPT_CARD_DIALOG)
}
}
diff --git a/app/src/main/java/org/oppia/app/testing/TopicTestActivity.kt b/app/src/main/java/org/oppia/app/testing/TopicTestActivity.kt
index cd5cf99dd53..4a076283dd5 100644
--- a/app/src/main/java/org/oppia/app/testing/TopicTestActivity.kt
+++ b/app/src/main/java/org/oppia/app/testing/TopicTestActivity.kt
@@ -14,13 +14,14 @@ import org.oppia.app.topic.TopicActivityPresenter
import org.oppia.app.topic.TopicFragment
import org.oppia.app.topic.TopicTab
import org.oppia.app.topic.conceptcard.ConceptCardFragment
+import org.oppia.app.topic.conceptcard.ConceptCardListener
import org.oppia.app.topic.questionplayer.QuestionPlayerActivity
import org.oppia.domain.topic.TEST_TOPIC_ID_0
import javax.inject.Inject
/** The activity for testing [TopicFragment]. */
class TopicTestActivity : InjectableAppCompatActivity(), RouteToQuestionPlayerListener, RouteToConceptCardListener,
- RouteToTopicPlayListener, RouteToStoryListener, RouteToExplorationListener {
+ RouteToTopicPlayListener, RouteToStoryListener, RouteToExplorationListener, ConceptCardListener {
@Inject
lateinit var topicActivityPresenter: TopicActivityPresenter
@@ -50,6 +51,10 @@ class TopicTestActivity : InjectableAppCompatActivity(), RouteToQuestionPlayerLi
}
}
+ override fun dismiss() {
+ getConceptCardFragment()?.dismiss()
+ }
+
override fun routeToExploration(explorationId: String) {
startActivity(ExplorationActivity.createExplorationActivityIntent(this, explorationId))
}
diff --git a/app/src/main/java/org/oppia/app/testing/TopicTestActivityForStory.kt b/app/src/main/java/org/oppia/app/testing/TopicTestActivityForStory.kt
index 966aa4ec590..8ddecadc5a6 100644
--- a/app/src/main/java/org/oppia/app/testing/TopicTestActivityForStory.kt
+++ b/app/src/main/java/org/oppia/app/testing/TopicTestActivityForStory.kt
@@ -14,6 +14,7 @@ import org.oppia.app.topic.TopicActivityPresenter
import org.oppia.app.topic.TopicFragment
import org.oppia.app.topic.TopicTab
import org.oppia.app.topic.conceptcard.ConceptCardFragment
+import org.oppia.app.topic.conceptcard.ConceptCardListener
import org.oppia.app.topic.questionplayer.QuestionPlayerActivity
import org.oppia.domain.topic.TEST_STORY_ID_1
import org.oppia.domain.topic.TEST_TOPIC_ID_0
@@ -21,8 +22,8 @@ import javax.inject.Inject
/** The test activity for [TopicFragment] to test displaying story by storyId. */
class TopicTestActivityForStory : InjectableAppCompatActivity(), RouteToQuestionPlayerListener,
- RouteToConceptCardListener,
- RouteToTopicPlayListener, RouteToStoryListener, RouteToExplorationListener {
+ RouteToConceptCardListener, RouteToTopicPlayListener, RouteToStoryListener,
+ RouteToExplorationListener, ConceptCardListener {
@Inject
lateinit var topicActivityPresenter: TopicActivityPresenter
@@ -52,6 +53,10 @@ class TopicTestActivityForStory : InjectableAppCompatActivity(), RouteToQuestion
}
}
+ override fun dismiss() {
+ getConceptCardFragment()?.dismiss()
+ }
+
override fun routeToExploration(explorationId: String) {
startActivity(ExplorationActivity.createExplorationActivityIntent(this, explorationId))
}
diff --git a/app/src/main/java/org/oppia/app/topic/TopicActivity.kt b/app/src/main/java/org/oppia/app/topic/TopicActivity.kt
index f296540852a..a3516c769f4 100644
--- a/app/src/main/java/org/oppia/app/topic/TopicActivity.kt
+++ b/app/src/main/java/org/oppia/app/topic/TopicActivity.kt
@@ -8,6 +8,7 @@ import org.oppia.app.home.RouteToExplorationListener
import org.oppia.app.player.exploration.ExplorationActivity
import org.oppia.app.story.StoryActivity
import org.oppia.app.topic.conceptcard.ConceptCardFragment
+import org.oppia.app.topic.conceptcard.ConceptCardListener
import org.oppia.app.topic.questionplayer.QuestionPlayerActivity
import javax.inject.Inject
@@ -15,7 +16,7 @@ const val TOPIC_ACTIVITY_TOPIC_ID_ARGUMENT_KEY = "TopicActivity.topic_id"
/** The activity for displaying [TopicFragment]. */
class TopicActivity : InjectableAppCompatActivity(), RouteToQuestionPlayerListener, RouteToConceptCardListener,
- RouteToTopicPlayListener, RouteToStoryListener, RouteToExplorationListener {
+ RouteToTopicPlayListener, RouteToStoryListener, RouteToExplorationListener, ConceptCardListener {
private lateinit var topicId: String
private lateinit var storyId: String
@Inject
@@ -52,6 +53,10 @@ class TopicActivity : InjectableAppCompatActivity(), RouteToQuestionPlayerListen
}
}
+ override fun dismiss() {
+ getConceptCardFragment()?.dismiss()
+ }
+
override fun routeToExploration(explorationId: String) {
startActivity(ExplorationActivity.createExplorationActivityIntent(this, explorationId))
}
diff --git a/app/src/main/java/org/oppia/app/topic/conceptcard/ConceptCardFragment.kt b/app/src/main/java/org/oppia/app/topic/conceptcard/ConceptCardFragment.kt
index a47cdddcc0d..b88f12c2da3 100644
--- a/app/src/main/java/org/oppia/app/topic/conceptcard/ConceptCardFragment.kt
+++ b/app/src/main/java/org/oppia/app/topic/conceptcard/ConceptCardFragment.kt
@@ -29,7 +29,7 @@ class ConceptCardFragment : InjectableDialogFragment() {
}
}
- @Inject lateinit var conceptCardPresenter: ConceptCardPresenter
+ @Inject lateinit var conceptCardFragmentPresenter: ConceptCardFragmentPresenter
override fun onAttach(context: Context) {
super.onAttach(context)
@@ -45,7 +45,7 @@ class ConceptCardFragment : InjectableDialogFragment() {
super.onCreateView(inflater, container, savedInstanceState)
val args = checkNotNull(arguments) { "Expected arguments to be passed to ConceptCardFragment" }
val skillId = checkNotNull(args.getString(KEY_SKILL_ID)) { "Expected skillId to be passed to ConceptCardFragment" }
- return conceptCardPresenter.handleCreateView(inflater, container, skillId)
+ return conceptCardFragmentPresenter.handleCreateView(inflater, container, skillId)
}
override fun onStart() {
diff --git a/app/src/main/java/org/oppia/app/topic/conceptcard/ConceptCardPresenter.kt b/app/src/main/java/org/oppia/app/topic/conceptcard/ConceptCardFragmentPresenter.kt
similarity index 58%
rename from app/src/main/java/org/oppia/app/topic/conceptcard/ConceptCardPresenter.kt
rename to app/src/main/java/org/oppia/app/topic/conceptcard/ConceptCardFragmentPresenter.kt
index 5284ded98b4..a0868ded824 100644
--- a/app/src/main/java/org/oppia/app/topic/conceptcard/ConceptCardPresenter.kt
+++ b/app/src/main/java/org/oppia/app/topic/conceptcard/ConceptCardFragmentPresenter.kt
@@ -3,35 +3,35 @@ package org.oppia.app.topic.conceptcard
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import org.oppia.app.R
-import org.oppia.app.databinding.ConceptCardExampleViewBinding
import org.oppia.app.databinding.ConceptCardFragmentBinding
import org.oppia.app.fragment.FragmentScope
-import org.oppia.app.model.SubtitledHtml
-import org.oppia.app.recyclerview.BindableAdapter
import org.oppia.app.viewmodel.ViewModelProvider
import javax.inject.Inject
/** Presenter for [ConceptCardFragment], sets up bindings from ViewModel */
@FragmentScope
-class ConceptCardPresenter @Inject constructor(
+class ConceptCardFragmentPresenter @Inject constructor(
private val fragment: Fragment,
private val viewModelProvider: ViewModelProvider
-){
+) {
+ private lateinit var skillId: String
- /** Sets up data binding and adapter for RecyclerView */
- fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?, skillId: String): View? {
- val viewModel = getConceptCardViewModel()
- viewModel.setSkillId(skillId)
+ /**
+ * Sets up data binding and toolbar.
+ * Host activity must inherit ConceptCardListener to dismiss this fragment.
+ */
+ fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?, id: String): View? {
val binding = ConceptCardFragmentBinding.inflate(inflater, container, /* attachToRoot= */ false)
+ val viewModel = getConceptCardViewModel()
+
+ skillId = id
+ viewModel.setSkillIdAndBinding(skillId, binding)
+
binding.conceptCardToolbar.setNavigationIcon(R.drawable.ic_close_white_24dp)
binding.conceptCardToolbar.setNavigationOnClickListener {
- (fragment as? DialogFragment)?.dismiss()
- }
- binding.workedExamples.apply {
- adapter = createRecyclerViewAdapter()
+ (fragment.requireActivity() as? ConceptCardListener)?.dismiss()
}
binding.let {
@@ -44,13 +44,4 @@ class ConceptCardPresenter @Inject constructor(
private fun getConceptCardViewModel(): ConceptCardViewModel {
return viewModelProvider.getForFragment(fragment, ConceptCardViewModel::class.java)
}
-
- private fun createRecyclerViewAdapter(): BindableAdapter {
- return BindableAdapter.Builder
- .newBuilder()
- .registerViewDataBinderWithSameModelType(
- inflateDataBinding = ConceptCardExampleViewBinding::inflate,
- setViewModel = ConceptCardExampleViewBinding::setSubtitledHtml)
- .build()
- }
}
diff --git a/app/src/main/java/org/oppia/app/topic/conceptcard/ConceptCardListener.kt b/app/src/main/java/org/oppia/app/topic/conceptcard/ConceptCardListener.kt
new file mode 100644
index 00000000000..7901f4006e7
--- /dev/null
+++ b/app/src/main/java/org/oppia/app/topic/conceptcard/ConceptCardListener.kt
@@ -0,0 +1,7 @@
+package org.oppia.app.topic.conceptcard
+
+/** Allows parent activity to dismiss the [ConceptCardFragment] */
+interface ConceptCardListener {
+ /** Called when the concept card dialog should be dismissed. */
+ fun dismiss()
+}
diff --git a/app/src/main/java/org/oppia/app/topic/conceptcard/ConceptCardViewModel.kt b/app/src/main/java/org/oppia/app/topic/conceptcard/ConceptCardViewModel.kt
index 73a3822f1d3..a928b6bd5cd 100644
--- a/app/src/main/java/org/oppia/app/topic/conceptcard/ConceptCardViewModel.kt
+++ b/app/src/main/java/org/oppia/app/topic/conceptcard/ConceptCardViewModel.kt
@@ -1,38 +1,42 @@
package org.oppia.app.topic.conceptcard
+import android.widget.TextView
import androidx.lifecycle.LiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.ViewModel
+import org.oppia.app.databinding.ConceptCardFragmentBinding
import org.oppia.app.fragment.FragmentScope
import org.oppia.app.model.ConceptCard
-import org.oppia.app.model.SubtitledHtml
import org.oppia.domain.topic.TopicController
import org.oppia.util.data.AsyncResult
import org.oppia.util.logging.Logger
+import org.oppia.util.parser.ConceptCardHtmlParserEntityType
+import org.oppia.util.parser.HtmlParser
import javax.inject.Inject
/** [ViewModel] for concept card, providing rich text and worked examples */
@FragmentScope
class ConceptCardViewModel @Inject constructor(
private val topicController: TopicController,
- private val logger: Logger
+ private val logger: Logger,
+ private val htmlParserFactory: HtmlParser.Factory,
+ @ConceptCardHtmlParserEntityType private val entityType: String
) : ViewModel() {
-
private lateinit var skillId: String
+ private lateinit var binding: ConceptCardFragmentBinding
- /** Live Data for concept card explanation */
val conceptCardLiveData: LiveData by lazy {
processConceptCardLiveData()
}
- /** Live Data for concept card worked examples. */
- val workedExamplesLiveData: LiveData> by lazy {
- processWorkedExamplesLiveData()
+ val explanationLiveData: LiveData by lazy {
+ processExplanationLiveData()
}
- /** Sets the value of skillId. Must be called before setting ViewModel to binding. */
- fun setSkillId(id: String) {
+ /** Sets the value of skillId and binding. Must be called before setting ViewModel to binding */
+ fun setSkillIdAndBinding(id: String, binding: ConceptCardFragmentBinding) {
skillId = id
+ this.binding = binding
}
private val conceptCardResultLiveData: LiveData> by lazy {
@@ -43,21 +47,23 @@ class ConceptCardViewModel @Inject constructor(
return Transformations.map(conceptCardResultLiveData, ::processConceptCardResult)
}
- private fun processWorkedExamplesLiveData(): LiveData> {
- return Transformations.map(conceptCardResultLiveData, ::processConceptCardWorkExamples)
+ private fun processExplanationLiveData(): LiveData {
+ return Transformations.map(conceptCardResultLiveData, ::processExplanationResult)
}
private fun processConceptCardResult(conceptCardResult: AsyncResult): ConceptCard {
if (conceptCardResult.isFailure()) {
- logger.e("ConceptCardFragment", "Failed to retrieve Concept Card: " + conceptCardResult.getErrorOrNull())
+ logger.e("ConceptCardFragment", "Failed to retrieve Concept Card", conceptCardResult.getErrorOrNull()!!)
}
return conceptCardResult.getOrDefault(ConceptCard.getDefaultInstance())
}
- private fun processConceptCardWorkExamples(conceptCardResult: AsyncResult): List {
+ private fun processExplanationResult(conceptCardResult: AsyncResult): CharSequence {
if (conceptCardResult.isFailure()) {
- logger.e("ConceptCardFragment", "Failed to retrieve Concept Card: " + conceptCardResult.getErrorOrNull())
+ logger.e("ConceptCardFragment", "Failed to retrieve Concept Card", conceptCardResult.getErrorOrNull()!!)
}
- return conceptCardResult.getOrDefault(ConceptCard.getDefaultInstance()).workedExampleList
+ val conceptCard = conceptCardResult.getOrDefault(ConceptCard.getDefaultInstance())
+ return htmlParserFactory.create(entityType, skillId)
+ .parseOppiaHtml(conceptCard.explanation.html, binding.conceptCardExplanationText)
}
}
diff --git a/app/src/main/res/layout/concept_card_example_view.xml b/app/src/main/res/layout/concept_card_example_view.xml
deleted file mode 100644
index 89f420b19ef..00000000000
--- a/app/src/main/res/layout/concept_card_example_view.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/concept_card_fragment.xml b/app/src/main/res/layout/concept_card_fragment.xml
index fe81eacd92b..ac5412a2955 100644
--- a/app/src/main/res/layout/concept_card_fragment.xml
+++ b/app/src/main/res/layout/concept_card_fragment.xml
@@ -16,36 +16,54 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorConceptToolbarBackground"
+ app:title="@string/concept_card_toolbar_title"
+ app:titleTextColor="@color/white"
app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintLeft_toLeftOf="parent"
- app:layout_constraintRight_toRightOf="parent" />
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent" />
+
+ app:layout_constraintTop_toTopOf="@+id/toolbar_shadow_view"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent">
+ android:orientation="vertical">
-
+
+ android:layout_marginTop="28dp"
+ android:layout_marginStart="40dp"
+ android:layout_marginEnd="40dp"
+ android:text="@{viewModel.explanationLiveData}"
+ android:textSize="16sp"
+ android:textColor="@color/oppiaPrimaryText"
+ android:fontFamily="sans-serif" />
+
diff --git a/app/src/main/res/layout/concept_card_fragment_test_activity.xml b/app/src/main/res/layout/concept_card_fragment_test_activity.xml
index df200985f2f..245c1497c66 100644
--- a/app/src/main/res/layout/concept_card_fragment_test_activity.xml
+++ b/app/src/main/res/layout/concept_card_fragment_test_activity.xml
@@ -4,12 +4,12 @@
xmlns:android="http://schemas.android.com/apk/res/android">
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index fddba8bf600..9da841898e9 100755
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -13,6 +13,7 @@
Currently on Cellular Data
Streaming audio may use a lot of cellular data.
Don\'t show this message again
+ Concept Card
Leave to Topic Page?
Your progress will be saved.
Cancel
diff --git a/app/src/sharedTest/java/org/oppia/app/parser/RichTextViewMatcher.kt b/app/src/sharedTest/java/org/oppia/app/parser/RichTextViewMatcher.kt
new file mode 100644
index 00000000000..89e814182ad
--- /dev/null
+++ b/app/src/sharedTest/java/org/oppia/app/parser/RichTextViewMatcher.kt
@@ -0,0 +1,24 @@
+package org.oppia.app.parser
+
+import android.text.style.CharacterStyle
+import android.view.View
+import android.widget.TextView
+import androidx.core.text.toSpannable
+import org.hamcrest.Description
+import org.hamcrest.Matcher
+import org.hamcrest.TypeSafeMatcher
+
+class RichTextViewMatcher {
+ companion object {
+ fun containsRichText(): Matcher {
+ return object : TypeSafeMatcher() {
+ override fun describeTo(description: Description) {
+ description.appendText("Checks if view contains rich text")
+ }
+ override fun matchesSafely(view: View): Boolean {
+ return view is TextView && view.text.toSpannable().getSpans(0, view.text.length, CharacterStyle::class.java).isNotEmpty()
+ }
+ }
+ }
+ }
+}
diff --git a/app/src/sharedTest/java/org/oppia/app/topic/conceptcard/ConceptCardFragmentTest.kt b/app/src/sharedTest/java/org/oppia/app/topic/conceptcard/ConceptCardFragmentTest.kt
index 2c67084a758..4ae04967d23 100644
--- a/app/src/sharedTest/java/org/oppia/app/topic/conceptcard/ConceptCardFragmentTest.kt
+++ b/app/src/sharedTest/java/org/oppia/app/topic/conceptcard/ConceptCardFragmentTest.kt
@@ -7,7 +7,6 @@ import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
-import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -16,12 +15,14 @@ import dagger.Component
import dagger.Module
import dagger.Provides
import kotlinx.coroutines.CoroutineDispatcher
+import org.hamcrest.Matchers.not
import org.junit.Before
import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.app.R
-import org.oppia.app.topic.conceptcard.testing.ConceptCardFragmentTestActivity
+import org.oppia.app.parser.RichTextViewMatcher.Companion.containsRichText
+import org.oppia.app.testing.ConceptCardFragmentTestActivity
import org.oppia.util.threading.BackgroundDispatcher
import org.oppia.util.threading.BlockingDispatcher
import javax.inject.Singleton
@@ -38,40 +39,32 @@ class ConceptCardFragmentTest {
}
@Test
- fun testConceptCardFragment_openDialogFragmentWithSkill1_explanationIsDisplayed() {
- onView(withId(R.id.open_dialog_1)).perform(click())
- onView(withId(R.id.explanation)).check(matches(withText("Explanation with rich text.")))
+ fun testConceptCardFragment_openDialogFragment0_checkSkillAndExplanationAreDisplayedWithoutRichText() {
+ onView(withId(R.id.open_dialog_0)).perform(click())
+ onView(withId(R.id.concept_card_heading_text)).check(matches(withText("An important skill")))
+ onView(withId(R.id.concept_card_explanation_text)).check(matches(withText("Hello. Welcome to Oppia.")))
+ onView(withId(R.id.concept_card_explanation_text)).check(matches(not(containsRichText())))
}
@Test
- fun testConceptCardFragment_openDialogFragmentWithSkill1_workedExamplesAreDisplayed() {
+ fun testConceptCardFragment_openDialogFragment1_checkSkillAndExplanationAreDisplayedWithRichText() {
onView(withId(R.id.open_dialog_1)).perform(click())
- onView(withText("Worked example with rich text.")).check(matches(isDisplayed()))
- }
-
- @Test
- fun testConceptCardFragment_openDialogFragmentWithSkill2_explanationIsDisplayed() {
- onView(withId(R.id.open_dialog_2)).perform(click())
- onView(withId(R.id.explanation)).check(matches(withText("Explanation without rich text.")))
- }
-
- @Test
- fun testConceptCardFragment_openDialogFragmentWithSkill2_workedExamplesAreDisplayed() {
- onView(withId(R.id.open_dialog_2)).perform(click())
- onView(withText("Worked example without rich text.")).check(matches(isDisplayed()))
- onView(withText("Second worked example.")).check(matches(isDisplayed()))
+ onView(withId(R.id.concept_card_heading_text)).check(matches(withText("Another important skill")))
+ onView(withId(R.id.concept_card_explanation_text)).check(matches(withText("Explanation with rich text.")))
+ onView(withId(R.id.concept_card_explanation_text)).check(matches(containsRichText()))
}
@Test
@Ignore("Landscape not properly supported") // TODO(#56): Reenable once landscape is supported.
fun testConceptCardFragment_openDialogFragmentWithSkill2_afterConfigurationChange_workedExamplesAreDisplayed() {
- onView(withId(R.id.open_dialog_2)).perform(click())
+ onView(withId(R.id.open_dialog_1)).perform(click())
activityScenario.onActivity { activity ->
activity.requestedOrientation = Configuration.ORIENTATION_LANDSCAPE
}
activityScenario.recreate()
- onView(withText("Worked example without rich text.")).check(matches(isDisplayed()))
- onView(withText("Second worked example.")).check(matches(isDisplayed()))
+ onView(withId(R.id.concept_card_heading_text)).check(matches(withText("Another important skill")))
+ onView(withId(R.id.concept_card_explanation_text)).check(matches(withText("Explanation with rich text.")))
+ onView(withId(R.id.concept_card_explanation_text)).check(matches(containsRichText()))
}
@Module
diff --git a/app/src/sharedTest/java/org/oppia/app/topic/review/TopicReviewFragmentTest.kt b/app/src/sharedTest/java/org/oppia/app/topic/review/TopicReviewFragmentTest.kt
index beebd3e6bfc..35bae61c25b 100644
--- a/app/src/sharedTest/java/org/oppia/app/topic/review/TopicReviewFragmentTest.kt
+++ b/app/src/sharedTest/java/org/oppia/app/topic/review/TopicReviewFragmentTest.kt
@@ -3,6 +3,10 @@ package org.oppia.app.topic.review
import android.app.Application
import android.content.Context
import android.content.res.Configuration
+import android.text.style.CharacterStyle
+import android.view.View
+import android.widget.TextView
+import androidx.core.text.toSpannable
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
@@ -18,11 +22,14 @@ import dagger.Component
import dagger.Module
import dagger.Provides
import kotlinx.coroutines.CoroutineDispatcher
+import org.hamcrest.Description
+import org.hamcrest.TypeSafeMatcher
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.app.R
+import org.oppia.app.parser.RichTextViewMatcher.Companion.containsRichText
import org.oppia.app.recyclerview.RecyclerViewMatcher.Companion.atPosition
import org.oppia.app.topic.TopicActivity
import org.oppia.app.topic.conceptcard.ConceptCardFragment
@@ -60,20 +67,8 @@ class TopicReviewFragmentTest {
fun testTopicReviewFragment_loadFragment_selectReviewSkill_conceptCardDisplaysCorrectExplanation() {
ActivityScenario.launch(TopicActivity::class.java).use {
onView(atPosition(R.id.review_skill_recycler_view, 1)).perform(click())
- onView(withId(R.id.explanation)).check(matches(withText("Explanation with rich text.")))
- }
- }
-
- @Test
- fun testTopicReviewFragment_loadFragment_selectReviewSkill_conceptCardDisplaysCorrectWorkedExamples() {
- ActivityScenario.launch(TopicActivity::class.java).use {
- onView(atPosition(R.id.review_skill_recycler_view, 1)).perform(click())
- onView(
- atPosition(
- R.id.worked_examples,
- 0
- )
- ).check(matches(hasDescendant(withText("Worked example with rich text."))))
+ onView(withId(R.id.concept_card_explanation_text)).check(matches(withText("Explanation with rich text.")))
+ onView(withId(R.id.concept_card_explanation_text)).check(matches(containsRichText()))
}
}
diff --git a/utility/src/main/java/org/oppia/util/parser/ExplorationHtmlParserEntityType.kt b/utility/src/main/java/org/oppia/util/parser/ExplorationHtmlParserEntityType.kt
index 779fbc5e55e..04622db903e 100644
--- a/utility/src/main/java/org/oppia/util/parser/ExplorationHtmlParserEntityType.kt
+++ b/utility/src/main/java/org/oppia/util/parser/ExplorationHtmlParserEntityType.kt
@@ -5,3 +5,7 @@ import javax.inject.Qualifier
/** Qualifier for injecting the entity type for exploration. */
@Qualifier
annotation class ExplorationHtmlParserEntityType
+
+/** Qualifier for injecting the entity type for concept card. */
+@Qualifier
+annotation class ConceptCardHtmlParserEntityType
diff --git a/utility/src/main/java/org/oppia/util/parser/HtmlParserEntityTypeModule.kt b/utility/src/main/java/org/oppia/util/parser/HtmlParserEntityTypeModule.kt
index bb33a097778..5e6227b89a6 100644
--- a/utility/src/main/java/org/oppia/util/parser/HtmlParserEntityTypeModule.kt
+++ b/utility/src/main/java/org/oppia/util/parser/HtmlParserEntityTypeModule.kt
@@ -11,4 +11,10 @@ class HtmlParserEntityTypeModule {
fun provideExplorationHtmlParserEntityType(): String {
return "exploration"
}
+
+ @Provides
+ @ConceptCardHtmlParserEntityType
+ fun provideConceptCardHtmlParserEntityType(): String {
+ return "skill"
+ }
}