Fix purchases
This commit is contained in:
parent
c8a26f52fa
commit
fb03d8b959
8 changed files with 44 additions and 20 deletions
|
@ -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"
|
||||
|
|
|
@ -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">
|
||||
|
||||
<android.support.v7.widget.AppCompatImageView
|
||||
android:layout_width="54dp"
|
||||
|
@ -149,7 +149,7 @@
|
|||
android:paddingTop="4dp"
|
||||
android:textColor="@color/color_white"
|
||||
android:visibility="visible"
|
||||
tools:text="GET FOR E5"/>
|
||||
tools:text="GET FOR 5 EUR"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -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"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/osmLiveLayout"
|
||||
|
@ -219,7 +219,7 @@
|
|||
android:paddingRight="14dp"
|
||||
android:paddingTop="4dp"
|
||||
android:textColor="@color/color_white"
|
||||
tools:text="GET FOR 1,5E PER MONTH"/>
|
||||
tools:text="GET FOR 1,5 EUR PER MONTH"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -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<String, Object> 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) {
|
||||
|
|
|
@ -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() {
|
||||
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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue