mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Report problem: add an optional TextField to provide a GitHub issue number.
This commit is contained in:
committed by
Benoit Marty
parent
a8e1274786
commit
1564736366
+2
@@ -20,6 +20,7 @@ interface BugReporter {
|
||||
* @param problemDescription the bug description
|
||||
* @param canContact true if the user opt in to be contacted directly
|
||||
* @param sendPushRules true to include the push rules
|
||||
* @param ghIssueNumber it not null, the GitHub issue number to link the bug report to.
|
||||
* @param listener the listener
|
||||
*/
|
||||
suspend fun sendBugReport(
|
||||
@@ -29,6 +30,7 @@ interface BugReporter {
|
||||
problemDescription: String,
|
||||
canContact: Boolean = false,
|
||||
sendPushRules: Boolean = false,
|
||||
ghIssueNumber: Int? = null,
|
||||
listener: BugReporterListener
|
||||
)
|
||||
|
||||
|
||||
+1
@@ -18,4 +18,5 @@ sealed interface BugReportEvents {
|
||||
data class SetCanContact(val canContact: Boolean) : BugReportEvents
|
||||
data class SetSendScreenshot(val sendScreenshot: Boolean) : BugReportEvents
|
||||
data class SetSendPushRules(val sendPushRules: Boolean) : BugReportEvents
|
||||
data class SetGhIssueNumber(val ghIssueNumber: Int?) : BugReportEvents
|
||||
}
|
||||
|
||||
+5
-1
@@ -113,6 +113,9 @@ class BugReportPresenter(
|
||||
sendingProgress.floatValue = 0f
|
||||
sendingAction.value = AsyncAction.Uninitialized
|
||||
}
|
||||
is BugReportEvents.SetGhIssueNumber -> updateFormState(formState) {
|
||||
copy(ghIssueNumber = event.ghIssueNumber)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +145,8 @@ class BugReportPresenter(
|
||||
problemDescription = formState.description,
|
||||
canContact = formState.canContact,
|
||||
sendPushRules = formState.sendPushRules,
|
||||
listener = listener
|
||||
ghIssueNumber = formState.ghIssueNumber,
|
||||
listener = listener,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -32,6 +32,7 @@ data class BugReportFormState(
|
||||
val canContact: Boolean,
|
||||
val sendScreenshot: Boolean,
|
||||
val sendPushRules: Boolean,
|
||||
val ghIssueNumber: Int?,
|
||||
) : Parcelable {
|
||||
companion object {
|
||||
val Default = BugReportFormState(
|
||||
@@ -40,6 +41,7 @@ data class BugReportFormState(
|
||||
canContact = false,
|
||||
sendScreenshot = false,
|
||||
sendPushRules = false,
|
||||
ghIssueNumber = null,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+35
@@ -155,6 +155,41 @@ fun BugReportView(
|
||||
title = stringResource(R.string.screen_bug_report_send_notification_settings_title),
|
||||
subtitle = stringResource(R.string.screen_bug_report_send_notification_settings_description),
|
||||
)
|
||||
PreferenceRow {
|
||||
var ghIssueNumberState by textFieldState(
|
||||
stateValue = state.formState.ghIssueNumber?.toString() ?: ""
|
||||
)
|
||||
TextField(
|
||||
value = ghIssueNumberState,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.onTabOrEnterKeyFocusNext(LocalFocusManager.current),
|
||||
enabled = isFormEnabled,
|
||||
label = stringResource(id = R.string.screen_bug_report_github_issue_label),
|
||||
placeholder = "1234",
|
||||
supportingText = stringResource(id = R.string.screen_bug_report_github_issue_description),
|
||||
onValueChange = {
|
||||
if (it.isEmpty()) {
|
||||
ghIssueNumberState = ""
|
||||
eventSink(BugReportEvents.SetGhIssueNumber(null))
|
||||
} else {
|
||||
val number = it.toIntOrNull()?.takeIf { ghInt -> ghInt in 1..99_999 }
|
||||
number?.let { ghIssueNumber ->
|
||||
ghIssueNumberState = ghIssueNumber.toString()
|
||||
eventSink(BugReportEvents.SetGhIssueNumber(ghIssueNumber))
|
||||
}
|
||||
}
|
||||
},
|
||||
keyboardOptions = KeyboardOptions(
|
||||
keyboardType = KeyboardType.Number,
|
||||
imeAction = ImeAction.Next,
|
||||
),
|
||||
keyboardActions = KeyboardActions(onNext = {
|
||||
keyboardController?.hide()
|
||||
}),
|
||||
singleLine = true,
|
||||
)
|
||||
}
|
||||
// Submit
|
||||
PreferenceRow {
|
||||
Button(
|
||||
|
||||
+4
@@ -123,6 +123,7 @@ class DefaultBugReporter(
|
||||
problemDescription: String,
|
||||
canContact: Boolean,
|
||||
sendPushRules: Boolean,
|
||||
ghIssueNumber: Int?,
|
||||
listener: BugReporterListener,
|
||||
) {
|
||||
val url = bugReporterUrlProvider.provide().first()
|
||||
@@ -144,6 +145,9 @@ class DefaultBugReporter(
|
||||
val crashCallStack = crashDataStore.crashInfo().first()
|
||||
val bugDescription = buildString {
|
||||
append(problemDescription)
|
||||
ghIssueNumber?.let {
|
||||
append("\n\nhttps://github.com/element-hq/element-x-android/issues/$it")
|
||||
}
|
||||
if (crashCallStack.isNotEmpty() && withCrashLogs) {
|
||||
append("\n\n\n\n--------------------------------- crash call stack ---------------------------------\n")
|
||||
append(crashCallStack)
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
<string name="screen_bug_report_editor_placeholder">"Describe the problem…"</string>
|
||||
<string name="screen_bug_report_editor_supporting">"If possible, please write the description in English."</string>
|
||||
<string name="screen_bug_report_error_description_too_short">"The description is too short, please provide more details about what happened. Thanks!"</string>
|
||||
<string name="screen_bug_report_github_issue_description">"You can enter the number of an associated GitHub issue, if any."</string>
|
||||
<string name="screen_bug_report_github_issue_label">"GitHub issue"</string>
|
||||
<string name="screen_bug_report_include_crash_logs">"Send crash logs"</string>
|
||||
<string name="screen_bug_report_include_logs">"Allow logs"</string>
|
||||
<string name="screen_bug_report_include_logs_error">"Your logs are excessively large so cannot be included in this report, please send them to us another way."</string>
|
||||
|
||||
+12
@@ -107,6 +107,18 @@ class BugReportPresenterTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `present - set GitHub issue number`() = runTest {
|
||||
val presenter = createPresenter()
|
||||
presenter.test {
|
||||
val initialState = awaitItem()
|
||||
initialState.eventSink.invoke(BugReportEvents.SetGhIssueNumber(1))
|
||||
assertThat(awaitItem().formState).isEqualTo(BugReportFormState.Default.copy(ghIssueNumber = 1))
|
||||
initialState.eventSink.invoke(BugReportEvents.SetGhIssueNumber(null))
|
||||
assertThat(awaitItem().formState).isEqualTo(BugReportFormState.Default.copy(ghIssueNumber = null))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `present - reset all`() = runTest {
|
||||
val presenter = createPresenter(
|
||||
|
||||
+1
@@ -28,6 +28,7 @@ class FakeBugReporter(val mode: Mode = Mode.Success) : BugReporter {
|
||||
problemDescription: String,
|
||||
canContact: Boolean,
|
||||
sendPushRules: Boolean,
|
||||
ghIssueNumber: Int?,
|
||||
listener: BugReporterListener,
|
||||
) {
|
||||
delay(100)
|
||||
|
||||
Reference in New Issue
Block a user