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 all 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
2 changes: 1 addition & 1 deletion .idea/codeStyles/Project.xml

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

2 changes: 1 addition & 1 deletion .idea/codeStyles/codeStyleConfig.xml

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

7 changes: 4 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ android {
unitTests {
includeAndroidResources = true
}
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 All @@ -63,9 +64,9 @@ dependencies {
'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",
"org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.1"
'org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version',
'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.1',
'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.1'
)
testImplementation(
'androidx.test:core:1.2.0',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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
attributes()
}

/** This function contains default attributes of [FractionInputInteractionView]. */
fun attributes() {
setBackgroundResource(R.drawable.edit_text_background)
val paddingPixel = mContext.resources.getDimension(R.dimen.padding_8)
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)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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 [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
attributes()
}

/** This function contains default attributes of [NumberInputInteractionView]. */
fun attributes() {
setBackgroundResource(R.drawable.edit_text_background)
val paddingPixel = mContext.resources.getDimension(R.dimen.padding_8)
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)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.oppia.app.customview.inputInteractionView

import android.content.Context
import android.text.InputFilter
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
attributes()
}

/** This function contains default attributes of [TextInputInteractionView]. */
fun attributes() {
setBackgroundResource(R.drawable.edit_text_background)
val paddingPixel = mContext.resources.getDimension(R.dimen.padding_8)
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)
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
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 androidx.lifecycle.Observer
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.model.CellularDataPreference
Expand All @@ -27,6 +33,7 @@ class StateFragmentPresenter @Inject constructor(
private var showCellularDataDialog = true
private var useCellularData = false

private var llRoot: LinearLayout? = null
fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?): View? {
cellularDialogController.getCellularDataPreference()
.observe(fragment, Observer<AsyncResult<CellularDataPreference>>{
Expand All @@ -42,6 +49,10 @@ class StateFragmentPresenter @Inject constructor(
it.stateFragment = fragment as StateFragment
it.viewModel = getStateViewModel()
}
llRoot = binding.root.findViewById(R.id.llRoot)
addTextInputContentCard("text")
addNumberInputContentCard("number 1")
addFractionInputContentCard("fraction 1/1")
return binding.root
}

Expand Down Expand Up @@ -74,6 +85,56 @@ class StateFragmentPresenter @Inject constructor(
dialogFragment.showNow(fragment.childFragmentManager, TAG_CELLULAR_DATA_DIALOG)
}

/** The function for adding [TextInputInteractionView]. */
fun addTextInputContentCard(placeholder: String) {
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)
}

/** The function for adding [NumberInputInteractionView]. */
fun addNumberInputContentCard(placeholder: String) {
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)

}

/** The function for adding [FractionInputInteractionView]. */
fun addFractionInputContentCard(placeholder: String) {
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)
}

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
6 changes: 6 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,6 @@
<?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" />
</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="4dp" />
<solid android:color="@color/white" />
<stroke
android:width="1dp"
android:color="@color/grey" />
</shape>
64 changes: 64 additions & 0 deletions app/src/main/res/drawable/edit_text_background_shadow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<corners android:radius="5dp"></corners>
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
<solid android:color="@color/grey_shade_10" />
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
</shape>
</item>
<item>
<shape>
<corners android:radius="5dp"></corners>
<solid android:color="@color/blue_shade_20" />
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
</shape>
</item>
<item>
<shape>
<corners android:radius="5dp"></corners>
<solid android:color="@color/blue_shade_40" />
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
</shape>
</item>
<item>
<shape>
<corners android:radius="5dp"></corners>
<solid android:color="@color/blue_shade_50" />
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
</shape>
</item>
<item>
<shape>
<corners android:radius="5dp"></corners>
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
<solid android:color="@color/blue_shade_60" />
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
</shape>
</item>
<item>
<shape>
<corners android:radius="4dp"></corners>
<solid android:color="@color/white" />
</shape>
</item>
</layer-list>
3 changes: 1 addition & 2 deletions app/src/main/res/layout/cellular_data_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:text="@string/cellular_data_alert_dialog_checkbox">
</CheckBox>
android:text="@string/cellular_data_alert_dialog_checkbox"/>
</RelativeLayout>
Loading