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);
}
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);
}
}
}
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();
}
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;
}
Aggregations