Skip to content

Commit

Permalink
Merge pull request #195 from mysteriumnetwork/update-feedback-page
Browse files Browse the repository at this point in the history
Keep only issue type for feedback
  • Loading branch information
anjmao authored May 12, 2020
2 parents 752da1e + 15870dc commit 026df0c
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 61 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ dependencies {
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
androidTestImplementation 'androidx.test:rules:1.3.0-alpha03'

implementation 'network.mysterium:mobile-node:0.31.3'
implementation 'network.mysterium:mobile-node:0.32.0'
// Comment network.mysterium:mobile-node and replace with your local path to use local node build.
// implementation files('/Users/anjmao/go/src/github.com/mysteriumnetwork/node/build/package/Mysterium.aar')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class NodeRepository(private val deferredNode: DeferredNode) {
// Unlock identity and return it's address. Internally mobile node will create default identity
// if it is not created yet.
suspend fun getIdentity(): Identity = withContext(Dispatchers.IO) {
val res = deferredNode.await().identity
val res = deferredNode.await().getIdentity(GetIdentityRequest())
Identity(address = res.identityAddress, channelAddress = res.channelAddress, registrationStatus = res.registrationStatus)
}

Expand Down Expand Up @@ -203,8 +203,9 @@ class NodeRepository(private val deferredNode: DeferredNode) {
}

// Send user feedback.
suspend fun sendFeedback(description: String) = withContext(Dispatchers.IO) {
suspend fun sendFeedback(email: String, description: String) = withContext(Dispatchers.IO) {
val req = SendFeedbackRequest()
req.email = email
req.description = description
deferredNode.await().sendFeedback(req)
}
Expand Down
20 changes: 3 additions & 17 deletions android/app/src/main/java/network/mysterium/ui/FeedbackFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import network.mysterium.vpn.R
class FeedbackFragment : Fragment() {
private lateinit var feedbackViewModel: FeedbackViewModel

private lateinit var feedbackTypeSpinner: Spinner
private lateinit var feedbackEmail: EditText
private lateinit var feedbackMessage: EditText
private lateinit var feedbackSubmitButton: MaterialButton
private lateinit var versionLabel: TextView
Expand All @@ -33,7 +33,7 @@ class FeedbackFragment : Fragment() {
val nodeRepository = AppContainer.from(activity).nodeRepository
feedbackViewModel = FeedbackViewModel(nodeRepository)

feedbackTypeSpinner = root.findViewById(R.id.feedback_type_spinner)
feedbackEmail = root.findViewById(R.id.feedback_email)
feedbackMessage = root.findViewById(R.id.feedback_message)
feedbackSubmitButton = root.findViewById(R.id.feedback_submit_button)
versionLabel = root.findViewById(R.id.vpn_version_label)
Expand All @@ -47,10 +47,8 @@ class FeedbackFragment : Fragment() {
navigateTo(root, Screen.MAIN)
}

// Add feedback types data.
initFeedbackTypesDropdown(root)

// Handle text change.
feedbackEmail.onChange { feedbackViewModel.setEmail(it) }
feedbackMessage.onChange { feedbackViewModel.setMessage(it) }

// Handle submit.
Expand Down Expand Up @@ -86,18 +84,6 @@ class FeedbackFragment : Fragment() {
}
}

private fun initFeedbackTypesDropdown(root: View) {
ArrayAdapter.createFromResource(
root.context,
R.array.feedback_types,
android.R.layout.simple_spinner_item
).also { adapter ->
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
feedbackTypeSpinner.adapter = adapter
feedbackTypeSpinner.onItemSelected { feedbackViewModel.setFeedbackType(it) }
}
}

@SuppressLint("SetTextI18n")
private fun updateVersionLabel() {
versionLabel.text = "${BuildConfig.VERSION_NAME}.${BuildConfig.VERSION_CODE}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,10 @@ package network.mysterium.ui
import androidx.lifecycle.ViewModel
import network.mysterium.service.core.NodeRepository

enum class FeedbackType(val type: Int) {
BUG(0),
CONNECTIVITY_ISSUE(1),
POSITIVE_FEEDBACK(2);

override fun toString(): String {
return when(this) {
BUG -> "bug"
CONNECTIVITY_ISSUE -> "connectivity"
POSITIVE_FEEDBACK -> "positive"
}
}

companion object {
fun parse(type: Int): FeedbackType {
return values().find { it.type == type } ?: BUG
}
}
}

class FeedbackViewModel(private val nodeRepository: NodeRepository): ViewModel() {
private var feedbackType = FeedbackType.BUG
private var email = ""
private var message = ""

fun setFeedbackType(type: Int) {
feedbackType = FeedbackType.parse(type)
}

fun setMessage(msg: String) {
message = msg
}
Expand All @@ -57,7 +33,11 @@ class FeedbackViewModel(private val nodeRepository: NodeRepository): ViewModel()
}

suspend fun submit() {
val description = "Platform: Android, Feedback Type: $feedbackType, Message: $message"
nodeRepository.sendFeedback(description)
val description = "Platform: Android, Message: $message"
nodeRepository.sendFeedback(email, description)
}

fun setEmail(email: String) {
this.email = email
}
}
28 changes: 19 additions & 9 deletions android/app/src/main/res/layout/fragment_feedback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:id="@+id/feedback_toolbar"
app:title="Feedback"
app:title="@string/feedback_page_title"
app:titleTextColor="@color/ColorWhite"
android:layout_width="match_parent"
app:navigationIcon="@drawable/ic_arrow_back_white_24dp"
Expand All @@ -28,23 +28,23 @@
android:paddingRight="20dp">

<TextView
android:id="@+id/feedback_type_spinner_label"
android:id="@+id/feedback_email_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/feedback_type_label"
android:text="@string/feedback_email_label"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Spinner
android:id="@+id/feedback_type_spinner"
<EditText
android:id="@+id/feedback_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/spinner_input_bg"
android:background="@drawable/bordered_input_bg"
android:padding="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/feedback_type_spinner_label" />
app:layout_constraintTop_toBottomOf="@id/feedback_email_label" />

<TextView
android:id="@+id/feedback_message_type_label"
Expand All @@ -53,19 +53,29 @@
android:layout_marginTop="10dp"
android:text="@string/feedback_message_label"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/feedback_type_spinner" />
app:layout_constraintTop_toBottomOf="@id/feedback_email" />

<EditText
android:id="@+id/feedback_message"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="10dp"
android:hint="@string/feedback_message_hint"
android:background="@drawable/bordered_input_bg"
android:gravity="top"
android:inputType="text|textMultiLine"
android:padding="5dp"
app:layout_constraintTop_toBottomOf="@id/feedback_message_type_label" />

<TextView
android:id="@+id/feedback_logs_notice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/feedback_logs_notice"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/feedback_message" />

<com.google.android.material.button.MaterialButton
android:id="@+id/feedback_submit_button"
style="@style/Widget.MaterialComponents.Button"
Expand All @@ -74,7 +84,7 @@
android:layout_marginTop="10dp"
android:text="Send feedback"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/feedback_message" />
app:layout_constraintTop_toBottomOf="@id/feedback_logs_notice" />

<TextView
android:id="@+id/vpn_version_label"
Expand Down
4 changes: 2 additions & 2 deletions android/app/src/main/res/menu/navigation_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

<item android:id="@+id/menu_item_account"
android:icon="@drawable/ic_account_circle_black_24dp"
android:title="Account"/>
android:title="@string/menu_account"/>

<item android:id="@+id/menu_item_feedback"
android:icon="@drawable/ic_bug_report_black_24dp"
android:title="Feedback"/>
android:title="@string/menu_report_issue"/>

</menu>
9 changes: 6 additions & 3 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@
<string name="vpn_select_proposal_warning">Please select proposal to connect.</string>
<string name="vpn_failed_to_connect">Failed to connect. Please try again.</string>
<string name="vpn_failed_to_disconnect">Failed to disconnect. Please try again.</string>
<string name="feedback_type_label">Feedback type</string>
<string name="feedback_email_label">Your contact email (optional)</string>

<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="connect_err_invalid_proposal">Proposal is not valid</string>
<string name="connect_err_insufficient_balance">Insufficient balance</string>
<string name="menu_account">Account</string>
<string name="menu_report_issue">Report issue</string>
<string name="feedback_page_title">Report issue</string>
<string name="feedback_logs_notice">By submitting this form, You agree to send to Mysterium Network some account information like IP, country and system information which will be used to improve the services and help investigate this issue.</string>
<string name="feedback_message_hint">Describe what when wrong</string>
</resources>

0 comments on commit 026df0c

Please sign in to comment.