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 all 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.

34 changes: 17 additions & 17 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.app">
<uses-permission android:name="android.permission.INTERNET"/>
package="org.oppia.app">

<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".application.OppiaApplication"
android:allowBackup="true"
Expand All @@ -10,27 +11,26 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/OppiaTheme">
<activity android:name="org.oppia.app.topic.conceptcard.testing.ConceptCardFragmentTestActivity"/>
<activity android:name="org.oppia.app.player.state.testing.StateFragmentTestActivity"/>
<activity android:name=".player.exploration.ExplorationActivity"/>
<activity android:name=".topic.questionplayer.QuestionPlayerActivity"/>
<activity android:name=".topic.TopicActivity"/>
<activity android:name=".player.audio.testing.AudioFragmentTestActivity"/>
<activity android:name="org.oppia.app.player.state.testing.StateFragmentTestActivity"/>
<activity android:name="org.oppia.app.home.HomeActivity">
<activity android:name="org.oppia.app.topic.conceptcard.testing.ConceptCardFragmentTestActivity" />
<activity android:name="org.oppia.app.player.state.testing.StateFragmentTestActivity" />
<activity android:name=".player.exploration.ExplorationActivity" />
<activity android:name=".topic.questionplayer.QuestionPlayerActivity" />
<activity android:name=".topic.TopicActivity" />
<activity android:name=".player.audio.testing.AudioFragmentTestActivity" />
<activity android:name="org.oppia.app.home.HomeActivity" />
<activity android:name=".activity.InputInteractionViewTestActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".splash.SplashActivity"
android:theme="@style/SplashScreenTheme">
</activity>
<activity android:name=".testing.BindableAdapterTestActivity"/>
android:theme="@style/SplashScreenTheme"></activity>
<activity android:name=".testing.BindableAdapterTestActivity" />
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.oppia.app.activity

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import org.oppia.app.R
import org.oppia.app.customview.interaction.NumericInputInteractionView

/**
* This is a dummy activity to test input interaction views.
* It contains [NumericInputInteractionView] .
*/
class InputInteractionViewTestActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_numeric_input_interaction_view_test)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.oppia.app.customview.interaction

import org.oppia.app.model.InteractionObject

/** This interface helps to get answer from input interaction views as [InteractionObject]. */
interface InteractionAnswerRetriever {
fun getPendingAnswer(): InteractionObject
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.oppia.app.customview.interaction

import android.content.Context
import android.util.AttributeSet
import android.widget.EditText
import org.oppia.app.model.InteractionObject

// TODO(#249): These are the attributes which should be defined in XML, that are required for this interaction view to work correctly
// digits="0123456789."
// hint="Write the digit here."
// inputType="numberDecimal"
// background="@drawable/edit_text_background"
// maxLength="200".

/** The custom EditText class for numeric input interaction view. */
class NumericInputInteractionView @JvmOverloads constructor(
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = android.R.attr.editTextStyle
) : EditText(context, attrs, defStyle), InteractionAnswerRetriever {

override fun getPendingAnswer(): InteractionObject {
val interactionObjectBuilder = InteractionObject.newBuilder()
if (!text.isNullOrEmpty()) {
interactionObjectBuilder.setReal(text.toString().toDouble())
}
return interactionObjectBuilder.build()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
tools:context=".activity.InputInteractionViewTestActivity">

<org.oppia.app.customview.interaction.NumericInputInteractionView
android:id="@+id/test_number_input_interaction_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="@drawable/edit_text_background"
android:digits="0123456789."
android:focusable="true"
android:hint="Write the digit here."
android:inputType="numberDecimal"
android:longClickable="false"
android:maxLength="200"
android:padding="8dp"
android:singleLine="true" />
</LinearLayout>
1 change: 0 additions & 1 deletion app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
<dimen name="audio_fragment_margin">32dp</dimen>
<dimen name="cellular_data_dialog_padding">24dp</dimen>
<dimen name="state_previous_next_button_radius">4dp</dimen>
<dimen name="padding_8">8dp</dimen>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package org.oppia.app.activity

import android.app.Activity
import android.content.Intent
import android.content.pm.ActivityInfo
import android.content.res.Configuration
import android.os.SystemClock
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.app.R
import org.oppia.app.model.InteractionObject
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.action.ViewActions.typeText
import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.intent.Intents
import androidx.test.espresso.matcher.ViewMatchers
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Before
import org.oppia.app.customview.interaction.NumericInputInteractionView

/** Tests for [InputInteractionViewTestActivity]. */
@RunWith(AndroidJUnit4::class)
class InputInteractionViewTestActivityTest {
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
@get:Rule
var activityTestRule: ActivityTestRule<InputInteractionViewTestActivity> = ActivityTestRule(
InputInteractionViewTestActivity::class.java, /* initialTouchMode= */ true, /* launchActivity= */ false
)
private lateinit var activityScenario: ActivityScenario<InputInteractionViewTestActivity>

@Before
fun setUp() {
activityScenario = ActivityScenario.launch(InputInteractionViewTestActivity::class.java)
Intents.init()
}

@Test
fun testNumericInputInteractionView_withNoInputText_hasCorrectPendingAnswerType() {
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
activityScenario.onActivity { activity ->
val textAnswerRetriever =
activity.findViewById(R.id.test_number_input_interaction_view) as NumericInputInteractionView
assertThat(textAnswerRetriever.getPendingAnswer()).isInstanceOf(InteractionObject::class.java)
assertThat(textAnswerRetriever.getPendingAnswer().real).isWithin(1e-5).of(0.0)
}
}

@Test
fun testNumericInputInteractionView_withInputtedText_hasCorrectPendingAnswer() {
onView(withId(R.id.test_number_input_interaction_view)).perform(typeText("9"))
activityScenario.onActivity { activity ->
val textAnswerRetriever =
activity.findViewById(R.id.test_number_input_interaction_view) as NumericInputInteractionView
assertThat(textAnswerRetriever.getPendingAnswer()).isInstanceOf(InteractionObject::class.java)
assertThat(textAnswerRetriever.getPendingAnswer().objectTypeCase).isEqualTo(InteractionObject.ObjectTypeCase.REAL)
assertThat(textAnswerRetriever.getPendingAnswer().real).isEqualTo(9.0)
}
}

@Test
fun testNumericInputInteractionView_withInputtedText_hasCorrectPendingAnswerWithDecimalValues() {
onView(withId(R.id.test_number_input_interaction_view)).perform(typeText("9.5"))
activityScenario.onActivity { activity ->
val textAnswerRetriever =
activity.findViewById(R.id.test_number_input_interaction_view) as NumericInputInteractionView
assertThat(textAnswerRetriever.getPendingAnswer().objectTypeCase).isEqualTo(InteractionObject.ObjectTypeCase.REAL)
assertThat(textAnswerRetriever.getPendingAnswer().real).isEqualTo(9.5)
}
}

@Test
fun testTextInputInteractionView_withInputtedText_onConfigurationChange_hasCorrectPendingAnswer() {
onView(withId(R.id.test_number_input_interaction_view)).perform(typeText("9"))
activityScenario.onActivity { activity ->
activity.requestedOrientation = Configuration.ORIENTATION_LANDSCAPE
}
onView(withId(R.id.test_number_input_interaction_view)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
.check(
ViewAssertions.matches(ViewMatchers.withText("9"))
)
activityScenario.recreate()
onView(withId(R.id.test_number_input_interaction_view)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
.check(
ViewAssertions.matches(ViewMatchers.withText("9"))
)
}
}