Added restore purchases button to choose plan screen

This commit is contained in:
max-klaus 2019-10-02 17:33:40 +03:00
parent cf57826741
commit ffef87f313
3 changed files with 52 additions and 1 deletions

View file

@ -80,6 +80,43 @@
android:layout_height="wrap_content"
android:orientation="vertical"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/card_padding"
android:layout_marginRight="@dimen/card_padding"
android:layout_marginTop="4dp"
android:background="?attr/wikivoyage_travel_card_bg">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/button_restore"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackgroundBorderless"
android:gravity="center"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:minHeight="@dimen/dialog_button_height"
android:paddingBottom="@dimen/list_header_padding"
android:paddingLeft="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding"
android:paddingTop="@dimen/list_header_padding"
android:text="@string/restore_purchases"
android:textColor="?attr/wikivoyage_active_color"
android:textSize="@dimen/text_button_text_size"
osmand:typeface="@string/font_roboto_regular"/>
<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center_vertical|right"
android:layout_marginRight="4dp"
android:layout_marginEnd="4dp"
android:indeterminate="true"
android:visibility="gone" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -197,6 +197,12 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment
dismiss();
}
});
view.findViewById(R.id.button_restore).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
purchaseHelper.requestInventory();
}
});
ViewGroup infoContainer = (ViewGroup) view.findViewById(R.id.info_container);
TextViewEx infoDescription = (TextViewEx) view.findViewById(R.id.info_description);
@ -329,9 +335,11 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment
@SuppressLint("CutPasteId")
private void setupOsmLiveCardButtons(boolean progress) {
final Context ctx = getContext();
if (ctx == null) {
View view = getView();
if (ctx == null || view == null) {
return;
}
view.findViewById(R.id.button_restore).setEnabled(!progress);
if (progress) {
if (osmLiveCardButtonsContainer != null) {
osmLiveCardButtonsContainer.setVisibility(View.GONE);
@ -639,6 +647,10 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment
@Override
public void onGetItems() {
OsmandApplication app = getMyApplication();
if (app != null && InAppPurchaseHelper.isSubscribedToLiveUpdates(app)) {
dismiss();
}
}
@Override

View file

@ -196,6 +196,8 @@ public class InAppPurchaseHelper {
private void exec(final @NonNull InAppPurchaseTaskType taskType, final @NonNull InAppRunnable runnable) {
if (isDeveloperVersion || !Version.isGooglePlayEnabled(ctx)) {
notifyDismissProgress(taskType);
stop(true);
return;
}