From b6e5b5a01efa8dbc0eddf1763c8bf0d4d209945c Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Wed, 27 Jan 2016 10:28:22 +0300 Subject: [PATCH 1/3] Added free and full inapp for live updates --- .../net/osmand/plus/inapp/InAppHelper.java | 26 ++++++++++++------- .../plus/liveupdates/LiveUpdatesFragment.java | 1 - .../liveupdates/SubscriptionFragment.java | 3 ++- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/inapp/InAppHelper.java b/OsmAnd/src/net/osmand/plus/inapp/InAppHelper.java index 9237a22a1c..0b489fd85c 100644 --- a/OsmAnd/src/net/osmand/plus/inapp/InAppHelper.java +++ b/OsmAnd/src/net/osmand/plus/inapp/InAppHelper.java @@ -41,14 +41,9 @@ public class InAppHelper { private static boolean mSubscribedToLiveUpdates = false; private static String mLiveUpdatesPrice; - public static final String SKU_LIVE_UPDATES = "osm_live_subscription_1"; - - // Static test - //public static final String SKU_LIVE_UPDATES = "android.test.purchased"; - //public static final String SKU_LIVE_UPDATES = "android.test.canceled"; - //public static final String SKU_LIVE_UPDATES = "android.test.refunded"; - //public static final String SKU_LIVE_UPDATES = "android.test.item_unavailable"; - + private static final String SKU_LIVE_UPDATES_FULL = "osm_live_subscription_2"; + private static final String SKU_LIVE_UPDATES_FREE = "osm_free_live_subscription_2"; + private static String SKU_LIVE_UPDATES; // (arbitrary) request code for the purchase flow private static final int RC_REQUEST = 10001; @@ -80,9 +75,20 @@ public class InAppHelper { return mLiveUpdatesPrice; } + public static String getSkuLiveUpdates() { + return SKU_LIVE_UPDATES; + } + public InAppHelper(OsmandApplication ctx, InAppCallbacks callbacks) { this.ctx = ctx; this.callbacks = callbacks; + if (SKU_LIVE_UPDATES == null) { + if (Version.isFreeVersion(ctx)) { + SKU_LIVE_UPDATES = SKU_LIVE_UPDATES_FREE; + } else { + SKU_LIVE_UPDATES = SKU_LIVE_UPDATES_FULL; + } + } } public void start(final boolean stopAfterResult) { @@ -110,7 +116,7 @@ public class InAppHelper { mHelper = new IabHelper(ctx, base64EncodedPublicKey); // enable debug logging (for a production application, you should set this to false). - mHelper.enableDebugLogging(true); + mHelper.enableDebugLogging(false); // Start setup. This is asynchronous and the specified listener // will be called once setup completes. @@ -401,7 +407,7 @@ public class InAppHelper { } private String sendRequest(String url, Map parameters, String userOperation) { - Log.d(TAG, "Sending request " + url); //$NON-NLS-1$ + Log.d(TAG, "Sending request " + url); HttpURLConnection connection = null; try { connection = NetworkUtils.getHttpURLConnection(url); diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java index 81f561ad28..eb9d47de7f 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java @@ -78,7 +78,6 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment { Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_live_updates, container, false); listView = (ExpandableListView) view.findViewById(android.R.id.list); -// View header = inflater.inflate(R.layout.live_updates_header, listView, false); View bottomShadowView = inflater.inflate(R.layout.shadow_bottom, listView, false); listView.addFooterView(bottomShadowView); diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/SubscriptionFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/SubscriptionFragment.java index 03201a876e..fe895a1e4a 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/SubscriptionFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/SubscriptionFragment.java @@ -172,7 +172,7 @@ public class SubscriptionFragment extends BaseOsmAndDialogFragment implements In @Override public void onItemPurchased(String sku) { - if (InAppHelper.SKU_LIVE_UPDATES.equals(sku)) { + if (InAppHelper.getSkuLiveUpdates().equals(sku)) { Fragment parentFragment = getParentFragment(); if (parentFragment instanceof LiveUpdatesFragment) { ((LiveUpdatesFragment) parentFragment).updateSubscriptionBanner(); @@ -190,6 +190,7 @@ public class SubscriptionFragment extends BaseOsmAndDialogFragment implements In dlg = new ProgressDialog(getActivity()); dlg.setTitle(""); dlg.setMessage(getString(R.string.wait_current_task_finished)); + dlg.setCancelable(false); dlg.show(); } From b56665b2b150523a90df65888d865a2259aea544 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Wed, 27 Jan 2016 10:56:39 +0300 Subject: [PATCH 2/3] Subscription UI fixes --- OsmAnd/res/drawable/bg_card_orange.xml | 14 ++++++++++++++ OsmAnd/res/drawable/btn_round_shade.xml | 13 +++++++++++++ OsmAnd/res/layout/live_updates_header.xml | 6 +++--- OsmAnd/res/layout/subscription_fragment.xml | 6 ++++++ 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 OsmAnd/res/drawable/bg_card_orange.xml create mode 100644 OsmAnd/res/drawable/btn_round_shade.xml diff --git a/OsmAnd/res/drawable/bg_card_orange.xml b/OsmAnd/res/drawable/bg_card_orange.xml new file mode 100644 index 0000000000..1eac7a0dfe --- /dev/null +++ b/OsmAnd/res/drawable/bg_card_orange.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/btn_round_shade.xml b/OsmAnd/res/drawable/btn_round_shade.xml new file mode 100644 index 0000000000..24d01d3f77 --- /dev/null +++ b/OsmAnd/res/drawable/btn_round_shade.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/live_updates_header.xml b/OsmAnd/res/layout/live_updates_header.xml index 673ef3052a..89423ff74c 100644 --- a/OsmAnd/res/layout/live_updates_header.xml +++ b/OsmAnd/res/layout/live_updates_header.xml @@ -13,7 +13,7 @@ android:id="@+id/subscription_banner" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@color/osmand_orange" + android:background="@drawable/bg_card_orange" android:orientation="vertical" android:paddingBottom="8dp" android:paddingLeft="24dp" @@ -60,7 +60,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/color_white" - android:background="@drawable/btn_round_transparent" + android:background="@drawable/btn_round_shade" android:text="@string/shared_string_read_more"/>