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

Topic issues fix #279

Closed
wants to merge 30 commits into from
Closed
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e2ed1c4
multiple tabs
nikitamarysolomanpvt Oct 7, 2019
089ea5a
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
nikitamarysolomanpvt Oct 14, 2019
43016b6
nit changes
nikitamarysolomanpvt Oct 17, 2019
3a1a350
nit changes
nikitamarysolomanpvt Oct 17, 2019
405a45e
nit changes
nikitamarysolomanpvt Oct 17, 2019
72c7360
nit changes
nikitamarysolomanpvt Oct 17, 2019
c5ffa61
nit changes
nikitamarysolomanpvt Oct 17, 2019
47e2efc
nit changes
nikitamarysolomanpvt Oct 17, 2019
b4ed9bb
nit changes
nikitamarysolomanpvt Oct 17, 2019
9dd39b9
nit changes
nikitamarysolomanpvt Oct 17, 2019
b2fca59
nit changes
nikitamarysolomanpvt Oct 17, 2019
f0cb60f
cust_args
nikitamarysolomanpvt Oct 18, 2019
2d21695
multiple tabs will getting topic id from home
nikitamarysolomanpvt Oct 29, 2019
93b889b
test cases,multiple tabs will getting topic id from home
nikitamarysolomanpvt Oct 29, 2019
3130323
nit
nikitamarysolomanpvt Oct 29, 2019
bbe7cf3
nit
nikitamarysolomanpvt Oct 29, 2019
046e297
nit
nikitamarysolomanpvt Oct 30, 2019
ba506ab
nit
nikitamarysolomanpvt Oct 30, 2019
6f228d1
nit
nikitamarysolomanpvt Oct 30, 2019
24be11b
separate test cases for all four tabs
nikitamarysolomanpvt Oct 30, 2019
bfa2b78
nit
nikitamarysolomanpvt Oct 30, 2019
0c6d5d8
nit
nikitamarysolomanpvt Oct 30, 2019
f8f84f1
nit
nikitamarysolomanpvt Oct 30, 2019
efae9f7
nit
nikitamarysolomanpvt Oct 30, 2019
1ecfc2f
nit
nikitamarysolomanpvt Oct 30, 2019
293aa52
nit
nikitamarysolomanpvt Oct 30, 2019
949f89e
nit
nikitamarysolomanpvt Oct 30, 2019
71ae233
nit
nikitamarysolomanpvt Oct 30, 2019
8197cc3
Topic Overview see more click and tab switch
nikitamarysolomanpvt Oct 30, 2019
dea65c2
Topic Overview see more click and tab switch
nikitamarysolomanpvt Oct 30, 2019
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
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ dependencies {
'androidx.multidex:multidex:2.0.1',
'androidx.recyclerview:recyclerview:1.0.0',
'com.github.bumptech.glide:glide:4.9.0',
'com.google.android.material:material:1.0.0',
'com.google.dagger:dagger:2.24',
'com.google.guava:guava:28.1-android',
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version",
@@ -86,7 +87,7 @@ dependencies {
'androidx.test.espresso:espresso-intents:3.1.0',
'androidx.test.ext:junit:1.1.1',
'androidx.test:runner:1.2.0',
'com.google.truth:truth:0.43',
'com.google.truth:truth:0.43'
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
)
androidTestUtil(
'androidx.test:orchestrator:1.2.0',
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -15,7 +15,8 @@
<activity android:name=".player.state.testing.StateFragmentTestActivity" />
<activity android:name=".player.exploration.ExplorationActivity" />
<activity android:name=".topic.questionplayer.QuestionPlayerActivity" />
<activity android:name=".topic.TopicActivity" />
<activity android:name=".topic.TopicActivity"
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
android:theme="@style/OppiaThemeWithoutActionBar"/>
<activity android:name=".player.audio.testing.AudioFragmentTestActivity" />
<activity android:name=".testing.InputInteractionViewTestActivity" />
<activity android:name=".profile.ProfileActivity" />
@@ -35,4 +36,4 @@
android:theme="@style/SplashScreenTheme" />
<activity android:name=".testing.BindableAdapterTestActivity" />
</application>
</manifest>
</manifest>
10 changes: 8 additions & 2 deletions app/src/main/java/org/oppia/app/home/HomeActivity.kt
Original file line number Diff line number Diff line change
@@ -3,11 +3,13 @@ package org.oppia.app.home
import android.os.Bundle
import org.oppia.app.activity.InjectableAppCompatActivity
import org.oppia.app.player.exploration.ExplorationActivity
import org.oppia.app.topic.TopicActivity
import javax.inject.Inject

/** The central activity for all users entering the app. */
class HomeActivity : InjectableAppCompatActivity(), RouteToExplorationListener {
@Inject lateinit var homeActivityPresenter: HomeActivityPresenter
class HomeActivity : InjectableAppCompatActivity(), RouteToExplorationListener, RouteToTopicListener {
@Inject
lateinit var homeActivityPresenter: HomeActivityPresenter

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -18,4 +20,8 @@ class HomeActivity : InjectableAppCompatActivity(), RouteToExplorationListener {
override fun routeToExploration(explorationId: String) {
startActivity(ExplorationActivity.createExplorationActivityIntent(this, explorationId))
}

override fun routeToTopic(topicId: String) {
startActivity(TopicActivity.createTopicActivityIntent(this, topicId))
}
}
15 changes: 11 additions & 4 deletions app/src/main/java/org/oppia/app/home/HomeFragmentPresenter.kt
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ import org.oppia.app.viewmodel.ViewModelProvider
import org.oppia.domain.UserAppHistoryController
import org.oppia.domain.exploration.ExplorationDataController
import org.oppia.domain.exploration.TEST_EXPLORATION_ID_5
import org.oppia.domain.topic.TEST_TOPIC_ID_1
import org.oppia.util.data.AsyncResult
import org.oppia.util.logging.Logger
import javax.inject.Inject
@@ -30,7 +31,8 @@ class HomeFragmentPresenter @Inject constructor(
) {

private val routeToExplorationListener = activity as RouteToExplorationListener

private val routeToTopicListener = activity as RouteToTopicListener
private val TAG_HOME_FRAGMENT = "HomeFragment"
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?): View? {
val binding = HomeFragmentBinding.inflate(inflater, container, /* attachToRoot= */ false)
// NB: Both the view model and lifecycle owner must be set in order to correctly bind LiveData elements to
@@ -55,13 +57,18 @@ class HomeFragmentPresenter @Inject constructor(
EXPLORATION_ID
).observe(fragment, Observer<AsyncResult<Any?>> { result ->
when {
result.isPending() -> logger.d("HomeFragment", "Loading exploration")
result.isFailure() -> logger.e("HomeFragment", "Failed to load exploration", result.getErrorOrNull()!!)
result.isPending() -> logger.d(TAG_HOME_FRAGMENT, "Loading exploration")
result.isFailure() -> logger.e(TAG_HOME_FRAGMENT, "Failed to load exploration", result.getErrorOrNull()!!)
else -> {
logger.d("HomeFragment", "Successfully loaded exploration")
logger.d(TAG_HOME_FRAGMENT, "Successfully loaded exploration")
routeToExplorationListener.routeToExploration(EXPLORATION_ID)
}
}
})
}

fun topicButtonClick(v: View) {
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
logger.d(TAG_HOME_FRAGMENT, "Successfully loaded topic")
routeToTopicListener.routeToTopic(TEST_TOPIC_ID_1)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.oppia.app.home

/** Listener for when an activity should route to a topic. */
interface RouteToTopicListener {
fun routeToTopic(topicId: String)
}
18 changes: 16 additions & 2 deletions app/src/main/java/org/oppia/app/topic/TopicActivity.kt
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
package org.oppia.app.topic

import android.content.Context
import android.content.Intent
import android.os.Bundle
import org.oppia.app.activity.InjectableAppCompatActivity
import org.oppia.app.story.StoryActivity
import org.oppia.app.topic.conceptcard.ConceptCardFragment
import org.oppia.app.topic.questionplayer.QuestionPlayerActivity
import org.oppia.domain.topic.TEST_TOPIC_ID_1
import javax.inject.Inject

/** The activity for tabs in Topic. */
const val TOPIC_ACTIVITY_TOPIC_ID_ARGUMENT_KEY = "TopicActivity.topic_id"

/** The activity for displaying [TopicFragment]. */
class TopicActivity : InjectableAppCompatActivity(), RouteToQuestionPlayerListener, RouteToConceptCardListener,
RouteToTopicPlayListener, RouteToStoryListener {
private lateinit var topicId: String
@Inject
lateinit var topicActivityPresenter: TopicActivityPresenter

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
activityComponent.inject(this)
topicActivityPresenter.handleOnCreate()
topicId =
if (intent.getStringExtra(TOPIC_ACTIVITY_TOPIC_ID_ARGUMENT_KEY) == null) TEST_TOPIC_ID_1
else intent.getStringExtra(TOPIC_ACTIVITY_TOPIC_ID_ARGUMENT_KEY)
topicActivityPresenter.handleOnCreate(topicId)
}

override fun routeToQuestionPlayer(skillIdList: ArrayList<String>) {
@@ -45,5 +53,11 @@ class TopicActivity : InjectableAppCompatActivity(), RouteToQuestionPlayerListen

companion object {
internal const val TAG_CONCEPT_CARD_DIALOG = "CONCEPT_CARD_DIALOG"
/** Returns a new [Intent] to route to [TopicActivity] for a specified topic ID. */
fun createTopicActivityIntent(context: Context, topicId: String): Intent {
val intent = Intent(context, TopicActivity::class.java)
intent.putExtra(TOPIC_ACTIVITY_TOPIC_ID_ARGUMENT_KEY, topicId)
return intent
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.oppia.app.topic

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import org.oppia.app.R
import org.oppia.app.activity.ActivityScope
@@ -8,12 +9,16 @@ import javax.inject.Inject
/** The presenter for [TopicActivity]. */
@ActivityScope
class TopicActivityPresenter @Inject constructor(private val activity: AppCompatActivity) {
fun handleOnCreate() {
fun handleOnCreate(topicId: String) {
activity.setContentView(R.layout.topic_activity)
if (getTopicFragment() == null) {
val topicFragment = TopicFragment()
val args = Bundle()
args.putString(TOPIC_ACTIVITY_TOPIC_ID_ARGUMENT_KEY, topicId)
topicFragment.arguments = args
activity.supportFragmentManager.beginTransaction().add(
R.id.topic_fragment_placeholder,
TopicFragment()
topicFragment
).commitNow()
}
}
11 changes: 9 additions & 2 deletions app/src/main/java/org/oppia/app/topic/TopicFragment.kt
Original file line number Diff line number Diff line change
@@ -10,14 +10,21 @@ import javax.inject.Inject

/** Fragment that contains tabs for Topic. */
class TopicFragment : InjectableFragment() {
@Inject lateinit var topicFragmentPresenter: TopicFragmentPresenter
@Inject
lateinit var topicFragmentPresenter: TopicFragmentPresenter
private var topicId: String = ""

override fun onAttach(context: Context?) {
super.onAttach(context)
fragmentComponent.inject(this)
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return topicFragmentPresenter.handleCreateView(inflater, container)
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
topicId =
if (arguments != null && arguments!!.getString(TOPIC_ACTIVITY_TOPIC_ID_ARGUMENT_KEY) != null) arguments!!.getString(
TOPIC_ACTIVITY_TOPIC_ID_ARGUMENT_KEY
) else ""
return topicFragmentPresenter.handleCreateView(inflater, container, topicId)
}
}
38 changes: 34 additions & 4 deletions app/src/main/java/org/oppia/app/topic/TopicFragmentPresenter.kt
Original file line number Diff line number Diff line change
@@ -4,6 +4,9 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.viewpager.widget.ViewPager
import com.google.android.material.tabs.TabLayout
import org.oppia.app.R
import org.oppia.app.databinding.TopicFragmentBinding
import org.oppia.app.fragment.FragmentScope
import javax.inject.Inject
@@ -13,11 +16,38 @@ import javax.inject.Inject
class TopicFragmentPresenter @Inject constructor(
private val fragment: Fragment
) {
fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?): View? {
private lateinit var tabLayout: TabLayout
private lateinit var viewPager: ViewPager
private val tabIcons =
intArrayOf(
R.drawable.ic_overview_white_24dp,
R.drawable.ic_play_icon,
R.drawable.ic_train_icon,
R.drawable.ic_review_icon
)

fun handleCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
topicId: String?
): View? {
val binding = TopicFragmentBinding.inflate(inflater, container, /* attachToRoot= */ false)
binding.let {
it.lifecycleOwner = fragment
}
binding.lifecycleOwner = fragment
viewPager = binding.root.findViewById(R.id.topic_tabs_viewpager) as ViewPager
tabLayout = binding.root.findViewById(R.id.topic_tabs_container) as TabLayout
setUpViewPager(viewPager, topicId)
return binding.root
}
fun setCurrentTab(tabNumber: Int){
viewPager.setCurrentItem(tabNumber,true)
}
private fun setUpViewPager(viewPager: ViewPager, topicId: String?) {
val adapter = ViewPagerAdapter(fragment.fragmentManager!!, tabIcons.size, topicId!!,this)
viewPager.adapter = adapter
tabLayout.setupWithViewPager(viewPager)
tabLayout.getTabAt(0)!!.setText(fragment.getString(R.string.overview)).setIcon(tabIcons[0])
tabLayout.getTabAt(1)!!.setText(fragment.getString(R.string.play)).setIcon(tabIcons[1])
tabLayout.getTabAt(2)!!.setText(fragment.getString(R.string.train)).setIcon(tabIcons[2])
tabLayout.getTabAt(3)!!.setText(fragment.getString(R.string.review)).setIcon(tabIcons[3])
}
}
52 changes: 52 additions & 0 deletions app/src/main/java/org/oppia/app/topic/ViewPagerAdapter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.oppia.app.topic

import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import org.oppia.app.topic.overview.TopicOverviewFragment
import org.oppia.app.topic.play.TopicPlayFragment
import org.oppia.app.topic.review.TopicReviewFragment
import org.oppia.app.topic.train.TopicTrainFragment

class ViewPagerAdapter(
fm: FragmentManager,
private val numOfTabs: Int,
private val topicId: String,
private val topicFragmentPresenter: TopicFragmentPresenter
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
) :
FragmentStatePagerAdapter(fm) {

override fun getItem(position: Int): Fragment? {
val args = Bundle()
args.putString(TOPIC_ACTIVITY_TOPIC_ID_ARGUMENT_KEY, topicId)
when (position) {
0 -> {
val topicOverviewTab = TopicOverviewFragment(topicFragmentPresenter)
topicOverviewTab.arguments = args
return topicOverviewTab
}
1 -> {
val topicPlayTab = TopicPlayFragment()
topicPlayTab.arguments = args
return topicPlayTab
}
2 -> {
val topicTrainTab = TopicTrainFragment()
topicTrainTab.arguments = args
return topicTrainTab
}
3 -> {
val topicReviewTab = TopicReviewFragment()
topicReviewTab.arguments = args
return topicReviewTab
}
else -> return null
}
}

override fun getCount(): Int {
return numOfTabs
}
}

Original file line number Diff line number Diff line change
@@ -6,10 +6,11 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import org.oppia.app.fragment.InjectableFragment
import org.oppia.app.topic.TopicFragmentPresenter
import javax.inject.Inject

/** Fragment that contains overview of Topic. */
class TopicOverviewFragment : InjectableFragment() {
class TopicOverviewFragment(private val topicFragmentPresenter: TopicFragmentPresenter) : InjectableFragment() {
@Inject
lateinit var topicOverviewFragmentPresenter: TopicOverviewFragmentPresenter

@@ -19,6 +20,6 @@ class TopicOverviewFragment : InjectableFragment() {
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return topicOverviewFragmentPresenter.handleCreateView(inflater, container)
return topicOverviewFragmentPresenter.handleCreateView(inflater, container,topicFragmentPresenter)
}
}
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ import androidx.lifecycle.Transformations
import org.oppia.app.databinding.TopicOverviewFragmentBinding
import org.oppia.app.fragment.FragmentScope
import org.oppia.app.model.Topic
import org.oppia.app.topic.RouteToTopicPlayListener
import org.oppia.app.topic.TopicFragmentPresenter
import org.oppia.app.viewmodel.ViewModelProvider
import org.oppia.domain.topic.TEST_TOPIC_ID_1
import org.oppia.domain.topic.TopicController
@@ -28,23 +28,28 @@ class TopicOverviewFragmentPresenter @Inject constructor(
private val logger: Logger,
private val topicController: TopicController
) {
private val routeToTopicPlayListener = activity as RouteToTopicPlayListener
private lateinit var topicFragmentPresenter: TopicFragmentPresenter

private val topicOverviewViewModel = getTopicOverviewViewModel()

fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?): View? {
fun handleCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
topicFragmentPresenter: TopicFragmentPresenter
): View? {
val binding = TopicOverviewFragmentBinding.inflate(inflater, container, /* attachToRoot= */ false)
subscribeToTopicLiveData()
binding.let {
it.lifecycleOwner = fragment
it.presenter = this
it.viewModel = topicOverviewViewModel
}
this.topicFragmentPresenter=topicFragmentPresenter;
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
return binding.root
}

fun seeMoreClicked(v: View) {
routeToTopicPlayListener.routeToTopicPlayFragment()
topicFragmentPresenter.setCurrentTab(1)
}

private fun getTopicOverviewViewModel(): TopicOverviewViewModel {
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_overview_white_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#FFFFFF"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M11,15h2v2h-2zM11,7h2v6h-2zM11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z" />
</vector>
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/ic_play_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="419.14468"
android:viewportHeight="403.60483">
<path
android:fillAlpha="1"
android:fillColor="#FFFFFF"
android:pathData="M281.781,0C280.899,0.011 279.993,0.055 279.094,0.125C243.27,6.308 223.573,44.189 220.719,77.594C216.548,107.905 229.906,146.864 263.188,153.656C268.015,154.575 273.031,154.155 277.75,152.875C317.827,139.437 335.762,91.972 329.969,52.656C328.285,27.264 309.143,-0.349 281.781,0zM129.906,1.625C107.631,2.172 90.28,24.763 86.75,46C79.309,88.074 98.448,140.352 142.281,153.656C146.387,154.549 150.634,154.641 154.781,154C184.408,149.063 196.958,115.846 195.719,89.031C194.827,53.659 176.453,12.758 139.719,2.813C136.361,1.922 133.088,1.547 129.906,1.625zM378.844,121.125C340.309,123.43 313.891,161.879 310.125,197.781C305.025,223.675 318.83,258.308 348.375,260.375C389.572,259.867 417.676,215.846 418.844,177.969C421.45,152.917 406.693,122.508 378.844,121.125zM41.563,129.656C25.168,129.515 9.045,139.335 3.688,156C-10.605,200.579 18.096,257.038 65.313,266.406C85.018,269.778 102.333,254.645 107.219,236.438C117.573,197.493 96.305,152.272 60.313,134.594C54.449,131.303 47.978,129.711 41.563,129.656zM214.313,209.594C182.173,209.662 149.53,225.972 128.719,250.25C106.241,278.547 87.828,311.477 80.625,347.188C71.874,372.894 91.708,402.478 119.188,402.656C152.246,403.575 180.658,380.873 213.531,379.188C241.421,374.936 266.394,389.443 291.469,398.938C312.818,408.069 342.319,404.569 353.219,381.594C361.792,358.175 349.173,333.204 338.719,312.406C317.397,278.649 294.554,243.17 259.594,222.094C245.581,213.408 230.008,209.56 214.313,209.594z"
android:strokeColor="#00000000" />
</vector>
Loading