Add subscription card

This commit is contained in:
cepprice 2021-03-23 23:36:38 +05:00
parent edc741e84f
commit 3e4153a5cb
14 changed files with 703 additions and 303 deletions

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/osmand_live_active" />
<corners android:radius="26dp" />
</shape>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/osmand_live_cancelled" />
<corners android:radius="26dp" />
</shape>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="4dp" />
<solid android:color="@color/switch_button_active_dark" />
</shape>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="4dp" />
<solid android:color="@color/switch_button_active_light" />
</shape>

View file

@ -45,7 +45,7 @@
osmand:typeface="@string/font_roboto_medium" />
<FrameLayout
android:id="@+id/btn_save"
android:id="@+id/btn_save_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/content_padding_half"
@ -53,12 +53,12 @@
android:layout_gravity="center_vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/btn_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:gravity="center_vertical"
android:duplicateParentState="true"
android:background="@drawable/btn_border_active"
android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_half"

View file

@ -13,329 +13,347 @@
</com.google.android.material.appbar.AppBarLayout>
<View
<ScrollView
android:layout_width="match_parent"
android:layout_height="@dimen/list_content_padding"
android:background="?attr/activity_background_color" />
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/report_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/list_item_height"
android:paddingStart="@dimen/list_content_padding"
android:paddingLeft="@dimen/list_content_padding"
android:paddingEnd="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/report_icon"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/map_widget_height"
android:layout_marginRight="@dimen/map_widget_height"
app:srcCompat="@drawable/ic_action_file_report"
app:tint="?attr/active_color_basic" />
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/report_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/report"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_list_text_size"
app:typeface="@string/font_roboto_medium" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/list_content_padding"
android:background="?attr/activity_background_color" />
</LinearLayout>
<FrameLayout
android:id="@+id/subscriptions_card_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<include
android:id="@+id/dismiss_button"
layout="@layout/divider_half_item" />
<LinearLayout
android:id="@+id/report_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/list_item_height"
android:paddingStart="@dimen/list_content_padding"
android:paddingLeft="@dimen/list_content_padding"
android:paddingEnd="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding">
<LinearLayout
android:id="@+id/live_updates_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/list_item_height"
android:paddingStart="@dimen/list_content_padding"
android:paddingLeft="@dimen/list_content_padding"
android:paddingEnd="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/report_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/map_widget_height"
android:layout_marginRight="@dimen/map_widget_height"
app:srcCompat="@drawable/ic_action_file_report"
app:tint="?attr/active_color_basic" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/live_updates_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/map_widget_height"
android:layout_marginRight="@dimen/map_widget_height"
app:srcCompat="@drawable/ic_action_at_mail"
app:tint="?attr/active_color_basic" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/report_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/report"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_list_text_size"
app:typeface="@string/font_roboto_medium" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/live_updates_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/card_button_progress_size_small"
android:layout_marginRight="@dimen/card_button_progress_size_small"
android:layout_weight="1"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:text="@string/live_updates"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_list_text_size"
app:typeface="@string/font_roboto_medium" />
</LinearLayout>
</LinearLayout>
<include
android:id="@+id/dismiss_button"
layout="@layout/divider_half_item" />
<include
android:id="@+id/dismiss_button"
layout="@layout/divider_half_item" />
<LinearLayout
android:id="@+id/live_updates_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/list_item_height"
android:paddingStart="@dimen/list_content_padding"
android:paddingLeft="@dimen/list_content_padding"
android:paddingEnd="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding">
<LinearLayout
android:id="@+id/manage_subscription_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/list_item_height"
android:paddingStart="@dimen/list_content_padding"
android:paddingLeft="@dimen/list_content_padding"
android:paddingEnd="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/live_updates_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/map_widget_height"
android:layout_marginRight="@dimen/map_widget_height"
app:srcCompat="@drawable/ic_action_at_mail"
app:tint="?attr/active_color_basic" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/manage_subscription_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/map_widget_height"
android:layout_marginRight="@dimen/map_widget_height"
app:srcCompat="@drawable/ic_action_purchases"
app:tint="?attr/active_color_basic" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/live_updates_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/card_button_progress_size_small"
android:layout_marginRight="@dimen/card_button_progress_size_small"
android:layout_weight="1"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:text="@string/live_updates"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_list_text_size"
app:typeface="@string/font_roboto_medium" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/manage_subscription_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/card_button_progress_size_small"
android:layout_marginRight="@dimen/card_button_progress_size_small"
android:layout_weight="1"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:text="@string/manage_subscription"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_list_text_size"
app:typeface="@string/font_roboto_medium" />
</LinearLayout>
</LinearLayout>
<include layout="@layout/card_bottom_divider"/>
<include
android:id="@+id/dismiss_button"
layout="@layout/divider_half_item" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/list_content_padding"
android:background="?attr/activity_background_color" />
<LinearLayout
android:id="@+id/manage_subscription_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/list_item_height"
android:paddingStart="@dimen/list_content_padding"
android:paddingLeft="@dimen/list_content_padding"
android:paddingEnd="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding">
<LinearLayout
android:id="@+id/troubleshooting_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/list_item_height"
android:orientation="vertical"
android:paddingStart="@dimen/list_content_padding"
android:paddingLeft="@dimen/list_content_padding"
android:paddingTop="14dp"
android:paddingEnd="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding"
android:paddingBottom="6dp">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/manage_subscription_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/map_widget_height"
android:layout_marginRight="@dimen/map_widget_height"
app:srcCompat="@drawable/ic_action_purchases"
app:tint="?attr/active_color_basic" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/troubleshooting_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/map_widget_height"
android:layout_marginRight="@dimen/map_widget_height"
android:paddingBottom="@dimen/dialog_content_bottom_margin"
app:srcCompat="@drawable/ic_action_help"
app:tint="?attr/profile_icon_color_green" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/manage_subscription_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/card_button_progress_size_small"
android:layout_marginRight="@dimen/card_button_progress_size_small"
android:layout_weight="1"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:text="@string/manage_subscription"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_list_text_size"
app:typeface="@string/font_roboto_medium" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/troubleshooting_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/card_button_progress_size_small"
android:layout_marginRight="@dimen/card_button_progress_size_small"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:text="@string/troubleshooting"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
app:typeface="@string/font_roboto_medium" />
</LinearLayout>
<include layout="@layout/card_bottom_divider"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/troubleshooting_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/card_button_progress_size_small"
android:layout_marginRight="@dimen/card_button_progress_size_small"
android:letterSpacing="@dimen/description_letter_spacing"
android:text="@string/troubleshooting_description"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
app:typeface="@string/font_roboto_regular" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/list_content_padding"
android:background="?attr/activity_background_color" />
</LinearLayout>
<LinearLayout
android:id="@+id/troubleshooting_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/list_item_height"
android:orientation="vertical"
android:paddingStart="@dimen/list_content_padding"
android:paddingLeft="@dimen/list_content_padding"
android:paddingTop="14dp"
android:paddingEnd="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding"
android:paddingBottom="6dp">
<LinearLayout
android:id="@+id/restore_purchases"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/list_item_height"
android:paddingStart="@dimen/list_content_padding"
android:paddingLeft="@dimen/list_content_padding"
android:paddingEnd="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/troubleshooting_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/map_widget_height"
android:layout_marginRight="@dimen/map_widget_height"
android:paddingBottom="@dimen/dialog_content_bottom_margin"
app:srcCompat="@drawable/ic_action_help"
app:tint="?attr/profile_icon_color_green" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/map_widget_height"
android:layout_marginRight="@dimen/map_widget_height"
app:srcCompat="@drawable/ic_action_reset_to_default_dark"
app:tint="?attr/active_color_basic" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/troubleshooting_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/card_button_progress_size_small"
android:layout_marginRight="@dimen/card_button_progress_size_small"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:text="@string/troubleshooting"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
app:typeface="@string/font_roboto_medium" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/restore_purchases"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_list_text_size"
app:typeface="@string/font_roboto_medium" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/troubleshooting_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/card_button_progress_size_small"
android:layout_marginRight="@dimen/card_button_progress_size_small"
android:letterSpacing="@dimen/description_letter_spacing"
android:text="@string/troubleshooting_description"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
app:typeface="@string/font_roboto_regular" />
</LinearLayout>
</LinearLayout>
<include
android:id="@+id/dismiss_button"
layout="@layout/divider_half_item" />
<LinearLayout
android:id="@+id/restore_purchases"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/list_item_height"
android:paddingStart="@dimen/list_content_padding"
android:paddingLeft="@dimen/list_content_padding"
android:paddingEnd="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding">
<LinearLayout
android:id="@+id/new_device_account_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/list_item_height"
android:paddingStart="@dimen/list_content_padding"
android:paddingLeft="@dimen/list_content_padding"
android:paddingEnd="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/map_widget_height"
android:layout_marginRight="@dimen/map_widget_height"
app:srcCompat="@drawable/ic_action_reset_to_default_dark"
app:tint="?attr/active_color_basic" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/icon_new_device_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/map_widget_height"
android:layout_marginRight="@dimen/map_widget_height"
app:srcCompat="@drawable/ic_action_help_online"
app:tint="?attr/active_color_basic" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/restore_purchases"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_list_text_size"
app:typeface="@string/font_roboto_medium" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/new_device_account_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/new_device_account"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_list_text_size"
app:typeface="@string/font_roboto_medium" />
</LinearLayout>
</LinearLayout>
<include
android:id="@+id/dismiss_button"
layout="@layout/divider_half_item" />
<include
android:id="@+id/dismiss_button"
layout="@layout/divider" />
<LinearLayout
android:id="@+id/new_device_account_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/list_item_height"
android:paddingStart="@dimen/list_content_padding"
android:paddingLeft="@dimen/list_content_padding"
android:paddingEnd="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding">
<LinearLayout
android:id="@+id/support_link_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/list_item_height"
android:paddingStart="@dimen/list_content_padding"
android:paddingLeft="@dimen/list_content_padding"
android:paddingEnd="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/icon_new_device_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/map_widget_height"
android:layout_marginRight="@dimen/map_widget_height"
app:srcCompat="@drawable/ic_action_help_online"
app:tint="?attr/active_color_basic" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/support_link_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/map_widget_height"
android:layout_marginRight="@dimen/map_widget_height"
app:srcCompat="@drawable/ic_action_at_mail"
app:tint="?attr/active_color_basic" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/new_device_account_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/new_device_account"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_list_text_size"
app:typeface="@string/font_roboto_medium" />
<TextView
android:id="@+id/support_link_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/card_button_progress_size_small"
android:layout_marginRight="@dimen/card_button_progress_size_small"
android:paddingTop="@dimen/contex_menu_top_shadow_height"
android:layout_weight="1"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:text="@string/contact_support_description"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size" />
</LinearLayout>
</LinearLayout>
<include
android:id="@+id/dismiss_button"
layout="@layout/divider" />
<LinearLayout
android:id="@+id/contact_support_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:paddingStart="@dimen/action_bar_image_side_margin"
android:paddingLeft="@dimen/action_bar_image_side_margin"
android:paddingTop="@dimen/card_padding"
android:paddingEnd="@dimen/action_bar_image_side_margin"
android:paddingRight="@dimen/action_bar_image_side_margin"
android:paddingBottom="@dimen/card_padding"
android:clickable="true"
android:focusable="true">
<LinearLayout
android:id="@+id/support_link_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/list_item_height"
android:paddingStart="@dimen/list_content_padding"
android:paddingLeft="@dimen/list_content_padding"
android:paddingEnd="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/contact_support_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/contact_support"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_list_text_size"
app:typeface="@string/font_roboto_medium" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/support_link_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/map_widget_height"
android:layout_marginRight="@dimen/map_widget_height"
app:srcCompat="@drawable/ic_action_at_mail"
app:tint="?attr/active_color_basic" />
</LinearLayout>
<TextView
android:id="@+id/support_link_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/card_button_progress_size_small"
android:layout_marginRight="@dimen/card_button_progress_size_small"
android:paddingTop="@dimen/contex_menu_top_shadow_height"
android:layout_weight="1"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:text="@string/contact_support_description"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size" />
<include layout="@layout/card_bottom_divider"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/activity_background_color" />
<LinearLayout
android:id="@+id/contact_support_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:paddingStart="@dimen/action_bar_image_side_margin"
android:paddingLeft="@dimen/action_bar_image_side_margin"
android:paddingTop="@dimen/card_padding"
android:paddingEnd="@dimen/action_bar_image_side_margin"
android:paddingRight="@dimen/action_bar_image_side_margin"
android:paddingBottom="@dimen/card_padding"
android:clickable="true"
android:focusable="true">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/contact_support_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/contact_support"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_list_text_size"
app:typeface="@string/font_roboto_medium" />
</LinearLayout>
<include layout="@layout/card_bottom_divider"/>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/card_row_min_height"
android:background="?attr/activity_background_color" />
</LinearLayout>
</ScrollView>
</LinearLayout>

View file

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@android:drawable/list_selector_background"
android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:paddingBottom="@dimen/title_padding">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/osmand_live_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/content_padding"
android:layout_marginEnd="@dimen/map_widget_height"
android:layout_marginRight="@dimen/map_widget_height"
app:srcCompat="@drawable/ic_action_subscription_osmand_live" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/content_padding_small"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/content_padding_half"
android:text="@string/osmand_live"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/subscription_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular"
tools:text="@string/annual_subscription"
tools:visibility="visible"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/next_billing_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular"
tools:text="@string/next_billing_date"
tools:visibility="visible"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/content_padding_small"
android:layout_gravity="center_vertical"
android:paddingStart="@dimen/content_padding_small"
android:paddingLeft="@dimen/content_padding_small"
android:paddingTop="@dimen/content_padding_small_half"
android:paddingRight="@dimen/content_padding_small"
android:paddingEnd="@dimen/content_padding_small"
android:paddingBottom="@dimen/content_padding_small_half"
android:textColor="?attr/app_bar_primary_item_color"
osmand:typeface="@string/font_roboto_medium"
tools:background="@drawable/bg_osmand_live_active"
tools:text="@string/osm_live_active" />
<FrameLayout
android:id="@+id/renewContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/content_padding_small"
android:visibility="gone"
tools:visibility="visible">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/renew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_half"
android:paddingRight="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:paddingBottom="@dimen/content_padding_half"
android:text="@string/renew_subscription"
android:textColor="?attr/colorPrimary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:background="@drawable/btn_solid_border_light"/>
</FrameLayout>
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />

View file

@ -75,6 +75,8 @@
<color name="icon_color_osmand_dark">#d28521</color>
<color name="icon_color_active_light">#237bff</color>
<color name="icon_color_active_dark">#d28521</color>
<color name="osmand_live_active">#14CC70</color>
<color name="osmand_live_cancelled">#EE5622</color>
<color name="on_map_icon_color">#505050</color>

View file

@ -12,6 +12,16 @@
-->
<string name="expired">Expired</string>
<string name="on_hold">On hold</string>
<string name="in_grace_period">In grace period</string>
<string name="renew_subscription">Renew subscription</string>
<string name="osmand_live_cancelled">Cancelled</string>
<string name="next_billing_date">Next billing date: %1$s</string>
<string name="three_months_subscription">Three months subscription</string>
<string name="monthly_subscription">Monthly subscription</string>
<string name="annual_subscription">Annual subscription</string>
<string name="osmand_live">OsmAnd Live</string>
<string name="troubleshooting_description">Please follow this link if you any issues with purchases.</string>
<string name="troubleshooting">Troubleshooting</string>
<string name="contact_support">Contact support</string>

View file

@ -8,8 +8,10 @@ import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import net.osmand.AndroidUtils;
import net.osmand.Period;
@ -580,24 +582,40 @@ public abstract class InAppPurchases {
private InAppSubscriptionIntroductoryInfo introductoryInfo;
public enum SubscriptionState {
UNDEFINED("undefined"),
ACTIVE("active"),
CANCELLED("cancelled"),
IN_GRACE_PERIOD("in_grace_period"),
ON_HOLD("on_hold"),
PAUSED("paused"),
EXPIRED("expired");
UNDEFINED("undefined", 0, 0),
ACTIVE("active", R.string.osm_live_active, R.drawable.bg_osmand_live_active),
CANCELLED("cancelled", R.string.osmand_live_cancelled, R.drawable.bg_osmand_live_cancelled),
IN_GRACE_PERIOD("in_grace_period", R.string.in_grace_period, R.drawable.bg_osmand_live_active),
ON_HOLD("on_hold", R.string.on_hold, R.drawable.bg_osmand_live_cancelled),
PAUSED("paused", R.string.shared_string_paused, R.drawable.bg_osmand_live_cancelled),
EXPIRED("expired", R.string.expired, R.drawable.bg_osmand_live_cancelled);
private final String stateStr;
@StringRes
private final int stringRes;
@DrawableRes
private final int backgroundRes;
SubscriptionState(@NonNull String stateStr) {
SubscriptionState(@NonNull String stateStr, @StringRes int stringRes, @DrawableRes int backgroundRes) {
this.stateStr = stateStr;
this.stringRes = stringRes;
this.backgroundRes = backgroundRes;
}
public String getStateStr() {
return stateStr;
}
@StringRes
public int getStringRes() {
return stringRes;
}
@DrawableRes
public int getBackgroundRes() {
return backgroundRes;
}
@NonNull
public static SubscriptionState getByStateStr(@NonNull String stateStr) {
for (SubscriptionState state : SubscriptionState.values()) {

View file

@ -38,11 +38,12 @@ import net.osmand.plus.activities.OsmandInAppPurchaseActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseListener;
import net.osmand.plus.liveupdates.LiveUpdatesFragmentNew;
import net.osmand.plus.liveupdates.OsmLiveActivity;
import net.osmand.plus.wikipedia.WikipediaDialogFragment;
public class PurchasesFragment extends BaseOsmAndFragment {
public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurchaseListener {
public static final String TAG = PurchasesFragment.class.getName();
public static final String KEY_IS_SUBSCRIBER = "action_is_new";
@ -50,6 +51,7 @@ public class PurchasesFragment extends BaseOsmAndFragment {
private static final String PLAY_STORE_SUBSCRIPTION_DEEPLINK_URL = "https://play.google.com/store/account/subscriptions?sku=%s&package=%s";
private InAppPurchaseHelper purchaseHelper;
private View mainView;
private SubscriptionsCard subscriptionsCard;
private Context context;
private OsmandApplication app;
private String url;
@ -83,9 +85,14 @@ public class PurchasesFragment extends BaseOsmAndFragment {
final boolean nightMode = !getMyApplication().getSettings().isLightContent();
LayoutInflater themedInflater = UiUtilities.getInflater(context, nightMode);
if (!isSubscriber) {
if (isSubscriber) {
mainView = themedInflater.inflate(R.layout.purchases_layout, container, false);
setSubscriptionClick(mapActivity);
if (mapActivity != null && purchaseHelper != null) {
ViewGroup subscriptionsCardContainer = mainView.findViewById(R.id.subscriptions_card_container);
subscriptionsCard = new SubscriptionsCard(mapActivity, purchaseHelper);
subscriptionsCardContainer.addView(subscriptionsCard.build(mapActivity));
}
} else {
mainView = themedInflater.inflate(R.layout.empty_purchases_layout, container, false);
LinearLayout osmandLive = mainView.findViewById(R.id.osmand_live);
@ -114,7 +121,7 @@ public class PurchasesFragment extends BaseOsmAndFragment {
purchasesRestore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (purchaseHelper != null && !purchaseHelper.hasInventory()) {
if (purchaseHelper != null) {
purchaseHelper.requestInventory();
}
}
@ -255,4 +262,30 @@ public class PurchasesFragment extends BaseOsmAndFragment {
url = PLAY_STORE_SUBSCRIPTION_URL;
}
}
@Override
public void onError(InAppPurchaseHelper.InAppPurchaseTaskType taskType, String error) {
}
@Override
public void onGetItems() {
if (subscriptionsCard != null) {
subscriptionsCard.update();
}
}
@Override
public void onItemPurchased(String sku, boolean active) {
if (purchaseHelper != null) {
purchaseHelper.requestInventory();
}
}
@Override
public void showProgress(InAppPurchaseHelper.InAppPurchaseTaskType taskType) {
}
@Override
public void dismissProgress(InAppPurchaseHelper.InAppPurchaseTaskType taskType) {
}
}

View file

@ -0,0 +1,179 @@
package net.osmand.plus.settings.fragments;
import android.os.Build;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.Period;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.inapp.InAppPurchases.InAppSubscription;
import net.osmand.plus.inapp.InAppPurchases.InAppSubscription.SubscriptionState;
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.util.Algorithms;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.appcompat.view.ContextThemeWrapper;
import androidx.core.content.ContextCompat;
public class SubscriptionsCard extends BaseCard {
private final InAppPurchaseHelper purchaseHelper;
@Override
public int getCardLayoutId() {
return R.layout.subscriptions_card;
}
public SubscriptionsCard(@NonNull MapActivity mapActivity, @NonNull InAppPurchaseHelper purchaseHelper) {
super(mapActivity);
this.purchaseHelper = purchaseHelper;
}
@Override
protected void updateContent() {
if (mapActivity == null) {
return;
}
List<InAppSubscription> subscriptions = getActiveAndCancelledSubscriptions();
if (Algorithms.isEmpty(subscriptions)) {
return;
}
ContextThemeWrapper ctx = new ContextThemeWrapper(mapActivity, !nightMode ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
LayoutInflater inflater = LayoutInflater.from(ctx);
((ViewGroup) view).removeAllViews();
for (int i = 0; i < subscriptions.size(); i++) {
InAppSubscription subscription = subscriptions.get(i);
SubscriptionState state = subscription.getState();
boolean autoRenewed = SubscriptionState.ACTIVE.equals(state) || SubscriptionState.IN_GRACE_PERIOD.equals(state);
View card = inflater.inflate(R.layout.subscription_layout, null, false);
((ViewGroup) view).addView(card);
TextView subscriptionPeriod = card.findViewById(R.id.subscription_type);
String period = getSubscriptionPeriod(subscription.getSubscriptionPeriod());
if (!Algorithms.isEmpty(period)) {
subscriptionPeriod.setText(period);
AndroidUiHelper.updateVisibility(subscriptionPeriod, true);
}
if (autoRenewed) {
TextView nextBillingDate = card.findViewById(R.id.next_billing_date);
String date = getHumanDate(subscription.getPurchaseTime(), subscription.getSubscriptionPeriod());
if (!Algorithms.isEmpty(date)) {
nextBillingDate.setText(app.getString(R.string.next_billing_date, date));
AndroidUiHelper.updateVisibility(nextBillingDate, true);
}
}
TextView status = card.findViewById(R.id.status);
status.setText(app.getString(state.getStringRes()));
status.setBackgroundDrawable(ContextCompat.getDrawable(mapActivity, state.getBackgroundRes()));
if (!autoRenewed) {
View renewContainer = card.findViewById(R.id.renewContainer);
AndroidUiHelper.updateVisibility(renewContainer, true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(ctx, renewContainer, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
} else {
AndroidUtils.setBackground(ctx, renewContainer, nightMode, R.drawable.btn_unstroked_light, R.drawable.btn_unstroked_dark);
}
final String sku = subscription.getSku();
renewContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
subscribe(sku);
}
});
View renew = card.findViewById(R.id.renew);
AndroidUtils.setBackground(ctx, renew, nightMode,
R.drawable.btn_solid_border_light, R.drawable.btn_solid_border_dark);
}
int dividerLayout = i + 1 == subscriptions.size() ? R.layout.simple_divider_item : R.layout.divider_half_item;
View divider = inflater.inflate(dividerLayout, (ViewGroup) view, false);
((ViewGroup) view).addView(divider);
}
}
private String getHumanDate(long time, Period period) {
Date date = new Date(time);
int monthsCount;
if (period == null || period.getUnit() == null) {
return "";
} else if (period.getUnit().equals(Period.PeriodUnit.YEAR)) {
monthsCount = 12;
} else {
monthsCount = period.getNumberOfUnits();
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, monthsCount);
date = calendar.getTime();
SimpleDateFormat format = new SimpleDateFormat("MMM d, yyyy", app.getLocaleHelper().getPreferredLocale());
return format.format(date);
}
private void subscribe(String sku) {
if (app == null) {
return;
}
if (!app.getSettings().isInternetConnectionAvailable(true)) {
Toast.makeText(app, R.string.internet_not_available, Toast.LENGTH_LONG).show();
} else if (mapActivity != null && purchaseHelper != null) {
OsmandSettings settings = app.getSettings();
purchaseHelper.purchaseLiveUpdates(mapActivity, sku,
settings.BILLING_USER_EMAIL.get(),
settings.BILLING_USER_NAME.get(),
settings.BILLING_USER_COUNTRY_DOWNLOAD_NAME.get(),
settings.BILLING_HIDE_USER_NAME.get());
}
}
private String getSubscriptionPeriod(Period period) {
if (period == null || period.getUnit() == null) {
return "";
} else if (period.getUnit().equals(Period.PeriodUnit.YEAR)) {
return app.getString(R.string.annual_subscription);
} else if (period.getUnit().equals(Period.PeriodUnit.MONTH)) {
int unitsNumber = period.getNumberOfUnits();
if (unitsNumber == 1) {
return app.getString(R.string.monthly_subscription);
} else if (unitsNumber == 3) {
return app.getString(R.string.three_months_subscription);
}
}
return "";
}
private List<InAppSubscription> getActiveAndCancelledSubscriptions() {
List<InAppSubscription> subscriptions = new ArrayList<>();
for (InAppSubscription subscription : purchaseHelper.getLiveUpdates().getVisibleSubscriptions()) {
if (shouldShowSubscription(subscription)) {
subscriptions.add(subscription);
}
}
return subscriptions;
}
private boolean shouldShowSubscription(InAppSubscription s) {
return s.getState() != null && !SubscriptionState.UNDEFINED.equals(s.getState());
}
}

View file

@ -110,9 +110,8 @@ public class GpxEditDescriptionDialogFragment extends BaseOsmAndDialogFragment {
}
private void setupSaveButton(View view) {
View btnSave = view.findViewById(R.id.btn_save);
btnSave.setOnClickListener(new View.OnClickListener() {
View btnSaveContainer = view.findViewById(R.id.btn_save_container);
btnSaveContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Editable editable = editableHtml.getText();
@ -122,12 +121,16 @@ public class GpxEditDescriptionDialogFragment extends BaseOsmAndDialogFragment {
}
});
Context ctx = btnSave.getContext();
Context ctx = btnSaveContainer.getContext();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(ctx, btnSave, isNightMode(true), R.drawable.ripple_light, R.drawable.ripple_dark);
AndroidUtils.setBackground(ctx, btnSaveContainer, isNightMode(true), R.drawable.ripple_light, R.drawable.ripple_dark);
} else {
AndroidUtils.setBackground(ctx, btnSave, isNightMode(true), R.drawable.btn_unstroked_light, R.drawable.btn_unstroked_dark);
AndroidUtils.setBackground(ctx, btnSaveContainer, isNightMode(true), R.drawable.btn_unstroked_light, R.drawable.btn_unstroked_dark);
}
View btnSave = view.findViewById(R.id.btn_save);
int drawableRes = isNightMode(true) ? R.drawable.btn_solid_border_dark : R.drawable.btn_solid_border_light;
btnSave.setBackgroundDrawable(ContextCompat.getDrawable(ctx, drawableRes));
}
private void showDismissDialog() {