upload: made duplicate picture dialog more informative and added checkbox to never show again (#4045)

This commit is contained in:
Anadi Kashyap 2020-11-25 15:33:37 +05:30 committed by GitHub
parent 0b5f56b682
commit cbca290e4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 14 deletions

View file

@ -8,6 +8,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -272,19 +273,33 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
@Override
public void showDuplicatePicturePopup(UploadItem uploadItem) {
String uploadTitleFormat = getString(R.string.upload_title_duplicate);
DialogUtil.showAlertDialog(getActivity(),
getString(R.string.duplicate_image_found),
String.format(Locale.getDefault(),
uploadTitleFormat,
uploadItem.getFileName()),
getString(R.string.upload),
getString(R.string.cancel),
() -> {
uploadItem.setImageQuality(ImageUtils.IMAGE_KEEP);
onNextButtonClicked();
}, null);
if (defaultKvStore.getBoolean("showDuplicatePicturePopup", true)) {
String uploadTitleFormat = getString(R.string.upload_title_duplicate);
View checkBoxView = View
.inflate(getActivity(), R.layout.nearby_permission_dialog, null);
CheckBox checkBox = (CheckBox) checkBoxView.findViewById(R.id.never_ask_again);
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
defaultKvStore.putBoolean("showDuplicatePicturePopup", false);
}
});
DialogUtil.showAlertDialog(getActivity(),
getString(R.string.duplicate_image_found),
String.format(Locale.getDefault(),
uploadTitleFormat,
uploadItem.getFileName()),
getString(R.string.upload),
getString(R.string.cancel),
() -> {
uploadItem.setImageQuality(ImageUtils.IMAGE_KEEP);
onNextButtonClicked();
}, null,
checkBoxView,
false);
} else {
uploadItem.setImageQuality(ImageUtils.IMAGE_KEEP);
onNextButtonClicked();
}
}
@Override

View file

@ -94,6 +94,31 @@ object DialogUtil {
)
}
@JvmStatic
fun showAlertDialog(
activity: Activity,
title: String,
message: String,
positiveButtonText: String?,
negativeButtonText: String?,
onPositiveBtnClick: Runnable?,
onNegativeBtnClick: Runnable?,
customView: View?,
cancelable: Boolean
) {
createAndShowDialogSafely(
activity = activity,
title = title,
message = message,
positiveButtonText = positiveButtonText,
negativeButtonText = negativeButtonText,
onPositiveBtnClick = onPositiveBtnClick,
onNegativeBtnClick = onNegativeBtnClick,
customView = customView,
cancelable = cancelable
)
}
@JvmStatic
fun showAlertDialog(
activity: Activity,

View file

@ -441,7 +441,7 @@
<string name="next">Next</string>
<string name="previous">Previous</string>
<string name="submit">Submit</string>
<string formatted="true" name="upload_title_duplicate">A file with the file name %1$s exists. Are you sure you want to proceed?</string>
<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>
<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>
<string name="navigation_item_bookmarks">Bookmarks</string>
<string name="title_activity_bookmarks">Bookmarks</string>