diff --git a/android/res/layout-w600dp/pager_fragment_bookmarks_all_subscription.xml b/android/res/layout-w600dp/pager_fragment_bookmarks_all_subscription.xml
index 0bd533f5fa..550dbdf61e 100644
--- a/android/res/layout-w600dp/pager_fragment_bookmarks_all_subscription.xml
+++ b/android/res/layout-w600dp/pager_fragment_bookmarks_all_subscription.xml
@@ -125,6 +125,27 @@
app:buttonBackground="@drawable/button_secondary_transparent"
app:buttonTextColor="@color/white_primary"
app:progressColor="@color/base_accent" />
+
+
+
+
CREATOR = new Creator()
{
@Override
@@ -79,5 +90,6 @@ class ProductDetails implements Parcelable
dest.writeFloat(mPrice);
dest.writeString(mCurrencyCode);
dest.writeString(mTitle);
+ dest.writeString(mFreeTrialPeriod);
}
}
diff --git a/android/src/com/mapswithme/maps/purchase/PurchaseUtils.java b/android/src/com/mapswithme/maps/purchase/PurchaseUtils.java
index e547b1b15f..60fd4f1c05 100644
--- a/android/src/com/mapswithme/maps/purchase/PurchaseUtils.java
+++ b/android/src/com/mapswithme/maps/purchase/PurchaseUtils.java
@@ -81,7 +81,8 @@ public class PurchaseUtils
{
float price = normalizePrice(skuDetails.getPriceAmountMicros());
String currencyCode = skuDetails.getPriceCurrencyCode();
- return new ProductDetails(skuDetails.getSku(), price, currencyCode, skuDetails.getTitle());
+ return new ProductDetails(skuDetails.getSku(), price, currencyCode, skuDetails.getTitle(),
+ skuDetails.getFreeTrialPeriod());
}
@NonNull
diff --git a/android/src/com/mapswithme/maps/purchase/TwoButtonsSubscriptionFragmentDelegate.java b/android/src/com/mapswithme/maps/purchase/TwoButtonsSubscriptionFragmentDelegate.java
index 558d971215..b4fe649698 100644
--- a/android/src/com/mapswithme/maps/purchase/TwoButtonsSubscriptionFragmentDelegate.java
+++ b/android/src/com/mapswithme/maps/purchase/TwoButtonsSubscriptionFragmentDelegate.java
@@ -1,25 +1,34 @@
package com.mapswithme.maps.purchase;
+import android.text.TextUtils;
import android.view.View;
+import android.widget.TextView;
import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import com.mapswithme.maps.R;
import com.mapswithme.maps.widget.SubscriptionButton;
+import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
import java.util.List;
class TwoButtonsSubscriptionFragmentDelegate extends SubscriptionFragmentDelegate
{
- @SuppressWarnings("NullableProblems")
+ @SuppressWarnings("NotNullFieldNotInitialized")
@NonNull
private SubscriptionButton mYearlyButton;
- @SuppressWarnings("NullableProblems")
+ @SuppressWarnings("NotNullFieldNotInitialized")
@NonNull
private SubscriptionButton mMonthlyButton;
@NonNull
private PurchaseUtils.Period mSelectedPeriod = PurchaseUtils.Period.P1Y;
+ @SuppressWarnings("NotNullFieldNotInitialized")
+ @NonNull
+ private View mFreeTrialButton;
+ @SuppressWarnings("NotNullFieldNotInitialized")
+ @NonNull
+ private TextView mFreeTrialMessage;
TwoButtonsSubscriptionFragmentDelegate(@NonNull AbstractBookmarkSubscriptionFragment fragment)
{
@@ -32,13 +41,12 @@ class TwoButtonsSubscriptionFragmentDelegate extends SubscriptionFragmentDelegat
{
super.onCreateView(root);
mYearlyButton = root.findViewById(R.id.annual_button);
- mYearlyButton.setOnClickListener(v -> {
- onSubscriptionButtonClicked(PurchaseUtils.Period.P1Y);
- });
+ mYearlyButton.setOnClickListener(v -> onSubscriptionButtonClicked(PurchaseUtils.Period.P1Y));
mMonthlyButton = root.findViewById(R.id.monthly_button);
- mMonthlyButton.setOnClickListener(v -> {
- onSubscriptionButtonClicked(PurchaseUtils.Period.P1M);
- });
+ mMonthlyButton.setOnClickListener(v -> onSubscriptionButtonClicked(PurchaseUtils.Period.P1M));
+ mFreeTrialButton = root.findViewById(R.id.free_trial_button);
+ mFreeTrialButton.setOnClickListener(v -> onSubscriptionButtonClicked(PurchaseUtils.Period.P1Y));
+ mFreeTrialMessage = root.findViewById(R.id.free_trial_mesage);
}
private void onSubscriptionButtonClicked(@NonNull PurchaseUtils.Period period)
@@ -75,6 +83,15 @@ class TwoButtonsSubscriptionFragmentDelegate extends SubscriptionFragmentDelegat
private void updatePaymentButtons()
{
+ ProductDetails details = getFragment().getProductDetailsForPeriod(PurchaseUtils.Period.P1Y);
+ if (!TextUtils.isEmpty(details.getFreeTrialPeriod()))
+ {
+ UiUtils.hide(mYearlyButton, mMonthlyButton);
+ UiUtils.show(mFreeTrialButton, mFreeTrialMessage);
+ String price = Utils.formatCurrencyString(details.getPrice(), details.getCurrencyCode());
+ mFreeTrialMessage.setText(getFragment().getString(R.string.guides_trial_message, price));
+ return;
+ }
updateYearlyButton();
updateMonthlyButton();
}