mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +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 problemDescription the bug description
|
||||||
* @param canContact true if the user opt in to be contacted directly
|
* @param canContact true if the user opt in to be contacted directly
|
||||||
* @param sendPushRules true to include the push rules
|
* @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
|
* @param listener the listener
|
||||||
*/
|
*/
|
||||||
suspend fun sendBugReport(
|
suspend fun sendBugReport(
|
||||||
@@ -29,6 +30,7 @@ interface BugReporter {
|
|||||||
problemDescription: String,
|
problemDescription: String,
|
||||||
canContact: Boolean = false,
|
canContact: Boolean = false,
|
||||||
sendPushRules: Boolean = false,
|
sendPushRules: Boolean = false,
|
||||||
|
ghIssueNumber: Int? = null,
|
||||||
listener: BugReporterListener
|
listener: BugReporterListener
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
@@ -18,4 +18,5 @@ sealed interface BugReportEvents {
|
|||||||
data class SetCanContact(val canContact: Boolean) : BugReportEvents
|
data class SetCanContact(val canContact: Boolean) : BugReportEvents
|
||||||
data class SetSendScreenshot(val sendScreenshot: Boolean) : BugReportEvents
|
data class SetSendScreenshot(val sendScreenshot: Boolean) : BugReportEvents
|
||||||
data class SetSendPushRules(val sendPushRules: 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
|
sendingProgress.floatValue = 0f
|
||||||
sendingAction.value = AsyncAction.Uninitialized
|
sendingAction.value = AsyncAction.Uninitialized
|
||||||
}
|
}
|
||||||
|
is BugReportEvents.SetGhIssueNumber -> updateFormState(formState) {
|
||||||
|
copy(ghIssueNumber = event.ghIssueNumber)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +145,8 @@ class BugReportPresenter(
|
|||||||
problemDescription = formState.description,
|
problemDescription = formState.description,
|
||||||
canContact = formState.canContact,
|
canContact = formState.canContact,
|
||||||
sendPushRules = formState.sendPushRules,
|
sendPushRules = formState.sendPushRules,
|
||||||
listener = listener
|
ghIssueNumber = formState.ghIssueNumber,
|
||||||
|
listener = listener,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
@@ -32,6 +32,7 @@ data class BugReportFormState(
|
|||||||
val canContact: Boolean,
|
val canContact: Boolean,
|
||||||
val sendScreenshot: Boolean,
|
val sendScreenshot: Boolean,
|
||||||
val sendPushRules: Boolean,
|
val sendPushRules: Boolean,
|
||||||
|
val ghIssueNumber: Int?,
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
companion object {
|
companion object {
|
||||||
val Default = BugReportFormState(
|
val Default = BugReportFormState(
|
||||||
@@ -40,6 +41,7 @@ data class BugReportFormState(
|
|||||||
canContact = false,
|
canContact = false,
|
||||||
sendScreenshot = false,
|
sendScreenshot = false,
|
||||||
sendPushRules = false,
|
sendPushRules = false,
|
||||||
|
ghIssueNumber = null,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+35
@@ -155,6 +155,41 @@ fun BugReportView(
|
|||||||
title = stringResource(R.string.screen_bug_report_send_notification_settings_title),
|
title = stringResource(R.string.screen_bug_report_send_notification_settings_title),
|
||||||
subtitle = stringResource(R.string.screen_bug_report_send_notification_settings_description),
|
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
|
// Submit
|
||||||
PreferenceRow {
|
PreferenceRow {
|
||||||
Button(
|
Button(
|
||||||
|
|||||||
+4
@@ -123,6 +123,7 @@ class DefaultBugReporter(
|
|||||||
problemDescription: String,
|
problemDescription: String,
|
||||||
canContact: Boolean,
|
canContact: Boolean,
|
||||||
sendPushRules: Boolean,
|
sendPushRules: Boolean,
|
||||||
|
ghIssueNumber: Int?,
|
||||||
listener: BugReporterListener,
|
listener: BugReporterListener,
|
||||||
) {
|
) {
|
||||||
val url = bugReporterUrlProvider.provide().first()
|
val url = bugReporterUrlProvider.provide().first()
|
||||||
@@ -144,6 +145,9 @@ class DefaultBugReporter(
|
|||||||
val crashCallStack = crashDataStore.crashInfo().first()
|
val crashCallStack = crashDataStore.crashInfo().first()
|
||||||
val bugDescription = buildString {
|
val bugDescription = buildString {
|
||||||
append(problemDescription)
|
append(problemDescription)
|
||||||
|
ghIssueNumber?.let {
|
||||||
|
append("\n\nhttps://github.com/element-hq/element-x-android/issues/$it")
|
||||||
|
}
|
||||||
if (crashCallStack.isNotEmpty() && withCrashLogs) {
|
if (crashCallStack.isNotEmpty() && withCrashLogs) {
|
||||||
append("\n\n\n\n--------------------------------- crash call stack ---------------------------------\n")
|
append("\n\n\n\n--------------------------------- crash call stack ---------------------------------\n")
|
||||||
append(crashCallStack)
|
append(crashCallStack)
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="screen_bug_report_editor_placeholder">"Describe the problem…"</string>
|
<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_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_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_crash_logs">"Send crash logs"</string>
|
||||||
<string name="screen_bug_report_include_logs">"Allow 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>
|
<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
|
@Test
|
||||||
fun `present - reset all`() = runTest {
|
fun `present - reset all`() = runTest {
|
||||||
val presenter = createPresenter(
|
val presenter = createPresenter(
|
||||||
|
|||||||
+1
@@ -28,6 +28,7 @@ class FakeBugReporter(val mode: Mode = Mode.Success) : BugReporter {
|
|||||||
problemDescription: String,
|
problemDescription: String,
|
||||||
canContact: Boolean,
|
canContact: Boolean,
|
||||||
sendPushRules: Boolean,
|
sendPushRules: Boolean,
|
||||||
|
ghIssueNumber: Int?,
|
||||||
listener: BugReporterListener,
|
listener: BugReporterListener,
|
||||||
) {
|
) {
|
||||||
delay(100)
|
delay(100)
|
||||||
|
|||||||
Reference in New Issue
Block a user