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 #5086 : Implement Dark Mode support for NPS Survey #5104

Merged
merged 12 commits into from
Aug 1, 2023
Merged
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
android:name=".app.survey.SurveyActivity"
android:label="@string/survey_activity_title"
android:theme="@style/OppiaThemeWithoutActionBar"
android:windowSoftInputMode="adjustResize" />
android:windowSoftInputMode="adjustNothing" />

<provider
android:name="androidx.work.impl.WorkManagerInitializer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class SurveyOnboardingBackgroundView : View {
strokeWidth = [email protected]
color = ContextCompat.getColor(
context,
R.color.component_color_survey_onboarding_background_color
R.color.component_color_survey_popup_background_color
)
}
setBackgroundColor(Color.TRANSPARENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ class ExplorationActivityPresenter @Inject constructor(
oppiaLogger.d("ExplorationActivity", "Successfully stopped exploration")
if (isCompletion) {
maybeShowSurveyDialog(profileId, topicId)
} else {
backPressActivitySelector()
}
}
}
Expand All @@ -310,8 +312,6 @@ class ExplorationActivityPresenter @Inject constructor(
* current exploration.
*/
fun backButtonPressed() {
// check if survey should be shown
maybeShowSurveyDialog(profileId, topicId)
// If checkpointing is not enabled, show StopExplorationDialogFragment to exit the exploration,
// this is expected to happen if the exploration is marked as completed.
if (!isCheckpointingEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class ExitSurveyConfirmationDialogFragment : InjectableDialogFragment() {

val profileId = args.getProto(PROFILE_ID_KEY, ProfileId.getDefaultInstance())

dialog?.setCanceledOnTouchOutside(false)
dialog?.setCancelable(false)

return exitSurveyConfirmationDialogFragmentPresenter.handleCreateView(
inflater,
container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,27 @@ class SurveyActivity : InjectableAutoLocalizedAppCompatActivity() {
@Inject
lateinit var surveyActivityPresenter: SurveyActivityPresenter

private lateinit var profileId: ProfileId

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
(activityComponent as ActivityComponentImpl).inject(this)

val params = intent.extractParams()
this.profileId = params.profileId ?: ProfileId.newBuilder().setInternalId(-1).build()

surveyActivityPresenter.handleOnCreate(
params.profileId,
profileId,
params.topicId,
params.explorationId
)
}

override fun onBackPressed() {
val dialogFragment = ExitSurveyConfirmationDialogFragment.newInstance(profileId)
dialogFragment.showNow(supportFragmentManager, TAG_EXIT_SURVEY_CONFIRMATION_DIALOG)
}

companion object {
private const val PARAMS_KEY = "SurveyActivity.params"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.oppia.android.app.model.SurveyQuestionName
import org.oppia.android.databinding.SurveyWelcomeDialogFragmentBinding
import org.oppia.android.domain.oppialogger.OppiaLogger
import org.oppia.android.domain.oppialogger.analytics.AnalyticsController
import org.oppia.android.domain.profile.ProfileManagementController
import org.oppia.android.domain.survey.SurveyController
import org.oppia.android.util.data.AsyncResult
import org.oppia.android.util.data.DataProviders.Companion.toLiveData
Expand All @@ -25,7 +26,8 @@ class SurveyWelcomeDialogFragmentPresenter @Inject constructor(
private val fragment: Fragment,
private val surveyController: SurveyController,
private val oppiaLogger: OppiaLogger,
private val analyticsController: AnalyticsController
private val analyticsController: AnalyticsController,
private val profileManagementController: ProfileManagementController
) {
private lateinit var explorationId: String

Expand Down Expand Up @@ -54,6 +56,7 @@ class SurveyWelcomeDialogFragmentPresenter @Inject constructor(
.commitNow()
}

profileManagementController.updateSurveyLastShownTimestamp(profileId)
logSurveyPopUpShownEvent(explorationId, topicId, profileId)

return binding.root
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/nps_survey_button_background.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="@dimen/survey_button_corner_radius" />
<solid android:color="@color/component_color_shared_button_active_solid_color" />
<stroke
android:width="1dp"
android:color="@color/component_color_shared_button_active_stroke_color" />
</shape>
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="@dimen/survey_button_corner_radius" />
<solid android:color="@color/component_color_shared_button_inactive_solid_color" />
<stroke
android:width="1dp"
android:color="@color/component_color_nps_survey_button_inactive_stroke_color" />
</shape>
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="@dimen/survey_shared_corner_radius" />
<solid android:color="@color/component_color_survey_background_color" />
<solid android:color="@color/component_color_survey_white_button_color" />
<stroke
android:width="1dp"
android:color="@color/component_color_survey_primary_button_background_color" />
android:color="@color/component_color_shared_button_active_stroke_color" />
</shape>
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="@dimen/survey_shared_corner_radius" />
<solid android:color="@color/component_color_survey_primary_button_background_color" />
<solid android:color="@color/component_color_survey_green_button_color" />
<stroke
android:width="1dp"
android:color="@color/component_color_survey_shared_button_color" />
android:color="@color/component_color_survey_white_button_color" />
</shape>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="@dimen/survey_shared_corner_radius" />
<solid android:color="@color/component_color_shared_white_background_color" />
<solid android:color="@color/component_color_shared_screen_primary_background_color" />
<stroke
android:width="2dp"
android:color="@color/component_color_survey_dialog_stroke_color" />
Expand Down
7 changes: 0 additions & 7 deletions app/src/main/res/drawable/survey_next_button_background.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:tint="#15716A"
android:tint="@color/component_color_survey_nps_selected_background_color"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/survey_nps_radio_text_color.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/component_color_shared_secondary_4_text_color" android:state_enabled="true" />
<item android:color="@color/component_color_shared_active_text_color" android:state_enabled="false" />
<item android:color="@color/component_color_survey_nps_selected_text_color" android:state_enabled="true" />
<item android:color="@color/component_color_survey_nps_unselected_text_color" android:state_enabled="false" />
</selector>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:tint="#E2F5F4"
android:tint="@color/component_color_survey_nps_unselected_background_color"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/survey_progress_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<scale android:scaleWidth="100%">
<shape>
<corners android:radius="0dp" />
<solid android:color="@color/component_color_shared_progress_bar_solid_color" />
<solid android:color="@color/component_color_survey_progress_bar_solid_color" />
<stroke
android:width="1dp"
android:color="@color/component_color_shared_progress_bar_background_color" />
android:color="@color/component_color_shared_white_background_color" />
</shape>
</scale>
</item>
Expand Down

This file was deleted.

146 changes: 146 additions & 0 deletions app/src/main/res/layout-land/survey_fragment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<data>

<variable
name="viewModel"
type="org.oppia.android.app.survey.SurveyViewModel" />
</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/component_color_survey_background_color">

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/survey_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<androidx.appcompat.widget.Toolbar
android:id="@+id/survey_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/component_color_shared_activity_toolbar_color"
android:contentDescription="@string/survey_exit_button_description"
android:minHeight="?attr/actionBarSize"
android:theme="@style/Widget.AppCompat.ActionBar"
app:navigationIcon="@drawable/ic_close_white_24dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<ProgressBar
android:id="@+id/survey_progress_bar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="0dp"
android:layout_height="@dimen/survey_progress_bar_height"
android:layout_weight="1"
android:max="100"
android:progress="@{viewModel.progressPercentage}"
android:progressDrawable="@drawable/survey_progress_bar" />

<TextView
android:id="@+id/survey_progress_text"
style="@style/TextViewCenter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/survey_progress_text_margin_start"
android:layout_marginEnd="@dimen/survey_progress_text_margin_end"
android:fontFamily="sans-serif"
android:text="@{viewModel.questionProgressText}"
android:textColor="@color/component_color_shared_secondary_4_text_color"
android:textSize="14sp"
tools:text="25%" />
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/survey_content_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/survey_app_bar_layout">

<TextView
android:id="@+id/survey_question_text"
style="@style/TextViewStart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/survey_question_text_margin"
android:layout_marginTop="@dimen/survey_question_text_margin"
android:layout_marginEnd="@dimen/survey_question_text_margin"
android:fontFamily="sans-serif-medium"
android:text="@{viewModel.questionText}"
android:textColor="@color/component_color_shared_primary_text_color"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Please select one of the following:" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/survey_answers_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/survey_question_recycler_view_margin"
android:layout_marginTop="@dimen/survey_question_recycler_view_margin"
android:layout_marginEnd="@dimen/survey_question_recycler_view_margin"
android:clipToPadding="false"
android:overScrollMode="never"
android:scrollbars="none"
app:data="@{viewModel.itemList}"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintTop_toBottomOf="@id/survey_question_text"
tools:itemCount="1" />
</androidx.constraintlayout.widget.ConstraintLayout>

<FrameLayout
android:id="@+id/survey_buttons_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/survey_navigation_buttons_container_margin"
android:layout_marginBottom="@dimen/survey_navigation_buttons_container_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/survey_navigation_buttons_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<Button
android:id="@+id/survey_previous_button"
style="@style/SurveyPreviousButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/survey_previous_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/survey_next_button"
style="@style/SurveyNextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@{viewModel.canMoveToNextQuestion ? @drawable/state_button_primary_background : @drawable/state_button_inactive_background}"
android:enabled="@{viewModel.canMoveToNextQuestion}"
android:text="@string/next"
android:textColor="@{viewModel.canMoveToNextQuestion ? @color/component_color_shared_secondary_4_text_color : @color/component_color_survey_disabled_button_text_color}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Loading
Loading