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 #42: Exploration player base (Part 1) #42 #100

Merged
merged 12 commits into from
Sep 18, 2019
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/OppiaTheme">
<activity android:name=".player.exploration.ExplorationActivity"/>
<activity android:name="org.oppia.app.home.HomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand Down
27 changes: 27 additions & 0 deletions app/src/main/java/org/oppia/app/FakeDataProvider.kt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import dagger.BindsInstance
import dagger.Subcomponent
import org.oppia.app.fragment.FragmentComponent
import org.oppia.app.home.HomeActivity
import org.oppia.app.player.exploration.ExplorationActivity
import javax.inject.Provider

/** Root subcomponent for all activities. */
Expand All @@ -19,5 +20,6 @@ interface ActivityComponent {

fun getFragmentComponentBuilderProvider(): Provider<FragmentComponent.Builder>

fun inject(explorationActivity: ExplorationActivity)
fun inject(homeActivity: HomeActivity)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import androidx.fragment.app.Fragment
import dagger.BindsInstance
import dagger.Subcomponent
import org.oppia.app.home.HomeFragment
import org.oppia.app.player.exploration.ExplorationFragment
import org.oppia.app.player.state.StateFragment

/** Root subcomponent for all fragments. */
@Subcomponent
Expand All @@ -15,5 +17,7 @@ interface FragmentComponent {
fun build(): FragmentComponent
}

fun inject(explorationFragment: ExplorationFragment)
fun inject(homeFragment: HomeFragment)
fun inject(stateFragment: StateFragment)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.oppia.app.player.exploration

import android.os.Bundle
import org.oppia.app.activity.InjectableAppCompatActivity
import javax.inject.Inject

/** The starting point for exploration*/
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
class ExplorationActivity : InjectableAppCompatActivity() {
@Inject lateinit var explorationActivityController: ExplorationActivityController
rt4914 marked this conversation as resolved.
Show resolved Hide resolved

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
activityComponent.inject(this)
explorationActivityController.handleOnCreate()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.oppia.app.player.exploration

import androidx.appcompat.app.AppCompatActivity
import org.oppia.app.R
import org.oppia.app.activity.ActivityScope
import javax.inject.Inject

/** The controller for [ExplorationActivity]. */
@ActivityScope
class ExplorationActivityController @Inject constructor(private val activity: AppCompatActivity) {
fun handleOnCreate() {
activity.setContentView(R.layout.exploration_activity)
activity.supportFragmentManager.beginTransaction().add(
R.id.exploration_fragment_placeholder,
ExplorationFragment()
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
).commitNow()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.oppia.app.player.exploration

import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import org.oppia.app.fragment.InjectableFragment
import javax.inject.Inject

/** Fragment that contains displays single exploration.*/
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
class ExplorationFragment : InjectableFragment() {
@Inject lateinit var explorationFragmentController: ExplorationFragmentController

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

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return explorationFragmentController.handleCreateView(inflater, container)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.oppia.app.player.exploration

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import org.oppia.app.databinding.ExplorationFragmentBinding
import org.oppia.app.fragment.FragmentScope
import javax.inject.Inject

/** The controller for [ExplorationFragment]. */
@FragmentScope
class ExplorationFragmentController @Inject constructor(
private val fragment: Fragment
) {
fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?): View? {
val binding = ExplorationFragmentBinding.inflate(inflater, container, /* attachToRoot= */ false)
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
return binding.root
}
}
24 changes: 24 additions & 0 deletions app/src/main/java/org/oppia/app/player/state/StateFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.oppia.app.player.state

import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import org.oppia.app.fragment.InjectableFragment
import javax.inject.Inject

/** Fragment that contains displays current state of exploration.*/
class StateFragment : InjectableFragment() {
@Inject
lateinit var stateFragmentController: StateFragmentController

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

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return stateFragmentController.handleCreateView(inflater, container)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.oppia.app.player.state

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import org.oppia.app.databinding.ExplorationFragmentBinding
import org.oppia.app.databinding.HomeFragmentBinding
import org.oppia.app.databinding.StateFragmentBinding
import org.oppia.app.fragment.FragmentScope
import javax.inject.Inject

/** The controller for [StateFragment]. */
@FragmentScope
class StateFragmentController @Inject constructor(
private val fragment: Fragment
) {
fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?): View? {
val binding = StateFragmentBinding.inflate(inflater, container, /* attachToRoot= */ false)
return binding.root
}
}
8 changes: 8 additions & 0 deletions app/src/main/res/layout/exploration_activity.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/exploration_fragment_placeholder"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".player.exploration.ExplorationActivity" />
12 changes: 12 additions & 0 deletions app/src/main/res/layout/exploration_fragment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android">
<data>
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
12 changes: 12 additions & 0 deletions app/src/main/res/layout/state_fragment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android">
<data>
</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>