From 8cdfb3399a0f35f3c05f89643f3cbd8edf5e41ee Mon Sep 17 00:00:00 2001 From: Rajat Talesra Date: Thu, 3 Oct 2019 15:20:32 +0530 Subject: [PATCH 1/6] All xml files for topic-train except layout folder --- app/build.gradle | 1 + .../state_button_primary_background.xml | 9 +++++++ .../state_button_transparent_background.xml | 7 +++++ app/src/main/res/values/colors.xml | 4 +++ app/src/main/res/values/dimens.xml | 1 + app/src/main/res/values/strings.xml | 3 +++ app/src/main/res/values/styles.xml | 27 +++++++++++++++++++ 7 files changed, 52 insertions(+) create mode 100644 app/src/main/res/drawable/state_button_primary_background.xml create mode 100644 app/src/main/res/drawable/state_button_transparent_background.xml diff --git a/app/build.gradle b/app/build.gradle index 22479f62151..5fc0e640fc5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -61,6 +61,7 @@ dependencies { 'androidx.constraintlayout:constraintlayout:1.1.3', 'androidx.core:core-ktx:1.0.2', 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0-alpha03', + 'androidx.recyclerview:recyclerview:1.0.0', 'com.google.dagger:dagger:2.24', "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version", "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.1", diff --git a/app/src/main/res/drawable/state_button_primary_background.xml b/app/src/main/res/drawable/state_button_primary_background.xml new file mode 100644 index 00000000000..c198754b5a8 --- /dev/null +++ b/app/src/main/res/drawable/state_button_primary_background.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/app/src/main/res/drawable/state_button_transparent_background.xml b/app/src/main/res/drawable/state_button_transparent_background.xml new file mode 100644 index 00000000000..96aa2dbe473 --- /dev/null +++ b/app/src/main/res/drawable/state_button_transparent_background.xml @@ -0,0 +1,7 @@ + + + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 1f75fbc6809..75cde50851b 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -9,8 +9,12 @@ #26A69A #2D4A9D + #333333 + #666666 #FFFFFF @color/oppiaDarkBlue + + #56000000 diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index d9c61be15b7..c96810de821 100755 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -6,4 +6,5 @@ 8dp 32dp 24dp + 4dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 19d07509e27..de2c8830744 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -12,4 +12,7 @@ Currently on Cellular Data Streaming audio may use a lot of cellular data. Don\'t show this message again + Master These Skills + Select or unselect skills that you want to practice + Start diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index f5695ca647d..c92ae2e725e 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -43,4 +43,31 @@ @anim/slide_up @anim/slide_down + + + + + + From afd819626417fbffec8d0115703859535cbe0ca0 Mon Sep 17 00:00:00 2001 From: Rajat Talesra Date: Thu, 3 Oct 2019 15:24:56 +0530 Subject: [PATCH 2/6] Skill item related files --- .../oppia/app/topic/train/SkillInterface.kt | 9 ++++ .../app/topic/train/SkillSelectionAdapter.kt | 52 +++++++++++++++++++ .../res/layout/topic_train_skill_view.xml | 28 ++++++++++ 3 files changed, 89 insertions(+) create mode 100644 app/src/main/java/org/oppia/app/topic/train/SkillInterface.kt create mode 100644 app/src/main/java/org/oppia/app/topic/train/SkillSelectionAdapter.kt create mode 100644 app/src/main/res/layout/topic_train_skill_view.xml diff --git a/app/src/main/java/org/oppia/app/topic/train/SkillInterface.kt b/app/src/main/java/org/oppia/app/topic/train/SkillInterface.kt new file mode 100644 index 00000000000..113ed35f4bc --- /dev/null +++ b/app/src/main/java/org/oppia/app/topic/train/SkillInterface.kt @@ -0,0 +1,9 @@ +package org.oppia.app.topic.train + +/** Interface to update the selectedSkillList in [TopicTrainFragmentPresenter]. */ +interface SkillInterface { + /** This skill will get added to selectedSkillList in [TopicTrainFragmentPresenter] */ + fun skillSelected(skill: String) + /** This skill will get removed from selectedSkillList in [TopicTrainFragmentPresenter] */ + fun skillUnselected(skill: String) +} diff --git a/app/src/main/java/org/oppia/app/topic/train/SkillSelectionAdapter.kt b/app/src/main/java/org/oppia/app/topic/train/SkillSelectionAdapter.kt new file mode 100644 index 00000000000..5ddeb7d9f9f --- /dev/null +++ b/app/src/main/java/org/oppia/app/topic/train/SkillSelectionAdapter.kt @@ -0,0 +1,52 @@ +package org.oppia.app.topic.train; + +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.databinding.DataBindingUtil +import androidx.databinding.ViewDataBinding +import androidx.databinding.library.baseAdapters.BR +import androidx.recyclerview.widget.RecyclerView +import kotlinx.android.synthetic.main.topic_train_skill_view.view.* +import org.oppia.app.R +import org.oppia.app.databinding.TopicTrainSkillViewBinding + +/** Adapter to bind skills to [RecyclerView] inside [TopicTrainFragment]. **/ +class SkillSelectionAdapter( + private val skillList: List, + private val skillInterface: SkillInterface +) : RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { + val inflater = LayoutInflater.from(parent.context) + val binding = + DataBindingUtil.inflate( + inflater, + R.layout.topic_train_skill_view, + parent, + false + ) + return SkillViewHolder(binding) + } + + override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { + (holder as SkillViewHolder).bind(skillList[position], position) + } + + override fun getItemCount(): Int { + return skillList.size + } + + private inner class SkillViewHolder(val binding: ViewDataBinding) : RecyclerView.ViewHolder(binding.root) { + internal fun bind(rawString: String?, position: Int) { + binding.setVariable(BR.skill, rawString) + binding.root.skill_check_box.setOnCheckedChangeListener { buttonView, isChecked -> + val skill = skillList[position] + if (isChecked) { + skillInterface.skillSelected(skill) + } else { + skillInterface.skillUnselected(skill) + } + } + } + } +} diff --git a/app/src/main/res/layout/topic_train_skill_view.xml b/app/src/main/res/layout/topic_train_skill_view.xml new file mode 100644 index 00000000000..a8ac2d9c8cb --- /dev/null +++ b/app/src/main/res/layout/topic_train_skill_view.xml @@ -0,0 +1,28 @@ + + + + + + + + + From 398b1e35b7989fa24ade302521cb4172b5d59e8f Mon Sep 17 00:00:00 2001 From: Rajat Talesra Date: Thu, 3 Oct 2019 15:38:54 +0530 Subject: [PATCH 3/6] Nit change to Javadoc --- app/src/main/java/org/oppia/app/topic/train/SkillInterface.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/oppia/app/topic/train/SkillInterface.kt b/app/src/main/java/org/oppia/app/topic/train/SkillInterface.kt index 113ed35f4bc..b87abeca0d6 100644 --- a/app/src/main/java/org/oppia/app/topic/train/SkillInterface.kt +++ b/app/src/main/java/org/oppia/app/topic/train/SkillInterface.kt @@ -2,8 +2,8 @@ package org.oppia.app.topic.train /** Interface to update the selectedSkillList in [TopicTrainFragmentPresenter]. */ interface SkillInterface { - /** This skill will get added to selectedSkillList in [TopicTrainFragmentPresenter] */ + /** This skill will get added to selectedSkillList in [TopicTrainFragmentPresenter]. */ fun skillSelected(skill: String) - /** This skill will get removed from selectedSkillList in [TopicTrainFragmentPresenter] */ + /** This skill will get removed from selectedSkillList in [TopicTrainFragmentPresenter]. */ fun skillUnselected(skill: String) } From 0f5b5215f1c4772e4e24bc4a6672fa91a2d13c45 Mon Sep 17 00:00:00 2001 From: Rajat Talesra Date: Thu, 3 Oct 2019 16:02:50 +0530 Subject: [PATCH 4/6] Added TODO #172 --- .../main/java/org/oppia/app/topic/train/SkillSelectionAdapter.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/org/oppia/app/topic/train/SkillSelectionAdapter.kt b/app/src/main/java/org/oppia/app/topic/train/SkillSelectionAdapter.kt index 5ddeb7d9f9f..8c00e145680 100644 --- a/app/src/main/java/org/oppia/app/topic/train/SkillSelectionAdapter.kt +++ b/app/src/main/java/org/oppia/app/topic/train/SkillSelectionAdapter.kt @@ -10,6 +10,7 @@ import kotlinx.android.synthetic.main.topic_train_skill_view.view.* import org.oppia.app.R import org.oppia.app.databinding.TopicTrainSkillViewBinding +// TODO(#172): Make use of generic data-binding-enabled RecyclerView adapter. /** Adapter to bind skills to [RecyclerView] inside [TopicTrainFragment]. **/ class SkillSelectionAdapter( private val skillList: List, From 7c5d6625df052a035b70d9e7b4570df97abb4b3f Mon Sep 17 00:00:00 2001 From: Rajat Talesra Date: Thu, 3 Oct 2019 18:16:53 +0530 Subject: [PATCH 5/6] Nit changes --- .../java/org/oppia/app/topic/train/SkillSelectionAdapter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/oppia/app/topic/train/SkillSelectionAdapter.kt b/app/src/main/java/org/oppia/app/topic/train/SkillSelectionAdapter.kt index 8c00e145680..c2ea57ea8f6 100644 --- a/app/src/main/java/org/oppia/app/topic/train/SkillSelectionAdapter.kt +++ b/app/src/main/java/org/oppia/app/topic/train/SkillSelectionAdapter.kt @@ -11,7 +11,7 @@ import org.oppia.app.R import org.oppia.app.databinding.TopicTrainSkillViewBinding // TODO(#172): Make use of generic data-binding-enabled RecyclerView adapter. -/** Adapter to bind skills to [RecyclerView] inside [TopicTrainFragment]. **/ +/** Adapter to bind skills to [RecyclerView] inside [TopicTrainFragment]. */ class SkillSelectionAdapter( private val skillList: List, private val skillInterface: SkillInterface From 2764e3bae4c348a702219994e8562c1b4ed02bb1 Mon Sep 17 00:00:00 2001 From: Rajat Talesra Date: Fri, 4 Oct 2019 15:25:07 +0530 Subject: [PATCH 6/6] Nit changes --- .../org/oppia/app/topic/train/SkillSelectionAdapter.kt | 8 ++++---- .../topic/train/{SkillInterface.kt => SkillSelector.kt} | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) rename app/src/main/java/org/oppia/app/topic/train/{SkillInterface.kt => SkillSelector.kt} (93%) diff --git a/app/src/main/java/org/oppia/app/topic/train/SkillSelectionAdapter.kt b/app/src/main/java/org/oppia/app/topic/train/SkillSelectionAdapter.kt index c2ea57ea8f6..7b45fbef6bd 100644 --- a/app/src/main/java/org/oppia/app/topic/train/SkillSelectionAdapter.kt +++ b/app/src/main/java/org/oppia/app/topic/train/SkillSelectionAdapter.kt @@ -14,7 +14,7 @@ import org.oppia.app.databinding.TopicTrainSkillViewBinding /** Adapter to bind skills to [RecyclerView] inside [TopicTrainFragment]. */ class SkillSelectionAdapter( private val skillList: List, - private val skillInterface: SkillInterface + private val skillSelector: SkillSelector ) : RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { @@ -24,7 +24,7 @@ class SkillSelectionAdapter( inflater, R.layout.topic_train_skill_view, parent, - false + /* attachToParent= */false ) return SkillViewHolder(binding) } @@ -43,9 +43,9 @@ class SkillSelectionAdapter( binding.root.skill_check_box.setOnCheckedChangeListener { buttonView, isChecked -> val skill = skillList[position] if (isChecked) { - skillInterface.skillSelected(skill) + skillSelector.skillSelected(skill) } else { - skillInterface.skillUnselected(skill) + skillSelector.skillUnselected(skill) } } } diff --git a/app/src/main/java/org/oppia/app/topic/train/SkillInterface.kt b/app/src/main/java/org/oppia/app/topic/train/SkillSelector.kt similarity index 93% rename from app/src/main/java/org/oppia/app/topic/train/SkillInterface.kt rename to app/src/main/java/org/oppia/app/topic/train/SkillSelector.kt index b87abeca0d6..2888b705161 100644 --- a/app/src/main/java/org/oppia/app/topic/train/SkillInterface.kt +++ b/app/src/main/java/org/oppia/app/topic/train/SkillSelector.kt @@ -1,7 +1,7 @@ package org.oppia.app.topic.train /** Interface to update the selectedSkillList in [TopicTrainFragmentPresenter]. */ -interface SkillInterface { +interface SkillSelector { /** This skill will get added to selectedSkillList in [TopicTrainFragmentPresenter]. */ fun skillSelected(skill: String) /** This skill will get removed from selectedSkillList in [TopicTrainFragmentPresenter]. */