use of net.osmand.plus.inapp.InAppPurchases in project Osmand by osmandapp.
the class DiscountHelper method openUrl.
public static void openUrl(final MapActivity mapActivity, String url) {
if (url.startsWith(INAPP_PREFIX)) {
OsmandApplication app = mapActivity.getMyApplication();
InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
if (purchaseHelper != null) {
InAppPurchase fullVersion = purchaseHelper.getFullVersion();
if (fullVersion != null && url.contains(fullVersion.getSku())) {
app.logEvent("in_app_purchase_redirect");
try {
purchaseHelper.purchaseFullVersion(mapActivity);
} catch (UnsupportedOperationException e) {
LOG.error("purchaseFullVersion is not supported", e);
}
} else {
InAppPurchases purchases = purchaseHelper.getInAppPurchases();
for (InAppPurchase p : purchaseHelper.getSubscriptions().getAllSubscriptions()) {
if (url.contains(p.getSku())) {
if (purchases.isMapsSubscription(p)) {
MapsPlusPlanFragment.showInstance(mapActivity, p.getSku());
} else if (purchases.isOsmAndProSubscription(p)) {
OsmAndProPlanFragment.showInstance(mapActivity, p.getSku());
} else {
ChoosePlanFragment.showDefaultInstance(mapActivity);
}
break;
}
}
}
}
} else if (url.startsWith(SEARCH_QUERY_PREFIX)) {
String query = url.substring(SEARCH_QUERY_PREFIX.length());
if (!query.isEmpty()) {
mapActivity.showQuickSearch(query);
}
} else if (url.startsWith(SHOW_POI_PREFIX)) {
String names = url.substring(SHOW_POI_PREFIX.length());
if (!names.isEmpty()) {
OsmandApplication app = mapActivity.getMyApplication();
MapPoiTypes poiTypes = app.getPoiTypes();
Map<PoiCategory, LinkedHashSet<String>> acceptedTypes = new LinkedHashMap<>();
for (String name : names.split(",")) {
AbstractPoiType abstractType = poiTypes.getAnyPoiTypeByKey(name);
if (abstractType instanceof PoiCategory) {
acceptedTypes.put((PoiCategory) abstractType, null);
} else if (abstractType instanceof PoiType) {
PoiType type = (PoiType) abstractType;
PoiCategory category = type.getCategory();
LinkedHashSet<String> set = acceptedTypes.get(category);
if (set == null) {
set = new LinkedHashSet<>();
acceptedTypes.put(category, set);
}
set.add(type.getKeyName());
}
}
if (!acceptedTypes.isEmpty()) {
PoiUIFilter filter = new PoiUIFilter("", null, acceptedTypes, app);
filter.setName(filter.getTypesName());
showPoiFilter(mapActivity, filter);
}
}
} else if (url.equals(OPEN_ACTIVITY)) {
if (mData != null && mData.activityJson != null) {
openActivity(mapActivity, mData.activityJson);
}
} else if (url.startsWith(SHOW_CHOOSE_PLAN_PREFIX)) {
String planType = url.substring(SHOW_CHOOSE_PLAN_PREFIX.length()).trim();
showDialogForPlanType(mapActivity, planType);
} else {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
AndroidUtils.startActivityIfSafe(mapActivity, intent);
}
}
use of net.osmand.plus.inapp.InAppPurchases in project Osmand by osmandapp.
the class OsmAndProPlanFragment method getVisibleSubscriptions.
public static List<InAppSubscription> getVisibleSubscriptions(OsmandApplication app, InAppPurchaseHelper purchaseHelper) {
InAppPurchases purchases = app.getInAppPurchaseHelper().getInAppPurchases();
List<InAppSubscription> subscriptions = new ArrayList<>();
List<InAppSubscription> visibleSubscriptions = purchaseHelper.getSubscriptions().getVisibleSubscriptions();
for (InAppSubscription subscription : visibleSubscriptions) {
if (purchases.isOsmAndProSubscription(subscription)) {
subscriptions.add(subscription);
}
}
return subscriptions;
}
use of net.osmand.plus.inapp.InAppPurchases in project Osmand by osmandapp.
the class MapsPlusPlanFragment method getVisibleSubscriptions.
protected static List<InAppSubscription> getVisibleSubscriptions(OsmandApplication app, InAppPurchaseHelper purchaseHelper) {
InAppPurchases purchases = app.getInAppPurchaseHelper().getInAppPurchases();
List<InAppSubscription> subscriptions = new ArrayList<>();
List<InAppSubscription> visibleSubscriptions = purchaseHelper.getSubscriptions().getVisibleSubscriptions();
for (InAppSubscription subscription : visibleSubscriptions) {
if (purchases.isMapsSubscription(subscription)) {
subscriptions.add(subscription);
}
}
return subscriptions;
}
Aggregations