Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
2959eeb2f1
10 changed files with 369 additions and 191 deletions
|
@ -9,6 +9,8 @@
|
|||
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
|
||||
-->
|
||||
<string name="paid_app">Paid application</string>
|
||||
<string name="paid_plugin">Paid plugin</string>
|
||||
<string name="travel_card_update_descr">We prepared updates and fixes in the Wikivoyage data, update the file to see them.</string>
|
||||
<string name="travel_card_download_descr">Download this Wikivoyage travel guides file to view articles about places around the world without an internet connection.</string>
|
||||
<string name="update_is_available">Update is available</string>
|
||||
|
|
|
@ -79,7 +79,7 @@ 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_INAPP_PARAM = "show_plus_version_inapp";
|
||||
private static final String SHOW_PLUS_VERSION_INAPP_PARAM = "show_plus_version_inapp";
|
||||
|
||||
final AppInitializer appInitializer = new AppInitializer(this);
|
||||
OsmandSettings osmandSettings = null;
|
||||
|
@ -88,6 +88,7 @@ public class OsmandApplication extends MultiDexApplication {
|
|||
private final OsmAndTaskManager taskManager = new OsmAndTaskManager(this);
|
||||
private final IconsCache iconsCache = new IconsCache(this);
|
||||
Handler uiHandler;
|
||||
private boolean plusVersionInApp;
|
||||
|
||||
NavigationService navigationService;
|
||||
|
||||
|
@ -167,6 +168,7 @@ public class OsmandApplication extends MultiDexApplication {
|
|||
// targetPointsHelper.clearPointToNavigate(false);
|
||||
// }
|
||||
initExternalLibs();
|
||||
plusVersionInApp = getRemoteBoolean(SHOW_PLUS_VERSION_INAPP_PARAM, true);
|
||||
startApplication();
|
||||
System.out.println("Time to start application " + (System.currentTimeMillis() - timeToStart) + " ms. Should be less < 800 ms");
|
||||
timeToStart = System.currentTimeMillis();
|
||||
|
@ -176,6 +178,10 @@ public class OsmandApplication extends MultiDexApplication {
|
|||
SearchUICore.setDebugMode(OsmandPlugin.isDevelopment());
|
||||
}
|
||||
|
||||
public boolean isPlusVersionInApp() {
|
||||
return plusVersionInApp;
|
||||
}
|
||||
|
||||
public boolean isExternalStorageDirectoryReadOnly() {
|
||||
return externalStorageDirectoryReadOnly;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package net.osmand.plus.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
|
@ -17,8 +19,6 @@ import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseTaskType;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import static net.osmand.plus.OsmandApplication.SHOW_PLUS_VERSION_INAPP_PARAM;
|
||||
|
||||
@SuppressLint("Registered")
|
||||
public class OsmandInAppPurchaseActivity extends AppCompatActivity implements InAppPurchaseListener {
|
||||
private static final Log LOG = PlatformUtil.getLog(OsmandInAppPurchaseActivity.class);
|
||||
|
@ -74,20 +74,21 @@ public class OsmandInAppPurchaseActivity extends AppCompatActivity implements In
|
|||
}
|
||||
}
|
||||
|
||||
public void purchaseFullVersion() {
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (Version.isFreeVersion(app)) {
|
||||
if (app.getRemoteBoolean(SHOW_PLUS_VERSION_INAPP_PARAM, true)) {
|
||||
public static void purchaseFullVersion(@NonNull final Activity activity) {
|
||||
OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
if (app != null && Version.isFreeVersion(app)) {
|
||||
if (app.isPlusVersionInApp()) {
|
||||
InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
|
||||
if (purchaseHelper != null) {
|
||||
app.logEvent(this, "in_app_purchase_redirect");
|
||||
purchaseHelper.purchaseFullVersion(this);
|
||||
app.logEvent(activity, "in_app_purchase_redirect");
|
||||
purchaseHelper.purchaseFullVersion(activity);
|
||||
}
|
||||
} else {
|
||||
app.logEvent(this, "paid_version_redirect");
|
||||
app.logEvent(activity, "paid_version_redirect");
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW,
|
||||
Uri.parse(Version.getUrlWithUtmRef(app, "net.osmand.plus")));
|
||||
try {
|
||||
startActivity(intent);
|
||||
activity.startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
LOG.error("ActivityNotFoundException", e);
|
||||
}
|
||||
|
@ -95,10 +96,14 @@ public class OsmandInAppPurchaseActivity extends AppCompatActivity implements In
|
|||
}
|
||||
}
|
||||
|
||||
public void purchaseDepthContours() {
|
||||
public static void purchaseDepthContours(@NonNull final Activity activity) {
|
||||
OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
if (app != null) {
|
||||
InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
|
||||
if (purchaseHelper != null) {
|
||||
getMyApplication().logEvent(this, "depth_contours_purchase_redirect");
|
||||
purchaseHelper.purchaseDepthContours(this);
|
||||
app.logEvent(activity, "depth_contours_purchase_redirect");
|
||||
purchaseHelper.purchaseDepthContours(activity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +1,24 @@
|
|||
package net.osmand.plus.dialogs;
|
||||
package net.osmand.plus.chooseplan;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.AppCompatImageView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.LinearLayout;
|
||||
|
@ -29,10 +30,8 @@ import net.osmand.PlatformUtil;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.BaseOsmAndDialogFragment;
|
||||
import net.osmand.plus.download.DownloadValidationManager;
|
||||
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
||||
import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseListener;
|
||||
import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseTaskType;
|
||||
|
@ -42,99 +41,18 @@ import net.osmand.plus.widgets.TextViewEx;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import static net.osmand.plus.OsmandApplication.SHOW_PLUS_VERSION_INAPP_PARAM;
|
||||
|
||||
public class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment implements InAppPurchaseListener {
|
||||
public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment implements InAppPurchaseListener {
|
||||
public static final String TAG = ChoosePlanDialogFragment.class.getSimpleName();
|
||||
private static final Log LOG = PlatformUtil.getLog(ChoosePlanDialogFragment.class);
|
||||
|
||||
private static final String PLAN_TYPE_KEY = "plan_type";
|
||||
|
||||
private OsmandApplication app;
|
||||
private InAppPurchaseHelper purchaseHelper;
|
||||
|
||||
private boolean nightMode;
|
||||
private PlanType planType;
|
||||
|
||||
private View osmLiveCardButton;
|
||||
private View planTypeCardButton;
|
||||
|
||||
public enum PlanType {
|
||||
FREE_VERSION_BANNER(
|
||||
new OsmAndFeature[]{
|
||||
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,
|
||||
},
|
||||
new OsmAndFeature[]{
|
||||
OsmAndFeature.DAILY_MAP_UPDATES,
|
||||
OsmAndFeature.UNLIMITED_DOWNLOADS,
|
||||
},
|
||||
new OsmAndFeature[]{
|
||||
OsmAndFeature.WIKIPEDIA_OFFLINE,
|
||||
OsmAndFeature.WIKIVOYAGE_OFFLINE,
|
||||
OsmAndFeature.UNLIMITED_DOWNLOADS,
|
||||
OsmAndFeature.MONTHLY_MAP_UPDATES,
|
||||
},
|
||||
new OsmAndFeature[]{});
|
||||
|
||||
private final OsmAndFeature[] osmLiveFeatures;
|
||||
private final OsmAndFeature[] planTypeFeatures;
|
||||
private final OsmAndFeature[] selectedOsmLiveFeatures;
|
||||
private final OsmAndFeature[] selectedPlanTypeFeatures;
|
||||
|
||||
PlanType(OsmAndFeature[] osmLiveFeatures, OsmAndFeature[] selectedOsmLiveFeatures,
|
||||
OsmAndFeature[] planTypeFeatures, OsmAndFeature[] selectedPlanTypeFeatures) {
|
||||
this.osmLiveFeatures = osmLiveFeatures;
|
||||
this.planTypeFeatures = planTypeFeatures;
|
||||
this.selectedOsmLiveFeatures = selectedOsmLiveFeatures;
|
||||
this.selectedPlanTypeFeatures = selectedPlanTypeFeatures;
|
||||
}
|
||||
|
||||
public OsmAndFeature[] getOsmLiveFeatures() {
|
||||
return osmLiveFeatures;
|
||||
}
|
||||
|
||||
public OsmAndFeature[] getPlanTypeFeatures() {
|
||||
return planTypeFeatures;
|
||||
}
|
||||
|
||||
public OsmAndFeature[] getSelectedOsmLiveFeatures() {
|
||||
return selectedOsmLiveFeatures;
|
||||
}
|
||||
|
||||
public OsmAndFeature[] getSelectedPlanTypeFeatures() {
|
||||
return selectedPlanTypeFeatures;
|
||||
}
|
||||
|
||||
public boolean hasSelectedOsmLiveFeature(OsmAndFeature feature) {
|
||||
if (selectedOsmLiveFeatures != null) {
|
||||
for (OsmAndFeature f : selectedOsmLiveFeatures) {
|
||||
if (feature == f) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasSelectedPlanTypeFeature(OsmAndFeature feature) {
|
||||
if (selectedPlanTypeFeatures != null) {
|
||||
for (OsmAndFeature f : selectedPlanTypeFeatures) {
|
||||
if (feature == f) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public enum OsmAndFeature {
|
||||
WIKIVOYAGE_OFFLINE(R.string.wikivoyage_offline),
|
||||
DAILY_MAP_UPDATES(R.string.daily_map_updates),
|
||||
|
@ -180,24 +98,33 @@ public class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment implement
|
|||
}
|
||||
}
|
||||
|
||||
public boolean hasSelectedOsmLiveFeature(OsmAndFeature feature) {
|
||||
if (getSelectedOsmLiveFeatures() != null) {
|
||||
for (OsmAndFeature f : getSelectedOsmLiveFeatures()) {
|
||||
if (feature == f) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasSelectedPlanTypeFeature(OsmAndFeature feature) {
|
||||
if (getSelectedPlanTypeFeatures() != null) {
|
||||
for (OsmAndFeature f : getSelectedPlanTypeFeatures()) {
|
||||
if (feature == f) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
app = getMyApplication();
|
||||
purchaseHelper = app.getInAppPurchaseHelper();
|
||||
|
||||
Bundle args = getArguments();
|
||||
if (args == null) {
|
||||
args = savedInstanceState;
|
||||
}
|
||||
if (args != null) {
|
||||
String planTypeStr = args.getString(PLAN_TYPE_KEY);
|
||||
if (!TextUtils.isEmpty(planTypeStr)) {
|
||||
planType = PlanType.valueOf(planTypeStr);
|
||||
}
|
||||
}
|
||||
|
||||
nightMode = isNightMode(getMapActivity() != null);
|
||||
}
|
||||
|
||||
|
@ -222,18 +149,18 @@ public class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment implement
|
|||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
Context ctx = getContext();
|
||||
if (planType == null || ctx == null) {
|
||||
if (ctx == null) {
|
||||
return null;
|
||||
}
|
||||
View view = inflate(R.layout.purchase_dialog_fragment, container);
|
||||
|
||||
view.findViewById(R.id.button_back).setOnClickListener(new View.OnClickListener() {
|
||||
view.findViewById(R.id.button_back).setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
view.findViewById(R.id.button_later).setOnClickListener(new View.OnClickListener() {
|
||||
view.findViewById(R.id.button_later).setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
|
@ -243,13 +170,8 @@ public class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment implement
|
|||
ViewGroup infoContainer = (ViewGroup) view.findViewById(R.id.info_container);
|
||||
TextViewEx infoDescription = (TextViewEx) view.findViewById(R.id.info_description);
|
||||
ViewGroup cardsContainer = (ViewGroup) view.findViewById(R.id.cards_container);
|
||||
|
||||
switch (planType) {
|
||||
case FREE_VERSION_BANNER: {
|
||||
infoDescription.setText(getString(R.string.free_version_message,
|
||||
DownloadValidationManager.MAXIMUM_AVAILABLE_FREE_DOWNLOADS));
|
||||
break;
|
||||
}
|
||||
if (!TextUtils.isEmpty(getInfoDescription())) {
|
||||
infoDescription.setText(getInfoDescription());
|
||||
}
|
||||
cardsContainer.addView(buildOsmLiveCard(ctx, cardsContainer));
|
||||
cardsContainer.addView(buildPlanTypeCard(ctx, cardsContainer));
|
||||
|
@ -261,6 +183,29 @@ public class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment implement
|
|||
return nightMode ? R.color.status_bar_wikivoyage_dark : R.color.status_bar_wikivoyage_light;
|
||||
}
|
||||
|
||||
public OsmandApplication getOsmandApplication() {
|
||||
return app;
|
||||
}
|
||||
|
||||
public abstract OsmAndFeature[] getOsmLiveFeatures();
|
||||
|
||||
public abstract OsmAndFeature[] getPlanTypeFeatures();
|
||||
|
||||
public abstract OsmAndFeature[] getSelectedOsmLiveFeatures();
|
||||
|
||||
public abstract OsmAndFeature[] getSelectedPlanTypeFeatures();
|
||||
|
||||
public abstract String getInfoDescription();
|
||||
|
||||
@DrawableRes
|
||||
public abstract int getPlanTypeHeaderImageId();
|
||||
|
||||
public abstract String getPlanTypeHeaderTitle();
|
||||
|
||||
public abstract String getPlanTypeHeaderDescription();
|
||||
|
||||
public abstract void setPlanTypeButtonClickListener(View button);
|
||||
|
||||
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))
|
||||
|
@ -275,9 +220,9 @@ public class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment implement
|
|||
headerDescr.setText(R.string.osm_live_subscription);
|
||||
ViewGroup rowsContainer = (ViewGroup) cardView.findViewById(R.id.rows_container);
|
||||
View featureRowDiv = null;
|
||||
for (OsmAndFeature feature : planType.getOsmLiveFeatures()) {
|
||||
for (OsmAndFeature feature : getOsmLiveFeatures()) {
|
||||
String featureName = feature.toHumanString(ctx);
|
||||
View featureRow = inflate(planType.hasSelectedOsmLiveFeature(feature)
|
||||
View featureRow = inflate(hasSelectedOsmLiveFeature(feature)
|
||||
? R.layout.purchase_dialog_card_selected_row : R.layout.purchase_dialog_card_row, cardView);
|
||||
TextViewEx titleView = (TextViewEx) featureRow.findViewById(R.id.title);
|
||||
titleView.setText(featureName);
|
||||
|
@ -321,7 +266,7 @@ public class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment implement
|
|||
buttonTitle.setVisibility(View.VISIBLE);
|
||||
buttonSubtitle.setVisibility(View.VISIBLE);
|
||||
progressBar.setVisibility(View.GONE);
|
||||
osmLiveCardButton.setOnClickListener(new View.OnClickListener() {
|
||||
osmLiveCardButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
subscript();
|
||||
|
@ -345,15 +290,27 @@ public class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment implement
|
|||
|
||||
private ViewGroup buildPlanTypeCard(@NonNull Context ctx, ViewGroup container) {
|
||||
ViewGroup cardView = (ViewGroup) inflate(R.layout.purchase_dialog_card, container);
|
||||
TextView headerTitle = (TextView) cardView.findViewById(R.id.header_title);
|
||||
TextView headerDescr = (TextView) cardView.findViewById(R.id.header_descr);
|
||||
headerTitle.setText(R.string.osmand_unlimited);
|
||||
headerDescr.setText(R.string.in_app_purchase);
|
||||
AppCompatImageView headerImageView = (AppCompatImageView) cardView.findViewById(R.id.header_img);
|
||||
TextView headerTitleView = (TextView) cardView.findViewById(R.id.header_title);
|
||||
TextView headerDescrView = (TextView) cardView.findViewById(R.id.header_descr);
|
||||
int headerImageId = getPlanTypeHeaderImageId();
|
||||
if (headerImageId != 0) {
|
||||
headerImageView.setImageDrawable(getIcon(headerImageId, 0));
|
||||
}
|
||||
String headerTitle = getPlanTypeHeaderTitle();
|
||||
if (!TextUtils.isEmpty(headerTitle)) {
|
||||
headerTitleView.setText(headerTitle);
|
||||
}
|
||||
String headerDescr = getPlanTypeHeaderDescription();
|
||||
if (!TextUtils.isEmpty(headerDescr)) {
|
||||
headerDescrView.setText(headerDescr);
|
||||
}
|
||||
|
||||
ViewGroup rowsContainer = (ViewGroup) cardView.findViewById(R.id.rows_container);
|
||||
View featureRow = null;
|
||||
for (OsmAndFeature feature : planType.getPlanTypeFeatures()) {
|
||||
for (OsmAndFeature feature : getPlanTypeFeatures()) {
|
||||
String featureName = feature.toHumanString(ctx);
|
||||
featureRow = inflate(planType.hasSelectedPlanTypeFeature(feature)
|
||||
featureRow = inflate(hasSelectedPlanTypeFeature(feature)
|
||||
? R.layout.purchase_dialog_card_selected_row : R.layout.purchase_dialog_card_row, cardView);
|
||||
TextViewEx titleView = (TextViewEx) featureRow.findViewById(R.id.title);
|
||||
titleView.setText(featureName);
|
||||
|
@ -393,49 +350,11 @@ public class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment implement
|
|||
buttonTitle.setVisibility(View.VISIBLE);
|
||||
buttonSubtitle.setVisibility(View.VISIBLE);
|
||||
progressBar.setVisibility(View.GONE);
|
||||
planTypeCardButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
purchaseFullVersion();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
setPlanTypeButtonClickListener(planTypeCardButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void purchaseFullVersion() {
|
||||
if (app.getRemoteBoolean(SHOW_PLUS_VERSION_INAPP_PARAM, true)) {
|
||||
app.logEvent(getActivity(), "in_app_purchase_redirect_from_banner");
|
||||
} else {
|
||||
app.logEvent(getActivity(), "paid_version_redirect_from_banner");
|
||||
}
|
||||
if (Version.isFreeVersion(app)) {
|
||||
if (app.getRemoteBoolean(SHOW_PLUS_VERSION_INAPP_PARAM, true)) {
|
||||
InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
|
||||
if (purchaseHelper != null) {
|
||||
app.logEvent(getActivity(), "in_app_purchase_redirect");
|
||||
purchaseHelper.purchaseFullVersion(getActivity());
|
||||
}
|
||||
} else {
|
||||
app.logEvent(getActivity(), "paid_version_redirect");
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW,
|
||||
Uri.parse(Version.getUrlWithUtmRef(app, "net.osmand.plus")));
|
||||
try {
|
||||
startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
LOG.error("ActivityNotFoundException", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putString(PLAN_TYPE_KEY, planType.name());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MapActivity getMapActivity() {
|
||||
Activity activity = getActivity();
|
||||
|
@ -498,21 +417,29 @@ public class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment implement
|
|||
}
|
||||
|
||||
public static void showFreeVersionInstance(@NonNull FragmentManager fm) {
|
||||
PlanType planType = PlanType.FREE_VERSION_BANNER;
|
||||
showInstance(fm, planType);
|
||||
}
|
||||
|
||||
private static void showInstance(@NonNull FragmentManager fm, PlanType planType) {
|
||||
try {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PLAN_TYPE_KEY, planType.name());
|
||||
|
||||
ChoosePlanDialogFragment fragment = new ChoosePlanDialogFragment();
|
||||
fragment.setArguments(args);
|
||||
fragment.show(fm, TAG);
|
||||
|
||||
ChoosePlanFreeBannerDialogFragment fragment = new ChoosePlanFreeBannerDialogFragment();
|
||||
fragment.show(fm, ChoosePlanFreeBannerDialogFragment.TAG);
|
||||
} catch (RuntimeException e) {
|
||||
LOG.error("showInstance", e);
|
||||
LOG.error("showFreeVersionInstance", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void showWikipediaInstance(@NonNull FragmentManager fm) {
|
||||
try {
|
||||
ChoosePlanWikipediaDialogFragment fragment = new ChoosePlanWikipediaDialogFragment();
|
||||
fragment.show(fm, ChoosePlanWikipediaDialogFragment.TAG);
|
||||
} catch (RuntimeException e) {
|
||||
LOG.error("showWikipediaInstance", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void showSeaDepthMapsInstance(@NonNull FragmentManager fm) {
|
||||
try {
|
||||
ChoosePlanSeaDepthMapsDialogFragment fragment = new ChoosePlanSeaDepthMapsDialogFragment();
|
||||
fragment.show(fm, ChoosePlanSeaDepthMapsDialogFragment.TAG);
|
||||
} catch (RuntimeException e) {
|
||||
LOG.error("showSeaDepthMapsInstance", e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package net.osmand.plus.chooseplan;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.OsmandInAppPurchaseActivity;
|
||||
import net.osmand.plus.download.DownloadValidationManager;
|
||||
|
||||
public class ChoosePlanFreeBannerDialogFragment extends ChoosePlanDialogFragment {
|
||||
public static final String TAG = ChoosePlanFreeBannerDialogFragment.class.getSimpleName();
|
||||
|
||||
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,
|
||||
};
|
||||
private final OsmAndFeature[] selectedOsmLiveFeatures = {
|
||||
OsmAndFeature.DAILY_MAP_UPDATES,
|
||||
OsmAndFeature.UNLIMITED_DOWNLOADS,
|
||||
};
|
||||
|
||||
private final OsmAndFeature[] planTypeFeatures = {
|
||||
OsmAndFeature.WIKIPEDIA_OFFLINE,
|
||||
OsmAndFeature.WIKIVOYAGE_OFFLINE,
|
||||
OsmAndFeature.UNLIMITED_DOWNLOADS,
|
||||
OsmAndFeature.MONTHLY_MAP_UPDATES,
|
||||
};
|
||||
private final OsmAndFeature[] selectedPlanTypeFeatures = {};
|
||||
|
||||
@Override
|
||||
public OsmAndFeature[] getOsmLiveFeatures() {
|
||||
return osmLiveFeatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OsmAndFeature[] getPlanTypeFeatures() {
|
||||
return planTypeFeatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OsmAndFeature[] getSelectedOsmLiveFeatures() {
|
||||
return selectedOsmLiveFeatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OsmAndFeature[] getSelectedPlanTypeFeatures() {
|
||||
return selectedPlanTypeFeatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoDescription() {
|
||||
return getString(R.string.free_version_message,
|
||||
DownloadValidationManager.MAXIMUM_AVAILABLE_FREE_DOWNLOADS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlanTypeHeaderImageId() {
|
||||
return R.drawable.img_logo_38dp_osmand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlanTypeHeaderTitle() {
|
||||
return getString(R.string.osmand_unlimited);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlanTypeHeaderDescription() {
|
||||
if (getOsmandApplication().isPlusVersionInApp()) {
|
||||
return getString(R.string.in_app_purchase);
|
||||
} else {
|
||||
return getString(R.string.paid_app);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlanTypeButtonClickListener(View button) {
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
OsmandApplication app = getOsmandApplication();
|
||||
if (app.isPlusVersionInApp()) {
|
||||
app.logEvent(getActivity(), "in_app_purchase_redirect_from_banner");
|
||||
} else {
|
||||
app.logEvent(getActivity(), "paid_version_redirect_from_banner");
|
||||
}
|
||||
OsmandInAppPurchaseActivity.purchaseFullVersion(activity);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package net.osmand.plus.chooseplan;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.OsmandInAppPurchaseActivity;
|
||||
|
||||
public class ChoosePlanSeaDepthMapsDialogFragment extends ChoosePlanDialogFragment {
|
||||
public static final String TAG = ChoosePlanSeaDepthMapsDialogFragment.class.getSimpleName();
|
||||
|
||||
private final OsmAndFeature[] osmLiveFeatures = {
|
||||
OsmAndFeature.CONTOUR_LINES_HILLSHADE_MAPS,
|
||||
OsmAndFeature.SEA_DEPTH_MAPS,
|
||||
OsmAndFeature.WIKIPEDIA_OFFLINE,
|
||||
OsmAndFeature.WIKIVOYAGE_OFFLINE,
|
||||
OsmAndFeature.DAILY_MAP_UPDATES,
|
||||
OsmAndFeature.UNLIMITED_DOWNLOADS,
|
||||
OsmAndFeature.UNLOCK_ALL_FEATURES,
|
||||
OsmAndFeature.DONATION_TO_OSM,
|
||||
};
|
||||
private final OsmAndFeature[] selectedOsmLiveFeatures = {
|
||||
OsmAndFeature.CONTOUR_LINES_HILLSHADE_MAPS,
|
||||
OsmAndFeature.SEA_DEPTH_MAPS,
|
||||
};
|
||||
|
||||
private final OsmAndFeature[] planTypeFeatures = {
|
||||
OsmAndFeature.SEA_DEPTH_MAPS,
|
||||
};
|
||||
private final OsmAndFeature[] selectedPlanTypeFeatures = {};
|
||||
|
||||
@Override
|
||||
public OsmAndFeature[] getOsmLiveFeatures() {
|
||||
return osmLiveFeatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OsmAndFeature[] getPlanTypeFeatures() {
|
||||
return planTypeFeatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OsmAndFeature[] getSelectedOsmLiveFeatures() {
|
||||
return selectedOsmLiveFeatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OsmAndFeature[] getSelectedPlanTypeFeatures() {
|
||||
return selectedPlanTypeFeatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoDescription() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlanTypeHeaderImageId() {
|
||||
return R.drawable.img_logo_38dp_sea_depth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlanTypeHeaderTitle() {
|
||||
return getString(R.string.index_item_depth_contours_osmand_ext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlanTypeHeaderDescription() {
|
||||
return getString(R.string.in_app_purchase);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlanTypeButtonClickListener(View button) {
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
OsmandInAppPurchaseActivity.purchaseDepthContours(activity);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package net.osmand.plus.chooseplan;
|
||||
|
||||
public class ChoosePlanWikipediaDialogFragment extends ChoosePlanFreeBannerDialogFragment {
|
||||
public static final String TAG = ChoosePlanWikipediaDialogFragment.class.getSimpleName();
|
||||
|
||||
private final OsmAndFeature[] osmLiveFeatures = {
|
||||
OsmAndFeature.WIKIPEDIA_OFFLINE,
|
||||
OsmAndFeature.WIKIVOYAGE_OFFLINE,
|
||||
OsmAndFeature.DAILY_MAP_UPDATES,
|
||||
OsmAndFeature.UNLIMITED_DOWNLOADS,
|
||||
OsmAndFeature.CONTOUR_LINES_HILLSHADE_MAPS,
|
||||
OsmAndFeature.SEA_DEPTH_MAPS,
|
||||
OsmAndFeature.UNLOCK_ALL_FEATURES,
|
||||
OsmAndFeature.DONATION_TO_OSM,
|
||||
};
|
||||
private final OsmAndFeature[] selectedOsmLiveFeatures = {
|
||||
OsmAndFeature.WIKIPEDIA_OFFLINE,
|
||||
OsmAndFeature.WIKIVOYAGE_OFFLINE,
|
||||
};
|
||||
|
||||
private final OsmAndFeature[] planTypeFeatures = {
|
||||
OsmAndFeature.WIKIPEDIA_OFFLINE,
|
||||
OsmAndFeature.WIKIVOYAGE_OFFLINE,
|
||||
OsmAndFeature.UNLIMITED_DOWNLOADS,
|
||||
OsmAndFeature.MONTHLY_MAP_UPDATES,
|
||||
};
|
||||
private final OsmAndFeature[] selectedPlanTypeFeatures = {};
|
||||
|
||||
@Override
|
||||
public OsmAndFeature[] getOsmLiveFeatures() {
|
||||
return osmLiveFeatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OsmAndFeature[] getPlanTypeFeatures() {
|
||||
return planTypeFeatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OsmAndFeature[] getSelectedOsmLiveFeatures() {
|
||||
return selectedOsmLiveFeatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OsmAndFeature[] getSelectedPlanTypeFeatures() {
|
||||
return selectedPlanTypeFeatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoDescription() {
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -51,14 +51,13 @@ import net.osmand.plus.activities.MapActivity;
|
|||
import net.osmand.plus.activities.TabActivity;
|
||||
import net.osmand.plus.base.BasicProgressAsyncTask;
|
||||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
||||
import net.osmand.plus.dialogs.ChoosePlanDialogFragment;
|
||||
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
|
||||
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
|
||||
import net.osmand.plus.download.ui.ActiveDownloadsDialogFragment;
|
||||
import net.osmand.plus.download.ui.DownloadResourceGroupFragment;
|
||||
import net.osmand.plus.download.ui.LocalIndexesFragment;
|
||||
import net.osmand.plus.download.ui.UpdatesIndexFragment;
|
||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
||||
import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseListener;
|
||||
import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseTaskType;
|
||||
import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin;
|
||||
|
|
|
@ -25,6 +25,7 @@ import net.osmand.plus.OsmandPlugin;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType;
|
||||
import net.osmand.plus.activities.LocalIndexInfo;
|
||||
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
|
||||
import net.osmand.plus.download.CityItem;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.DownloadActivityType;
|
||||
|
@ -333,10 +334,10 @@ public class ItemViewHolder {
|
|||
switch (clickAction) {
|
||||
case ASK_FOR_FULL_VERSION_PURCHASE:
|
||||
context.getMyApplication().logEvent(context, "in_app_purchase_show_from_wiki_context_menu");
|
||||
context.purchaseFullVersion();
|
||||
ChoosePlanDialogFragment.showWikipediaInstance(context.getSupportFragmentManager());
|
||||
break;
|
||||
case ASK_FOR_DEPTH_CONTOURS_PURCHASE:
|
||||
context.purchaseDepthContours();
|
||||
ChoosePlanDialogFragment.showSeaDepthMapsInstance(context.getSupportFragmentManager());
|
||||
break;
|
||||
case ASK_FOR_SEAMARKS_PLUGIN:
|
||||
context.startActivity(new Intent(context, context.getMyApplication().getAppCustomization()
|
||||
|
|
|
@ -9,7 +9,7 @@ import android.widget.TextView;
|
|||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.dialogs.ChoosePlanDialogFragment;
|
||||
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
|
||||
|
||||
public class OpenBetaTravelCard extends BaseTravelCard {
|
||||
|
||||
|
|
Loading…
Reference in a new issue