report-presentation: update resource prefix to `core_report`; fix links in report/README.md

This commit is contained in:
Mateusz Armatys 2021-12-22 11:06:34 +01:00
parent b1f2f2cc75
commit eb5cd58158
9 changed files with 49 additions and 49 deletions

View File

@ -29,7 +29,7 @@ import org.junit.Test
class BugReportsTests : BaseTest() {
private val closeButton: OnView
get() = BugReportRobot().view.withContentDesc(R.string.report_bug_close)
get() = BugReportRobot().view.withContentDesc(R.string.core_report_bug_close)
@Test
fun showErrorsIfEmptyForm() {
@ -38,8 +38,8 @@ class BugReportsTests : BaseTest() {
.send<BugReportRobot>()
.verify {
bugReportFormIsEditable()
subjectFieldHasError(R.string.report_bug_form_field_required)
descriptionFieldHasError(R.string.report_bug_form_field_required)
subjectFieldHasError(R.string.core_report_bug_form_field_required)
descriptionFieldHasError(R.string.core_report_bug_form_field_required)
}
}
@ -51,8 +51,8 @@ class BugReportsTests : BaseTest() {
.send<BugReportRobot>()
.verify {
bugReportFormIsEditable()
subjectFieldHasError(R.string.report_bug_form_field_required)
descriptionFieldHasError(R.string.report_bug_form_field_required)
subjectFieldHasError(R.string.core_report_bug_form_field_required)
descriptionFieldHasError(R.string.core_report_bug_form_field_required)
}
}
@ -65,7 +65,7 @@ class BugReportsTests : BaseTest() {
.verify {
bugReportFormIsEditable()
descriptionFieldHasError(
R.plurals.report_bug_form_field_too_short,
R.plurals.core_report_bug_form_field_too_short,
BugReport.DescriptionMinLength,
BugReport.DescriptionMinLength
)
@ -141,7 +141,7 @@ class BugReportsTests : BaseTest() {
.send<CoreexampleRobot>()
.verify {
accountSwitcherDisplayed()
snackbarDisplayed(R.string.report_bug_success)
snackbarDisplayed(R.string.core_report_bug_success)
}
}
@ -160,7 +160,7 @@ class BugReportsTests : BaseTest() {
CoreexampleRobot().verify {
accountSwitcherDisplayed()
snackbarDisplayed(R.string.report_bug_success)
snackbarDisplayed(R.string.core_report_bug_success)
}
}

View File

@ -22,4 +22,4 @@ Once a report is written, and user submits it, it is enqueued into a WorkManager
- [configure `WorkManager` to be available in Hilt](https://developer.android.com/training/dependency-injection/hilt-jetpack#workmanager) (i.e. your `Application` should implement `androidx.work.Configuration.Provider`)
- provide a `WorkManager` instance from your dagger module
5. Whenever you want to display a Bug Report screen, use [ReportOrchestrator](presentation/src/main/kotlin/me/proton/core/report/presentation/ReportOrchestrator.kt).
6. Refer to [BugReportViewModel](../coreexample/src/main/kotlin/me/proton/android/core/coreexample/viewmodel/BugReportViewModel.kt) from CoreExample app for sample usage.
6. Refer to [ReportsViewModel](../coreexample/src/main/kotlin/me/proton/android/core/coreexample/viewmodel/ReportsViewModel.kt) from CoreExample app for sample usage.

View File

@ -30,7 +30,7 @@ plugins {
publishOption.shouldBePublishedAsLib = true
android(useViewBinding = true) {
resourcePrefix = "report_"
resourcePrefix = "core_report_"
}
extensions.configure<com.android.build.gradle.LibraryExtension> {

View File

@ -42,7 +42,7 @@ import me.proton.core.report.domain.entity.BugReport
import me.proton.core.report.domain.entity.BugReportValidationError
import me.proton.core.report.domain.usecase.SendBugReport
import me.proton.core.report.presentation.R
import me.proton.core.report.presentation.databinding.ReportActivityBugReportBinding
import me.proton.core.report.presentation.databinding.CoreReportActivityBugReportBinding
import me.proton.core.report.presentation.entity.BugReportFormState
import me.proton.core.report.presentation.entity.BugReportInput
import me.proton.core.report.presentation.entity.BugReportOutput
@ -52,8 +52,8 @@ import me.proton.core.report.presentation.viewmodel.BugReportViewModel
import me.proton.core.util.kotlin.exhaustive
@AndroidEntryPoint
internal class BugReportActivity : ProtonViewBindingActivity<ReportActivityBugReportBinding>(
ReportActivityBugReportBinding::inflate
internal class BugReportActivity : ProtonViewBindingActivity<CoreReportActivityBugReportBinding>(
CoreReportActivityBugReportBinding::inflate
) {
private var exitDialog: AlertDialog? = null
private val input: BugReportInput by lazy {
@ -136,22 +136,22 @@ internal class BugReportActivity : ProtonViewBindingActivity<ReportActivityBugRe
private fun handleFormError(validationError: BugReportValidationError) {
val (textView, message) = when (validationError) {
BugReportValidationError.DescriptionMissing ->
binding.bugReportDescriptionLayout to getString(R.string.report_bug_form_field_required)
binding.bugReportDescriptionLayout to getString(R.string.core_report_bug_form_field_required)
BugReportValidationError.SubjectMissing ->
binding.bugReportSubjectLayout to getString(R.string.report_bug_form_field_required)
binding.bugReportSubjectLayout to getString(R.string.core_report_bug_form_field_required)
BugReportValidationError.SubjectTooLong ->
binding.bugReportSubjectLayout to resources.getQuantityString(
R.plurals.report_bug_form_field_too_long,
R.plurals.core_report_bug_form_field_too_long,
BugReport.SubjectMaxLength, BugReport.SubjectMaxLength
)
BugReportValidationError.DescriptionTooLong ->
binding.bugReportDescriptionLayout to resources.getQuantityString(
R.plurals.report_bug_form_field_too_long,
R.plurals.core_report_bug_form_field_too_long,
BugReport.DescriptionMaxLength, BugReport.DescriptionMaxLength
)
BugReportValidationError.DescriptionTooShort ->
binding.bugReportDescriptionLayout to resources.getQuantityString(
R.plurals.report_bug_form_field_too_short,
R.plurals.core_report_bug_form_field_too_short,
BugReport.DescriptionMinLength, BugReport.DescriptionMinLength
)
}.exhaustive
@ -167,7 +167,7 @@ internal class BugReportActivity : ProtonViewBindingActivity<ReportActivityBugRe
is SendBugReport.Result.Failed -> {
setFormState(isLoading = false)
binding.root.errorSnack(result.message ?: getString(R.string.report_bug_general_error))
binding.root.errorSnack(result.message ?: getString(R.string.core_report_bug_general_error))
}
is SendBugReport.Result.Blocked,
@ -215,16 +215,16 @@ internal class BugReportActivity : ProtonViewBindingActivity<ReportActivityBugRe
private fun showExitDialog() {
exitDialog?.dismiss()
exitDialog = MaterialAlertDialogBuilder(this)
.setTitle(R.string.report_bug_discard_changes_title)
.setMessage(R.string.report_bug_discard_changes_description)
.setPositiveButton(R.string.report_bug_discard_changes_confirm) { _, _ -> viewModel.tryExit(force = true) }
.setNegativeButton(R.string.report_bug_discard_changes_cancel, null)
.setTitle(R.string.core_report_bug_discard_changes_title)
.setMessage(R.string.core_report_bug_discard_changes_description)
.setPositiveButton(R.string.core_report_bug_discard_changes_confirm) { _, _ -> viewModel.tryExit(force = true) }
.setNegativeButton(R.string.core_report_bug_discard_changes_cancel, null)
.show()
}
private fun setResultOk() {
val data = Intent().apply {
putExtra(OUTPUT_SUCCESS_MESSAGE, getString(R.string.report_bug_success))
putExtra(OUTPUT_SUCCESS_MESSAGE, getString(R.string.core_report_bug_success))
}
setResult(RESULT_OK, data)
}

View File

@ -31,10 +31,10 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu="@menu/report_bug_menu"
app:navigationContentDescription="@string/report_bug_close"
app:menu="@menu/core_report_bug_menu"
app:navigationContentDescription="@string/core_report_bug_close"
app:navigationIcon="@drawable/ic_close"
app:title="@string/report_bug_activity_title" />
app:title="@string/core_report_bug_activity_title" />
</com.google.android.material.appbar.AppBarLayout>
@ -56,7 +56,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:hint="@string/report_bug_subject_field_hint"
android:hint="@string/core_report_bug_subject_field_hint"
app:boxBackgroundColor="@color/transparent"
app:boxBackgroundMode="none"
app:expandedHintEnabled="true">
@ -89,10 +89,10 @@
android:id="@+id/bug_report_description_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/report_bug_description_field_hint"
android:hint="@string/core_report_bug_description_field_hint"
app:boxBackgroundColor="@color/transparent"
app:boxBackgroundMode="none"
app:placeholderText="@string/report_bug_description_field_placeholder"
app:placeholderText="@string/core_report_bug_description_field_placeholder"
app:placeholderTextAppearance="@style/Proton.Text.Default">
<com.google.android.material.textfield.TextInputEditText

View File

@ -20,8 +20,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/bug_report_send"
android:icon="@drawable/report_ic_paper_plane"
android:title="@string/report_bug_send"
android:icon="@drawable/core_report_ic_paper_plane"
android:title="@string/core_report_bug_send"
app:showAsAction="ifRoom" />
<item
android:id="@+id/bug_report_loader"

View File

@ -17,25 +17,25 @@
-->
<resources>
<string name="report_bug_activity_title">Report bug</string>
<string name="report_bug_close">Close</string>
<string name="report_bug_subject_field_hint">Subject</string>
<string name="report_bug_description_field_hint">Description</string>
<string name="report_bug_description_field_placeholder">Please describe the problem and include any error messages.</string>
<string name="report_bug_discard_changes_title">Unsaved Changes</string>
<string name="report_bug_discard_changes_description">There are unsaved entries in the form. Are you sure you want to discard them?</string>
<string name="report_bug_discard_changes_cancel">Keep writing</string>
<string name="report_bug_discard_changes_confirm">Discard</string>
<string name="report_bug_form_field_required">This field is required</string>
<plurals name="report_bug_form_field_too_short">
<string name="core_report_bug_activity_title">Report bug</string>
<string name="core_report_bug_close">Close</string>
<string name="core_report_bug_subject_field_hint">Subject</string>
<string name="core_report_bug_description_field_hint">Description</string>
<string name="core_report_bug_description_field_placeholder">Please describe the problem and include any error messages.</string>
<string name="core_report_bug_discard_changes_title">Unsaved Changes</string>
<string name="core_report_bug_discard_changes_description">There are unsaved entries in the form. Are you sure you want to discard them?</string>
<string name="core_report_bug_discard_changes_cancel">Keep writing</string>
<string name="core_report_bug_discard_changes_confirm">Discard</string>
<string name="core_report_bug_form_field_required">This field is required</string>
<plurals name="core_report_bug_form_field_too_short">
<item quantity="one">This field should have at least %d character</item>
<item quantity="other">This field should have at least %d characters</item>
</plurals>
<plurals name="report_bug_form_field_too_long">
<plurals name="core_report_bug_form_field_too_long">
<item quantity="one">This field should have at most %d character</item>
<item quantity="other">This field should have at most %d characters</item>
</plurals>
<string name="report_bug_general_error">Error sending report, please try again later</string>
<string name="report_bug_send">Send</string>
<string name="report_bug_success">Thank you for your report</string>
<string name="core_report_bug_general_error">Error sending report, please try again later</string>
<string name="core_report_bug_send">Send</string>
<string name="core_report_bug_success">Thank you for your report</string>
</resources>

View File

@ -42,12 +42,12 @@ class BugReportRobot : CoreRobot() {
/**
* Clicks "Discard" button
*/
inline fun <reified T> discard(): T = clickElement(stringFromResource(R.string.report_bug_discard_changes_confirm))
inline fun <reified T> discard(): T = clickElement(stringFromResource(R.string.core_report_bug_discard_changes_confirm))
/**
* Clicks "Keep writing" button
*/
fun keepWriting(): BugReportRobot = clickElement(stringFromResource(R.string.report_bug_discard_changes_cancel))
fun keepWriting(): BugReportRobot = clickElement(stringFromResource(R.string.core_report_bug_discard_changes_cancel))
/**
* Clicks "Send" button