File tree 2 files changed +30
-11
lines changed
main/java/fr/free/nrw/commons/review
test/kotlin/fr/free/nrw/commons/review
2 files changed +30
-11
lines changed Original file line number Diff line number Diff line change @@ -156,19 +156,23 @@ void sendThanks(@NonNull Activity activity) {
156
156
.subscribeOn (Schedulers .io ())
157
157
.observeOn (AndroidSchedulers .mainThread ())
158
158
.subscribe ((result ) -> {
159
- String message ;
160
- String title ;
161
- if (result ) {
162
- title = context .getString (R .string .send_thank_success_title );
163
- message = context .getString (R .string .send_thank_success_message , media .getDisplayTitle ());
164
- } else {
165
- title = context .getString (R .string .send_thank_failure_title );
166
- message = context .getString (R .string .send_thank_failure_message , media .getDisplayTitle ());
167
- }
159
+ displayThanksToast (context ,result );
160
+ }, Timber ::e );
161
+ }
168
162
169
- showNotification (title , message );
163
+ @ SuppressLint ("StringFormatInvalid" )
164
+ private void displayThanksToast (final Context context , final boolean result ){
165
+ final String message ;
166
+ final String title ;
167
+ if (result ) {
168
+ title = context .getString (R .string .send_thank_success_title );
169
+ message = context .getString (R .string .send_thank_success_message , media .getDisplayTitle ());
170
+ } else {
171
+ title = context .getString (R .string .send_thank_failure_title );
172
+ message = context .getString (R .string .send_thank_failure_message , media .getDisplayTitle ());
173
+ }
170
174
171
- }, Timber :: e );
175
+ ViewUtil . showShortToast ( context , message );
172
176
}
173
177
174
178
private void showNotification (String title , String message ) {
Original file line number Diff line number Diff line change @@ -144,8 +144,23 @@ class ReviewControllerTest {
144
144
R .string.send_thank_toast, media.displayTitle
145
145
)
146
146
)
147
+
148
+ val method: Method = ReviewController ::class .java.getDeclaredMethod(
149
+ " displayThanksToast" , Context ::class .java, Boolean ::class .java
150
+ )
151
+
152
+ method.isAccessible = true
153
+ method.invoke(controller,context,true )
154
+
155
+ assertEquals(
156
+ ShadowToast .getTextOfLatestToast().toString(),
157
+ context.getString(
158
+ R .string.send_thank_success_message, media.displayTitle
159
+ )
160
+ )
147
161
}
148
162
163
+
149
164
@Test
150
165
fun testSendThanksCaseNull () {
151
166
shadowOf(Looper .getMainLooper()).idle()
You can’t perform that action at this time.
0 commit comments