Skip to content

Commit cbca290

Browse files
authored
upload: made duplicate picture dialog more informative and added checkbox to never show again (commons-app#4045)
1 parent 0b5f56b commit cbca290

File tree

3 files changed

+54
-14
lines changed

3 files changed

+54
-14
lines changed

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

+28-13
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.view.View;
99
import android.view.View.OnClickListener;
1010
import android.view.ViewGroup;
11+
import android.widget.CheckBox;
1112
import android.widget.ImageView;
1213
import android.widget.LinearLayout;
1314
import android.widget.TextView;
@@ -272,19 +273,33 @@ public void showMessage(String message, int colorResourceId) {
272273

273274
@Override
274275
public void showDuplicatePicturePopup(UploadItem uploadItem) {
275-
String uploadTitleFormat = getString(R.string.upload_title_duplicate);
276-
DialogUtil.showAlertDialog(getActivity(),
277-
getString(R.string.duplicate_image_found),
278-
String.format(Locale.getDefault(),
279-
uploadTitleFormat,
280-
uploadItem.getFileName()),
281-
getString(R.string.upload),
282-
getString(R.string.cancel),
283-
() -> {
284-
uploadItem.setImageQuality(ImageUtils.IMAGE_KEEP);
285-
onNextButtonClicked();
286-
}, null);
287-
276+
if (defaultKvStore.getBoolean("showDuplicatePicturePopup", true)) {
277+
String uploadTitleFormat = getString(R.string.upload_title_duplicate);
278+
View checkBoxView = View
279+
.inflate(getActivity(), R.layout.nearby_permission_dialog, null);
280+
CheckBox checkBox = (CheckBox) checkBoxView.findViewById(R.id.never_ask_again);
281+
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
282+
if (isChecked) {
283+
defaultKvStore.putBoolean("showDuplicatePicturePopup", false);
284+
}
285+
});
286+
DialogUtil.showAlertDialog(getActivity(),
287+
getString(R.string.duplicate_image_found),
288+
String.format(Locale.getDefault(),
289+
uploadTitleFormat,
290+
uploadItem.getFileName()),
291+
getString(R.string.upload),
292+
getString(R.string.cancel),
293+
() -> {
294+
uploadItem.setImageQuality(ImageUtils.IMAGE_KEEP);
295+
onNextButtonClicked();
296+
}, null,
297+
checkBoxView,
298+
false);
299+
} else {
300+
uploadItem.setImageQuality(ImageUtils.IMAGE_KEEP);
301+
onNextButtonClicked();
302+
}
288303
}
289304

290305
@Override

app/src/main/java/fr/free/nrw/commons/utils/DialogUtil.kt

+25
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,31 @@ object DialogUtil {
9494
)
9595
}
9696

97+
@JvmStatic
98+
fun showAlertDialog(
99+
activity: Activity,
100+
title: String,
101+
message: String,
102+
positiveButtonText: String?,
103+
negativeButtonText: String?,
104+
onPositiveBtnClick: Runnable?,
105+
onNegativeBtnClick: Runnable?,
106+
customView: View?,
107+
cancelable: Boolean
108+
) {
109+
createAndShowDialogSafely(
110+
activity = activity,
111+
title = title,
112+
message = message,
113+
positiveButtonText = positiveButtonText,
114+
negativeButtonText = negativeButtonText,
115+
onPositiveBtnClick = onPositiveBtnClick,
116+
onNegativeBtnClick = onNegativeBtnClick,
117+
customView = customView,
118+
cancelable = cancelable
119+
)
120+
}
121+
97122
@JvmStatic
98123
fun showAlertDialog(
99124
activity: Activity,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@
441441
<string name="next">Next</string>
442442
<string name="previous">Previous</string>
443443
<string name="submit">Submit</string>
444-
<string formatted="true" name="upload_title_duplicate">A file with the file name %1$s exists. Are you sure you want to proceed?</string>
444+
<string formatted="true" name="upload_title_duplicate">A file with the file name %1$s exists. Are you sure you want to proceed?\n\nNote: A suitable suffix will be added to the file name automatically.</string>
445445
<string name="map_application_missing">No compatible map application could be found on your device. Please install a map application to use this feature.</string>
446446
<string name="navigation_item_bookmarks">Bookmarks</string>
447447
<string name="title_activity_bookmarks">Bookmarks</string>

0 commit comments

Comments
 (0)