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 #151: Lowfi numeric input interaction view part 2 #223

Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
faca25a
NumberInputInteractionView dynamically created on state interaction i…
nikitamarysolomanpvt Oct 9, 2019
c9b5919
NumberInputInteractionView dynamically created on state interaction i…
nikitamarysolomanpvt Oct 10, 2019
6235dfb
added fetch button, and fetch textview to fetch the data from dynamic…
nikitamarysolomanpvt Oct 10, 2019
3ab9ae3
nit changes
nikitamarysolomanpvt Oct 10, 2019
ceb27a4
nit changes
nikitamarysolomanpvt Oct 10, 2019
6b3daed
nit changes
nikitamarysolomanpvt Oct 10, 2019
b0fa8b4
nit changes
nikitamarysolomanpvt Oct 10, 2019
ce34219
nit changes
nikitamarysolomanpvt Oct 10, 2019
6755d5c
numericInputTypeView test case is in progress
nikitamarysolomanpvt Oct 11, 2019
acff28d
numericInputTypeView test case is in progress
nikitamarysolomanpvt Oct 11, 2019
7fb5ea4
nit changes as per #223
nikitamarysolomanpvt Oct 11, 2019
ba3be9b
nit changes as per #223
nikitamarysolomanpvt Oct 11, 2019
b474a73
On configuration changes save and restore the text of numericInputType
nikitamarysolomanpvt Oct 11, 2019
fc60566
Test Cases for NumericInputInteractionView,
nikitamarysolomanpvt Oct 11, 2019
9e5dc2e
Test Cases for NumericInputInteractionView,
nikitamarysolomanpvt Oct 14, 2019
a7ef482
PR suggestions updated
nikitamarysolomanpvt Oct 14, 2019
69b0b8c
PR suggestions updated
nikitamarysolomanpvt Oct 14, 2019
3578a0c
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
nikitamarysolomanpvt Oct 14, 2019
e7a6411
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
nikitamarysolomanpvt Oct 14, 2019
5d1c769
nit changes as per PR review
nikitamarysolomanpvt Oct 14, 2019
ed31dd5
nit changes as per PR review
nikitamarysolomanpvt Oct 14, 2019
65c41ca
nit changes as per PR review
nikitamarysolomanpvt Oct 15, 2019
5d4db81
nit changes as per PR review
nikitamarysolomanpvt Oct 15, 2019
fed8c7f
Number input test Activity test cases
nikitamarysolomanpvt Oct 15, 2019
ac13a74
nit changes
nikitamarysolomanpvt Oct 15, 2019
cce10c1
nit changes
nikitamarysolomanpvt Oct 15, 2019
41650b4
nit changes
nikitamarysolomanpvt Oct 15, 2019
0664bc6
nit changes
nikitamarysolomanpvt Oct 15, 2019
f55b8a8
nit changes
nikitamarysolomanpvt Oct 15, 2019
e652e42
nit changes
nikitamarysolomanpvt Oct 15, 2019
30f7ce0
nit changes
nikitamarysolomanpvt Oct 15, 2019
1737a33
nit changes
nikitamarysolomanpvt Oct 15, 2019
9920380
nit changes
nikitamarysolomanpvt Oct 15, 2019
7b86a0c
nit changes
nikitamarysolomanpvt Oct 15, 2019
46d37e6
nit changes
nikitamarysolomanpvt Oct 15, 2019
107e154
setReal type in getPendingAnswer
nikitamarysolomanpvt Oct 16, 2019
b7a406f
updated test cases, disabled long click to prevent pasting value
nikitamarysolomanpvt Oct 16, 2019
3b6c56d
nit changes
nikitamarysolomanpvt Oct 16, 2019
3b7a01f
Merge branches 'develop' and 'text-input-lowfi-numeric-input-interact…
nikitamarysolomanpvt Oct 16, 2019
326d3a9
nit changes
nikitamarysolomanpvt Oct 16, 2019
3aa6724
nit changes
nikitamarysolomanpvt Oct 16, 2019
7f51265
nit changes
nikitamarysolomanpvt Oct 16, 2019
a3cbe65
nit changes
nikitamarysolomanpvt Oct 16, 2019
6c18922
nit changes
nikitamarysolomanpvt Oct 16, 2019
eda21ad
nit changes
nikitamarysolomanpvt Oct 16, 2019
b72961c
nit changes
nikitamarysolomanpvt Oct 16, 2019
ade8a73
nit changes
nikitamarysolomanpvt Oct 16, 2019
0f033d9
NumericInputInteractionViewTestActivity renamed to InputInteractionVi…
nikitamarysolomanpvt Oct 16, 2019
b4fc329
nit changes
nikitamarysolomanpvt Oct 16, 2019
966f84d
nit changes
nikitamarysolomanpvt Oct 16, 2019
0b82bbf
nit changes
nikitamarysolomanpvt Oct 17, 2019
719a4db
nit
nikitamarysolomanpvt Oct 18, 2019
dd9163b
NumericInputInteractionView attributes are moved to xml,testcases upd…
nikitamarysolomanpvt Oct 18, 2019
910ec00
NumericInputInteractionView attributes are moved to xml,testcases upd…
nikitamarysolomanpvt Oct 18, 2019
d20c12e
TextInputInteractionView
nikitamarysolomanpvt Oct 18, 2019
2bc3292
TextInputInteractionView
nikitamarysolomanpvt Oct 19, 2019
61abbe9
nit
nikitamarysolomanpvt Oct 20, 2019
38d8e14
nit
nikitamarysolomanpvt Oct 20, 2019
9dae69d
nit
nikitamarysolomanpvt Oct 20, 2019
1c1e4cb
nit
nikitamarysolomanpvt Oct 20, 2019
16d4543
nit
nikitamarysolomanpvt Oct 21, 2019
fb2c026
nit
nikitamarysolomanpvt Oct 21, 2019
d729e43
nit
nikitamarysolomanpvt Oct 21, 2019
f27c017
nit
nikitamarysolomanpvt Oct 21, 2019
13a2013
Merge branches 'develop' and 'text-input-lowfi-numeric-input-interact…
nikitamarysolomanpvt Oct 21, 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
18 changes: 8 additions & 10 deletions .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.

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() {
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
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) {
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
val filterArray = arrayOfNulls<InputFilter>(1)
filterArray[0] = InputFilter.LengthFilter(length)
setFilters(filterArray)
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
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.Button
import android.widget.LinearLayout
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.Transformations
import org.oppia.app.R
import org.oppia.app.customview.inputInteractionView.NumberInputInteractionView
import org.oppia.app.databinding.StateFragmentBinding
import org.oppia.app.fragment.FragmentScope
import org.oppia.app.model.CellularDataPreference
Expand All @@ -17,6 +23,7 @@ import org.oppia.domain.audio.CellularDialogController
import org.oppia.domain.exploration.ExplorationProgressController
import org.oppia.util.data.AsyncResult
import org.oppia.util.logging.Logger
import java.lang.Exception
import javax.inject.Inject

private const val TAG_CELLULAR_DATA_DIALOG = "CELLULAR_DATA_DIALOG"
Expand All @@ -33,7 +40,9 @@ class StateFragmentPresenter @Inject constructor(

private var showCellularDataDialog = true
private var useCellularData = false

private var llRoot: LinearLayout? = null
private var dummyEditTextButton: Button? = null
private var dummyFetchDataTV: TextView? = null
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?): View? {
cellularDialogController.getCellularDataPreference()
.observe(fragment, Observer<AsyncResult<CellularDataPreference>> {
Expand All @@ -51,7 +60,9 @@ class StateFragmentPresenter @Inject constructor(
}

subscribeToCurrentState()

llRoot = binding.root.findViewById(R.id.llRoot)
dummyEditTextButton = binding.root.findViewById(R.id.dummy_edittext_button)
dummyFetchDataTV = binding.root.findViewById(R.id.fetched_data_tv)
return binding.root
}

Expand Down Expand Up @@ -94,10 +105,33 @@ class StateFragmentPresenter @Inject constructor(

private fun subscribeToCurrentState() {
ephemeralStateLiveData.observe(fragment, Observer<EphemeralState> { result ->
try {
if (result.state.interaction.id.equals("NumericInput"))
addNumberInputContentCard(result.state.interaction.customizationArgsMap.get("placeholder")!!.normalizedString)
} catch (e: Exception) {
}
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
logger.d("StateFragment", "getCurrentState: ${result.state.name}")
})
}

/** The function for adding [NumberInputInteractionView]. */
fun addNumberInputContentCard(placeholder: String) {
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
var contentComponent = NumberInputInteractionView(
fragment.context!!,
placeholder,
1
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
)
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
dummyEditTextButton!!.setOnClickListener(View.OnClickListener {
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
dummyFetchDataTV!!.setText(contentComponent.text)
})
}

private val ephemeralStateLiveData: LiveData<EphemeralState> by lazy {
getEphemeralState()
}
Expand All @@ -112,4 +146,8 @@ class StateFragmentPresenter @Inject constructor(
}
return ephemeralStateResult.getOrDefault(EphemeralState.getDefaultInstance())
}

fun dpToPx(dp: Int): Int {
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
return (dp * Resources.getSystem().getDisplayMetrics().density).toInt()
}
}
61 changes: 54 additions & 7 deletions app/src/main/res/layout/state_fragment.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>
<import type="android.view.View"/>

<import type="android.view.View" />

<variable
name="stateFragment"
type="org.oppia.app.player.state.StateFragment"/>
type="org.oppia.app.player.state.StateFragment" />

<variable
name="viewModel"
type="org.oppia.app.player.state.StateViewModel"/>
type="org.oppia.app.player.state.StateViewModel" />

<variable
name="presenter"
type="org.oppia.app.player.state.StateFragmentPresenter" />
</data>

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

<LinearLayout
android:id="@+id/linearLayout"
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:orientation="vertical"
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
android:visibility="@{viewModel.isAudioFragmentVisible? View.VISIBLE: View.GONE}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<fragment
android:id="@+id/audio_fragment"
class="org.oppia.app.player.audio.AudioFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content" />
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
</LinearLayout>

<LinearLayout
android:id="@+id/llRoot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="24dp"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="@id/dummy_edittext_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/dummy_edittext_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:text="fetch"
app:layout_constraintBottom_toTopOf="@id/fetched_data_tv"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/fetched_data_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/padding_8"
android:gravity="center"
android:hint="click the fetch button to fetch data from edit text"
app:layout_constraintBottom_toTopOf="@id/dummy_audio_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/dummy_audio_button"
android:layout_width="wrap_content"
Expand All @@ -42,6 +88,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.935" />
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Loading