Skip to content

Commit 165c375

Browse files
authored
UploadMediaDetail: replace discreet error toast with more-noticeable dialog (commons-app#4433)
1 parent ca18763 commit 165c375

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

app/src/main/java/fr/free/nrw/commons/upload/mediaDetails/UploadMediaDetailFragment.java

+8
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,14 @@ public void showBadImagePopup(Integer errorCode,
365365
//If the error message is null, we will probably not show anything
366366
}
367367

368+
@Override
369+
public void showConnectionErrorPopup() {
370+
DialogUtil.showAlertDialog(getActivity(),
371+
getString(R.string.upload_connection_error_alert_title),
372+
getString(R.string.upload_connection_error_alert_detail), getString(R.string.ok),
373+
() -> {}, true);
374+
}
375+
368376
@Override public void showMapWithImageCoordinates(boolean shouldShow) {
369377
ibMap.setVisibility(shouldShow ? View.VISIBLE : View.GONE);
370378
}

app/src/main/java/fr/free/nrw/commons/upload/mediaDetails/UploadMediaDetailsContract.java

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ interface View extends SimilarImageInterface {
3232

3333
void showBadImagePopup(Integer errorCode, UploadItem uploadItem);
3434

35+
void showConnectionErrorPopup();
36+
3537
void showMapWithImageCoordinates(boolean shouldShow);
3638

3739
void showExternalMap(UploadItem uploadItem);

app/src/main/java/fr/free/nrw/commons/upload/mediaDetails/UploadMediaPresenter.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import io.reactivex.disposables.CompositeDisposable;
2424
import io.reactivex.disposables.Disposable;
2525
import java.lang.reflect.Proxy;
26+
import java.net.UnknownHostException;
2627
import java.util.ArrayList;
2728
import java.util.List;
2829
import javax.inject.Inject;
@@ -138,8 +139,12 @@ public void verifyImageQuality(int uploadItemIndex) {
138139
},
139140
throwable -> {
140141
view.showProgress(false);
141-
view.showMessage("" + throwable.getLocalizedMessage(),
142-
R.color.color_error);
142+
if (throwable instanceof UnknownHostException) {
143+
view.showConnectionErrorPopup();
144+
} else {
145+
view.showMessage("" + throwable.getLocalizedMessage(),
146+
R.color.color_error);
147+
}
143148
Timber.e(throwable, "Error occurred while handling image");
144149
})
145150
);

app/src/main/res/values/strings.xml

+3
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@
227227
<string name="upload_problem_fbmd">Please only upload pictures that you have taken by yourself. Don\'t upload pictures that you have found on other people\'s Facebook accounts.</string>
228228
<string name="upload_problem_do_you_continue">Do you still want to upload this picture?</string>
229229

230+
<string name="upload_connection_error_alert_title">Connection Error</string>
231+
<string name="upload_connection_error_alert_detail">The upload process requires active internet
232+
access. Please check your network connection.</string>
230233

231234
<string name="upload_problem_image">Problems found in image</string>
232235
<string name="internet_downloaded">Please only upload pictures that you have taken by yourself. Don\'t upload pictures that you have downloaded from the Internet.</string>

0 commit comments

Comments
 (0)