From cd62f39d8fec54c61810731a99a2bdd7a02f7fee Mon Sep 17 00:00:00 2001 From: Dmitry Donskoy Date: Mon, 1 Jul 2019 22:18:00 +0300 Subject: [PATCH] [android] Improvements of cards' appearance --- android/res/animator/lift_on_touch.xml | 2 +- android/res/drawable/annual_card_edge.xml | 13 + .../res/drawable/annual_card_edge_night.xml | 13 + android/res/drawable/monthly_card_edge.xml | 13 + .../res/drawable/monthly_card_edge_night.xml | 13 + .../layout/bookmark_subscription_fragment.xml | 9 +- .../res/layout/subscription_offer_card.xml | 320 ++++++++++-------- android/res/values/attrs.xml | 2 + android/res/values/themes-base.xml | 4 + .../BookmarkSubscriptionFragment.java | 143 ++++++++ .../BookmarkSubscriptionFragment.java | 37 +- 11 files changed, 426 insertions(+), 143 deletions(-) create mode 100644 android/res/drawable/annual_card_edge.xml create mode 100644 android/res/drawable/annual_card_edge_night.xml create mode 100644 android/res/drawable/monthly_card_edge.xml create mode 100644 android/res/drawable/monthly_card_edge_night.xml create mode 100644 android/src/com/mapswithme/maps/bookmarks/BookmarkSubscriptionFragment.java diff --git a/android/res/animator/lift_on_touch.xml b/android/res/animator/lift_on_touch.xml index f4b44ce1ac..49940dbb5c 100644 --- a/android/res/animator/lift_on_touch.xml +++ b/android/res/animator/lift_on_touch.xml @@ -7,7 +7,7 @@ diff --git a/android/res/drawable/annual_card_edge.xml b/android/res/drawable/annual_card_edge.xml new file mode 100644 index 0000000000..daabcbd92d --- /dev/null +++ b/android/res/drawable/annual_card_edge.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/android/res/drawable/annual_card_edge_night.xml b/android/res/drawable/annual_card_edge_night.xml new file mode 100644 index 0000000000..c904d44c36 --- /dev/null +++ b/android/res/drawable/annual_card_edge_night.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/android/res/drawable/monthly_card_edge.xml b/android/res/drawable/monthly_card_edge.xml new file mode 100644 index 0000000000..c2b0249be8 --- /dev/null +++ b/android/res/drawable/monthly_card_edge.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/android/res/drawable/monthly_card_edge_night.xml b/android/res/drawable/monthly_card_edge_night.xml new file mode 100644 index 0000000000..c2b0249be8 --- /dev/null +++ b/android/res/drawable/monthly_card_edge_night.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/android/res/layout/bookmark_subscription_fragment.xml b/android/res/layout/bookmark_subscription_fragment.xml index c5f3b9cff7..23031ace1e 100644 --- a/android/res/layout/bookmark_subscription_fragment.xml +++ b/android/res/layout/bookmark_subscription_fragment.xml @@ -23,6 +23,8 @@ android:orientation="vertical" android:background="?attr/bookmarkSubscriptionScreenBg" android:padding="@dimen/margin_base" + android:clipToPadding="false" + android:clipChildren="false" android:layout_width="match_parent" android:layout_height="wrap_content"> @@ -60,10 +62,14 @@ android:layout_marginTop="@dimen/margin_base" android:layout_width="match_parent" android:gravity="center" + android:clipToPadding="false" + android:clipChildren="false" android:layout_height="wrap_content"> @@ -98,10 +104,11 @@ @@ -18,89 +19,113 @@ android:layout_width="0dp" android:layout_height="wrap_content" app:cardBackgroundColor="@color/turquoise" - app:cardCornerRadius="@dimen/margin_quarter" + app:cardCornerRadius="@dimen/margin_half_plus_eight" android:layout_marginRight="@dimen/margin_half" android:layout_marginEnd="@dimen/margin_half"> - - - - - - - - + - + + + + + + + + + + + + - - + android:layout_alignBottom="@id/annual_price_card_payload" + android:layout_alignTop="@id/annual_price_card_payload" + android:layout_alignRight="@id/annual_price_card_payload" + android:layout_alignEnd="@id/annual_price_card_payload" + android:layout_alignStart="@id/annual_price_card_payload" + android:layout_alignLeft="@id/annual_price_card_payload"/> + + app:cardBackgroundColor="?attr/cardBackground" + app:cardCornerRadius="@dimen/margin_half_plus_eight" + android:layout_marginStart="@dimen/margin_quarter" + android:layout_marginLeft="@dimen/margin_quarter"> + - - + - - - + android:text="@string/montly_subscription_message" + tools:text="1 month unlimited guides" + tools:ignore="UnusedAttribute"/> + + + + + - + + diff --git a/android/res/values/attrs.xml b/android/res/values/attrs.xml index 368efc73cb..0bad695ba3 100644 --- a/android/res/values/attrs.xml +++ b/android/res/values/attrs.xml @@ -77,6 +77,8 @@ + + diff --git a/android/res/values/themes-base.xml b/android/res/values/themes-base.xml index 0571cc2809..f612b89834 100644 --- a/android/res/values/themes-base.xml +++ b/android/res/values/themes-base.xml @@ -147,6 +147,8 @@ @style/TextAppearance.Large @color/light_green @drawable/bookmark_subscription_screen_bg + @drawable/annual_card_edge + @drawable/monthly_card_edge @@ -297,5 +299,7 @@ @style/TextAppearance.Large @color/driving_options_bg_black @drawable/bookmark_subscription_screen_bg_night + @drawable/annual_card_edge_night + @drawable/monthly_card_edge_night diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarkSubscriptionFragment.java b/android/src/com/mapswithme/maps/bookmarks/BookmarkSubscriptionFragment.java new file mode 100644 index 0000000000..cde2d7a969 --- /dev/null +++ b/android/src/com/mapswithme/maps/bookmarks/BookmarkSubscriptionFragment.java @@ -0,0 +1,143 @@ +package com.mapswithme.maps.bookmarks; + +import android.content.Context; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v7.widget.CardView; +import android.text.Html; +import android.text.Spanned; +import android.text.method.LinkMovementMethod; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import com.mapswithme.maps.R; +import com.mapswithme.maps.base.BaseMwmFragment; + +public class BookmarkSubscriptionFragment extends BaseMwmFragment +{ + private static final int DEF_ELEVATION = 0; + + @SuppressWarnings("NullableProblems") + @NonNull + private View mContentView; + + @SuppressWarnings("NullableProblems") + @NonNull + private View mRootScreenProgress; + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) + { + View root = inflater.inflate(R.layout.bookmark_subscription_fragment, container, false); + mContentView = root.findViewById(R.id.content_view); + mRootScreenProgress = root.findViewById(R.id.root_screen_progress); + CardView annualPriceCard = root.findViewById(R.id.annual_price_card); + CardView monthlyPriceCard = root.findViewById(R.id.monthly_price_card); + View annualCardEdge = root.findViewById(R.id.annual_price_card_edge); + View monthlyCardEdge = root.findViewById(R.id.monthly_price_card_edge); + AnnualCardClickListener annualCardListener = new AnnualCardClickListener(monthlyPriceCard, + annualPriceCard, + annualCardEdge, + monthlyCardEdge); + annualPriceCard.setOnClickListener(annualCardListener); + MonthlyCardClickListener monthlyCardListener = new MonthlyCardClickListener(monthlyPriceCard, + annualPriceCard, + annualCardEdge, + monthlyCardEdge); + monthlyPriceCard.setOnClickListener(monthlyCardListener); + annualPriceCard.setCardElevation(getResources().getDimension(R.dimen.margin_base_plus_quarter)); + TextView restorePurchasesLink = root.findViewById(R.id.restore_purchase_btn); + + final Spanned html = makeRestorePurchaseHtml(requireContext()); + restorePurchasesLink.setText(html); + restorePurchasesLink.setMovementMethod(LinkMovementMethod.getInstance()); + return root; + } + + private void showContent() + { + mContentView.setVisibility(View.VISIBLE); + mRootScreenProgress.setVisibility(View.GONE); + } + + private static Spanned makeRestorePurchaseHtml(@NonNull Context context) + { + final String restorePurchaseLink = ""; + return Html.fromHtml(context.getString(R.string.restore_purchase_link, + restorePurchaseLink)); + } + + private class AnnualCardClickListener implements View.OnClickListener + { + @NonNull + private final CardView mMonthlyPriceCard; + + @NonNull + private final CardView mAnnualPriceCard; + + @NonNull + private final View mAnnualCardFrame; + + @NonNull + private final View mMonthlyCardFrame; + + public AnnualCardClickListener(@NonNull CardView monthlyPriceCard, + @NonNull CardView annualPriceCard, + @NonNull View annualCardFrame, + @NonNull View monthlyCardFrame) + { + mMonthlyPriceCard = monthlyPriceCard; + mAnnualPriceCard = annualPriceCard; + mAnnualCardFrame = annualCardFrame; + mMonthlyCardFrame = monthlyCardFrame; + } + + @Override + public void onClick(View v) + { + mMonthlyPriceCard.setCardElevation(DEF_ELEVATION); + mAnnualPriceCard.setCardElevation(getResources().getDimension(R.dimen.margin_base_plus_quarter)); + mAnnualCardFrame.setVisibility(View.VISIBLE); + mMonthlyCardFrame.setVisibility(View.VISIBLE); + } + } + + private class MonthlyCardClickListener implements View.OnClickListener + { + @NonNull + private final CardView mMonthlyPriceCard; + + @NonNull + private final CardView mAnnualPriceCard; + + @NonNull + private final View mAnnualCardFrame; + + @NonNull + private final View mMonthlyCardFrame; + + public MonthlyCardClickListener(@NonNull CardView monthlyPriceCard, + @NonNull CardView annualPriceCard, + @NonNull View annualCardFrame, + @NonNull View monthlyCardFrame) + { + mMonthlyPriceCard = monthlyPriceCard; + mAnnualPriceCard = annualPriceCard; + mAnnualCardFrame = annualCardFrame; + mMonthlyCardFrame = monthlyCardFrame; + } + + @Override + public void onClick(View v) + { + mMonthlyPriceCard.setCardElevation(getResources().getDimension(R.dimen.margin_base_plus_quarter)); + mAnnualPriceCard.setCardElevation(DEF_ELEVATION); + mAnnualCardFrame.setVisibility(View.GONE); + mMonthlyCardFrame.setVisibility(View.GONE); + } + } +} diff --git a/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionFragment.java b/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionFragment.java index db0b15f622..c096143730 100644 --- a/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionFragment.java +++ b/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionFragment.java @@ -18,6 +18,7 @@ import com.android.billingclient.api.SkuDetails; import com.mapswithme.maps.R; import com.mapswithme.maps.base.BaseMwmFragment; import com.mapswithme.maps.dialog.AlertDialogCallback; +import com.mapswithme.util.UiUtils; import com.mapswithme.util.Utils; import com.mapswithme.util.log.Logger; import com.mapswithme.util.log.LoggerFactory; @@ -57,11 +58,17 @@ public class BookmarkSubscriptionFragment extends BaseMwmFragment View root = inflater.inflate(R.layout.bookmark_subscription_fragment, container, false); CardView annualPriceCard = root.findViewById(R.id.annual_price_card); CardView monthlyPriceCard = root.findViewById(R.id.monthly_price_card); + View annualCardEdge = root.findViewById(R.id.annual_price_card_edge); + View monthlyCardEdge = root.findViewById(R.id.monthly_price_card_edge); AnnualCardClickListener annualCardListener = new AnnualCardClickListener(monthlyPriceCard, - annualPriceCard); + annualPriceCard, + annualCardEdge, + monthlyCardEdge); annualPriceCard.setOnClickListener(annualCardListener); MonthlyCardClickListener monthlyCardListener = new MonthlyCardClickListener(monthlyPriceCard, - annualPriceCard); + annualPriceCard, + annualCardEdge, + monthlyCardEdge); monthlyPriceCard.setOnClickListener(monthlyCardListener); annualPriceCard.setCardElevation(getResources().getDimension(R.dimen.margin_base_plus_quarter)); @@ -240,11 +247,21 @@ public class BookmarkSubscriptionFragment extends BaseMwmFragment @NonNull private final CardView mAnnualPriceCard; + @NonNull + private final View mAnnualCardFrame; + + @NonNull + private final View mMonthlyCardFrame; + AnnualCardClickListener(@NonNull CardView monthlyPriceCard, - @NonNull CardView annualPriceCard) + @NonNull CardView annualPriceCard, + @NonNull View annualCardFrame, + @NonNull View monthlyCardFrame) { mMonthlyPriceCard = monthlyPriceCard; mAnnualPriceCard = annualPriceCard; + mAnnualCardFrame = annualCardFrame; + mMonthlyCardFrame = monthlyCardFrame; } @Override @@ -252,6 +269,7 @@ public class BookmarkSubscriptionFragment extends BaseMwmFragment { mMonthlyPriceCard.setCardElevation(DEF_ELEVATION); mAnnualPriceCard.setCardElevation(getResources().getDimension(R.dimen.margin_base_plus_quarter)); + UiUtils.show(mAnnualCardFrame, mMonthlyCardFrame); } } @@ -263,11 +281,21 @@ public class BookmarkSubscriptionFragment extends BaseMwmFragment @NonNull private final CardView mAnnualPriceCard; + @NonNull + private final View mAnnualCardFrame; + + @NonNull + private final View mMonthlyCardFrame; + MonthlyCardClickListener(@NonNull CardView monthlyPriceCard, - @NonNull CardView annualPriceCard) + @NonNull CardView annualPriceCard, + @NonNull View annualCardFrame, + @NonNull View monthlyCardFrame) { mMonthlyPriceCard = monthlyPriceCard; mAnnualPriceCard = annualPriceCard; + mAnnualCardFrame = annualCardFrame; + mMonthlyCardFrame = monthlyCardFrame; } @Override @@ -275,6 +303,7 @@ public class BookmarkSubscriptionFragment extends BaseMwmFragment { mMonthlyPriceCard.setCardElevation(getResources().getDimension(R.dimen.margin_base_plus_quarter)); mAnnualPriceCard.setCardElevation(DEF_ELEVATION); + UiUtils.hide(mAnnualCardFrame, mMonthlyCardFrame); } }