Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Commit 6fec907

Browse files
SamuraiKekmtwalli
andauthored
Srs progress loading button (EXPOSUREAPP-14322) (#5710)
* Add progress loading button to end of srs submission. * Fix buttons state. * Address comments. Co-authored-by: Mohamed <[email protected]>
1 parent 6ecf04b commit 6fec907

8 files changed

+28
-14
lines changed

Corona-Warn-App/src/main/java/de/rki/coronawarnapp/srs/ui/symptoms/calendar/SrsSymptomsCalendarFragment.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class SrsSymptomsCalendarFragment : Fragment(R.layout.fragment_submission_sympto
6666

6767
binding.toolbar.setNavigationOnClickListener { viewModel.onCancelConfirmed() }
6868

69+
viewModel.showLoadingIndicator.observe(viewLifecycleOwner) { binding.symptomButtonNext.isLoading = it }
70+
6971
viewModel.events.observe(viewLifecycleOwner) {
7072
when (it) {
7173
SrsSymptomsCalendarNavigation.ShowCloseDialog -> showCloseDialog { viewModel.goHome() }
@@ -114,7 +116,7 @@ class SrsSymptomsCalendarFragment : Fragment(R.layout.fragment_submission_sympto
114116
}
115117

116118
symptomButtonNext.apply {
117-
isEnabled = symptomStart != null
119+
isActive = symptomStart != null
118120
setOnClickListener { viewModel.onDone() }
119121
}
120122
}

Corona-Warn-App/src/main/java/de/rki/coronawarnapp/srs/ui/symptoms/calendar/SrsSymptomsCalendarViewModel.kt

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class SrsSymptomsCalendarViewModel @AssistedInject constructor(
3232
val symptomStart = symptomStartInternal.asLiveData(context = dispatcherProvider.Default)
3333

3434
val events = SingleLiveEvent<SrsSymptomsCalendarNavigation>()
35+
val showLoadingIndicator = SingleLiveEvent<Boolean>()
3536

3637
fun onCancelConfirmed() {
3738
Timber.d("Canceled SRS submission")
@@ -47,6 +48,7 @@ class SrsSymptomsCalendarViewModel @AssistedInject constructor(
4748
return
4849
}
4950
Timber.tag(TAG).d("onDone() clicked on calender screen.")
51+
showLoadingIndicator.postValue(true)
5052
submitSrs()
5153
}
5254

@@ -65,6 +67,8 @@ class SrsSymptomsCalendarViewModel @AssistedInject constructor(
6567
events.postValue(SrsSymptomsCalendarNavigation.GoToThankYouScreen(submissionType))
6668
} catch (e: Exception) {
6769
events.postValue(SrsSymptomsCalendarNavigation.Error(e))
70+
} finally {
71+
showLoadingIndicator.postValue(false)
6872
}
6973
}
7074

Corona-Warn-App/src/main/java/de/rki/coronawarnapp/srs/ui/symptoms/intro/SrsSymptomsIntroductionFragment.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class SrsSymptomsIntroductionFragment : Fragment(R.layout.fragment_submission_sy
5656
updateButtons(it)
5757
}
5858

59+
viewModel.showLoadingIndicator.observe(viewLifecycleOwner) { binding.symptomButtonNext.isLoading = it }
60+
5961
viewModel.events.observe(viewLifecycleOwner) {
6062
when (it) {
6163
SrsSymptomsIntroductionNavigation.ShowCloseDialog -> showCloseDialog { viewModel.goHome() }
@@ -105,8 +107,8 @@ class SrsSymptomsIntroductionFragment : Fragment(R.layout.fragment_submission_sy
105107
}
106108

107109
binding.symptomButtonNext.apply {
108-
isEnabled = symptomIndication != null
109-
setText(
110+
isActive = symptomIndication != null
111+
defaultButton.setText(
110112
when (symptomIndication) {
111113
Symptoms.Indication.NEGATIVE -> R.string.submission_done_button_done
112114
Symptoms.Indication.NO_INFORMATION -> R.string.submission_done_button_done

Corona-Warn-App/src/main/java/de/rki/coronawarnapp/srs/ui/symptoms/intro/SrsSymptomsIntroductionViewModel.kt

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class SrsSymptomsIntroductionViewModel @AssistedInject constructor(
2626
) : CWAViewModel(dispatcherProvider) {
2727

2828
val events = SingleLiveEvent<SrsSymptomsIntroductionNavigation>()
29+
val showLoadingIndicator = SingleLiveEvent<Boolean>()
2930

3031
private val symptomIndicationInternal = MutableStateFlow<Symptoms.Indication?>(null)
3132
val symptomIndication = symptomIndicationInternal.asLiveData(context = dispatcherProvider.Default)
@@ -47,6 +48,7 @@ class SrsSymptomsIntroductionViewModel @AssistedInject constructor(
4748
}
4849

4950
fun onWarningClicked() {
51+
showLoadingIndicator.postValue(true)
5052
when (symptomIndication.value) {
5153
Symptoms.Indication.NEGATIVE -> {
5254
submitSRS(Symptoms.Indication.NEGATIVE)
@@ -76,6 +78,8 @@ class SrsSymptomsIntroductionViewModel @AssistedInject constructor(
7678
events.postValue(SrsSymptomsIntroductionNavigation.GoToThankYouScreen(submissionType))
7779
} catch (e: Exception) {
7880
events.postValue(SrsSymptomsIntroductionNavigation.Error(e))
81+
} finally {
82+
showLoadingIndicator.postValue(false)
7983
}
8084
}
8185

Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/submission/symptoms/calendar/SubmissionSymptomCalendarFragment.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class SubmissionSymptomCalendarFragment :
9595
}
9696

9797
symptomButtonNext.apply {
98-
isEnabled = symptomStart != null
98+
isActive = symptomStart != null
9999
setOnClickListener { viewModel.onDone() }
100100
}
101101
}

Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/submission/symptoms/introduction/SubmissionSymptomIntroductionFragment.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ class SubmissionSymptomIntroductionFragment :
8585
}
8686

8787
binding.symptomButtonNext.apply {
88-
isEnabled = symptomIndication != null
89-
setText(
88+
isActive = symptomIndication != null
89+
defaultButton.setText(
9090
when (symptomIndication) {
9191
Symptoms.Indication.NEGATIVE -> R.string.submission_done_button_done
9292
Symptoms.Indication.NO_INFORMATION -> R.string.submission_done_button_done

Corona-Warn-App/src/main/res/layout/fragment_submission_symptom_calendar.xml

+5-4
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,20 @@
108108

109109
</ScrollView>
110110

111-
<Button
111+
<de.rki.coronawarnapp.ui.view.ProgressLoadingButton
112112
android:id="@+id/symptom_button_next"
113113
style="@style/buttonPrimary"
114114
android:layout_width="match_parent"
115115
android:layout_height="wrap_content"
116-
android:layout_marginHorizontal="@dimen/spacing_normal"
117116
android:layout_marginVertical="@dimen/spacing_small"
118117
android:layout_marginBottom="@dimen/spacing_small"
119-
android:text="@string/submission_done_button_done"
118+
app:buttonText="@string/submission_done_button_done"
119+
app:isLoading="false"
120120
app:layout_constraintBottom_toBottomOf="parent"
121121
app:layout_constraintEnd_toEndOf="parent"
122122
app:layout_constraintStart_toStartOf="parent"
123-
app:layout_constraintTop_toBottomOf="@id/scrollView" />
123+
app:layout_constraintTop_toBottomOf="@id/scrollView"
124+
app:loadingText="@string/start_validation_rule_check_loading_text" />
124125

125126
</androidx.constraintlayout.widget.ConstraintLayout>
126127
</layout>

Corona-Warn-App/src/main/res/layout/fragment_submission_symptom_intro.xml

+5-4
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,18 @@
9696

9797
</ScrollView>
9898

99-
<Button
99+
<de.rki.coronawarnapp.ui.view.ProgressLoadingButton
100100
android:id="@+id/symptom_button_next"
101101
style="@style/buttonPrimary"
102102
android:layout_width="match_parent"
103103
android:layout_height="wrap_content"
104-
android:layout_marginHorizontal="@dimen/spacing_normal"
105104
android:layout_marginVertical="@dimen/spacing_small"
106-
android:text="@string/submission_symptom_further_button"
105+
app:buttonText="@string/submission_symptom_further_button"
106+
app:isLoading="false"
107107
app:layout_constraintBottom_toBottomOf="parent"
108108
app:layout_constraintEnd_toEndOf="parent"
109109
app:layout_constraintStart_toStartOf="parent"
110-
app:layout_constraintTop_toBottomOf="@id/scrollView" />
110+
app:layout_constraintTop_toBottomOf="@id/scrollView"
111+
app:loadingText="@string/start_validation_rule_check_loading_text" />
111112
</androidx.constraintlayout.widget.ConstraintLayout>
112113
</layout>

0 commit comments

Comments
 (0)