Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions app/src/main/java/fr/free/nrw/commons/review/ReviewController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,12 @@ class ReviewController @Inject constructor(
.commonsApplicationComponent
.inject(this)

ViewUtil.showShortToast(
context,
context.getString(R.string.send_thank_toast, media?.displayTitle)
)
val message = firstRevision?.user()?.let {
context.getString(R.string.send_thank_toast, media?.displayTitle, it)
} ?: run {
context.getString(R.string.send_thank_toast_no_author, media?.displayTitle)
}
ViewUtil.showShortToast(context, message)

if (firstRevision == null) return

Expand Down Expand Up @@ -198,10 +200,18 @@ class ReviewController @Inject constructor(
private fun displayThanksToast(context: Context, result: Boolean) {
val (title, message) = if (result) {
context.getString(R.string.send_thank_success_title) to
context.getString(R.string.send_thank_success_message, media?.displayTitle)
(firstRevision?.user()?.let {
context.getString(R.string.send_thank_success_message, media?.displayTitle, it)
} ?: run {
context.getString(R.string.send_thank_success_message_no_author, media?.displayTitle)
})
} else {
context.getString(R.string.send_thank_failure_title) to
context.getString(R.string.send_thank_failure_message, media?.displayTitle)
(firstRevision?.user()?.let {
context.getString(R.string.send_thank_failure_message, media?.displayTitle, it)
} ?: run {
context.getString(R.string.send_thank_failure_message_no_author, media?.displayTitle)
})
}

ViewUtil.showShortToast(context, message)
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,14 @@ Upload your first media by tapping on the add button.</string>
<string name="check_category_toast">Requesting category check for %1$s</string>
<string name="nominate_for_deletion_done">Done</string>
<string name="send_thank_success_title">Sending thanks: Success</string>
<string name="send_thank_success_message">Sent thanks to %1$s</string>
<string name="send_thank_failure_message">Failed to send thanks to %1$s</string>
<string name="send_thank_success_message">Successfully sent thanks for %1$s to %2$s</string>
<string name="send_thank_failure_message">Failed to send thanks for %1$s to %2$s</string>
<string name="send_thank_failure_title">Sending thanks: Failure</string>

<string name="send_thank_toast">Sending thanks for %1$s</string>
<string name="send_thank_toast">Sending thanks for %1$s to %2$s</string>
<string name="send_thank_toast_no_author">Sending thanks for %1$s</string>
<string name="send_thank_success_message_no_author">Successfully sent thanks for %1$s</string>
<string name="send_thank_failure_message_no_author">Failed to send thanks for %1$s</string>
<string name="review_copyright">Does this follow the rules of copyright?</string>
<string name="review_category">Is this correctly categorized?</string>
<string name="review_spam">Is this in-scope?</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,15 @@ class ReviewControllerTest {
fun testSendThanks() {
shadowOf(Looper.getMainLooper()).idle()
whenever(firstRevision.revisionId()).thenReturn(1)
whenever(firstRevision.user()).thenReturn("test_user")
Whitebox.setInternalState(controller, "firstRevision", firstRevision)
controller.sendThanks(activity)
assertEquals(
ShadowToast.getTextOfLatestToast().toString(),
context.getString(
R.string.send_thank_toast,
media.displayTitle,
"test_user"
),
)

Expand All @@ -165,6 +167,7 @@ class ReviewControllerTest {
context.getString(
R.string.send_thank_success_message,
media.displayTitle,
"test_user"
),
)
}
Expand All @@ -176,7 +179,7 @@ class ReviewControllerTest {
assertEquals(
ShadowToast.getTextOfLatestToast().toString(),
context.getString(
R.string.send_thank_toast,
R.string.send_thank_toast_no_author,
media.displayTitle,
),
)
Expand Down
Loading