Fix #5148: Use DialogUtil method in Uploadactivity (#5149)

* Replace showInfoAlert with available DialogUtil method

* Remove test case that is no longer relevant
This commit is contained in:
Chan Jun Da 2023-02-20 14:27:57 +08:00 committed by GitHub
parent 1a8a068552
commit f56ee50c60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 35 deletions

View file

@ -225,9 +225,13 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.filter(result -> result)
.subscribe(result -> showInfoAlert(R.string.block_notification_title,
R.string.block_notification, UploadActivity.this::finish)
));
.subscribe(result -> DialogUtil.showAlertDialog(
this,
getString(R.string.block_notification_title),
getString(R.string.block_notification),
getString(R.string.ok),
this::finish,
true)));
}
private void checkStoragePermissions() {
@ -457,18 +461,6 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
finish();
}
private void showInfoAlert(int titleStringID, int messageStringId, Runnable positive, String... formatArgs) {
new AlertDialog.Builder(this)
.setTitle(titleStringID)
.setMessage(getString(messageStringId, (Object[]) formatArgs))
.setCancelable(true)
.setPositiveButton(android.R.string.ok, (dialog, id) -> {
positive.run();
dialog.cancel();
})
.create()
.show();
}
@Override
public void showAlertDialog(int messageResourceId, Runnable onPositiveClick) {

View file

@ -233,26 +233,6 @@ class UploadActivityUnitTests {
method.invoke(activity)
}
@Test
@Throws(Exception::class)
fun testShowInfoAlert() {
val method: Method = UploadActivity::class.java.getDeclaredMethod(
"showInfoAlert",
Int::class.java,
Int::class.java,
Runnable::class.java,
Array<String>::class.java
)
method.isAccessible = true
method.invoke(
activity,
R.string.block_notification_title,
R.string.block_notification,
mock(Runnable::class.java),
arrayOf("")
)
}
@Test
@Throws(Exception::class)
fun testOnNextButtonClicked() {