Fixed inapp purchases. Added cancelled subscription screen.
This commit is contained in:
parent
215413b2b4
commit
2c3d2033e6
27 changed files with 622 additions and 131 deletions
12
OsmAnd/res/drawable/circle_dialog_bg_light.xml
Normal file
12
OsmAnd/res/drawable/circle_dialog_bg_light.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<inset>
|
||||||
|
<shape android:shape="oval">
|
||||||
|
<solid android:color="@color/dialog_bg_color_light"/>
|
||||||
|
</shape>
|
||||||
|
</inset>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
</layer-list>
|
12
OsmAnd/res/drawable/circle_dialog_bg_night.xml
Normal file
12
OsmAnd/res/drawable/circle_dialog_bg_night.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<inset>
|
||||||
|
<shape android:shape="oval">
|
||||||
|
<solid android:color="@color/dialog_bg_color_night"/>
|
||||||
|
</shape>
|
||||||
|
</inset>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
</layer-list>
|
124
OsmAnd/res/layout/osmlive_cancelled_dialog_fragment.xml
Normal file
124
OsmAnd/res/layout/osmlive_cancelled_dialog_fragment.xml
Normal file
|
@ -0,0 +1,124 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/dialog_transparent_bg_color"
|
||||||
|
android:clickable="true"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:fillViewport="true">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/button_close"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:padding="@dimen/list_content_padding">
|
||||||
|
|
||||||
|
<android.support.v7.widget.AppCompatImageView
|
||||||
|
android:id="@+id/button_close_img"
|
||||||
|
android:layout_width="@dimen/standard_icon_size"
|
||||||
|
android:layout_height="@dimen/standard_icon_size"
|
||||||
|
android:background="?attr/circle_dialog_bg"
|
||||||
|
android:src="@drawable/ic_action_remove_small"
|
||||||
|
android:tint="@color/icon_color"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginBottom="@dimen/title_padding"
|
||||||
|
android:layout_marginTop="@dimen/list_header_padding"
|
||||||
|
android:src="@drawable/img_help_osmand_live"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/list_content_padding_large"
|
||||||
|
android:layout_marginRight="@dimen/list_content_padding_large"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="@dimen/title_padding"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/purchase_cancelled_dialog_title"
|
||||||
|
android:textColor="?attr/dialog_title_color"
|
||||||
|
android:textSize="@dimen/dialog_header_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"/>
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/info_description"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/title_padding"
|
||||||
|
android:textColor="?attr/dialog_text_description_color"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
android:lineSpacingMultiplier="@dimen/text_button_line_spacing_multiplier"
|
||||||
|
osmand:typeface="@string/font_roboto_regular"
|
||||||
|
tools:text="@string/purchase_cancelled_dialog_descr"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/cards_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"/>
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/inapp_descr"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/list_content_padding_large"
|
||||||
|
android:layout_marginRight="@dimen/list_content_padding_large"
|
||||||
|
android:layout_marginTop="@dimen/list_header_padding"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/osm_live_payment_desc"
|
||||||
|
android:textColor="?attr/card_description_text_color"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_regular"/>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="@dimen/card_padding"
|
||||||
|
android:layout_marginTop="@dimen/card_padding">
|
||||||
|
|
||||||
|
<include layout="@layout/purchase_dialog_card_button"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -65,8 +65,12 @@
|
||||||
<attr name="primary_icon_color" format="color"/>
|
<attr name="primary_icon_color" format="color"/>
|
||||||
<attr name="light_icon_color" format="color"/>
|
<attr name="light_icon_color" format="color"/>
|
||||||
|
|
||||||
|
<attr name="circle_dialog_bg" format="reference"/>
|
||||||
|
<attr name="dialog_bg_color" format="reference"/>
|
||||||
|
<attr name="dialog_transparent_bg_color" format="reference"/>
|
||||||
<attr name="dialog_title_color" format="reference"/>
|
<attr name="dialog_title_color" format="reference"/>
|
||||||
<attr name="dialog_description_color" format="reference"/>
|
<attr name="dialog_description_color" format="reference"/>
|
||||||
|
<attr name="dialog_text_description_color" format="reference"/>
|
||||||
<attr name="card_description_text_color" format="reference"/>
|
<attr name="card_description_text_color" format="reference"/>
|
||||||
|
|
||||||
<attr name="wikivoyage_bg_color" format="reference"/>
|
<attr name="wikivoyage_bg_color" format="reference"/>
|
||||||
|
|
|
@ -3,6 +3,11 @@
|
||||||
|
|
||||||
<color name="feature_purchased_bg">#78cc5c</color>
|
<color name="feature_purchased_bg">#78cc5c</color>
|
||||||
|
|
||||||
|
<color name="dialog_bg_color_light">#f0f0f0</color>
|
||||||
|
<color name="dialog_bg_color_night">#17191a</color>
|
||||||
|
<color name="dialog_transparent_bg_color_light">#14f0f0f0</color>
|
||||||
|
<color name="dialog_transparent_bg_color_night">#1417191a</color>
|
||||||
|
|
||||||
<color name="dialog_title_color_light">#212121</color>
|
<color name="dialog_title_color_light">#212121</color>
|
||||||
<color name="dialog_title_color_dark">#cccccc</color>
|
<color name="dialog_title_color_dark">#cccccc</color>
|
||||||
<color name="dialog_description_color_light">#212121</color>
|
<color name="dialog_description_color_light">#212121</color>
|
||||||
|
@ -10,6 +15,7 @@
|
||||||
<color name="dialog_divider_light">#e6e6e6</color>
|
<color name="dialog_divider_light">#e6e6e6</color>
|
||||||
<color name="dialog_divider_dark">#2d3133</color>
|
<color name="dialog_divider_dark">#2d3133</color>
|
||||||
<color name="dialog_text_description_color">#727272</color>
|
<color name="dialog_text_description_color">#727272</color>
|
||||||
|
<color name="dialog_text_description_color_night">#808080</color>
|
||||||
<color name="card_description_text_color_light">#b3b3b3</color>
|
<color name="card_description_text_color_light">#b3b3b3</color>
|
||||||
<color name="card_description_text_color_dark">#4d4d4d</color>
|
<color name="card_description_text_color_dark">#4d4d4d</color>
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
<string name="purchase_cancelled_dialog_title">You have cancel OsmAnd Live subscription</string>
|
||||||
|
<string name="purchase_cancelled_dialog_descr">Renew subscription to continue use the all features:</string>
|
||||||
|
|
||||||
<string name="osmand_team">OsmAnd team</string>
|
<string name="osmand_team">OsmAnd team</string>
|
||||||
<string name="popular_destinations">Popular destinations</string>
|
<string name="popular_destinations">Popular destinations</string>
|
||||||
<string name="paid_app">Paid app</string>
|
<string name="paid_app">Paid app</string>
|
||||||
|
|
|
@ -179,6 +179,7 @@
|
||||||
<item name="android:actionMenuTextColor">@color/color_white</item>
|
<item name="android:actionMenuTextColor">@color/color_white</item>
|
||||||
<item name="actionOverflowButtonStyle">@style/OverflowMenuButton</item>
|
<item name="actionOverflowButtonStyle">@style/OverflowMenuButton</item>
|
||||||
|
|
||||||
|
<item name="circle_dialog_bg">@drawable/circle_dialog_bg_light</item>
|
||||||
<item name="dialog_inactive_text_color">@color/icon_color_light</item>
|
<item name="dialog_inactive_text_color">@color/icon_color_light</item>
|
||||||
<item name="secondary_icon_color">@color/icon_color_light</item>
|
<item name="secondary_icon_color">@color/icon_color_light</item>
|
||||||
<item name="primary_icon_color">@color/icon_color</item>
|
<item name="primary_icon_color">@color/icon_color</item>
|
||||||
|
@ -197,8 +198,11 @@
|
||||||
|
|
||||||
<item name="coordinate_input_edit_text_normal">@color/coordinate_input_edit_text_normal_light</item>
|
<item name="coordinate_input_edit_text_normal">@color/coordinate_input_edit_text_normal_light</item>
|
||||||
|
|
||||||
|
<item name="dialog_bg_color">@color/dialog_bg_color_light</item>
|
||||||
|
<item name="dialog_transparent_bg_color">@color/dialog_transparent_bg_color_light</item>
|
||||||
<item name="dialog_title_color">@color/dialog_title_color_light</item>
|
<item name="dialog_title_color">@color/dialog_title_color_light</item>
|
||||||
<item name="dialog_description_color">@color/dialog_description_color_light</item>
|
<item name="dialog_description_color">@color/dialog_description_color_light</item>
|
||||||
|
<item name="dialog_text_description_color">@color/dialog_text_description_color</item>
|
||||||
<item name="card_description_text_color">@color/card_description_text_color_light</item>
|
<item name="card_description_text_color">@color/card_description_text_color_light</item>
|
||||||
|
|
||||||
<item name="wikivoyage_bg_color">@color/wikivoyage_bg_light</item>
|
<item name="wikivoyage_bg_color">@color/wikivoyage_bg_light</item>
|
||||||
|
@ -398,8 +402,12 @@
|
||||||
|
|
||||||
<item name="coordinate_input_edit_text_normal">@color/coordinate_input_edit_text_normal_dark</item>
|
<item name="coordinate_input_edit_text_normal">@color/coordinate_input_edit_text_normal_dark</item>
|
||||||
|
|
||||||
|
<item name="circle_dialog_bg">@drawable/circle_dialog_bg_night</item>
|
||||||
|
<item name="dialog_bg_color">@color/dialog_bg_color_night</item>
|
||||||
|
<item name="dialog_transparent_bg_color">@color/dialog_transparent_bg_color_night</item>
|
||||||
<item name="dialog_title_color">@color/dialog_title_color_dark</item>
|
<item name="dialog_title_color">@color/dialog_title_color_dark</item>
|
||||||
<item name="dialog_description_color">@color/dialog_description_color_dark</item>
|
<item name="dialog_description_color">@color/dialog_description_color_dark</item>
|
||||||
|
<item name="dialog_text_description_color">@color/dialog_text_description_color_night</item>
|
||||||
<item name="card_description_text_color">@color/card_description_text_color_dark</item>
|
<item name="card_description_text_color">@color/card_description_text_color_dark</item>
|
||||||
|
|
||||||
<item name="wikivoyage_bg_color">@color/wikivoyage_bg_dark</item>
|
<item name="wikivoyage_bg_color">@color/wikivoyage_bg_dark</item>
|
||||||
|
|
|
@ -876,10 +876,8 @@ public class OsmandApplication extends MultiDexApplication {
|
||||||
|
|
||||||
public void logEvent(Activity ctx, String event) {
|
public void logEvent(Activity ctx, String event) {
|
||||||
try {
|
try {
|
||||||
if (Version.isGooglePlayEnabled(this) && Version.isFreeVersion(this)
|
if (Version.isGooglePlayEnabled(this) && !Version.isPaidVersion(this)
|
||||||
&& !osmandSettings.DO_NOT_SEND_ANONYMOUS_APP_USAGE.get()
|
&& !osmandSettings.DO_NOT_SEND_ANONYMOUS_APP_USAGE.get()) {
|
||||||
&& !InAppPurchaseHelper.isFullVersionPurchased(this)
|
|
||||||
&& !InAppPurchaseHelper.isSubscribedToLiveUpdates(this)) {
|
|
||||||
Class<?> cl = Class.forName("com.google.firebase.analytics.FirebaseAnalytics");
|
Class<?> cl = Class.forName("com.google.firebase.analytics.FirebaseAnalytics");
|
||||||
Method mm = cl.getMethod("getInstance", Context.class);
|
Method mm = cl.getMethod("getInstance", Context.class);
|
||||||
Object inst = mm.invoke(null, ctx == null ? this : ctx);
|
Object inst = mm.invoke(null, ctx == null ? this : ctx);
|
||||||
|
|
|
@ -76,6 +76,7 @@ import net.osmand.plus.activities.search.SearchActivity;
|
||||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
import net.osmand.plus.base.FailSafeFuntions;
|
import net.osmand.plus.base.FailSafeFuntions;
|
||||||
import net.osmand.plus.base.MapViewTrackingUtilities;
|
import net.osmand.plus.base.MapViewTrackingUtilities;
|
||||||
|
import net.osmand.plus.chooseplan.OsmLiveCancelledDialog;
|
||||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||||
import net.osmand.plus.dialogs.ErrorBottomSheetDialog;
|
import net.osmand.plus.dialogs.ErrorBottomSheetDialog;
|
||||||
import net.osmand.plus.dialogs.RateUsBottomSheetDialog;
|
import net.osmand.plus.dialogs.RateUsBottomSheetDialog;
|
||||||
|
@ -203,7 +204,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
private boolean permissionGranted;
|
private boolean permissionGranted;
|
||||||
|
|
||||||
private boolean mIsDestroyed = false;
|
private boolean mIsDestroyed = false;
|
||||||
private InAppPurchaseHelper inAppPurchaseHelper;
|
|
||||||
private Timer splashScreenTimer;
|
private Timer splashScreenTimer;
|
||||||
|
|
||||||
private ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
|
private ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
|
||||||
|
@ -785,9 +785,13 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
.add(R.id.fragmentContainer, new FirstUsageWelcomeFragment(),
|
.add(R.id.fragmentContainer, new FirstUsageWelcomeFragment(),
|
||||||
FirstUsageWelcomeFragment.TAG).commitAllowingStateLoss();
|
FirstUsageWelcomeFragment.TAG).commitAllowingStateLoss();
|
||||||
} else if (!isFirstScreenShowing() && XMasDialogFragment.shouldShowXmasDialog(app)) {
|
} else if (!isFirstScreenShowing()) {
|
||||||
SecondSplashScreenFragment.SHOW = false;
|
if (XMasDialogFragment.shouldShowXmasDialog(app)) {
|
||||||
new XMasDialogFragment().show(getSupportFragmentManager(), XMasDialogFragment.TAG);
|
SecondSplashScreenFragment.SHOW = false;
|
||||||
|
new XMasDialogFragment().show(getSupportFragmentManager(), XMasDialogFragment.TAG);
|
||||||
|
} else if (OsmLiveCancelledDialog.shouldShowDialog(app)) {
|
||||||
|
OsmLiveCancelledDialog.showInstance(getSupportFragmentManager());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
FirstUsageWelcomeFragment.SHOW = false;
|
FirstUsageWelcomeFragment.SHOW = false;
|
||||||
|
|
||||||
|
@ -865,6 +869,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isInAppPurchaseAllowed() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private void dismissSecondSplashScreen() {
|
private void dismissSecondSplashScreen() {
|
||||||
if (SecondSplashScreenFragment.VISIBLE) {
|
if (SecondSplashScreenFragment.VISIBLE) {
|
||||||
SecondSplashScreenFragment.VISIBLE = false;
|
SecondSplashScreenFragment.VISIBLE = false;
|
||||||
|
@ -1213,9 +1221,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
if (atlasMapRendererView != null) {
|
if (atlasMapRendererView != null) {
|
||||||
atlasMapRendererView.handleOnDestroy();
|
atlasMapRendererView.handleOnDestroy();
|
||||||
}
|
}
|
||||||
if (inAppPurchaseHelper != null) {
|
|
||||||
inAppPurchaseHelper.stop();
|
|
||||||
}
|
|
||||||
mIsDestroyed = true;
|
mIsDestroyed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1512,9 +1517,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
if (inAppPurchaseHelper != null && inAppPurchaseHelper.onActivityResultHandled(requestCode, resultCode, data)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (ActivityResultListener listener : activityResultListeners) {
|
for (ActivityResultListener listener : activityResultListeners) {
|
||||||
if (listener.processResult(requestCode, resultCode, data)) {
|
if (listener.processResult(requestCode, resultCode, data)) {
|
||||||
removeActivityResultListener(listener);
|
removeActivityResultListener(listener);
|
||||||
|
@ -1522,6 +1524,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OsmandPlugin.onMapActivityResult(requestCode, resultCode, data);
|
OsmandPlugin.onMapActivityResult(requestCode, resultCode, data);
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshMap() {
|
public void refreshMap() {
|
||||||
|
|
|
@ -8,6 +8,8 @@ import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
@ -23,6 +25,8 @@ import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@SuppressLint("Registered")
|
@SuppressLint("Registered")
|
||||||
public class OsmandInAppPurchaseActivity extends AppCompatActivity implements InAppPurchaseListener {
|
public class OsmandInAppPurchaseActivity extends AppCompatActivity implements InAppPurchaseListener {
|
||||||
private static final Log LOG = PlatformUtil.getLog(OsmandInAppPurchaseActivity.class);
|
private static final Log LOG = PlatformUtil.getLog(OsmandInAppPurchaseActivity.class);
|
||||||
|
@ -64,7 +68,7 @@ public class OsmandInAppPurchaseActivity extends AppCompatActivity implements In
|
||||||
deinitInAppPurchaseHelper();
|
deinitInAppPurchaseHelper();
|
||||||
|
|
||||||
if (purchaseHelper != null) {
|
if (purchaseHelper != null) {
|
||||||
purchaseHelper.addListener(this);
|
purchaseHelper.setUiActivity(this);
|
||||||
if (purchaseHelper.needRequestInventory()) {
|
if (purchaseHelper.needRequestInventory()) {
|
||||||
purchaseHelper.requestInventory();
|
purchaseHelper.requestInventory();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +77,7 @@ public class OsmandInAppPurchaseActivity extends AppCompatActivity implements In
|
||||||
|
|
||||||
private void deinitInAppPurchaseHelper() {
|
private void deinitInAppPurchaseHelper() {
|
||||||
if (purchaseHelper != null) {
|
if (purchaseHelper != null) {
|
||||||
purchaseHelper.removeListener(this);
|
purchaseHelper.resetUiActivity(this);
|
||||||
purchaseHelper.stop();
|
purchaseHelper.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,26 +145,79 @@ public class OsmandInAppPurchaseActivity extends AppCompatActivity implements In
|
||||||
@Override
|
@Override
|
||||||
public void onError(InAppPurchaseTaskType taskType, String error) {
|
public void onError(InAppPurchaseTaskType taskType, String error) {
|
||||||
onInAppPurchaseError(taskType, error);
|
onInAppPurchaseError(taskType, error);
|
||||||
|
fireInAppPurchaseErrorOnFragments(getSupportFragmentManager(), taskType, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fireInAppPurchaseErrorOnFragments(@NonNull FragmentManager fragmentManager,
|
||||||
|
InAppPurchaseTaskType taskType, String error) {
|
||||||
|
List<Fragment> fragments = fragmentManager.getFragments();
|
||||||
|
for (Fragment f : fragments) {
|
||||||
|
if (f instanceof InAppPurchaseListener && f.isAdded()) {
|
||||||
|
((InAppPurchaseListener) f).onError(taskType, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGetItems() {
|
public void onGetItems() {
|
||||||
onInAppPurchaseGetItems();
|
onInAppPurchaseGetItems();
|
||||||
|
fireInAppPurchaseGetItemsOnFragments(getSupportFragmentManager());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fireInAppPurchaseGetItemsOnFragments(@NonNull FragmentManager fragmentManager) {
|
||||||
|
List<Fragment> fragments = fragmentManager.getFragments();
|
||||||
|
for (Fragment f : fragments) {
|
||||||
|
if (f instanceof InAppPurchaseListener && f.isAdded()) {
|
||||||
|
((InAppPurchaseListener) f).onGetItems();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemPurchased(String sku) {
|
public void onItemPurchased(String sku) {
|
||||||
onInAppPurchaseItemPurchased(sku);
|
onInAppPurchaseItemPurchased(sku);
|
||||||
|
fireInAppPurchaseItemPurchasedOnFragments(getSupportFragmentManager(), sku);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fireInAppPurchaseItemPurchasedOnFragments(@NonNull FragmentManager fragmentManager, String sku) {
|
||||||
|
List<Fragment> fragments = fragmentManager.getFragments();
|
||||||
|
for (Fragment f : fragments) {
|
||||||
|
if (f instanceof InAppPurchaseListener && f.isAdded()) {
|
||||||
|
((InAppPurchaseListener) f).onItemPurchased(sku);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showProgress(InAppPurchaseTaskType taskType) {
|
public void showProgress(InAppPurchaseTaskType taskType) {
|
||||||
showInAppPurchaseProgress(taskType);
|
showInAppPurchaseProgress(taskType);
|
||||||
|
fireInAppPurchaseShowProgressOnFragments(getSupportFragmentManager(), taskType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fireInAppPurchaseShowProgressOnFragments(@NonNull FragmentManager fragmentManager,
|
||||||
|
InAppPurchaseTaskType taskType) {
|
||||||
|
List<Fragment> fragments = fragmentManager.getFragments();
|
||||||
|
for (Fragment f : fragments) {
|
||||||
|
if (f instanceof InAppPurchaseListener && f.isAdded()) {
|
||||||
|
((InAppPurchaseListener) f).showProgress(taskType);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dismissProgress(InAppPurchaseTaskType taskType) {
|
public void dismissProgress(InAppPurchaseTaskType taskType) {
|
||||||
dismissInAppPurchaseProgress(taskType);
|
dismissInAppPurchaseProgress(taskType);
|
||||||
|
fireInAppPurchaseDismissProgressOnFragments(getSupportFragmentManager(), taskType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fireInAppPurchaseDismissProgressOnFragments(@NonNull FragmentManager fragmentManager,
|
||||||
|
InAppPurchaseTaskType taskType) {
|
||||||
|
List<Fragment> fragments = fragmentManager.getFragments();
|
||||||
|
for (Fragment f : fragments) {
|
||||||
|
if (f instanceof InAppPurchaseListener && f.isAdded()) {
|
||||||
|
((InAppPurchaseListener) f).dismissProgress(taskType);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onInAppPurchaseError(InAppPurchaseTaskType taskType, String error) {
|
public void onInAppPurchaseError(InAppPurchaseTaskType taskType, String error) {
|
||||||
|
|
|
@ -497,9 +497,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
|
||||||
misc.addPreference(createCheckBoxPreference(settings.MAP_EMPTY_STATE_ALLOWED, R.string.tap_on_map_to_hide_interface, R.string.tap_on_map_to_hide_interface_descr));
|
misc.addPreference(createCheckBoxPreference(settings.MAP_EMPTY_STATE_ALLOWED, R.string.tap_on_map_to_hide_interface, R.string.tap_on_map_to_hide_interface_descr));
|
||||||
misc.addPreference(createCheckBoxPreference(settings.DO_NOT_SHOW_STARTUP_MESSAGES, R.string.do_not_show_startup_messages, R.string.do_not_show_startup_messages_desc));
|
misc.addPreference(createCheckBoxPreference(settings.DO_NOT_SHOW_STARTUP_MESSAGES, R.string.do_not_show_startup_messages, R.string.do_not_show_startup_messages_desc));
|
||||||
OsmandApplication app = getMyApplication();
|
OsmandApplication app = getMyApplication();
|
||||||
if (Version.isGooglePlayEnabled(getMyApplication()) && Version.isFreeVersion(app)
|
if (Version.isGooglePlayEnabled(getMyApplication()) && !Version.isPaidVersion(app)) {
|
||||||
&& !InAppPurchaseHelper.isFullVersionPurchased(app)
|
|
||||||
&& !InAppPurchaseHelper.isSubscribedToLiveUpdates(app)) {
|
|
||||||
misc.addPreference(createCheckBoxPreference(settings.DO_NOT_SEND_ANONYMOUS_APP_USAGE, R.string.do_not_send_anonymous_app_usage, R.string.do_not_send_anonymous_app_usage_desc));
|
misc.addPreference(createCheckBoxPreference(settings.DO_NOT_SEND_ANONYMOUS_APP_USAGE, R.string.do_not_send_anonymous_app_usage, R.string.do_not_send_anonymous_app_usage_desc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.OsmandActionBarActivity;
|
import net.osmand.plus.activities.OsmandActionBarActivity;
|
||||||
|
import net.osmand.plus.activities.OsmandInAppPurchaseActivity;
|
||||||
|
|
||||||
public class BaseOsmAndFragment extends Fragment implements TransitionAnimator {
|
public class BaseOsmAndFragment extends Fragment implements TransitionAnimator {
|
||||||
private IconsCache iconsCache;
|
private IconsCache iconsCache;
|
||||||
|
@ -128,6 +129,15 @@ public class BaseOsmAndFragment extends Fragment implements TransitionAnimator {
|
||||||
return (OsmandActionBarActivity) getActivity();
|
return (OsmandActionBarActivity) getActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected OsmandInAppPurchaseActivity getInAppPurchaseActivity() {
|
||||||
|
Activity activity = getActivity();
|
||||||
|
if (activity instanceof OsmandInAppPurchaseActivity) {
|
||||||
|
return (OsmandInAppPurchaseActivity) getActivity();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected IconsCache getIconsCache() {
|
protected IconsCache getIconsCache() {
|
||||||
if (iconsCache == null) {
|
if (iconsCache == null) {
|
||||||
iconsCache = getMyApplication().getIconsCache();
|
iconsCache = getMyApplication().getIconsCache();
|
||||||
|
|
|
@ -32,7 +32,6 @@ import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.Version;
|
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.base.BaseOsmAndDialogFragment;
|
import net.osmand.plus.base.BaseOsmAndDialogFragment;
|
||||||
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
||||||
|
@ -276,9 +275,6 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment
|
||||||
cardDescription.setText(R.string.osm_live_payment_desc);
|
cardDescription.setText(R.string.osm_live_payment_desc);
|
||||||
|
|
||||||
osmLiveCardButton = cardView.findViewById(R.id.card_button);
|
osmLiveCardButton = cardView.findViewById(R.id.card_button);
|
||||||
InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
|
|
||||||
boolean requestingInventory = purchaseHelper != null && purchaseHelper.getActiveTask() == InAppPurchaseTaskType.REQUEST_INVENTORY;
|
|
||||||
setupOsmLiveCardButton(requestingInventory);
|
|
||||||
|
|
||||||
return cardView;
|
return cardView;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +284,7 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment
|
||||||
ProgressBar progressBar = (ProgressBar) osmLiveCardButton.findViewById(R.id.card_button_progress);
|
ProgressBar progressBar = (ProgressBar) osmLiveCardButton.findViewById(R.id.card_button_progress);
|
||||||
TextViewEx buttonTitle = (TextViewEx) osmLiveCardButton.findViewById(R.id.card_button_title);
|
TextViewEx buttonTitle = (TextViewEx) osmLiveCardButton.findViewById(R.id.card_button_title);
|
||||||
TextViewEx buttonSubtitle = (TextViewEx) osmLiveCardButton.findViewById(R.id.card_button_subtitle);
|
TextViewEx buttonSubtitle = (TextViewEx) osmLiveCardButton.findViewById(R.id.card_button_subtitle);
|
||||||
if (!purchaseHelper.hasPrices()) {
|
if (purchaseHelper == null || !purchaseHelper.hasPrices()) {
|
||||||
buttonTitle.setText(getString(R.string.purchase_subscription_title, getString(R.string.osm_live_default_price)));
|
buttonTitle.setText(getString(R.string.purchase_subscription_title, getString(R.string.osm_live_default_price)));
|
||||||
} else {
|
} else {
|
||||||
buttonTitle.setText(getString(R.string.purchase_subscription_title, purchaseHelper.getLiveUpdatesPrice()));
|
buttonTitle.setText(getString(R.string.purchase_subscription_title, purchaseHelper.getLiveUpdatesPrice()));
|
||||||
|
@ -376,9 +372,6 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment
|
||||||
cardDescription.setText(R.string.in_app_purchase_desc_ex);
|
cardDescription.setText(R.string.in_app_purchase_desc_ex);
|
||||||
|
|
||||||
planTypeCardButton = cardView.findViewById(R.id.card_button);
|
planTypeCardButton = cardView.findViewById(R.id.card_button);
|
||||||
InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
|
|
||||||
boolean requestingInventory = purchaseHelper != null && purchaseHelper.getActiveTask() == InAppPurchaseTaskType.REQUEST_INVENTORY;
|
|
||||||
setupPlanTypeCardButton(requestingInventory);
|
|
||||||
|
|
||||||
return cardView;
|
return cardView;
|
||||||
}
|
}
|
||||||
|
@ -421,6 +414,14 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
mapActivity.disableDrawer();
|
mapActivity.disableDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean requestingInventory = purchaseHelper != null && purchaseHelper.getActiveTask() == InAppPurchaseTaskType.REQUEST_INVENTORY;
|
||||||
|
if (osmLiveCardButton != null) {
|
||||||
|
setupOsmLiveCardButton(requestingInventory);
|
||||||
|
}
|
||||||
|
if (planTypeCardButton != null) {
|
||||||
|
setupPlanTypeCardButton(requestingInventory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,261 @@
|
||||||
|
package net.osmand.plus.chooseplan;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.ColorRes;
|
||||||
|
import android.support.annotation.LayoutRes;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.view.ContextThemeWrapper;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.base.BaseOsmAndDialogFragment;
|
||||||
|
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.OsmAndFeature;
|
||||||
|
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
||||||
|
import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseListener;
|
||||||
|
import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseTaskType;
|
||||||
|
import net.osmand.plus.liveupdates.OsmLiveActivity;
|
||||||
|
import net.osmand.plus.liveupdates.SubscriptionFragment;
|
||||||
|
import net.osmand.plus.widgets.TextViewEx;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
public class OsmLiveCancelledDialog extends BaseOsmAndDialogFragment implements InAppPurchaseListener {
|
||||||
|
public static final String TAG = OsmLiveCancelledDialog.class.getSimpleName();
|
||||||
|
private static final Log LOG = PlatformUtil.getLog(OsmLiveCancelledDialog.class);
|
||||||
|
|
||||||
|
private OsmandApplication app;
|
||||||
|
private InAppPurchaseHelper purchaseHelper;
|
||||||
|
|
||||||
|
private boolean nightMode;
|
||||||
|
private View osmLiveButton;
|
||||||
|
|
||||||
|
private final OsmAndFeature[] osmLiveFeatures = {
|
||||||
|
OsmAndFeature.DAILY_MAP_UPDATES,
|
||||||
|
OsmAndFeature.UNLIMITED_DOWNLOADS,
|
||||||
|
OsmAndFeature.WIKIPEDIA_OFFLINE,
|
||||||
|
OsmAndFeature.WIKIVOYAGE_OFFLINE,
|
||||||
|
OsmAndFeature.CONTOUR_LINES_HILLSHADE_MAPS,
|
||||||
|
OsmAndFeature.SEA_DEPTH_MAPS,
|
||||||
|
OsmAndFeature.UNLOCK_ALL_FEATURES,
|
||||||
|
OsmAndFeature.DONATION_TO_OSM,
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
app = getMyApplication();
|
||||||
|
purchaseHelper = app.getInAppPurchaseHelper();
|
||||||
|
nightMode = isNightMode(getMapActivity() != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
Activity ctx = requireActivity();
|
||||||
|
int themeId = nightMode ? R.style.OsmandDarkTheme_DarkActionbar : R.style.OsmandLightTheme_DarkActionbar_LightStatusBar;
|
||||||
|
Dialog dialog = new Dialog(ctx, themeId);
|
||||||
|
Window window = dialog.getWindow();
|
||||||
|
if (window != null) {
|
||||||
|
if (!getSettings().DO_NOT_USE_ANIMATIONS.get()) {
|
||||||
|
window.getAttributes().windowAnimations = R.style.Animations_Alpha;
|
||||||
|
}
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
window.setStatusBarColor(ContextCompat.getColor(ctx, getStatusBarColor()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
Context ctx = getContext();
|
||||||
|
if (ctx == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
View view = inflate(R.layout.osmlive_cancelled_dialog_fragment, container);
|
||||||
|
|
||||||
|
view.findViewById(R.id.button_close).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
TextViewEx infoDescr = (TextViewEx) view.findViewById(R.id.info_description);
|
||||||
|
StringBuilder descr = new StringBuilder();
|
||||||
|
descr.append(getString(R.string.purchase_cancelled_dialog_descr));
|
||||||
|
for (OsmAndFeature feature : osmLiveFeatures) {
|
||||||
|
descr.append("\n").append("— ").append(feature.toHumanString(ctx));
|
||||||
|
}
|
||||||
|
infoDescr.setText(descr);
|
||||||
|
|
||||||
|
osmLiveButton = view.findViewById(R.id.card_button);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public MapActivity getMapActivity() {
|
||||||
|
Activity activity = getActivity();
|
||||||
|
if (activity != null && activity instanceof MapActivity) {
|
||||||
|
return (MapActivity) activity;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null) {
|
||||||
|
mapActivity.disableDrawer();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean requestingInventory = purchaseHelper != null && purchaseHelper.getActiveTask() == InAppPurchaseTaskType.REQUEST_INVENTORY;
|
||||||
|
setupOsmLiveButton(requestingInventory);
|
||||||
|
|
||||||
|
OsmandPreference<Boolean> firstTimeShown = app.getSettings().LIVE_UPDATES_PURCHASE_CANCELLED_FIRST_DLG_SHOWN;
|
||||||
|
OsmandPreference<Boolean> secondTimeShown = app.getSettings().LIVE_UPDATES_PURCHASE_CANCELLED_SECOND_DLG_SHOWN;
|
||||||
|
if (!firstTimeShown.get()) {
|
||||||
|
firstTimeShown.set(true);
|
||||||
|
} else if (!secondTimeShown.get()) {
|
||||||
|
secondTimeShown.set(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null) {
|
||||||
|
mapActivity.enableDrawer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorRes
|
||||||
|
protected int getStatusBarColor() {
|
||||||
|
return nightMode ? R.color.status_bar_wikivoyage_dark : R.color.status_bar_wikivoyage_light;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(InAppPurchaseTaskType taskType, String error) {
|
||||||
|
if (taskType == InAppPurchaseTaskType.REQUEST_INVENTORY) {
|
||||||
|
setupOsmLiveButton(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGetItems() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemPurchased(String sku) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showProgress(InAppPurchaseTaskType taskType) {
|
||||||
|
if (taskType == InAppPurchaseTaskType.REQUEST_INVENTORY) {
|
||||||
|
setupOsmLiveButton(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dismissProgress(InAppPurchaseTaskType taskType) {
|
||||||
|
if (taskType == InAppPurchaseTaskType.REQUEST_INVENTORY) {
|
||||||
|
setupOsmLiveButton(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupOsmLiveButton(boolean progress) {
|
||||||
|
if (osmLiveButton != null) {
|
||||||
|
ProgressBar progressBar = (ProgressBar) osmLiveButton.findViewById(R.id.card_button_progress);
|
||||||
|
TextViewEx buttonTitle = (TextViewEx) osmLiveButton.findViewById(R.id.card_button_title);
|
||||||
|
TextViewEx buttonSubtitle = (TextViewEx) osmLiveButton.findViewById(R.id.card_button_subtitle);
|
||||||
|
if (!purchaseHelper.hasPrices()) {
|
||||||
|
buttonTitle.setText(getString(R.string.purchase_subscription_title, getString(R.string.osm_live_default_price)));
|
||||||
|
} else {
|
||||||
|
buttonTitle.setText(getString(R.string.purchase_subscription_title, purchaseHelper.getLiveUpdatesPrice()));
|
||||||
|
}
|
||||||
|
buttonSubtitle.setText(R.string.osm_live_month_cost_desc);
|
||||||
|
if (progress) {
|
||||||
|
buttonTitle.setVisibility(View.GONE);
|
||||||
|
buttonSubtitle.setVisibility(View.GONE);
|
||||||
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
|
osmLiveButton.setOnClickListener(null);
|
||||||
|
} else {
|
||||||
|
buttonTitle.setVisibility(View.VISIBLE);
|
||||||
|
buttonSubtitle.setVisibility(View.VISIBLE);
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
osmLiveButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
subscript();
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void subscript() {
|
||||||
|
FragmentActivity ctx = getActivity();
|
||||||
|
if (ctx != null) {
|
||||||
|
if (ctx instanceof OsmLiveActivity) {
|
||||||
|
SubscriptionFragment subscriptionFragment = new SubscriptionFragment();
|
||||||
|
subscriptionFragment.show(ctx.getSupportFragmentManager(), SubscriptionFragment.TAG);
|
||||||
|
} else {
|
||||||
|
Intent intent = new Intent(ctx, OsmLiveActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
|
intent.putExtra(OsmLiveActivity.OPEN_SUBSCRIPTION_INTENT_PARAM, true);
|
||||||
|
ctx.startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private View inflate(@LayoutRes int layoutId, @Nullable ViewGroup container) {
|
||||||
|
int themeRes = nightMode ? R.style.OsmandDarkTheme_DarkActionbar : R.style.OsmandLightTheme_DarkActionbar_LightStatusBar;
|
||||||
|
return LayoutInflater.from(new ContextThemeWrapper(getContext(), themeRes))
|
||||||
|
.inflate(layoutId, container, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean shouldShowDialog(OsmandApplication app) {
|
||||||
|
OsmandSettings settings = app.getSettings();
|
||||||
|
long cancelledTime = settings.LIVE_UPDATES_PURCHASE_CANCELLED_TIME.get();
|
||||||
|
boolean firstTimeShown = settings.LIVE_UPDATES_PURCHASE_CANCELLED_FIRST_DLG_SHOWN.get();
|
||||||
|
boolean secondTimeShown = settings.LIVE_UPDATES_PURCHASE_CANCELLED_SECOND_DLG_SHOWN.get();
|
||||||
|
return cancelledTime > 0
|
||||||
|
&& (!firstTimeShown
|
||||||
|
|| (System.currentTimeMillis() - cancelledTime > InAppPurchaseHelper.getSubscriptionHoldingTime(app)
|
||||||
|
&& !secondTimeShown));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showInstance(@NonNull FragmentManager fm) {
|
||||||
|
try {
|
||||||
|
OsmLiveCancelledDialog fragment = new OsmLiveCancelledDialog();
|
||||||
|
fragment.show(fm, OsmLiveCancelledDialog.TAG);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
LOG.error("showInstance", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -206,54 +206,25 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
||||||
@Override
|
@Override
|
||||||
public void onInAppPurchaseError(InAppPurchaseTaskType taskType, String error) {
|
public void onInAppPurchaseError(InAppPurchaseTaskType taskType, String error) {
|
||||||
visibleBanner.updateFreeVersionBanner();
|
visibleBanner.updateFreeVersionBanner();
|
||||||
for (WeakReference<Fragment> ref : fragSet) {
|
|
||||||
Fragment f = ref.get();
|
|
||||||
if (f instanceof InAppPurchaseListener && f.isAdded()) {
|
|
||||||
((InAppPurchaseListener) f).onError(taskType, error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInAppPurchaseGetItems() {
|
public void onInAppPurchaseGetItems() {
|
||||||
visibleBanner.updateFreeVersionBanner();
|
visibleBanner.updateFreeVersionBanner();
|
||||||
for (WeakReference<Fragment> ref : fragSet) {
|
|
||||||
Fragment f = ref.get();
|
|
||||||
if (f instanceof InAppPurchaseListener && f.isAdded()) {
|
|
||||||
((InAppPurchaseListener) f).onGetItems();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInAppPurchaseItemPurchased(String sku) {
|
public void onInAppPurchaseItemPurchased(String sku) {
|
||||||
visibleBanner.updateFreeVersionBanner();
|
visibleBanner.updateFreeVersionBanner();
|
||||||
for (WeakReference<Fragment> ref : fragSet) {
|
|
||||||
Fragment f = ref.get();
|
|
||||||
if (f instanceof InAppPurchaseListener && f.isAdded()) {
|
|
||||||
((InAppPurchaseListener) f).onItemPurchased(sku);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showInAppPurchaseProgress(InAppPurchaseTaskType taskType) {
|
public void showInAppPurchaseProgress(InAppPurchaseTaskType taskType) {
|
||||||
for (WeakReference<Fragment> ref : fragSet) {
|
|
||||||
Fragment f = ref.get();
|
|
||||||
if (f instanceof InAppPurchaseListener && f.isAdded()) {
|
|
||||||
((InAppPurchaseListener) f).showProgress(taskType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dismissInAppPurchaseProgress(InAppPurchaseTaskType taskType) {
|
public void dismissInAppPurchaseProgress(InAppPurchaseTaskType taskType) {
|
||||||
for (WeakReference<Fragment> ref : fragSet) {
|
|
||||||
Fragment f = ref.get();
|
|
||||||
if (f instanceof InAppPurchaseListener && f.isAdded()) {
|
|
||||||
((InAppPurchaseListener) f).dismissProgress(taskType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DownloadIndexesThread getDownloadThread() {
|
public DownloadIndexesThread getDownloadThread() {
|
||||||
|
@ -404,8 +375,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shouldShowFreeVersionBanner(OsmandApplication application) {
|
public static boolean shouldShowFreeVersionBanner(OsmandApplication application) {
|
||||||
return (Version.isFreeVersion(application) && !InAppPurchaseHelper.isSubscribedToLiveUpdates(application)
|
return !Version.isPaidVersion(application)
|
||||||
&& !InAppPurchaseHelper.isFullVersionPurchased(application))
|
|
||||||
|| application.getSettings().SHOULD_SHOW_FREE_VERSION_BANNER.get();
|
|| application.getSettings().SHOULD_SHOW_FREE_VERSION_BANNER.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -563,9 +563,7 @@ public class DownloadIndexesThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateNotExceedsFreeLimit(IndexItem item) {
|
private boolean validateNotExceedsFreeLimit(IndexItem item) {
|
||||||
boolean exceed = Version.isFreeVersion(app)
|
boolean exceed = !Version.isPaidVersion(app)
|
||||||
&& !InAppPurchaseHelper.isSubscribedToLiveUpdates(app)
|
|
||||||
&& !InAppPurchaseHelper.isFullVersionPurchased(app)
|
|
||||||
&& DownloadActivityType.isCountedInDownloads(item)
|
&& DownloadActivityType.isCountedInDownloads(item)
|
||||||
&& downloads.get() >= DownloadValidationManager.MAXIMUM_AVAILABLE_FREE_DOWNLOADS;
|
&& downloads.get() >= DownloadValidationManager.MAXIMUM_AVAILABLE_FREE_DOWNLOADS;
|
||||||
if(exceed) {
|
if(exceed) {
|
||||||
|
|
|
@ -325,7 +325,9 @@ public class DownloadResources extends DownloadResourceGroup {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ii.getType() == DownloadActivityType.DEPTH_CONTOUR_FILE) {
|
if (ii.getType() == DownloadActivityType.DEPTH_CONTOUR_FILE) {
|
||||||
if (InAppPurchaseHelper.isDepthContoursPurchased(app) || nauticalMaps.size() == 0) {
|
if (InAppPurchaseHelper.isDepthContoursPurchased(app)
|
||||||
|
|| InAppPurchaseHelper.isSubscribedToLiveUpdates(app)
|
||||||
|
|| nauticalMaps.size() == 0) {
|
||||||
nauticalMaps.addItem(ii);
|
nauticalMaps.addItem(ii);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -155,14 +155,12 @@ public class DownloadValidationManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void downloadFilesCheck_1_FreeVersion(FragmentActivity context, IndexItem[] items) {
|
protected void downloadFilesCheck_1_FreeVersion(FragmentActivity context, IndexItem[] items) {
|
||||||
if (Version.isFreeVersion(getMyApplication()) && !InAppPurchaseHelper.isSubscribedToLiveUpdates(app)
|
if (!Version.isPaidVersion(app)) {
|
||||||
&& !InAppPurchaseHelper.isFullVersionPurchased(app)) {
|
|
||||||
int total = settings.NUMBER_OF_FREE_DOWNLOADS.get();
|
int total = settings.NUMBER_OF_FREE_DOWNLOADS.get();
|
||||||
if (total > MAXIMUM_AVAILABLE_FREE_DOWNLOADS) {
|
if (total > MAXIMUM_AVAILABLE_FREE_DOWNLOADS) {
|
||||||
if (context instanceof FragmentActivity) {
|
if (context != null) {
|
||||||
FragmentActivity activity = context;
|
|
||||||
new InstallPaidVersionDialogFragment()
|
new InstallPaidVersionDialogFragment()
|
||||||
.show(activity.getSupportFragmentManager(), InstallPaidVersionDialogFragment.TAG);
|
.show(context.getSupportFragmentManager(), InstallPaidVersionDialogFragment.TAG);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
downloadFilesCheck_2_Internet(context, items);
|
downloadFilesCheck_2_Internet(context, items);
|
||||||
|
|
|
@ -21,6 +21,7 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.map.WorldRegion;
|
import net.osmand.map.WorldRegion;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType;
|
import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType;
|
||||||
import net.osmand.plus.activities.LocalIndexInfo;
|
import net.osmand.plus.activities.LocalIndexInfo;
|
||||||
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
|
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
|
||||||
|
@ -50,7 +51,6 @@ public class ItemViewHolder {
|
||||||
private boolean srtmDisabled;
|
private boolean srtmDisabled;
|
||||||
private boolean srtmNeedsInstallation;
|
private boolean srtmNeedsInstallation;
|
||||||
private boolean nauticalPluginDisabled;
|
private boolean nauticalPluginDisabled;
|
||||||
private boolean freeVersion;
|
|
||||||
private boolean depthContoursPurchased;
|
private boolean depthContoursPurchased;
|
||||||
|
|
||||||
protected final DownloadActivity context;
|
protected final DownloadActivity context;
|
||||||
|
@ -128,9 +128,9 @@ public class ItemViewHolder {
|
||||||
private void initAppStatusVariables() {
|
private void initAppStatusVariables() {
|
||||||
srtmDisabled = context.isSrtmDisabled();
|
srtmDisabled = context.isSrtmDisabled();
|
||||||
nauticalPluginDisabled = context.isNauticalPluginDisabled();
|
nauticalPluginDisabled = context.isNauticalPluginDisabled();
|
||||||
freeVersion = context.isFreeVersion();
|
|
||||||
srtmNeedsInstallation = context.isSrtmNeedsInstallation();
|
srtmNeedsInstallation = context.isSrtmNeedsInstallation();
|
||||||
depthContoursPurchased = InAppPurchaseHelper.isDepthContoursPurchased(context.getMyApplication());
|
depthContoursPurchased = InAppPurchaseHelper.isDepthContoursPurchased(context.getMyApplication())
|
||||||
|
|| InAppPurchaseHelper.isSubscribedToLiveUpdates(context.getMyApplication());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bindIndexItem(final IndexItem indexItem) {
|
public void bindIndexItem(final IndexItem indexItem) {
|
||||||
|
@ -314,11 +314,10 @@ public class ItemViewHolder {
|
||||||
clickAction = RightButtonAction.ASK_FOR_SRTM_PLUGIN_ENABLE;
|
clickAction = RightButtonAction.ASK_FOR_SRTM_PLUGIN_ENABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (indexItem.getType() == DownloadActivityType.WIKIPEDIA_FILE && freeVersion
|
} else if (indexItem.getType() == DownloadActivityType.WIKIPEDIA_FILE
|
||||||
&& !InAppPurchaseHelper.isFullVersionPurchased(context.getMyApplication())) {
|
&& !Version.isPaidVersion(context.getMyApplication())) {
|
||||||
clickAction = RightButtonAction.ASK_FOR_FULL_VERSION_PURCHASE;
|
clickAction = RightButtonAction.ASK_FOR_FULL_VERSION_PURCHASE;
|
||||||
} else if (indexItem.getType() == DownloadActivityType.DEPTH_CONTOUR_FILE
|
} else if (indexItem.getType() == DownloadActivityType.DEPTH_CONTOUR_FILE && !depthContoursPurchased) {
|
||||||
&& !InAppPurchaseHelper.isDepthContoursPurchased(context.getMyApplication())) {
|
|
||||||
clickAction = RightButtonAction.ASK_FOR_DEPTH_CONTOURS_PURCHASE;
|
clickAction = RightButtonAction.ASK_FOR_DEPTH_CONTOURS_PURCHASE;
|
||||||
}
|
}
|
||||||
return clickAction;
|
return clickAction;
|
||||||
|
|
|
@ -110,7 +110,8 @@ public class DiscountHelper {
|
||||||
if (url.startsWith(INAPP_PREFIX) && url.length() > INAPP_PREFIX.length()) {
|
if (url.startsWith(INAPP_PREFIX) && url.length() > INAPP_PREFIX.length()) {
|
||||||
String inAppSku = url.substring(INAPP_PREFIX.length());
|
String inAppSku = url.substring(INAPP_PREFIX.length());
|
||||||
InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
|
InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
|
||||||
if (purchaseHelper != null && purchaseHelper.isPurchased(inAppSku)) {
|
if (purchaseHelper != null
|
||||||
|
&& (purchaseHelper.isPurchased(inAppSku) || InAppPurchaseHelper.isSubscribedToLiveUpdates(app))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,7 +215,10 @@ public class DiscountHelper {
|
||||||
if (url.contains(InAppPurchaseHelper.SKU_FULL_VERSION_PRICE)) {
|
if (url.contains(InAppPurchaseHelper.SKU_FULL_VERSION_PRICE)) {
|
||||||
OsmandApplication app = mapActivity.getMyApplication();
|
OsmandApplication app = mapActivity.getMyApplication();
|
||||||
app.logEvent(mapActivity, "in_app_purchase_redirect");
|
app.logEvent(mapActivity, "in_app_purchase_redirect");
|
||||||
app.getInAppPurchaseHelper().purchaseFullVersion(mapActivity);
|
InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
|
||||||
|
if (purchaseHelper != null) {
|
||||||
|
purchaseHelper.purchaseFullVersion(mapActivity);
|
||||||
|
}
|
||||||
} else if (url.contains(InAppPurchaseHelper.SKU_LIVE_UPDATES)){
|
} else if (url.contains(InAppPurchaseHelper.SKU_LIVE_UPDATES)){
|
||||||
Intent intent = new Intent(mapActivity, OsmLiveActivity.class);
|
Intent intent = new Intent(mapActivity, OsmLiveActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
|
|
|
@ -11,6 +11,7 @@ import net.osmand.AndroidNetworkUtils;
|
||||||
import net.osmand.AndroidNetworkUtils.OnRequestResultListener;
|
import net.osmand.AndroidNetworkUtils.OnRequestResultListener;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.inapp.util.IabHelper;
|
import net.osmand.plus.inapp.util.IabHelper;
|
||||||
|
@ -36,7 +37,9 @@ import java.util.Map;
|
||||||
public class InAppPurchaseHelper {
|
public class InAppPurchaseHelper {
|
||||||
// Debug tag, for logging
|
// Debug tag, for logging
|
||||||
private static final String TAG = InAppPurchaseHelper.class.getSimpleName();
|
private static final String TAG = InAppPurchaseHelper.class.getSimpleName();
|
||||||
boolean mDebugLog = false;
|
boolean mDebugLog = true;
|
||||||
|
|
||||||
|
private static final long SUBSCRIPTION_HOLDING_TIME_MSEC = 1000 * 60 * 60 * 24 * 3; // 3 days
|
||||||
|
|
||||||
private long lastValidationCheckTime;
|
private long lastValidationCheckTime;
|
||||||
private String liveUpdatesPrice;
|
private String liveUpdatesPrice;
|
||||||
|
@ -69,7 +72,7 @@ public class InAppPurchaseHelper {
|
||||||
private boolean processingTask = false;
|
private boolean processingTask = false;
|
||||||
|
|
||||||
private OsmandApplication ctx;
|
private OsmandApplication ctx;
|
||||||
private List<InAppPurchaseListener> listeners = new ArrayList<>();
|
private InAppPurchaseListener uiActivity = null;
|
||||||
|
|
||||||
/* base64EncodedPublicKey should be YOUR APPLICATION'S PUBLIC KEY
|
/* base64EncodedPublicKey should be YOUR APPLICATION'S PUBLIC KEY
|
||||||
* (that you got from the Google Play developer console). This is not your
|
* (that you got from the Google Play developer console). This is not your
|
||||||
|
@ -121,6 +124,14 @@ public class InAppPurchaseHelper {
|
||||||
return activeTask;
|
return activeTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long getSubscriptionHoldingTime(OsmandApplication app) {
|
||||||
|
if (Version.isDeveloperBuild(app)) {
|
||||||
|
return 1000 * 60 * 60; // 1 hour (test)
|
||||||
|
} else {
|
||||||
|
return SUBSCRIPTION_HOLDING_TIME_MSEC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isSubscribedToLiveUpdates(@NonNull OsmandApplication ctx) {
|
public static boolean isSubscribedToLiveUpdates(@NonNull OsmandApplication ctx) {
|
||||||
return Version.isDeveloperBuild(ctx) || ctx.getSettings().LIVE_UPDATES_PURCHASED.get();
|
return Version.isDeveloperBuild(ctx) || ctx.getSettings().LIVE_UPDATES_PURCHASED.get();
|
||||||
}
|
}
|
||||||
|
@ -193,7 +204,6 @@ public class InAppPurchaseHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPurchased(String inAppSku) {
|
public boolean isPurchased(String inAppSku) {
|
||||||
OsmandSettings settings = ctx.getSettings();
|
|
||||||
if (inAppSku.equals(SKU_FULL_VERSION_PRICE)) {
|
if (inAppSku.equals(SKU_FULL_VERSION_PRICE)) {
|
||||||
return isFullVersionPurchased(ctx);
|
return isFullVersionPurchased(ctx);
|
||||||
} else if (inAppSku.equals(SKU_LIVE_UPDATES_FULL) || inAppSku.equals(SKU_LIVE_UPDATES_FREE)) {
|
} else if (inAppSku.equals(SKU_LIVE_UPDATES_FULL) || inAppSku.equals(SKU_LIVE_UPDATES_FREE)) {
|
||||||
|
@ -358,10 +368,19 @@ public class InAppPurchaseHelper {
|
||||||
// Do we have the live updates?
|
// Do we have the live updates?
|
||||||
Purchase liveUpdatesPurchase = inventory.getPurchase(SKU_LIVE_UPDATES);
|
Purchase liveUpdatesPurchase = inventory.getPurchase(SKU_LIVE_UPDATES);
|
||||||
boolean subscribedToLiveUpdates = (liveUpdatesPurchase != null && liveUpdatesPurchase.getPurchaseState() == 0);
|
boolean subscribedToLiveUpdates = (liveUpdatesPurchase != null && liveUpdatesPurchase.getPurchaseState() == 0);
|
||||||
if (!subscribedToLiveUpdates && ctx.getSettings().LIVE_UPDATES_PURCHASED.get()) {
|
OsmandPreference<Long> subscriptionCancelledTime = ctx.getSettings().LIVE_UPDATES_PURCHASE_CANCELLED_TIME;
|
||||||
ctx.getSettings().LIVE_UPDATES_PURCHASE_CANCELLED_TIME.set(System.currentTimeMillis());
|
if (!subscribedToLiveUpdates) {
|
||||||
|
if (ctx.getSettings().LIVE_UPDATES_PURCHASED.get()) {
|
||||||
|
subscriptionCancelledTime.set(System.currentTimeMillis());
|
||||||
|
ctx.getSettings().LIVE_UPDATES_PURCHASE_CANCELLED_FIRST_DLG_SHOWN.set(false);
|
||||||
|
ctx.getSettings().LIVE_UPDATES_PURCHASE_CANCELLED_SECOND_DLG_SHOWN.set(false);
|
||||||
|
} else if (System.currentTimeMillis() - subscriptionCancelledTime.get() > getSubscriptionHoldingTime(ctx)) {
|
||||||
|
ctx.getSettings().LIVE_UPDATES_PURCHASED.set(false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
subscriptionCancelledTime.set(0L);
|
||||||
|
ctx.getSettings().LIVE_UPDATES_PURCHASED.set(true);
|
||||||
}
|
}
|
||||||
ctx.getSettings().LIVE_UPDATES_PURCHASED.set(subscribedToLiveUpdates);
|
|
||||||
|
|
||||||
Purchase fullVersionPurchase = inventory.getPurchase(SKU_FULL_VERSION_PRICE);
|
Purchase fullVersionPurchase = inventory.getPurchase(SKU_FULL_VERSION_PRICE);
|
||||||
boolean fullVersionPurchased = (fullVersionPurchase != null && fullVersionPurchase.getPurchaseState() == 0);
|
boolean fullVersionPurchased = (fullVersionPurchase != null && fullVersionPurchase.getPurchaseState() == 0);
|
||||||
|
@ -722,41 +741,44 @@ public class InAppPurchaseHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyError(InAppPurchaseTaskType taskType, String message) {
|
private void notifyError(InAppPurchaseTaskType taskType, String message) {
|
||||||
for (InAppPurchaseListener l : listeners) {
|
if (uiActivity != null) {
|
||||||
l.onError(taskType, message);
|
uiActivity.onError(taskType, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyGetItems() {
|
private void notifyGetItems() {
|
||||||
for (InAppPurchaseListener l : listeners) {
|
if (uiActivity != null) {
|
||||||
l.onGetItems();
|
uiActivity.onGetItems();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyItemPurchased(String sku) {
|
private void notifyItemPurchased(String sku) {
|
||||||
for (InAppPurchaseListener l : listeners) {
|
if (uiActivity != null) {
|
||||||
l.onItemPurchased(sku);
|
uiActivity.onItemPurchased(sku);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyShowProgress(InAppPurchaseTaskType taskType) {
|
private void notifyShowProgress(InAppPurchaseTaskType taskType) {
|
||||||
for (InAppPurchaseListener l : listeners) {
|
if (uiActivity != null) {
|
||||||
l.showProgress(taskType);
|
uiActivity.showProgress(taskType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyDismissProgress(InAppPurchaseTaskType taskType) {
|
private void notifyDismissProgress(InAppPurchaseTaskType taskType) {
|
||||||
for (InAppPurchaseListener l : listeners) {
|
if (uiActivity != null) {
|
||||||
l.dismissProgress(taskType);
|
uiActivity.dismissProgress(taskType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListener(InAppPurchaseListener listener) {
|
/// UI notifications methods
|
||||||
this.listeners.add(listener);
|
public void setUiActivity(InAppPurchaseListener uiActivity) {
|
||||||
|
this.uiActivity = uiActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeListener(InAppPurchaseListener listener) {
|
public void resetUiActivity(InAppPurchaseListener uiActivity) {
|
||||||
this.listeners.remove(listener);
|
if (this.uiActivity == uiActivity) {
|
||||||
|
this.uiActivity = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void complain(String message) {
|
private void complain(String message) {
|
||||||
|
|
|
@ -37,6 +37,7 @@ import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.map.WorldRegion;
|
import net.osmand.map.WorldRegion;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
@ -229,7 +230,6 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
if (purchaseHelper.getActiveTask() == InAppPurchaseTaskType.REQUEST_INVENTORY) {
|
if (purchaseHelper.getActiveTask() == InAppPurchaseTaskType.REQUEST_INVENTORY) {
|
||||||
enableProgress();
|
enableProgress();
|
||||||
}
|
}
|
||||||
purchaseHelper.addListener(this);
|
|
||||||
}
|
}
|
||||||
if (((OsmLiveActivity) getActivity()).shouldOpenSubscription()) {
|
if (((OsmLiveActivity) getActivity()).shouldOpenSubscription()) {
|
||||||
SubscriptionFragment subscriptionFragment = new SubscriptionFragment();
|
SubscriptionFragment subscriptionFragment = new SubscriptionFragment();
|
||||||
|
@ -245,15 +245,6 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
InAppPurchaseHelper purchaseHelper = getInAppPurchaseHelper();
|
|
||||||
if (purchaseHelper != null) {
|
|
||||||
purchaseHelper.removeListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void notifyLiveUpdatesChanged() {
|
public void notifyLiveUpdatesChanged() {
|
||||||
if (getActivity() != null) {
|
if (getActivity() != null) {
|
||||||
if (adapter != null && getMyApplication() != null) {
|
if (adapter != null && getMyApplication() != null) {
|
||||||
|
@ -702,6 +693,11 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
@Override
|
@Override
|
||||||
public void onError(InAppPurchaseTaskType taskType, String error) {
|
public void onError(InAppPurchaseTaskType taskType, String error) {
|
||||||
disableProgress();
|
disableProgress();
|
||||||
|
|
||||||
|
OsmandInAppPurchaseActivity activity = getInAppPurchaseActivity();
|
||||||
|
if (activity != null) {
|
||||||
|
activity.fireInAppPurchaseErrorOnFragments(getChildFragmentManager(), taskType, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -711,6 +707,11 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
adapter.enableLiveUpdates(false);
|
adapter.enableLiveUpdates(false);
|
||||||
}
|
}
|
||||||
disableProgress();
|
disableProgress();
|
||||||
|
|
||||||
|
OsmandInAppPurchaseActivity activity = getInAppPurchaseActivity();
|
||||||
|
if (activity != null) {
|
||||||
|
activity.fireInAppPurchaseGetItemsOnFragments(getChildFragmentManager());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -719,15 +720,30 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
if (purchaseHelper != null && purchaseHelper.getSkuLiveUpdates().equals(sku)) {
|
if (purchaseHelper != null && purchaseHelper.getSkuLiveUpdates().equals(sku)) {
|
||||||
updateSubscriptionHeader();
|
updateSubscriptionHeader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OsmandInAppPurchaseActivity activity = getInAppPurchaseActivity();
|
||||||
|
if (activity != null) {
|
||||||
|
activity.fireInAppPurchaseItemPurchasedOnFragments(getChildFragmentManager(), sku);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showProgress(InAppPurchaseTaskType taskType) {
|
public void showProgress(InAppPurchaseTaskType taskType) {
|
||||||
enableProgress();
|
enableProgress();
|
||||||
|
|
||||||
|
OsmandInAppPurchaseActivity activity = getInAppPurchaseActivity();
|
||||||
|
if (activity != null) {
|
||||||
|
activity.fireInAppPurchaseShowProgressOnFragments(getChildFragmentManager(), taskType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dismissProgress(InAppPurchaseTaskType taskType) {
|
public void dismissProgress(InAppPurchaseTaskType taskType) {
|
||||||
disableProgress();
|
disableProgress();
|
||||||
|
|
||||||
|
OsmandInAppPurchaseActivity activity = getInAppPurchaseActivity();
|
||||||
|
if (activity != null) {
|
||||||
|
activity.fireInAppPurchaseDismissProgressOnFragments(getChildFragmentManager(), taskType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,24 +308,6 @@ public class SubscriptionFragment extends BaseOsmAndDialogFragment implements In
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
InAppPurchaseHelper purchaseHelper = getInAppPurchaseHelper();
|
|
||||||
if (purchaseHelper != null) {
|
|
||||||
purchaseHelper.addListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
InAppPurchaseHelper purchaseHelper = getInAppPurchaseHelper();
|
|
||||||
if (purchaseHelper != null) {
|
|
||||||
purchaseHelper.removeListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|
|
@ -582,10 +582,10 @@ public class ResourceManager {
|
||||||
collectFiles(appPath, IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
collectFiles(appPath, IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
||||||
renameRoadsFiles(files, roadsPath);
|
renameRoadsFiles(files, roadsPath);
|
||||||
collectFiles(roadsPath, IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
collectFiles(roadsPath, IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
||||||
if (!Version.isFreeVersion(context) || InAppPurchaseHelper.isFullVersionPurchased(context)) {
|
if (Version.isPaidVersion(context)) {
|
||||||
collectFiles(context.getAppPath(IndexConstants.WIKI_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
collectFiles(context.getAppPath(IndexConstants.WIKI_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
||||||
}
|
}
|
||||||
if (OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null) {
|
if (OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null || InAppPurchaseHelper.isSubscribedToLiveUpdates(context)) {
|
||||||
collectFiles(context.getAppPath(IndexConstants.SRTM_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
collectFiles(context.getAppPath(IndexConstants.SRTM_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,7 +619,7 @@ public class ResourceManager {
|
||||||
}
|
}
|
||||||
boolean wikiMap = (f.getName().contains("_wiki") || f.getName().contains(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT));
|
boolean wikiMap = (f.getName().contains("_wiki") || f.getName().contains(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT));
|
||||||
boolean srtmMap = f.getName().contains(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT);
|
boolean srtmMap = f.getName().contains(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT);
|
||||||
if (mapReader == null || (Version.isFreeVersion(context) && wikiMap && !InAppPurchaseHelper.isFullVersionPurchased(context))) {
|
if (mapReader == null || (!Version.isPaidVersion(context) && wikiMap)) {
|
||||||
warnings.add(MessageFormat.format(context.getString(R.string.version_index_is_not_supported), f.getName())); //$NON-NLS-1$
|
warnings.add(MessageFormat.format(context.getString(R.string.version_index_is_not_supported), f.getName())); //$NON-NLS-1$
|
||||||
} else {
|
} else {
|
||||||
if (mapReader.isBasemap()) {
|
if (mapReader.isBasemap()) {
|
||||||
|
|
|
@ -17,6 +17,7 @@ import net.osmand.plus.download.DownloadIndexesThread;
|
||||||
import net.osmand.plus.download.DownloadResources;
|
import net.osmand.plus.download.DownloadResources;
|
||||||
import net.osmand.plus.download.DownloadValidationManager;
|
import net.osmand.plus.download.DownloadValidationManager;
|
||||||
import net.osmand.plus.download.IndexItem;
|
import net.osmand.plus.download.IndexItem;
|
||||||
|
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
||||||
import net.osmand.render.RenderingRuleProperty;
|
import net.osmand.render.RenderingRuleProperty;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -47,7 +48,7 @@ public class ContourLinesMenu {
|
||||||
final OsmandApplication app = mapActivity.getMyApplication();
|
final OsmandApplication app = mapActivity.getMyApplication();
|
||||||
final OsmandSettings settings = app.getSettings();
|
final OsmandSettings settings = app.getSettings();
|
||||||
final SRTMPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
|
final SRTMPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
|
||||||
final boolean srtmEnabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null;
|
final boolean srtmEnabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null || InAppPurchaseHelper.isSubscribedToLiveUpdates(app);
|
||||||
|
|
||||||
final RenderingRuleProperty contourLinesProp = app.getRendererRegistry().getCustomRenderingRuleProperty(CONTOUR_LINES_ATTR);
|
final RenderingRuleProperty contourLinesProp = app.getRendererRegistry().getCustomRenderingRuleProperty(CONTOUR_LINES_ATTR);
|
||||||
final RenderingRuleProperty colorSchemeProp = app.getRendererRegistry().getCustomRenderingRuleProperty(CONTOUR_LINES_SCHEME_ATTR);
|
final RenderingRuleProperty colorSchemeProp = app.getRendererRegistry().getCustomRenderingRuleProperty(CONTOUR_LINES_SCHEME_ATTR);
|
||||||
|
|
|
@ -16,6 +16,7 @@ import net.osmand.plus.download.DownloadIndexesThread;
|
||||||
import net.osmand.plus.download.DownloadResources;
|
import net.osmand.plus.download.DownloadResources;
|
||||||
import net.osmand.plus.download.DownloadValidationManager;
|
import net.osmand.plus.download.DownloadValidationManager;
|
||||||
import net.osmand.plus.download.IndexItem;
|
import net.osmand.plus.download.IndexItem;
|
||||||
|
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -42,7 +43,7 @@ public class HillshadeMenu {
|
||||||
final OsmandApplication app = mapActivity.getMyApplication();
|
final OsmandApplication app = mapActivity.getMyApplication();
|
||||||
final OsmandSettings settings = app.getSettings();
|
final OsmandSettings settings = app.getSettings();
|
||||||
final SRTMPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
|
final SRTMPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
|
||||||
final boolean srtmEnabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null;
|
final boolean srtmEnabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null || InAppPurchaseHelper.isSubscribedToLiveUpdates(app);
|
||||||
if (plugin == null) {
|
if (plugin == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import net.osmand.core.jni.ObfsCollection;
|
||||||
import net.osmand.core.jni.QIODeviceLogSink;
|
import net.osmand.core.jni.QIODeviceLogSink;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
|
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
||||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
|
@ -60,7 +61,7 @@ public class NativeCoreContext {
|
||||||
|
|
||||||
ObfsCollection obfsCollection = new ObfsCollection();
|
ObfsCollection obfsCollection = new ObfsCollection();
|
||||||
obfsCollection.addDirectory(directory.getAbsolutePath(), false);
|
obfsCollection.addDirectory(directory.getAbsolutePath(), false);
|
||||||
if(OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null) {
|
if(OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null || InAppPurchaseHelper.isSubscribedToLiveUpdates(app)) {
|
||||||
obfsCollection.addDirectory(app.getAppPath(IndexConstants.SRTM_INDEX_DIR).getAbsolutePath(), false);
|
obfsCollection.addDirectory(app.getAppPath(IndexConstants.SRTM_INDEX_DIR).getAbsolutePath(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue