mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
* 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:
parent
11bc72c514
commit
1ae013d2b3
2 changed files with 31 additions and 12 deletions
|
|
@ -156,21 +156,25 @@ public class ReviewController {
|
|||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe((result) -> {
|
||||
String message;
|
||||
String title;
|
||||
if (result) {
|
||||
title = context.getString(R.string.send_thank_success_title);
|
||||
message = context.getString(R.string.send_thank_success_message, media.getDisplayTitle());
|
||||
} else {
|
||||
title = context.getString(R.string.send_thank_failure_title);
|
||||
message = context.getString(R.string.send_thank_failure_message, media.getDisplayTitle());
|
||||
}
|
||||
|
||||
showNotification(title, message);
|
||||
|
||||
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());
|
||||
} else {
|
||||
title = context.getString(R.string.send_thank_failure_title);
|
||||
message = context.getString(R.string.send_thank_failure_message, media.getDisplayTitle());
|
||||
}
|
||||
|
||||
ViewUtil.showShortToast(context,message);
|
||||
}
|
||||
|
||||
private void showNotification(String title, String message) {
|
||||
notificationBuilder.setDefaults(NotificationCompat.DEFAULT_ALL)
|
||||
.setContentTitle(title)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue