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 #417: Ensure state navigation buttons are de-duplicated, the same size, and aligned #495

Merged
merged 12 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
4 changes: 2 additions & 2 deletions .idea/misc.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 @@ -113,6 +113,8 @@ dependencies {
// TODO (#59): Remove this once Bazel is introduced
api project(':data')
implementation project(":model")
testImplementation project(":model")
androidTestImplementation project(":model")
implementation project(":domain")
implementation project(":utility")
}
23 changes: 10 additions & 13 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.app">

<!-- TODO(#56): Reenable landscape support. -->

<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".application.OppiaApplication"
Expand All @@ -15,17 +13,17 @@
android:theme="@style/OppiaTheme">
<activity
android:name=".home.continueplaying.ContinuePlayingActivity"
android:theme="@style/OppiaThemeWithoutActionBar"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".home.HomeActivity"
android:screenOrientation="portrait" />
<activity android:name=".player.audio.testing.AudioFragmentTestActivity" />
<activity
android:name=".player.exploration.ExplorationActivity"
android:theme="@style/OppiaThemeWithoutActionBar"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"/>
android:theme="@style/OppiaThemeWithoutActionBar"
android:windowSoftInputMode="adjustResize" />
<activity android:name=".player.state.testing.StateFragmentTestActivity" />
<activity
android:name=".profile.ProfileActivity"
Expand All @@ -38,8 +36,8 @@
android:screenOrientation="portrait" />
<activity
android:name=".splash.SplashActivity"
android:theme="@style/SplashScreenTheme"
android:screenOrientation="portrait">
android:screenOrientation="portrait"
android:theme="@style/SplashScreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand All @@ -51,11 +49,10 @@
</activity>
<activity
android:name=".story.StoryActivity"
android:theme="@style/OppiaThemeWithoutActionBar"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity android:name=".story.testing.StoryFragmentTestActivity" />
<activity android:name=".testing.BindableAdapterTestActivity" />
<activity android:name=".testing.ContentCardTestActivity" />
<activity android:name=".testing.ContinuePlayingFragmentTestActivity" />
<activity android:name=".testing.HtmlParserTestActivity" />
<activity android:name=".testing.InputInteractionViewTestActivity" />
Expand All @@ -71,7 +68,7 @@
android:screenOrientation="portrait" />
<activity
android:name=".topic.TopicActivity"
android:theme="@style/OppiaThemeWithoutActionBar"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/OppiaThemeWithoutActionBar" />
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import org.oppia.app.settings.profile.ProfileResetPinActivity
import org.oppia.app.story.StoryActivity
import org.oppia.app.story.testing.StoryFragmentTestActivity
import org.oppia.app.testing.BindableAdapterTestActivity
import org.oppia.app.testing.ContentCardTestActivity
import org.oppia.app.testing.ContinuePlayingFragmentTestActivity
import org.oppia.app.testing.HtmlParserTestActivity
import org.oppia.app.testing.TopicTestActivity
Expand All @@ -42,7 +41,6 @@ interface ActivityComponent {
fun inject(audioFragmentTestActivity: AudioFragmentTestActivity)
fun inject(bindableAdapterTestActivity: BindableAdapterTestActivity)
fun inject(conceptCardFragmentTestActivity: ConceptCardFragmentTestActivity)
fun inject(contentCardTestActivity: ContentCardTestActivity)
fun inject(continuePlayingActivity: ContinuePlayingActivity)
fun inject(continuePlayingFragmentTestActivity: ContinuePlayingFragmentTestActivity)
fun inject(explorationActivity: ExplorationActivity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package org.oppia.app.databinding

import android.graphics.drawable.GradientDrawable
import android.view.View
import android.widget.Button
import androidx.annotation.ColorInt
import androidx.annotation.DrawableRes
import androidx.databinding.BindingAdapter
import org.oppia.app.R

Expand All @@ -27,3 +29,8 @@ fun setRectangleBackgroundDrawable(view: View, @ColorInt colorRgb: Int) {
// The input color needs to have alpha channel prepended to it.
(view.background as GradientDrawable).setColor((0xff000000 or colorRgb.toLong()).toInt())
}

@BindingAdapter("android:button")
fun setBackgroundResource(button: Button, @DrawableRes resource: Int) {
button.setBackgroundResource(resource)
}
20 changes: 0 additions & 20 deletions app/src/main/java/org/oppia/app/home/HomeFragmentPresenter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@ import org.oppia.app.model.TopicSummary
import org.oppia.app.model.UserAppHistory
import org.oppia.domain.UserAppHistoryController
import org.oppia.domain.exploration.ExplorationDataController
import org.oppia.domain.exploration.TEST_EXPLORATION_ID_30
import org.oppia.domain.topic.TopicListController
import org.oppia.util.data.AsyncResult
import org.oppia.util.logging.Logger
import javax.inject.Inject

private const val EXPLORATION_ID = TEST_EXPLORATION_ID_30
private const val TAG_HOME_FRAGMENT = "HomeFragment"

/** The presenter for [HomeFragment]. */
@FragmentScope
class HomeFragmentPresenter @Inject constructor(
Expand Down Expand Up @@ -79,22 +75,6 @@ class HomeFragmentPresenter @Inject constructor(
return binding.root
}

fun playExplorationButton(v: View) {
explorationDataController.stopPlayingExploration()
explorationDataController.startPlayingExploration(
EXPLORATION_ID
).observe(fragment, Observer<AsyncResult<Any?>> { result ->
when {
result.isPending() -> logger.d(TAG_HOME_FRAGMENT, "Loading exploration")
result.isFailure() -> logger.e(TAG_HOME_FRAGMENT, "Failed to load exploration", result.getErrorOrNull()!!)
else -> {
logger.d(TAG_HOME_FRAGMENT, "Successfully loaded exploration")
routeToExplorationListener.routeToExploration(EXPLORATION_ID)
}
}
})
}

private val topicListSummaryResultLiveData: LiveData<AsyncResult<TopicList>> by lazy {
topicListController.getTopicList()
}
Expand Down
20 changes: 19 additions & 1 deletion app/src/main/java/org/oppia/app/player/state/StateFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@ import org.oppia.app.fragment.InjectableFragment
import org.oppia.app.model.UserAnswer
import org.oppia.app.player.audio.CellularDataInterface
import org.oppia.app.player.state.answerhandling.InteractionAnswerReceiver
import org.oppia.app.player.state.listener.ContinueNavigationButtonListener
import org.oppia.app.player.state.listener.NextNavigationButtonListener
import org.oppia.app.player.state.listener.PreviousNavigationButtonListener
import org.oppia.app.player.state.listener.ReturnToTopicNavigationButtonListener
import org.oppia.app.player.state.listener.SubmitNavigationButtonListener
import javax.inject.Inject

/** Fragment that represents the current state of an exploration. */
class StateFragment : InjectableFragment(), CellularDataInterface, InteractionAnswerReceiver {
class StateFragment : InjectableFragment(), CellularDataInterface, InteractionAnswerReceiver,
ContinueNavigationButtonListener, NextNavigationButtonListener, PreviousNavigationButtonListener,
ReturnToTopicNavigationButtonListener, SubmitNavigationButtonListener {

companion object {
/**
* Creates a new instance of a StateFragment.
Expand Down Expand Up @@ -52,6 +60,16 @@ class StateFragment : InjectableFragment(), CellularDataInterface, InteractionAn
stateFragmentPresenter.handleAnswerReadyForSubmission(answer)
}

override fun onContinueButtonClicked() = stateFragmentPresenter.onContinueButtonClicked()

override fun onNextButtonClicked() = stateFragmentPresenter.onNextButtonClicked()

override fun onPreviousButtonClicked() = stateFragmentPresenter.onPreviousButtonClicked()

override fun onReturnToTopicButtonClicked() = stateFragmentPresenter.onReturnToTopicButtonClicked()

override fun onSubmitButtonClicked() = stateFragmentPresenter.onSubmitButtonClicked()

fun handlePlayAudio() = stateFragmentPresenter.handleAudioClick()

fun handleKeyboardAction() = stateFragmentPresenter.handleKeyboardAction()
Expand Down
Loading