diff --git a/android/res/drawable/ic_img_whatsnew_trial.xml b/android/res/drawable/ic_img_whatsnew_trial.xml new file mode 100644 index 0000000000..80f7ce3b50 --- /dev/null +++ b/android/res/drawable/ic_img_whatsnew_trial.xml @@ -0,0 +1,252 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/res/drawable/img_wnew_newguides.xml b/android/res/drawable/img_wnew_newguides.xml deleted file mode 100644 index 9a209ebad5..0000000000 --- a/android/res/drawable/img_wnew_newguides.xml +++ /dev/null @@ -1,487 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/android/res/values/arrays.xml b/android/res/values/arrays.xml index 47c10d42dd..3d17a2ddfd 100644 --- a/android/res/values/arrays.xml +++ b/android/res/values/arrays.xml @@ -3,15 +3,15 @@ - @drawable/img_wnew_newguides + @drawable/ic_img_whatsnew_trial - whatsnew_guides_on_map_title + whatsnew_trial_title - @string/whatsnew_guides_on_map_message + @string/whatsnew_trial_message @@ -19,7 +19,7 @@ - + @string/whatsnew_trial_cta diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarksCatalogFragment.java b/android/src/com/mapswithme/maps/bookmarks/BookmarksCatalogFragment.java index 3071a64c56..cc465f0919 100644 --- a/android/src/com/mapswithme/maps/bookmarks/BookmarksCatalogFragment.java +++ b/android/src/com/mapswithme/maps/bookmarks/BookmarksCatalogFragment.java @@ -25,6 +25,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; import com.android.billingclient.api.SkuDetails; import com.mapswithme.maps.Framework; import com.mapswithme.maps.PrivateVariables; @@ -35,7 +36,6 @@ import com.mapswithme.maps.bookmarks.data.BookmarkCategory; import com.mapswithme.maps.bookmarks.data.BookmarkManager; import com.mapswithme.maps.dialog.AlertDialog; import com.mapswithme.maps.dialog.AlertDialogCallback; -import com.mapswithme.maps.dialog.ConfirmationDialogFactory; import com.mapswithme.maps.metrics.UserActionsLogger; import com.mapswithme.maps.purchase.AbstractProductDetailsLoadingCallback; import com.mapswithme.maps.purchase.BillingManager; @@ -244,7 +244,7 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment if (requestCode == PurchaseUtils.REQ_CODE_PAY_SUBSCRIPTION) { mWebView.reload(); - showSubscriptionSuccessDialog(); + showSubscriptionSuccessDialog(this); return; } @@ -252,19 +252,11 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment mWebView.reload(); } - private void showSubscriptionSuccessDialog() + private static void showSubscriptionSuccessDialog(@NonNull Fragment fragment) { - AlertDialog dialog = new AlertDialog.Builder() - .setTitleId(R.string.subscription_success_dialog_title) - .setMessageId(R.string.subscription_success_dialog_message) - .setPositiveBtnId(R.string.subscription_error_button) - .setReqCode(PurchaseUtils.REQ_CODE_BMK_SUBS_SUCCESS_DIALOG) - .setFragManagerStrategyType(AlertDialog.FragManagerStrategyType.ACTIVITY_FRAGMENT_MANAGER) - .setDialogViewStrategyType(AlertDialog.DialogViewStrategyType.CONFIRMATION_DIALOG) - .setDialogFactory(new ConfirmationDialogFactory()) - .build(); - dialog.setTargetFragment(this, PurchaseUtils.REQ_CODE_BMK_SUBS_SUCCESS_DIALOG); - dialog.show(this, PurchaseUtils.DIALOG_TAG_BMK_SUBSCRIPTION_SUCCESS); + PurchaseUtils.showSubscriptionSuccessDialog(fragment, + PurchaseUtils.DIALOG_TAG_BMK_SUBSCRIPTION_SUCCESS, + PurchaseUtils.REQ_CODE_BMK_SUBS_SUCCESS_DIALOG); } @Override diff --git a/android/src/com/mapswithme/maps/onboarding/BaseNewsFragment.java b/android/src/com/mapswithme/maps/onboarding/BaseNewsFragment.java index 6cac65aa30..713fab628a 100644 --- a/android/src/com/mapswithme/maps/onboarding/BaseNewsFragment.java +++ b/android/src/com/mapswithme/maps/onboarding/BaseNewsFragment.java @@ -29,8 +29,6 @@ import com.mapswithme.maps.BuildConfig; import com.mapswithme.maps.MwmApplication; import com.mapswithme.maps.R; import com.mapswithme.maps.base.BaseMwmDialogFragment; -import com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity; -import com.mapswithme.maps.bookmarks.BookmarksCatalogActivity; import com.mapswithme.util.ThemeUtils; import com.mapswithme.util.UiUtils; import com.mapswithme.util.Utils; @@ -207,7 +205,7 @@ public abstract class BaseNewsFragment extends BaseMwmDialogFragment private void processButton(int position, @NonNull View res) { - TextView button = res.findViewById(R.id.button); + final TextView button = res.findViewById(R.id.button); PromoButton promo = mPromoButtons.get(position); if (promo == null || TextUtils.isEmpty(promo.getLabel())) { @@ -216,13 +214,11 @@ public abstract class BaseNewsFragment extends BaseMwmDialogFragment } button.setText(promo.getLabel()); - button.setOnClickListener(v -> { - BookmarksCatalogActivity.startForResult( - BaseNewsFragment.this, - BookmarkCategoriesActivity.REQ_CODE_DOWNLOAD_BOOKMARK_CATEGORY, promo.getLink()); - }); + button.setOnClickListener(v -> onPromoButtonClicked(button)); } + abstract void onPromoButtonClicked(@NonNull View view); + @Override public void destroyItem(ViewGroup container, int position, Object object) { diff --git a/android/src/com/mapswithme/maps/onboarding/NewsFragment.java b/android/src/com/mapswithme/maps/onboarding/NewsFragment.java index b76ad9c0d9..eba8dbe4e6 100644 --- a/android/src/com/mapswithme/maps/onboarding/NewsFragment.java +++ b/android/src/com/mapswithme/maps/onboarding/NewsFragment.java @@ -1,6 +1,9 @@ package com.mapswithme.maps.onboarding; +import android.app.Activity; import android.content.Context; +import android.content.Intent; +import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -8,14 +11,24 @@ import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; import com.mapswithme.maps.BuildConfig; +import com.mapswithme.maps.Framework; import com.mapswithme.maps.R; +import com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity; +import com.mapswithme.maps.bookmarks.BookmarksCatalogActivity; +import com.mapswithme.maps.bookmarks.data.BookmarkCategory; +import com.mapswithme.maps.bookmarks.data.BookmarkManager; +import com.mapswithme.maps.dialog.AlertDialogCallback; import com.mapswithme.maps.downloader.UpdaterDialogFragment; +import com.mapswithme.maps.purchase.BookmarksAllSubscriptionActivity; +import com.mapswithme.maps.purchase.PurchaseUtils; import com.mapswithme.util.Counters; import com.mapswithme.util.SharedPropertiesUtils; +import com.mapswithme.util.UTM; +import com.mapswithme.util.UiUtils; +import com.mapswithme.util.statistics.Statistics; -public class NewsFragment extends BaseNewsFragment +public class NewsFragment extends BaseNewsFragment implements AlertDialogCallback { - private class Adapter extends BaseNewsFragment.Adapter { @Override @@ -65,6 +78,15 @@ public class NewsFragment extends BaseNewsFragment { return R.array.news_images; } + + @Override + void onPromoButtonClicked(@NonNull View view) + { + UiUtils.hide(view); + BookmarksAllSubscriptionActivity.startForResult(NewsFragment.this, + PurchaseUtils.REQ_CODE_PAY_SUBSCRIPTION, + Statistics.ParamValue.WHATSNEW); + } } @Override @@ -132,4 +154,53 @@ public class NewsFragment extends BaseNewsFragment return sb.toString().trim(); } + + @Override + public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) + { + super.onActivityResult(requestCode, resultCode, data); + if (resultCode != Activity.RESULT_OK) + return; + + switch (requestCode) + { + case PurchaseUtils.REQ_CODE_PAY_SUBSCRIPTION: + PurchaseUtils.showSubscriptionSuccessDialog(this, + PurchaseUtils.DIALOG_TAG_BMK_SUBSCRIPTION_SUCCESS, + PurchaseUtils.REQ_CODE_BMK_SUBS_SUCCESS_DIALOG); + break; + case BookmarkCategoriesActivity.REQ_CODE_DOWNLOAD_BOOKMARK_CATEGORY: + if (data == null) + break; + + BookmarkCategory category + = data.getParcelableExtra(BookmarksCatalogActivity.EXTRA_DOWNLOADED_CATEGORY); + + if (category == null) + throw new IllegalArgumentException("Category not found in bundle"); + Framework.nativeShowBookmarkCategory(category.getId()); + break; + } + } + + @Override + public void onAlertDialogPositiveClick(int requestCode, int which) + { + if (requestCode == PurchaseUtils.REQ_CODE_BMK_SUBS_SUCCESS_DIALOG) + BookmarksCatalogActivity.startForResult(this, + BookmarkCategoriesActivity.REQ_CODE_DOWNLOAD_BOOKMARK_CATEGORY, + BookmarkManager.INSTANCE.getCatalogFrontendUrl(UTM.UTM_NONE)); + } + + @Override + public void onAlertDialogNegativeClick(int requestCode, int which) + { + // No op. + } + + @Override + public void onAlertDialogCancel(int requestCode) + { + // No op. + } } diff --git a/android/src/com/mapswithme/maps/purchase/PurchaseUtils.java b/android/src/com/mapswithme/maps/purchase/PurchaseUtils.java index 60fd4f1c05..160a1740da 100644 --- a/android/src/com/mapswithme/maps/purchase/PurchaseUtils.java +++ b/android/src/com/mapswithme/maps/purchase/PurchaseUtils.java @@ -10,6 +10,7 @@ import com.android.billingclient.api.Purchase; import com.android.billingclient.api.SkuDetails; import com.mapswithme.maps.R; import com.mapswithme.maps.dialog.AlertDialog; +import com.mapswithme.maps.dialog.ConfirmationDialogFactory; import com.mapswithme.util.CrashlyticsUtils; import com.mapswithme.util.Utils; import com.mapswithme.util.log.Logger; @@ -212,6 +213,22 @@ public class PurchaseUtils return SubscriptionType.BOOKMARKS_ALL.getServerId(); } + public static void showSubscriptionSuccessDialog(@NonNull Fragment targetFragment, + @NonNull String tag, int reqCode) + { + AlertDialog dialog = new AlertDialog.Builder() + .setTitleId(R.string.subscription_success_dialog_title) + .setMessageId(R.string.subscription_success_dialog_message) + .setPositiveBtnId(R.string.subscription_error_button) + .setReqCode(reqCode) + .setFragManagerStrategyType(AlertDialog.FragManagerStrategyType.ACTIVITY_FRAGMENT_MANAGER) + .setDialogViewStrategyType(AlertDialog.DialogViewStrategyType.CONFIRMATION_DIALOG) + .setDialogFactory(new ConfirmationDialogFactory()) + .build(); + dialog.setTargetFragment(targetFragment, reqCode); + dialog.show(targetFragment, tag); + } + enum Period { // Order is important. diff --git a/android/src/com/mapswithme/util/statistics/Statistics.java b/android/src/com/mapswithme/util/statistics/Statistics.java index 8351253704..0445bc0be3 100644 --- a/android/src/com/mapswithme/util/statistics/Statistics.java +++ b/android/src/com/mapswithme/util/statistics/Statistics.java @@ -751,6 +751,7 @@ public enum Statistics public static final String SPONSORED_BUTTON = "sponsored_button"; public static final String POPUP = "popup"; public static final String WEBVIEW = "webview"; + public static final String WHATSNEW = "whatsnew"; public static final String ONBOARDING_GUIDES_SUBSCRIPTION = "onboarding_guides_subscription"; public static final String PLUS = "plus"; public static final String DOWNLOAD = "download";