diff --git a/OsmAnd/build.gradle b/OsmAnd/build.gradle index 0bfb24f141..32ac68e7e3 100644 --- a/OsmAnd/build.gradle +++ b/OsmAnd/build.gradle @@ -126,6 +126,11 @@ android { dimension "version" applicationId "net.osmand" } + freeres { + dimension "version" + applicationId "net.osmand" + resConfig "en" + } full { dimension "version" applicationId "net.osmand.plus" diff --git a/OsmAnd/res/layout/free_version_banner.xml b/OsmAnd/res/layout/free_version_banner.xml index 96f8b12100..61faf6a321 100644 --- a/OsmAnd/res/layout/free_version_banner.xml +++ b/OsmAnd/res/layout/free_version_banner.xml @@ -99,7 +99,7 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/list_content_padding" android:orientation="horizontal" - android:visibility="gone"> + android:visibility="visible"> + tools:text="GET FOR 5 EUR"/> @@ -162,7 +162,7 @@ android:layout_marginLeft="54dp" android:layout_marginTop="@dimen/list_content_padding" android:background="@color/dashboard_divider_dark" - android:visibility="gone"/> + android:visibility="visible"/> + tools:text="GET FOR 1,5 EUR PER MONTH"/> diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index e7201458a6..5a51aae975 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -74,7 +74,6 @@ public class OsmandApplication extends MultiDexApplication { public static final String EXCEPTION_PATH = "exception.log"; //$NON-NLS-1$ private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(OsmandApplication.class); - public static final String SHOW_PLUS_VERSION_PARAM = "show_plus_version"; public static final String SHOW_PLUS_VERSION_INAPP_PARAM = "show_plus_version_inapp"; final AppInitializer appInitializer = new AppInitializer(this); @@ -841,7 +840,7 @@ public class OsmandApplication extends MultiDexApplication { Object inst = mm.invoke(null); Method log = cl.getMethod("setDefaults", Map.class); Map defaults = new HashMap<>(); - defaults.put(SHOW_PLUS_VERSION_PARAM, Boolean.FALSE); + defaults.put(SHOW_PLUS_VERSION_INAPP_PARAM, Boolean.TRUE); log.invoke(inst, defaults); } } catch (Exception e) { diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index dd6d8dacae..3d1dece0ed 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -1,10 +1,12 @@ package net.osmand.plus.download; import android.Manifest; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; +import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.os.StatFs; @@ -77,6 +79,8 @@ import java.util.List; import java.util.Locale; import java.util.Set; +import static net.osmand.plus.OsmandApplication.SHOW_PLUS_VERSION_INAPP_PARAM; + public class DownloadActivity extends AbstractDownloadActivity implements DownloadEvents, OnRequestPermissionsResultCallback, InAppListener { private static final Log LOG = PlatformUtil.getLog(DownloadActivity.class); @@ -231,13 +235,29 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo } public void purchaseFullVersion() { - if (inAppHelper != null) { - inAppHelper.purchaseFullVersion(this); + OsmandApplication app = getMyApplication(); + if (Version.isFreeVersion(app)) { + if (app.getRemoteBoolean(SHOW_PLUS_VERSION_INAPP_PARAM, true)) { + if (inAppHelper != null) { + app.logEvent(this, "in_app_purchase_redirect"); + inAppHelper.purchaseFullVersion(this); + } + } else { + app.logEvent(this, "paid_version_redirect"); + Intent intent = new Intent(Intent.ACTION_VIEW, + Uri.parse(Version.marketPrefix(app) + "net.osmand.plus")); + try { + startActivity(intent); + } catch (ActivityNotFoundException e) { + LOG.error("ActivityNotFoundException", e); + } + } } } public void purchaseDepthContours() { if (inAppHelper != null) { + getMyApplication().logEvent(this, "depth_contours_purchase_redirect"); inAppHelper.purchaseDepthContours(this); } } @@ -533,8 +553,13 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo fullVersionButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - ctx.getMyApplication().logEvent(ctx, "click_buy_plus"); - ctx.inAppHelper.purchaseFullVersion(ctx); + OsmandApplication app = ctx.getMyApplication(); + if (app.getRemoteBoolean(SHOW_PLUS_VERSION_INAPP_PARAM, true)) { + app.logEvent(ctx, "in_app_purchase_redirect_from_banner"); + } else { + app.logEvent(ctx, "paid_version_redirect_from_banner"); + } + ctx.purchaseFullVersion(); DialogFragment f = (DialogFragment) ctx.getSupportFragmentManager() .findFragmentByTag(FreeVersionDialogFragment.TAG); if (f != null) { diff --git a/OsmAnd/src/net/osmand/plus/download/ui/FreeVersionDialogFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/FreeVersionDialogFragment.java index f69924daab..5cabbd16e7 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/FreeVersionDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/FreeVersionDialogFragment.java @@ -15,7 +15,6 @@ import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity.FreeVersionDialog; import static net.osmand.plus.OsmandApplication.SHOW_PLUS_VERSION_INAPP_PARAM; -import static net.osmand.plus.OsmandApplication.SHOW_PLUS_VERSION_PARAM; public class FreeVersionDialogFragment extends DialogFragment { public static final String TAG = "FreeVersionDialogFragment"; @@ -30,10 +29,6 @@ public class FreeVersionDialogFragment extends DialogFragment { AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.OsmandDarkTheme)); builder.setNegativeButton(R.string.later, null); View view = getActivity().getLayoutInflater().inflate(R.layout.free_version_banner, null); - - boolean hidePlus = !Version.isFreeVersion(app) || !app.getRemoteBoolean(SHOW_PLUS_VERSION_INAPP_PARAM, true); - view.findViewById(R.id.osmLiveLayoutTopDivider).setVisibility(hidePlus ? View.GONE : View.VISIBLE); - view.findViewById(R.id.fullVersionLayout).setVisibility(hidePlus ? View.GONE : View.VISIBLE); builder.setView(view); dialog = new DownloadActivity.FreeVersionDialog(view, getDownloadActivity(), true); diff --git a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java index 17a4491967..c8853a782d 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java @@ -331,11 +331,10 @@ public class ItemViewHolder { public void onClick(View v) { switch (clickAction) { case ASK_FOR_FULL_VERSION_PURCHASE: - context.getMyApplication().logEvent(context, "click_buy_plus_inapp"); + context.getMyApplication().logEvent(context, "in_app_purchase_show_from_wiki_context_menu"); context.purchaseFullVersion(); break; case ASK_FOR_DEPTH_CONTOURS_PURCHASE: - context.getMyApplication().logEvent(context, "click_buy_depth_contours_inapp"); context.purchaseDepthContours(); break; case ASK_FOR_SEAMARKS_PLUGIN: diff --git a/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java b/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java index 281de080d7..97de9cc1e8 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java @@ -213,6 +213,7 @@ public class DiscountHelper { mapActivity.execInAppTask(new InAppHelper.InAppRunnable() { @Override public void run(InAppHelper helper) { + mapActivity.getMyApplication().logEvent(mapActivity, "in_app_purchase_redirect"); helper.purchaseFullVersion(mapActivity); } }); diff --git a/OsmAnd/src/net/osmand/plus/notifications/OsmandNotification.java b/OsmAnd/src/net/osmand/plus/notifications/OsmandNotification.java index a9d8ccc7e2..eaf4c0a707 100644 --- a/OsmAnd/src/net/osmand/plus/notifications/OsmandNotification.java +++ b/OsmAnd/src/net/osmand/plus/notifications/OsmandNotification.java @@ -130,7 +130,7 @@ public abstract class OsmandNotification { Notification notification = notificationBuilder.build(); setupNotification(notification); if (top) { - notificationManager.cancel(getOsmandNotificationId()); + removeNotification(); notificationManager.notify(TOP_NOTIFICATION_SERVICE_ID, notification); Builder wearNotificationBuilder = buildNotification(true); @@ -144,10 +144,10 @@ public abstract class OsmandNotification { } return true; } else { - notificationManager.cancel(getOsmandNotificationId()); + removeNotification(); } } else { - notificationManager.cancel(getOsmandNotificationId()); + removeNotification(); } return false; }