summaryrefslogtreecommitdiffhomepage
path: root/android/src
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-06-21 15:10:02 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-06-24 14:33:00 +0000
commite76c997d2cc654b6c4ea24f079fde9cf1ac038a1 (patch)
treecfd8a2adf0bce5bf68869826d3241b506a1f21cf /android/src
parent3b335a668ad1b2d36f5a00c081ad660d7c0baf80 (diff)
downloadmullvadvpn-e76c997d2cc654b6c4ea24f079fde9cf1ac038a1.tar.xz
mullvadvpn-e76c997d2cc654b6c4ea24f079fde9cf1ac038a1.zip
Show dialog if user email is empty
Diffstat (limited to 'android/src')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ProblemReportFragment.kt38
1 files changed, 29 insertions, 9 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ProblemReportFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ProblemReportFragment.kt
index 1e72aef5f6..e2caee4fd8 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ProblemReportFragment.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ProblemReportFragment.kt
@@ -2,6 +2,7 @@ package net.mullvad.mullvadvpn
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
+import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.Job
@@ -82,7 +83,7 @@ class ProblemReportFragment : Fragment() {
sendButton.setOnClickListener {
sendReportJob?.cancel()
- sendReportJob = sendReport()
+ sendReportJob = sendReport(true)
}
editMessageButton.setOnClickListener {
@@ -90,7 +91,7 @@ class ProblemReportFragment : Fragment() {
}
tryAgainButton.setOnClickListener {
- sendReportJob = sendReport()
+ sendReportJob = sendReport(false)
}
userEmailInput.setText(problemReport.userEmail)
@@ -112,22 +113,33 @@ class ProblemReportFragment : Fragment() {
super.onDestroyView()
}
- private fun sendReport() = GlobalScope.launch(Dispatchers.Main) {
+ private fun sendReport(shouldConfirmNoEmail: Boolean) = GlobalScope.launch(Dispatchers.Main) {
val userEmail = userEmailInput.text.toString()
problemReport.userEmail = userEmail
problemReport.userMessage = userMessageInput.text.toString()
- showSendingScreen()
+ if (!userEmail.isEmpty() || !shouldConfirmNoEmail || confirmSendWithNoEmail()) {
+ showSendingScreen()
- if (problemReport.send().await()) {
- clearForm()
- showSuccessScreen(userEmail)
- } else {
- showErrorScreen()
+ if (problemReport.send().await()) {
+ clearForm()
+ showSuccessScreen(userEmail)
+ } else {
+ showErrorScreen()
+ }
}
}
+ private suspend fun confirmSendWithNoEmail(): Boolean {
+ val confirmation = CompletableDeferred<Boolean>()
+
+ problemReport.confirmNoEmail = confirmation
+ showConfirmNoEmailDialog()
+
+ return confirmation.await()
+ }
+
private fun clearForm() {
userEmailInput.setText("")
userMessageInput.setText("")
@@ -140,6 +152,14 @@ class ProblemReportFragment : Fragment() {
bodyContainer.displayedChild = 0
}
+ private fun showConfirmNoEmailDialog() {
+ val transaction = fragmentManager?.beginTransaction()
+
+ transaction?.addToBackStack(null)
+
+ ConfirmNoEmailDialogFragment().show(transaction, null)
+ }
+
private fun showSendingScreen() {
bodyContainer.displayedChild = 1