Fixed #4906 : Peer review: "thank the contributor" should show snackb… (#4914)

* Fixed #4906 : Peer review: "thank the contributor" should show snackbar instead of notification

* changes the snackbar to toast

* added the tests

* minor changes

* minor changes - 2
This commit is contained in:
Arin Modi 2022-04-26 01:18:43 +05:30 committed by GitHub
parent 11bc72c514
commit 1ae013d2b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 12 deletions

View file

@ -156,8 +156,14 @@ public class ReviewController {
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe((result) -> {
String message;
String title;
displayThanksToast(context,result);
}, Timber::e);
}
@SuppressLint("StringFormatInvalid")
private void displayThanksToast(final Context context, final boolean result){
final String message;
final String title;
if (result) {
title = context.getString(R.string.send_thank_success_title);
message = context.getString(R.string.send_thank_success_message, media.getDisplayTitle());
@ -166,9 +172,7 @@ public class ReviewController {
message = context.getString(R.string.send_thank_failure_message, media.getDisplayTitle());
}
showNotification(title, message);
}, Timber::e);
ViewUtil.showShortToast(context,message);
}
private void showNotification(String title, String message) {

View file

@ -144,8 +144,23 @@ class ReviewControllerTest {
R.string.send_thank_toast, media.displayTitle
)
)
val method: Method = ReviewController::class.java.getDeclaredMethod(
"displayThanksToast", Context::class.java, Boolean::class.java
)
method.isAccessible = true
method.invoke(controller,context,true)
assertEquals(
ShadowToast.getTextOfLatestToast().toString(),
context.getString(
R.string.send_thank_success_message, media.displayTitle
)
)
}
@Test
fun testSendThanksCaseNull() {
shadowOf(Looper.getMainLooper()).idle()