From 98bb16639e73549411f9af0312a2b30b8d9f10ef Mon Sep 17 00:00:00 2001 From: Dmitry Donskoy Date: Thu, 24 Jan 2019 15:26:39 +0300 Subject: [PATCH] [android] Added potential dialogs --- .../mapswithme/maps/dialog/AlertDialog.java | 10 ++-- .../ugc/routes/UgcSharingOptionsFragment.java | 50 +++++++++++++++---- 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/android/src/com/mapswithme/maps/dialog/AlertDialog.java b/android/src/com/mapswithme/maps/dialog/AlertDialog.java index 12fc2cc908..bb8dd858f1 100644 --- a/android/src/com/mapswithme/maps/dialog/AlertDialog.java +++ b/android/src/com/mapswithme/maps/dialog/AlertDialog.java @@ -179,7 +179,7 @@ public class AlertDialog extends BaseMwmDialogFragment @StringRes private int mNegativeBtn = INVALID_ID; @DrawableRes - private int mImageResId; + private int mImageResId = INVALID_ID; @NonNull private FragManagerStrategyType mFragManagerStrategyType = FragManagerStrategyType.DEFAULT; @NonNull @@ -380,9 +380,11 @@ public class AlertDialog extends BaseMwmDialogFragment titleView.setText(args.getInt(ARG_TITLE_ID)); ImageView imageView = root.findViewById(R.id.image); - boolean hasImage = args.containsKey(ARG_IMAGE_RES_ID); - imageView.setImageResource(hasImage ? args.getInt(ARG_IMAGE_RES_ID) - : R.drawable.ic_error_36px); + int imageResId = args.getInt(ARG_IMAGE_RES_ID); + boolean hasImage = imageResId != INVALID_ID; + + imageView.setImageDrawable(hasImage ? fragment.getResources().getDrawable(imageResId) + : null); UiUtils.showIf(hasImage, imageView); appCompatDialog.setContentView(root); return appCompatDialog; diff --git a/android/src/com/mapswithme/maps/ugc/routes/UgcSharingOptionsFragment.java b/android/src/com/mapswithme/maps/ugc/routes/UgcSharingOptionsFragment.java index ba1b60097c..0858a2edf7 100644 --- a/android/src/com/mapswithme/maps/ugc/routes/UgcSharingOptionsFragment.java +++ b/android/src/com/mapswithme/maps/ugc/routes/UgcSharingOptionsFragment.java @@ -53,6 +53,8 @@ public class UgcSharingOptionsFragment extends BaseMwmAuthorizationFragment impl private static final int REQ_CODE_ERROR_COMMON = 106; private static final int REQ_CODE_ERROR_NOT_ENOUGH_BOOKMARKS = 107; private static final int REQ_CODE_UPLOAD_CONFIRMATION_DIALOG = 108; + private static final int REQ_CODE_ERROR_HTML_FORMATTING_DIALOG = 109; + private static final String BUNDLE_CURRENT_MODE = "current_mode"; private static final String UPLOADING_PROGRESS_DIALOG_TAG = "uploading_progress_dialog"; private static final String NO_NETWORK_CONNECTION_DIALOG_TAG = "no_network_connection_dialog"; @@ -61,6 +63,8 @@ public class UgcSharingOptionsFragment extends BaseMwmAuthorizationFragment impl private static final String ERROR_EDITED_ON_WEB_DIALOG_REQ_TAG = "error_edited_on_web_dialog"; private static final String ERROR_COMMON_DIALOG_TAG = "error_common_dialog"; private static final String UPLOAD_CONFIRMATION_DIALOG_TAG = "upload_confirmation_dialog"; + private static final String ERROR_HTML_FORMATTING_DIALOG_TAG = "error_html_formatting_dialog"; + @SuppressWarnings("NullableProblems") @NonNull @@ -546,21 +550,47 @@ public class UgcSharingOptionsFragment extends BaseMwmAuthorizationFragment impl } - private void showUploadCatalogConfirmationDialog() + private void showConfirmationDialog(int reqCode, String tag, @StringRes int acceptBtn, + @StringRes int declineBtn, @StringRes int title, + @StringRes int description) { - /*FIXME text later*/ AlertDialog dialog = new AlertDialog.Builder() - .setTitleId(R.string.common_check_internet_connection_dialog_title) - .setMessageId(R.string.common_check_internet_connection_dialog) - .setPositiveBtnId(R.string.try_again) - .setNegativeBtnId(R.string.cancel) - .setReqCode(REQ_CODE_UPLOAD_CONFIRMATION_DIALOG) - .setImageResId(R.drawable.ic_error_36px) + .setTitleId(title) + .setMessageId(description) + .setPositiveBtnId(acceptBtn) + .setNegativeBtnId(declineBtn) + .setReqCode(reqCode) .setFragManagerStrategyType(AlertDialog.FragManagerStrategyType.ACTIVITY_FRAGMENT_MANAGER) .setDialogViewStrategyType(AlertDialog.DialogViewStrategyType.CONFIRMATION_DIALOG) .setDialogFactory(new ConfirmationDialogFactory()) .build(); - dialog.setTargetFragment(this, REQ_CODE_UPLOAD_CONFIRMATION_DIALOG); - dialog.show(this, UPLOAD_CONFIRMATION_DIALOG_TAG); + dialog.setTargetFragment(this, reqCode); + dialog.show(this, tag); + } + + private void showHtmlFormattingError() + { + showConfirmationDialog(REQ_CODE_ERROR_HTML_FORMATTING_DIALOG, + ERROR_HTML_FORMATTING_DIALOG_TAG, R.string.common_check_internet_connection_dialog_title, + R.string.common_check_internet_connection_dialog_title, + R.string.try_again, R.string.cancel); + } + + private void showUploadCatalogConfirmationDialog() + { + /*FIXME text later*/ + showConfirmationDialog(REQ_CODE_UPLOAD_CONFIRMATION_DIALOG, + UPLOAD_CONFIRMATION_DIALOG_TAG, R.string.common_check_internet_connection_dialog_title, + R.string.common_check_internet_connection_dialog_title, + R.string.try_again, R.string.cancel); + } + + private void showUnresolvedConflictsErrorDialog() + { + /*FIXME text later*/ + showConfirmationDialog(REQ_CODE_UPLOAD_CONFIRMATION_DIALOG, + UPLOAD_CONFIRMATION_DIALOG_TAG, R.string.common_check_internet_connection_dialog_title, + R.string.common_check_internet_connection_dialog_title, + R.string.try_again, R.string.cancel); } }