From 59e74dae4be5046c0775ad4502b375fee6853106 Mon Sep 17 00:00:00 2001 From: Dmitry Donskoy Date: Thu, 5 Sep 2019 09:43:54 +0300 Subject: [PATCH] [android] Fixed review notes https://github.com/mapsme/omim/pull/11568#discussion_r319884088 https://github.com/mapsme/omim/pull/11568#discussion_r319888921 https://github.com/mapsme/omim/pull/11568#discussion_r319893250 https://github.com/mapsme/omim/pull/11568#discussion_r319896252 https://github.com/mapsme/omim/pull/11568#discussion_r319903334 https://github.com/mapsme/omim/pull/11568#discussion_r319907407 https://github.com/mapsme/omim/pull/11568#discussion_r319906833 https://github.com/mapsme/omim/pull/11568#discussion_r319888394 https://github.com/mapsme/omim/pull/11568#discussion_r319888795 --- .../{ic_fab_blue.png => ic_crown.png} | Bin .../{ic_fab_blue.png => ic_crown.png} | Bin .../{ic_fab_blue.png => ic_crown.png} | Bin .../{ic_fab_blue.png => ic_crown.png} | Bin .../{ic_fab_blue.png => ic_crown.png} | Bin android/res/drawable/bg_crown.xml | 1 - android/res/drawable/bg_crown_night.xml | 1 - .../layout-land/map_navigation_buttons.xml | 60 ++++++++---------- android/res/layout/map_navigation_buttons.xml | 53 ++++++---------- .../src/com/mapswithme/maps/MwmActivity.java | 47 ++++++++------ .../NavigationButtonsAnimationController.java | 32 +++++++++- .../dialog/ActivityCallbackAlertDialog.java | 11 ---- .../mapswithme/maps/dialog/AlertDialog.java | 9 ++- .../dialog/CatalogUnlimitedAccessDialog.java | 12 ---- .../dialog/DrivingOptionsDialogFactory.java | 13 ---- .../BookmarkSubscriptionFragment.java | 53 +++++----------- .../BookmarkSubscriptionPaymentState.java | 4 +- .../maps/purchase/PurchaseUtils.java | 16 +++++ 18 files changed, 145 insertions(+), 167 deletions(-) rename android/res/drawable-hdpi/{ic_fab_blue.png => ic_crown.png} (100%) rename android/res/drawable-mdpi/{ic_fab_blue.png => ic_crown.png} (100%) rename android/res/drawable-xhdpi/{ic_fab_blue.png => ic_crown.png} (100%) rename android/res/drawable-xxhdpi/{ic_fab_blue.png => ic_crown.png} (100%) rename android/res/drawable-xxxhdpi/{ic_fab_blue.png => ic_crown.png} (100%) delete mode 100644 android/src/com/mapswithme/maps/dialog/ActivityCallbackAlertDialog.java delete mode 100644 android/src/com/mapswithme/maps/dialog/CatalogUnlimitedAccessDialog.java delete mode 100644 android/src/com/mapswithme/maps/dialog/DrivingOptionsDialogFactory.java diff --git a/android/res/drawable-hdpi/ic_fab_blue.png b/android/res/drawable-hdpi/ic_crown.png similarity index 100% rename from android/res/drawable-hdpi/ic_fab_blue.png rename to android/res/drawable-hdpi/ic_crown.png diff --git a/android/res/drawable-mdpi/ic_fab_blue.png b/android/res/drawable-mdpi/ic_crown.png similarity index 100% rename from android/res/drawable-mdpi/ic_fab_blue.png rename to android/res/drawable-mdpi/ic_crown.png diff --git a/android/res/drawable-xhdpi/ic_fab_blue.png b/android/res/drawable-xhdpi/ic_crown.png similarity index 100% rename from android/res/drawable-xhdpi/ic_fab_blue.png rename to android/res/drawable-xhdpi/ic_crown.png diff --git a/android/res/drawable-xxhdpi/ic_fab_blue.png b/android/res/drawable-xxhdpi/ic_crown.png similarity index 100% rename from android/res/drawable-xxhdpi/ic_fab_blue.png rename to android/res/drawable-xxhdpi/ic_crown.png diff --git a/android/res/drawable-xxxhdpi/ic_fab_blue.png b/android/res/drawable-xxxhdpi/ic_crown.png similarity index 100% rename from android/res/drawable-xxxhdpi/ic_fab_blue.png rename to android/res/drawable-xxxhdpi/ic_crown.png diff --git a/android/res/drawable/bg_crown.xml b/android/res/drawable/bg_crown.xml index 130c4f1e7c..df34356d6c 100644 --- a/android/res/drawable/bg_crown.xml +++ b/android/res/drawable/bg_crown.xml @@ -1,6 +1,5 @@ - diff --git a/android/res/drawable/bg_crown_night.xml b/android/res/drawable/bg_crown_night.xml index 819fdc6266..8e39462ade 100644 --- a/android/res/drawable/bg_crown_night.xml +++ b/android/res/drawable/bg_crown_night.xml @@ -1,6 +1,5 @@ - diff --git a/android/res/layout-land/map_navigation_buttons.xml b/android/res/layout-land/map_navigation_buttons.xml index e49069daf0..d327168fc9 100644 --- a/android/res/layout-land/map_navigation_buttons.xml +++ b/android/res/layout-land/map_navigation_buttons.xml @@ -24,43 +24,23 @@ android:background="?attr/nav_bg_subway" android:visibility="invisible"/> - + - - - - - - - - + android:layout_alignParentEnd="true" + android:layout_alignParentRight="true" + android:background="?nav_background" + android:src="@drawable/ic_zoom_out"/> + + diff --git a/android/res/layout/map_navigation_buttons.xml b/android/res/layout/map_navigation_buttons.xml index 43e81ad69d..3e64563fbc 100644 --- a/android/res/layout/map_navigation_buttons.xml +++ b/android/res/layout/map_navigation_buttons.xml @@ -36,43 +36,30 @@ android:contentDescription="@string/core_my_position" android:tint="@null"/> - - - + android:layout_below="@+id/nav_zoom_in" + android:src="@drawable/ic_zoom_out"/> - - - - - + android:layout_alignParentRight="true" + android:layout_alignParentEnd="true"/> + diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index 41dea76c63..056db581a7 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -46,9 +46,8 @@ import com.mapswithme.maps.bookmarks.data.CatalogCustomProperty; import com.mapswithme.maps.bookmarks.data.CatalogTagsGroup; import com.mapswithme.maps.bookmarks.data.MapObject; import com.mapswithme.maps.dialog.AlertDialogCallback; -import com.mapswithme.maps.dialog.CatalogUnlimitedAccessDialog; +import com.mapswithme.maps.dialog.DefaultConfirmationAlertDialog; import com.mapswithme.maps.dialog.DialogUtils; -import com.mapswithme.maps.dialog.DrivingOptionsDialogFactory; import com.mapswithme.maps.discovery.DiscoveryActivity; import com.mapswithme.maps.discovery.DiscoveryFragment; import com.mapswithme.maps.discovery.ItemType; @@ -114,8 +113,8 @@ import com.mapswithme.maps.settings.UnitLocale; import com.mapswithme.maps.sound.TtsPlayer; import com.mapswithme.maps.taxi.TaxiInfo; import com.mapswithme.maps.taxi.TaxiManager; -import com.mapswithme.maps.tips.TutorialAction; import com.mapswithme.maps.tips.Tutorial; +import com.mapswithme.maps.tips.TutorialAction; import com.mapswithme.maps.widget.FadeView; import com.mapswithme.maps.widget.menu.BaseMenu; import com.mapswithme.maps.widget.menu.MainMenu; @@ -711,24 +710,35 @@ public class MwmActivity extends BaseMwmFragmentActivity if (frame == null) return; - View zoomIn = frame.findViewById(R.id.nav_zoom_in_container); - zoomIn.findViewById(R.id.nav_zoom_in).setOnClickListener(this); - View zoomOut = frame.findViewById(R.id.nav_zoom_out_container); - zoomOut.findViewById(R.id.nav_zoom_out).setOnClickListener(this); + View zoomIn = frame.findViewById(R.id.nav_zoom_in); + zoomIn.setOnClickListener(this); + View zoomOut = frame.findViewById(R.id.nav_zoom_out); + zoomOut.setOnClickListener(this); View myPosition = frame.findViewById(R.id.my_position); mNavMyPosition = new MyPositionButton(myPosition, mOnMyPositionClickListener); initToggleMapLayerController(frame); - mNavAnimationController = new NavigationButtonsAnimationController( - zoomIn, zoomOut, myPosition, getWindow().getDecorView().getRootView(), this); View openSubsScreenBtn = frame.findViewById(R.id.subs_screen_btn); - openSubsScreenBtn.setOnClickListener(v -> openSubscriptionsScreen()); - openSubsScreenBtn.setVisibility(true ? View.VISIBLE : View.GONE); + mNavAnimationController = new NavigationButtonsAnimationController( + zoomIn, zoomOut, myPosition, getWindow().getDecorView().getRootView(), this, openSubsScreenBtn); + + openSubsScreenBtn.setOnClickListener(v -> onCrownClicked()); + UiUtils.showIf(Framework.nativeNeedToShowCrown(), openSubsScreenBtn); } - private void openSubscriptionsScreen() + private void onCrownClicked() { - Intent intent = new Intent(MwmActivity.this, BookmarkSubscriptionActivity.class); + openBookmarkSubscriptionScreen(); + UserActionsLogger.logCrownClicked(); + if (mNavAnimationController == null) + return; + + mNavAnimationController.hideCrownView(); + } + + private void openBookmarkSubscriptionScreen() + { + Intent intent = new Intent(this, BookmarkSubscriptionActivity.class); startActivityForResult(intent, PurchaseUtils.REQ_CODE_PAY_SUBSCRIPTION); } @@ -957,12 +967,12 @@ public class MwmActivity extends BaseMwmFragmentActivity { com.mapswithme.maps.dialog.AlertDialog dialog = new com.mapswithme.maps.dialog.AlertDialog.Builder() - .setTitleId(R.string.unable_to_calc_alert_title) - .setMessageId(R.string.unable_to_calc_alert_subtitle) - .setPositiveBtnId(R.string.settings) - .setNegativeBtnId(R.string.cancel) + .setTitleId(R.string.popup_subscription_success_map_title) + .setMessageId(R.string.popup_subscription_success_map_message) + .setPositiveBtnId(R.string.popup_subscription_success_map_start_button) + .setNegativeBtnId(R.string.popup_subscription_success_map_not_now_button) .setDialogViewStrategyType(com.mapswithme.maps.dialog.AlertDialog.DialogViewStrategyType.CONFIRMATION_DIALOG) - .setDialogFactory(CatalogUnlimitedAccessDialog::new) + .setDialogFactory(DefaultConfirmationAlertDialog::new) .setReqCode(REQ_CODE_CATALOG_UNLIMITED_ACCESS) .setFragManagerStrategyType(com.mapswithme.maps.dialog.AlertDialog .FragManagerStrategyType.ACTIVITY_FRAGMENT_MANAGER) @@ -2104,7 +2114,6 @@ public class MwmActivity extends BaseMwmFragmentActivity .setPositiveBtnId(R.string.settings) .setNegativeBtnId(R.string.cancel) .setReqCode(REQ_CODE_ERROR_DRIVING_OPTIONS_DIALOG) - .setDialogFactory(new DrivingOptionsDialogFactory()) .setFragManagerStrategyType(com.mapswithme.maps.dialog.AlertDialog .FragManagerStrategyType.ACTIVITY_FRAGMENT_MANAGER) .build(); diff --git a/android/src/com/mapswithme/maps/NavigationButtonsAnimationController.java b/android/src/com/mapswithme/maps/NavigationButtonsAnimationController.java index 586bc54525..9313fd2aec 100644 --- a/android/src/com/mapswithme/maps/NavigationButtonsAnimationController.java +++ b/android/src/com/mapswithme/maps/NavigationButtonsAnimationController.java @@ -19,6 +19,8 @@ class NavigationButtonsAnimationController private final View mZoomOut; @NonNull private final View mMyPosition; + @Nullable + private View mCrownView; @Nullable private final OnTranslationChangedListener mTranslationListener; @@ -34,10 +36,12 @@ class NavigationButtonsAnimationController NavigationButtonsAnimationController(@NonNull View zoomIn, @NonNull View zoomOut, @NonNull View myPosition, @NonNull final View contentView, - @Nullable OnTranslationChangedListener translationListener) + @Nullable OnTranslationChangedListener translationListener, + @NonNull View crownView) { mZoomIn = zoomIn; mZoomOut = zoomOut; + mCrownView = crownView; checkZoomButtonsVisibility(); mMyPosition = myPosition; Resources res = mZoomIn.getResources(); @@ -110,17 +114,23 @@ class NavigationButtonsAnimationController mMyPosition.setTranslationY(translation); mZoomOut.setTranslationY(translation); mZoomIn.setTranslationY(translation); + if (mCrownView != null) + mCrownView.setTranslationY(translation); + if (mZoomIn.getVisibility() == View.VISIBLE && !isViewInsideLimits(mZoomIn)) { UiUtils.invisible(mZoomIn, mZoomOut); + if (mCrownView != null) + UiUtils.invisible(mCrownView); + if (mTranslationListener != null) mTranslationListener.onFadeOutZoomButtons(); } else if (mZoomIn.getVisibility() == View.INVISIBLE && isViewInsideLimits(mZoomIn)) { - UiUtils.show(mZoomIn, mZoomOut); + UiUtils.show(mZoomIn, mZoomOut, mCrownView); if (mTranslationListener != null) mTranslationListener.onFadeInZoomButtons(); } @@ -157,6 +167,19 @@ class NavigationButtonsAnimationController return; UiUtils.hide(mZoomIn, mZoomOut); + if (mCrownView == null) + return; + + UiUtils.hide(mCrownView); + } + + void hideCrownView() + { + if (mCrownView == null) + return; + + mCrownView.setVisibility(View.GONE); + mCrownView = null; } void appearZoomButtons() @@ -165,6 +188,11 @@ class NavigationButtonsAnimationController return; UiUtils.show(mZoomIn, mZoomOut); + + if (mCrownView == null) + return; + + UiUtils.show(mCrownView); } private static boolean showZoomButtons() diff --git a/android/src/com/mapswithme/maps/dialog/ActivityCallbackAlertDialog.java b/android/src/com/mapswithme/maps/dialog/ActivityCallbackAlertDialog.java deleted file mode 100644 index 4afe6c66c6..0000000000 --- a/android/src/com/mapswithme/maps/dialog/ActivityCallbackAlertDialog.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.mapswithme.maps.dialog; - -public class ActivityCallbackAlertDialog extends AlertDialog -{ - @Override - protected void onAttachInternal() - { - AlertDialogCallback callback = (AlertDialogCallback) getActivity(); - setTargetCallback(callback); - } -} diff --git a/android/src/com/mapswithme/maps/dialog/AlertDialog.java b/android/src/com/mapswithme/maps/dialog/AlertDialog.java index 6a6ca73311..6f24a55cc5 100644 --- a/android/src/com/mapswithme/maps/dialog/AlertDialog.java +++ b/android/src/com/mapswithme/maps/dialog/AlertDialog.java @@ -99,10 +99,17 @@ public class AlertDialog extends BaseMwmDialogFragment } } - protected void onAttachInternal() + private void onAttachInternal() { mTargetCallback = (AlertDialogCallback) (getParentFragment() == null ? getTargetFragment() : getParentFragment()); + if (mTargetCallback != null) + return; + + if (!(getActivity() instanceof AlertDialogCallback)) + return; + + mTargetCallback = (AlertDialogCallback) getActivity(); } @Override diff --git a/android/src/com/mapswithme/maps/dialog/CatalogUnlimitedAccessDialog.java b/android/src/com/mapswithme/maps/dialog/CatalogUnlimitedAccessDialog.java deleted file mode 100644 index 0e9b20a2f4..0000000000 --- a/android/src/com/mapswithme/maps/dialog/CatalogUnlimitedAccessDialog.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.mapswithme.maps.dialog; - -import com.mapswithme.maps.R; - -public class CatalogUnlimitedAccessDialog extends ActivityCallbackAlertDialog -{ - @Override - protected int getLayoutId() - { - return R.layout.fragment_confirmation; - } -} diff --git a/android/src/com/mapswithme/maps/dialog/DrivingOptionsDialogFactory.java b/android/src/com/mapswithme/maps/dialog/DrivingOptionsDialogFactory.java deleted file mode 100644 index caadcc32bb..0000000000 --- a/android/src/com/mapswithme/maps/dialog/DrivingOptionsDialogFactory.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.mapswithme.maps.dialog; - -import android.support.annotation.NonNull; - -public class DrivingOptionsDialogFactory implements DialogFactory -{ - @NonNull - @Override - public AlertDialog createDialog() - { - return new ActivityCallbackAlertDialog(); - } -} diff --git a/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionFragment.java b/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionFragment.java index 825dab9acd..03740be48c 100644 --- a/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionFragment.java +++ b/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionFragment.java @@ -22,7 +22,6 @@ import com.mapswithme.maps.bookmarks.data.BookmarkManager; import com.mapswithme.maps.dialog.AlertDialog; import com.mapswithme.maps.dialog.AlertDialogCallback; import com.mapswithme.maps.dialog.ResolveFragmentManagerStrategy; -import com.mapswithme.util.ConnectionState; import com.mapswithme.util.Utils; import com.mapswithme.util.log.Logger; import com.mapswithme.util.log.LoggerFactory; @@ -39,8 +38,6 @@ public class BookmarkSubscriptionFragment extends BaseAuthFragment private final static String EXTRA_CURRENT_STATE = "extra_current_state"; private final static String EXTRA_PRODUCT_DETAILS = "extra_product_details"; private static final int DEF_ELEVATION = 0; - private static final int REQ_CODE_NO_NETWORK_CONNECTION_DIALOG = 102; - private static final String NO_NETWORK_CONNECTION_DIALOG_TAG = "no_network_connection_dialog_tag"; @SuppressWarnings("NullableProblems") @NonNull @@ -56,10 +53,6 @@ public class BookmarkSubscriptionFragment extends BaseAuthFragment private boolean mValidationResult; private boolean mPingingResult; - @SuppressWarnings("NullableProblems") - @NonNull - private View mContentView; - @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @@ -72,7 +65,6 @@ public class BookmarkSubscriptionFragment extends BaseAuthFragment mPingCallback.attach(this); BookmarkManager.INSTANCE.addCatalogPingListener(mPingCallback); View root = inflater.inflate(R.layout.bookmark_subscription_fragment, container, false); - mContentView = root.findViewById(R.id.content_view); CardView annualPriceCard = root.findViewById(R.id.annual_price_card); CardView monthlyPriceCard = root.findViewById(R.id.monthly_price_card); AnnualCardClickListener annualCardListener = new AnnualCardClickListener(monthlyPriceCard, @@ -227,23 +219,25 @@ public class BookmarkSubscriptionFragment extends BaseAuthFragment @Override public void onAlertDialogPositiveClick(int requestCode, int which) { - if (requestCode == REQ_CODE_NO_NETWORK_CONNECTION_DIALOG && ConnectionState.isConnected()) - onNetworkCheckPassed(); - else if (requestCode == REQ_CODE_NO_NETWORK_CONNECTION_DIALOG) - showNoConnectionDialog(); + if (requestCode == PurchaseUtils.REQ_CODE_NO_NETWORK_CONNECTION_DIALOG) + { + dismissOutdatedNoNetworkDialog(); + activateState(BookmarkSubscriptionPaymentState.NONE); + activateState(BookmarkSubscriptionPaymentState.CHECK_NETWORK_CONNECTION); + } } @Override public void onAlertDialogNegativeClick(int requestCode, int which) { - if (requestCode == REQ_CODE_NO_NETWORK_CONNECTION_DIALOG) + if (requestCode == PurchaseUtils.REQ_CODE_NO_NETWORK_CONNECTION_DIALOG) requireActivity().finish(); } @Override public void onAlertDialogCancel(int requestCode) { - if (requestCode == REQ_CODE_NO_NETWORK_CONNECTION_DIALOG) + if (requestCode == PurchaseUtils.REQ_CODE_NO_NETWORK_CONNECTION_DIALOG) requireActivity().finish(); } @@ -333,35 +327,20 @@ public class BookmarkSubscriptionFragment extends BaseAuthFragment public void onNetworkCheckPassed() { - mContentView.setVisibility(View.VISIBLE); activateState(BookmarkSubscriptionPaymentState.PRODUCT_DETAILS_LOADING); } - public void showNoConnectionDialog() + private void dismissOutdatedNoNetworkDialog() { - - AlertDialog.FragManagerStrategyType fragManagerStrategyType = - AlertDialog.FragManagerStrategyType.ACTIVITY_FRAGMENT_MANAGER; - - ResolveFragmentManagerStrategy strategy = fragManagerStrategyType.getValue(); + ResolveFragmentManagerStrategy strategy + = AlertDialog.FragManagerStrategyType.ACTIVITY_FRAGMENT_MANAGER.getValue(); FragmentManager manager = strategy.resolve(this); - Fragment outdatedInstance = manager.findFragmentByTag(NO_NETWORK_CONNECTION_DIALOG_TAG); - if (outdatedInstance != null) - { - manager.beginTransaction().remove(outdatedInstance).commitAllowingStateLoss(); - manager.executePendingTransactions(); - } + Fragment outdatedInstance = manager.findFragmentByTag(PurchaseUtils.NO_NETWORK_CONNECTION_DIALOG_TAG); + if (outdatedInstance == null) + return; - 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) - .setFragManagerStrategyType(fragManagerStrategyType) - .setReqCode(REQ_CODE_NO_NETWORK_CONNECTION_DIALOG) - .build(); - dialog.setTargetFragment(this, REQ_CODE_NO_NETWORK_CONNECTION_DIALOG); - dialog.show(this, NO_NETWORK_CONNECTION_DIALOG_TAG); + manager.beginTransaction().remove(outdatedInstance).commitAllowingStateLoss(); + manager.executePendingTransactions(); } private class AnnualCardClickListener implements View.OnClickListener diff --git a/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionPaymentState.java b/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionPaymentState.java index a21c972553..ca17c43791 100644 --- a/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionPaymentState.java +++ b/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionPaymentState.java @@ -14,7 +14,7 @@ public enum BookmarkSubscriptionPaymentState @Override void activate(@NonNull BookmarkSubscriptionFragment fragment) { - throw new UnsupportedOperationException("This state can't bu used!"); + UiUtils.hide(fragment.getViewOrThrow(), R.id.root_screen_progress, R.id.content_view); } }, PRODUCT_DETAILS_LOADING @@ -95,7 +95,7 @@ public enum BookmarkSubscriptionPaymentState NetworkPolicy.checkNetworkPolicy(fragment.requireFragmentManager(), policy -> onNetworkPolicyResult(policy, fragment), true); else - fragment.showNoConnectionDialog(); + PurchaseUtils.showNoConnectionDialog(fragment); } diff --git a/android/src/com/mapswithme/maps/purchase/PurchaseUtils.java b/android/src/com/mapswithme/maps/purchase/PurchaseUtils.java index 48eb1c5893..2937096283 100644 --- a/android/src/com/mapswithme/maps/purchase/PurchaseUtils.java +++ b/android/src/com/mapswithme/maps/purchase/PurchaseUtils.java @@ -38,6 +38,8 @@ public class PurchaseUtils final static int MONTHS_IN_YEAR = 12; private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.BILLING); private static final String TAG = PurchaseUtils.class.getSimpleName(); + static final int REQ_CODE_NO_NETWORK_CONNECTION_DIALOG = 11; + static final String NO_NETWORK_CONNECTION_DIALOG_TAG = "no_network_connection_dialog_tag"; private PurchaseUtils() { @@ -162,6 +164,20 @@ public class PurchaseUtils alertDialog.show(fragment, null); } + static void showNoConnectionDialog(@NonNull Fragment fragment) + { + 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) + .setFragManagerStrategyType(AlertDialog.FragManagerStrategyType.ACTIVITY_FRAGMENT_MANAGER) + .setReqCode(REQ_CODE_NO_NETWORK_CONNECTION_DIALOG) + .build(); + dialog.setTargetFragment(fragment, REQ_CODE_NO_NETWORK_CONNECTION_DIALOG); + dialog.show(fragment, NO_NETWORK_CONNECTION_DIALOG_TAG); + } + enum Period { // Order is important.