Search in sources :

Example 6 with InAppPurchaseHelper

use of net.osmand.plus.inapp.InAppPurchaseHelper in project Osmand by osmandapp.

the class InAppPurchaseCard method setupManageButton.

private void setupManageButton(boolean visible) {
    View manageSubscription = view.findViewById(R.id.manage_subscription);
    manageSubscription.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
            if (purchaseHelper != null) {
                purchaseHelper.manageSubscription(activity, purchase.getSku());
            }
        }
    });
    setupSelectableBackground(manageSubscription);
    ImageView icon = manageSubscription.findViewById(android.R.id.icon);
    icon.setImageDrawable(getActiveIcon(R.drawable.ic_action_purchases));
    TextView title = manageSubscription.findViewById(android.R.id.title);
    title.setText(R.string.manage_subscription);
    AndroidUiHelper.updateVisibility(manageSubscription, visible);
}
Also used : InAppPurchaseHelper(net.osmand.plus.inapp.InAppPurchaseHelper) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 7 with InAppPurchaseHelper

use of net.osmand.plus.inapp.InAppPurchaseHelper in project Osmand by osmandapp.

the class OsmandInAppPurchaseActivity method purchaseFullVersion.

public static void purchaseFullVersion(@NonNull final Activity activity) {
    OsmandApplication app = (OsmandApplication) activity.getApplication();
    if (app != null && Version.isFreeVersion(app)) {
        if (app.isPlusVersionInApp()) {
            InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
            if (purchaseHelper != null) {
                app.logEvent("in_app_purchase_redirect");
                try {
                    purchaseHelper.purchaseFullVersion(activity);
                } catch (UnsupportedOperationException e) {
                    LOG.error("purchaseFullVersion is not supported", e);
                }
            }
        } else {
            app.logEvent("paid_version_redirect");
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Version.getUrlWithUtmRef(app, "net.osmand.plus")));
            AndroidUtils.startActivityIfSafe(activity, intent);
        }
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) InAppPurchaseHelper(net.osmand.plus.inapp.InAppPurchaseHelper) Intent(android.content.Intent)

Example 8 with InAppPurchaseHelper

use of net.osmand.plus.inapp.InAppPurchaseHelper in project Osmand by osmandapp.

the class PromoCodeBottomSheet method onRightBottomButtonClick.

@Override
protected void onRightBottomButtonClick() {
    OsmandApplication app = getMyApplication();
    if (app != null) {
        String promoCode = editText.getText().toString();
        app.getSettings().BACKUP_PROMOCODE.set(promoCode);
        InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
        if (purchaseHelper != null) {
            CallbackWithObject<Boolean> listener = result -> {
                app.runInUIThread(() -> app.getBackupHelper().prepareBackup());
                return true;
            };
            purchaseHelper.checkPromoAsync(listener);
        }
    }
    dismiss();
}
Also used : Context(android.content.Context) AndroidUtils(net.osmand.plus.utils.AndroidUtils) FragmentManager(androidx.fragment.app.FragmentManager) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) R(net.osmand.plus.R) ViewGroup(android.view.ViewGroup) OsmandApplication(net.osmand.plus.OsmandApplication) UiUtilities(net.osmand.plus.utils.UiUtilities) CallbackWithObject(net.osmand.CallbackWithObject) SimpleBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) InAppPurchaseHelper(net.osmand.plus.inapp.InAppPurchaseHelper) View(android.view.View) MenuBottomSheetDialogFragment(net.osmand.plus.base.MenuBottomSheetDialogFragment) EditText(android.widget.EditText) OsmandApplication(net.osmand.plus.OsmandApplication) InAppPurchaseHelper(net.osmand.plus.inapp.InAppPurchaseHelper)

Example 9 with InAppPurchaseHelper

use of net.osmand.plus.inapp.InAppPurchaseHelper in project Osmand by osmandapp.

the class DiscountHelper method validateUrl.

public static boolean validateUrl(OsmandApplication app, String url) {
    if (url.startsWith(INAPP_PREFIX) && url.length() > INAPP_PREFIX.length()) {
        String inAppSku = url.substring(INAPP_PREFIX.length());
        InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
        return purchaseHelper == null || !purchaseHelper.isPurchased(inAppSku);
    }
    return true;
}
Also used : InAppPurchaseHelper(net.osmand.plus.inapp.InAppPurchaseHelper)

Aggregations

InAppPurchaseHelper (net.osmand.plus.inapp.InAppPurchaseHelper)9 OsmandApplication (net.osmand.plus.OsmandApplication)5 Intent (android.content.Intent)2 View (android.view.View)2 OsmandSettings (net.osmand.plus.settings.backend.OsmandSettings)2 JSONException (org.json.JSONException)2 SuppressLint (android.annotation.SuppressLint)1 Context (android.content.Context)1 Bundle (android.os.Bundle)1 ViewGroup (android.view.ViewGroup)1 EditText (android.widget.EditText)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 FragmentManager (androidx.fragment.app.FragmentManager)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 WeakReference (java.lang.ref.WeakReference)1 SimpleDateFormat (java.text.SimpleDateFormat)1