diff options
Diffstat (limited to 'android/src')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ProblemReportFragment.kt | 58 | ||||
| -rw-r--r-- | android/src/main/res/layout/problem_report.xml | 35 | ||||
| -rw-r--r-- | android/src/main/res/values/strings.xml | 3 |
3 files changed, 90 insertions, 6 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ProblemReportFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ProblemReportFragment.kt index 16fa27ebf1..d897d23d8d 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ProblemReportFragment.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ProblemReportFragment.kt @@ -1,5 +1,10 @@ package net.mullvad.mullvadvpn +import kotlinx.coroutines.launch +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.Job + import android.content.Context import android.os.Bundle import android.support.v4.app.Fragment @@ -10,6 +15,7 @@ import android.view.View import android.view.ViewGroup import android.widget.Button import android.widget.EditText +import android.widget.TextView import android.widget.ViewSwitcher import net.mullvad.mullvadvpn.dataproxy.MullvadProblemReport @@ -22,6 +28,15 @@ class ProblemReportFragment : Fragment() { private lateinit var userMessageInput: EditText private lateinit var sendButton: Button + private lateinit var sendingSpinner: View + private lateinit var sentSuccessfullyIcon: View + private lateinit var sendStatusLabel: TextView + private lateinit var sendDetailsLabel: TextView + private lateinit var responseMessageLabel: TextView + private lateinit var responseEmailLabel: TextView + + private var sendReportJob: Job? = null + override fun onAttach(context: Context) { super.onAttach(context) @@ -47,7 +62,17 @@ class ProblemReportFragment : Fragment() { userMessageInput = view.findViewById<EditText>(R.id.user_message) sendButton = view.findViewById<Button>(R.id.send_button) - sendButton.setOnClickListener { sendReport() } + sendingSpinner = view.findViewById<View>(R.id.sending_spinner) + sentSuccessfullyIcon = view.findViewById<View>(R.id.sent_successfully_icon) + sendStatusLabel = view.findViewById<TextView>(R.id.send_status) + sendDetailsLabel = view.findViewById<TextView>(R.id.send_details) + responseMessageLabel = view.findViewById<TextView>(R.id.response_message) + responseEmailLabel = view.findViewById<TextView>(R.id.response_email) + + sendButton.setOnClickListener { + sendReportJob?.cancel() + sendReportJob = sendReport() + } setSendButtonEnabled(false) userMessageInput.addTextChangedListener(InputWatcher()) @@ -55,12 +80,37 @@ class ProblemReportFragment : Fragment() { return view } - private fun sendReport() { - problemReport.userEmail = userEmailInput.text.toString() + override fun onDestroyView() { + sendReportJob?.cancel() + super.onDestroyView() + } + + private fun sendReport() = GlobalScope.launch(Dispatchers.Main) { + val userEmail = userEmailInput.text.toString() + + problemReport.userEmail = userEmail problemReport.userMessage = userMessageInput.text.toString() - problemReport.send() bodyContainer.showNext() + + problemReport.send().await() + showSuccessScreen(userEmail) + } + + private fun showSuccessScreen(userEmail: String) { + sendingSpinner.visibility = View.GONE + + sentSuccessfullyIcon.visibility = View.VISIBLE + sendStatusLabel.visibility = View.VISIBLE + sendDetailsLabel.visibility = View.VISIBLE + + if (!userEmail.isEmpty()) { + responseMessageLabel.visibility = View.VISIBLE + responseEmailLabel.visibility = View.VISIBLE + responseEmailLabel.text = userEmail + } + + sendStatusLabel.setText(R.string.sent) } private fun setSendButtonEnabled(enabled: Boolean) { diff --git a/android/src/main/res/layout/problem_report.xml b/android/src/main/res/layout/problem_report.xml index 99fbf5669d..03827ebd15 100644 --- a/android/src/main/res/layout/problem_report.xml +++ b/android/src/main/res/layout/problem_report.xml @@ -103,7 +103,7 @@ android:layout_gravity="center_horizontal" android:layout_marginBottom="32dp" > - <ProgressBar + <ProgressBar android:id="@+id/sending_spinner" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" @@ -112,6 +112,13 @@ android:indeterminateDuration="600" android:indeterminateDrawable="@drawable/icon_spinner" /> + <ImageView android:id="@+id/sent_successfully_icon" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_gravity="center" + android:src="@drawable/icon_success" + android:visibility="gone" + /> </FrameLayout> <TextView android:layout_width="wrap_content" @@ -123,7 +130,7 @@ android:text="@string/secure_connection" android:textAllCaps="true" /> - <TextView + <TextView android:id="@+id/send_status" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="4dp" @@ -132,6 +139,30 @@ android:textStyle="bold" android:text="@string/sending" /> + <TextView android:id="@+id/send_details" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textColor="@color/white60" + android:textSize="13sp" + android:text="@string/sent_thanks" + android:visibility="gone" + /> + <TextView android:id="@+id/response_message" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textColor="@color/white60" + android:textSize="13sp" + android:text="@string/sent_contact" + android:visibility="gone" + /> + <TextView android:id="@+id/response_email" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textColor="@color/white" + android:textSize="13sp" + android:textStyle="bold" + android:visibility="gone" + /> </LinearLayout> </ViewSwitcher> </LinearLayout> diff --git a/android/src/main/res/values/strings.xml b/android/src/main/res/values/strings.xml index 7f909a06a0..8bb198b45b 100644 --- a/android/src/main/res/values/strings.xml +++ b/android/src/main/res/values/strings.xml @@ -34,6 +34,9 @@ <string name="user_message_hint">Describe your problem</string> <string name="send">Send</string> <string name="sending">Sending...</string> + <string name="sent">Sent</string> + <string name="sent_thanks">Thanks! We will look into this.</string> + <string name="sent_contact">If needed we will contact you on</string> <string name="unsecured_connection">Unsecured connection</string> <string name="creating_secure_connection">Creating secure connection</string> |
