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 #150, #151, #155: TextInputInteractionView, NumericInputInteractionView, FractionInputInteractionView #190

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
4908754
Exploration Player base code for activity and fragment
Sep 13, 2019
8e45390
Fake Data Provider
Sep 13, 2019
451cb3f
Merge remote-tracking branch 'upstream/develop' into HEAD
Sep 16, 2019
10768a3
Nit changes mainly in documentation
Sep 16, 2019
e257140
Nit changes mainly in documentation for State too
Sep 16, 2019
2d7e210
Changed Controller to Presenter and optimised the fragment transactio…
Sep 16, 2019
fb9e952
Basic code for ExporationActivityTest
Sep 16, 2019
84c42b8
ExplorationActivity dummy test
Sep 16, 2019
dbb97c0
Merge remote-tracking branch 'upstream/develop' into exploration-play…
Sep 17, 2019
5392792
Nit changes
Sep 17, 2019
133a9e9
Merge remote-tracking branch 'upstream/develop' into exploration-play…
Sep 18, 2019
209ab5c
Code checking and refactoring in ExplorationActivityTest
Sep 18, 2019
a74ff1a
codeStyle
nikitamarysolomanpvt Sep 18, 2019
f6322a3
TextInputInteractionView
nikitamarysolomanpvt Sep 19, 2019
c8dcb31
TextInputInteractionView
nikitamarysolomanpvt Sep 19, 2019
4ff87ce
TextInputInteractionView ,NumberInputInteractionView,FractionInputInt…
nikitamarysolomanpvt Sep 25, 2019
881736a
TextInputInteractionView,NumberInputInteractionView,FractionInputInte…
nikitamarysolomanpvt Sep 26, 2019
ca1009c
TextInputInteractionView,NumberInputInteractionView,FractionInputInte…
nikitamarysolomanpvt Sep 27, 2019
a7d3438
PR #190 ressolved issues
nikitamarysolomanpvt Sep 27, 2019
48d2217
PR #190 ressolved issues
nikitamarysolomanpvt Sep 27, 2019
6e73146
PR #190 ressolved issues
nikitamarysolomanpvt Sep 27, 2019
7bca1d1
PR #190 ressolved issues
nikitamarysolomanpvt Sep 27, 2019
39521bc
PR #190 ressolved issues
nikitamarysolomanpvt Sep 27, 2019
a9e96f2
PR #190 ressolved issues
nikitamarysolomanpvt Sep 27, 2019
773ca30
PR #190 ressolved issues
nikitamarysolomanpvt Sep 27, 2019
f6c211d
PR #84 suggestion of ben fixes
nikitamarysolomanpvt Sep 30, 2019
15e9f34
Merge branches 'develop' and 'exploration-player-3-interaction' of ht…
nikitamarysolomanpvt Sep 30, 2019
cab0c90
#190 review fixes
nikitamarysolomanpvt Oct 1, 2019
5cfe9a7
#190 review fixes
nikitamarysolomanpvt Oct 1, 2019
ee9e644
Merge branches 'develop' and 'exploration-player-3-interaction' of ht…
nikitamarysolomanpvt Oct 3, 2019
3db9e06
build.gradle revert to develop code
nikitamarysolomanpvt Oct 3, 2019
2c878fb
styles revert to develop code
nikitamarysolomanpvt Oct 3, 2019
301448e
End with self-closing tag. /> fix in cellular_data_dialog
nikitamarysolomanpvt Oct 3, 2019
3788a36
HomeFragment revert to develop code
nikitamarysolomanpvt Oct 3, 2019
1d08f9d
files revert to develop code
nikitamarysolomanpvt Oct 3, 2019
24434c9
files revert to develop code
nikitamarysolomanpvt Oct 3, 2019
62c9908
files revert to develop code
nikitamarysolomanpvt Oct 3, 2019
d67f4c4
files revert to develop code
nikitamarysolomanpvt Oct 3, 2019
802c7ce
files revert to develop code
nikitamarysolomanpvt Oct 3, 2019
3e899e3
files revert to develop code
nikitamarysolomanpvt Oct 3, 2019
66f671a
files revert to develop code
nikitamarysolomanpvt Oct 3, 2019
9ecb21b
files revert to develop code
nikitamarysolomanpvt Oct 3, 2019
ee16fad
files revert to develop code
nikitamarysolomanpvt Oct 3, 2019
86f5d78
files revert to develop code
nikitamarysolomanpvt Oct 3, 2019
59820e7
files revert to develop code
nikitamarysolomanpvt Oct 3, 2019
e6eb115
files revert to develop code
nikitamarysolomanpvt Oct 3, 2019
5538aaa
files revert to develop code
nikitamarysolomanpvt Oct 3, 2019
2e87629
changed double quote to single quotes in build.gradle
nikitamarysolomanpvt Oct 3, 2019
eba3be7
KDoc update in state presenter
nikitamarysolomanpvt Oct 3, 2019
a9e3ea1
files revert to develop code
nikitamarysolomanpvt Oct 7, 2019
f1d11ea
files revert to develop code
nikitamarysolomanpvt Oct 7, 2019
6d8adb8
Merge branches 'develop' and 'exploration-player-3-interaction' of ht…
nikitamarysolomanpvt Oct 7, 2019
0c463ad
statefragment testcase updated as per review
nikitamarysolomanpvt Oct 7, 2019
6538131
statefragment testcase updated as per review
nikitamarysolomanpvt Oct 9, 2019
2953b79
statefragment testcase updated as per review
nikitamarysolomanpvt Oct 9, 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 .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ android {
execution 'ANDROIDX_TEST_ORCHESTRATOR'
unitTests {
includeAndroidResources = true

nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
}
unitTests.returnDefaultValues = true
}

// https://proandroiddev.com/isolated-fragments-unit-tests-that-run-both-instrumented-and-on-the-jvm-with-the-same-source-code-283db2e9be5d
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.oppia.app.customview.inputInteractionView

import android.content.Context
import android.text.InputFilter
import android.text.method.DigitsKeyListener
import android.widget.EditText
import org.oppia.app.R

/** The customclass for [FractionInputInteractionView]. */
class FractionInputInteractionView : EditText {

private var mContext: Context
private var placeholder: String
private var rows: Int

constructor(context: Context, placeholder: String, rows: Int) : super(context) {
this.mContext = context
this.placeholder = placeholder
this.rows = rows
init()
}

//update default attributes of TextInputInteractionView here
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
fun init() {
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
setBackgroundResource(R.drawable.edit_text_background)
val paddingPixel = 10
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
val density = resources.displayMetrics.density
val paddingDp = (paddingPixel * density).toInt()
setPadding(paddingDp, paddingDp, paddingDp, paddingDp)
setHint(placeholder)
setKeyListener(DigitsKeyListener.getInstance("0123456789/"))
setEditTextMaxLength(200)
}

fun setEditTextMaxLength(length: Int) {
val filterArray = arrayOfNulls<InputFilter>(1)
filterArray[0] = InputFilter.LengthFilter(length)
setFilters(filterArray)
}

nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
}

nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.oppia.app.customview.inputInteractionView

import android.content.Context
import android.text.InputFilter
import android.text.InputType
import android.text.method.DigitsKeyListener
import android.widget.EditText

import org.oppia.app.R

/** The customclass for [NumberInputInteractionView]. */
class NumberInputInteractionView : EditText {

private var mContext: Context
private var placeholder: String
private var rows: Int

constructor(context: Context, placeholder: String, rows: Int) : super(context) {
this.mContext = context
this.placeholder = placeholder
this.rows = rows
init()
}

//update default attributes of NumberInputInteractionView here
fun init() {
setBackgroundResource(R.drawable.edit_text_background)
val paddingPixel = 10
val density = resources.displayMetrics.density
val paddingDp = (paddingPixel * density).toInt()
setPadding(paddingDp, paddingDp, paddingDp, paddingDp)
setHint(placeholder)
setKeyListener(DigitsKeyListener.getInstance("0123456789."))
setEditTextMaxLength(200)
}

fun setEditTextMaxLength(length: Int) {
val filterArray = arrayOfNulls<InputFilter>(1)
filterArray[0] = InputFilter.LengthFilter(length)
setFilters(filterArray)
}

}

nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.oppia.app.customview.inputInteractionView

import android.content.Context
import android.text.InputFilter
import android.text.InputType
import android.text.method.DigitsKeyListener
import android.widget.EditText

import org.oppia.app.R
/** The customclass for [TextInputInteractionView]. */
class TextInputInteractionView : EditText {

private var mContext: Context
private var placeholder: String
private var rows: Int

constructor(context: Context, placeholder: String, rows: Int) : super(context) {
this.mContext = context
this.placeholder = placeholder
this.rows = rows
init()
}

//update default attributes of TextInputInteractionView here
fun init() {
setBackgroundResource(R.drawable.edit_text_background)
val paddingPixel = 10
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
val density = resources.displayMetrics.density
val paddingDp = (paddingPixel * density).toInt()
setPadding(paddingDp, paddingDp, paddingDp, paddingDp)
setHint(placeholder)
setEditTextMaxLength(200)
}

fun setEditTextMaxLength(length: Int) {
val filterArray = arrayOfNulls<InputFilter>(1)
filterArray[0] = InputFilter.LengthFilter(length)
setFilters(filterArray)
}


}

nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions app/src/main/java/org/oppia/app/fragment/FragmentComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +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
import org.oppia.app.player.exploration.ExplorationFragment
import org.oppia.app.player.audio.AudioFragment
import org.oppia.app.topic.conceptcard.ConceptCardFragment

Expand All @@ -19,8 +19,8 @@ interface FragmentComponent {
fun build(): FragmentComponent
}

fun inject(audioFragment: AudioFragment)
fun inject(explorationFragment: ExplorationFragment)
fun inject(audioFragment: AudioFragment)
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
fun inject(homeFragment: HomeFragment)
fun inject(stateFragment: StateFragment)
fun inject(conceptCardFragment: ConceptCardFragment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.oppia.app.home
import androidx.appcompat.app.AppCompatActivity
import org.oppia.app.R
import org.oppia.app.activity.ActivityScope
import org.oppia.app.player.state.StateFragment
import javax.inject.Inject

/** The controller for [HomeActivity]. */
Expand All @@ -12,7 +13,7 @@ class HomeActivityController @Inject constructor(private val activity: AppCompat
activity.setContentView(R.layout.home_activity)
activity.supportFragmentManager.beginTransaction().add(
R.id.home_fragment_placeholder,
HomeFragment()
StateFragment()
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
).commitNow()
}
}
4 changes: 4 additions & 0 deletions app/src/main/java/org/oppia/app/home/HomeFragment.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.oppia.app.home

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

Expand All @@ -17,7 +19,9 @@ class HomeFragment : InjectableFragment() {
fragmentComponent.inject(this)
}

@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return homeFragmentController.handleCreateView(inflater, container)
}

nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
}
38 changes: 35 additions & 3 deletions app/src/main/java/org/oppia/app/home/HomeFragmentController.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.oppia.app.home

import android.content.res.Resources
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand All @@ -9,6 +10,10 @@ import org.oppia.app.fragment.FragmentScope
import org.oppia.app.viewmodel.ViewModelProvider
import org.oppia.domain.UserAppHistoryController
import javax.inject.Inject
import android.widget.LinearLayout
import androidx.lifecycle.LifecycleOwner
import org.oppia.app.R
import org.oppia.app.customview.inputInteractionView.TextInputInteractionView

/** The controller for [HomeFragment]. */
@FragmentScope
Expand All @@ -17,20 +22,47 @@ class HomeFragmentController @Inject constructor(
private val viewModelProvider: ViewModelProvider<UserAppHistoryViewModel>,
private val userAppHistoryController: UserAppHistoryController
) {
private var llRoot: LinearLayout? = null

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
// data-bound view models.
binding.let {
it.viewModel = getUserAppHistoryViewModel()
it.lifecycleOwner = fragment
it.lifecycleOwner = fragment as LifecycleOwner?
}

userAppHistoryController.markUserOpenedApp()

llRoot = binding.root.findViewById(R.id.llRoot)
addContentCard("edit_text_background_border",1)
addContentCard("edit_text_background_border_",2)
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
return binding.root
}

nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
private fun addContentCard(placeholder: String, rows: Int) {
val contentComponent = TextInputInteractionView(
fragment.context!!,
placeholder,
rows
)
val params = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
)

params.setMargins( dpToPx(8), dpToPx(8), dpToPx(8), dpToPx(8))
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved


llRoot!!.addView(contentComponent, params)



nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
}

fun dpToPx(dp: Int): Int {
return (dp * Resources.getSystem().getDisplayMetrics().density).toInt()
}

private fun getUserAppHistoryViewModel(): UserAppHistoryViewModel {
return viewModelProvider.getForFragment(fragment, UserAppHistoryViewModel::class.java)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class StateFragment : InjectableFragment(), CellularDataInterface {
@Inject
lateinit var stateFragmentPresenter: StateFragmentPresenter
// Control this boolean value from controllers in domain module.
private var showCellularDataDialog = true
private var showCellularDataDialog = false

init {
// TODO(#116): Code to control the value of showCellularDataDialog using AudioController.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package org.oppia.app.player.state

import android.content.res.Resources
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.fragment.app.Fragment
import org.oppia.app.R
import org.oppia.app.customview.inputInteractionView.FractionInputInteractionView
import org.oppia.app.customview.inputInteractionView.NumberInputInteractionView
import org.oppia.app.customview.inputInteractionView.TextInputInteractionView
import org.oppia.app.databinding.StateFragmentBinding
import org.oppia.app.fragment.FragmentScope
import org.oppia.app.viewmodel.ViewModelProvider
Expand All @@ -15,15 +21,73 @@ class StateFragmentPresenter @Inject constructor(
private val fragment: Fragment,
private val viewModelProvider: ViewModelProvider<StateViewModel>
) {
private var llRoot: LinearLayout? = null

fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?): View? {
val binding = StateFragmentBinding.inflate(inflater, container, /* attachToRoot= */ false)
binding.let {
it.stateFragment = fragment as StateFragment
it.viewModel = getStateViewModel()
}
llRoot = binding.root.findViewById(R.id.llRoot)
addTextInputContentCard("text", 1)
addNumberInputContentCard("number 1", 2)
addFractionInputContentCard("fraction 1/1", 3)
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
return binding.root
}

//for adding textinputinteraction view
fun addTextInputContentCard(placeholder: String, type: Int) {
var contentComponent = TextInputInteractionView(
fragment.context!!,
placeholder,
1
)
val params = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
)
params.setMargins(dpToPx(8), dpToPx(8), dpToPx(8), dpToPx(8))
llRoot!!.addView(contentComponent, params)

nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
}

//for adding numberinputinteraction view
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
fun addNumberInputContentCard(placeholder: String, type: Int) {
var contentComponent = NumberInputInteractionView(
fragment.context!!,
placeholder,
1
)
val params = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
)
params.setMargins(dpToPx(8), dpToPx(8), dpToPx(8), dpToPx(8))
llRoot!!.addView(contentComponent, params)

}

//for adding numberinputinteraction view
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
fun addFractionInputContentCard(placeholder: String, type: Int) {
var contentComponent = FractionInputInteractionView(
fragment.context!!,
placeholder,
1
)
val params = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
)
params.setMargins(dpToPx(8), dpToPx(8), dpToPx(8), dpToPx(8))
llRoot!!.addView(contentComponent, params)

nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
}

fun dpToPx(dp: Int): Int {
return (dp * Resources.getSystem().getDisplayMetrics().density).toInt()
}

private fun getStateViewModel(): StateViewModel {
return viewModelProvider.getForFragment(fragment, StateViewModel::class.java)
}
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/drawable/edit_text_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/edit_text_background_shadow" android:state_focused="true" />
<item android:drawable="@drawable/edit_text_background_shadow" android:state_pressed="true" />
<item android:drawable="@drawable/edit_text_background_border" />
//means normal
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
</selector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/edit_text_background_border.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="3dp" />
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
<solid android:color="@color/white" />
<stroke
android:width="1dip"
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
android:color="@color/grey" />
</shape>
Loading