diff --git a/OsmAnd/res/layout/subscription_fragment.xml b/OsmAnd/res/layout/subscription_fragment.xml
index b9c4ce6480..8fe6d11e04 100644
--- a/OsmAnd/res/layout/subscription_fragment.xml
+++ b/OsmAnd/res/layout/subscription_fragment.xml
@@ -15,17 +15,17 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:orientation="vertical"
+ android:visibility="visible">
-
-
-
-
+ android:minHeight="56dp"
+ android:orientation="horizontal">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -185,99 +295,111 @@
-
+
+
+ android:layout_height="8dp"/>
-
-
-
+
-
+
-
+ android:layout_marginRight="16dp"
+ android:orientation="vertical">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 5426081d04..fe3de6beff 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -1,4 +1,4 @@
-
+
+ Subscription fee will be charged each month. You can always cancel your subscription on Google Play.
+ Donation to OpenStreetMap community
+ Part of your donation will be sent to OSM users who submit changes to the OpenStreetMaps. Cost of the subscription remains the same.
+ Subscription enables hourly, daily, weekly updates and unlimited downloads for all maps around the world.
Get it
Get for %1$s
Get for %1$s month
diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
index 876b9c30f3..f8daed640a 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
@@ -895,11 +895,14 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference USER_NAME = new StringPreference("user_name", "").makeGlobal();
+ public static final String BILLING_USER_DONATION_WORLD_PARAMETER = "";
+ public static final String BILLING_USER_DONATION_NONE_PARAMETER = "none";
+
public final OsmandPreference BILLING_USER_ID = new StringPreference("billing_user_id", "").makeGlobal();
public final OsmandPreference BILLING_USER_NAME = new StringPreference("billing_user_name", "").makeGlobal();
public final OsmandPreference BILLING_USER_EMAIL = new StringPreference("billing_user_email", "").makeGlobal();
public final OsmandPreference BILLING_USER_COUNTRY = new StringPreference("billing_user_country", "").makeGlobal();
- public final OsmandPreference BILLING_USER_COUNTRY_DOWNLOAD_NAME = new StringPreference("billing_user_country_download_name", "").makeGlobal();
+ public final OsmandPreference BILLING_USER_COUNTRY_DOWNLOAD_NAME = new StringPreference("billing_user_country_download_name", BILLING_USER_DONATION_NONE_PARAMETER).makeGlobal();
public final OsmandPreference BILLING_HIDE_USER_NAME = new BooleanPreference("billing_hide_user_name", false).makeGlobal();
public final OsmandPreference BILLING_PURCHASE_TOKEN_SENT = new BooleanPreference("billing_purchase_token_sent", false).makeGlobal();
public final OsmandPreference LIVE_UPDATES_PURCHASED = new BooleanPreference("billing_live_updates_purchased", false).makeGlobal();
diff --git a/OsmAnd/src/net/osmand/plus/inapp/InAppHelper.java b/OsmAnd/src/net/osmand/plus/inapp/InAppHelper.java
index 1c779e824b..1329384af4 100644
--- a/OsmAnd/src/net/osmand/plus/inapp/InAppHelper.java
+++ b/OsmAnd/src/net/osmand/plus/inapp/InAppHelper.java
@@ -463,10 +463,10 @@ public class InAppHelper {
ctx.getSettings().BILLING_USER_COUNTRY_DOWNLOAD_NAME.set(prefferedCountry);
CountrySelectionFragment countrySelectionFragment = new CountrySelectionFragment();
countrySelectionFragment.initCountries(ctx);
- CountryItem countryItem;
+ CountryItem countryItem = null;
if (Algorithms.isEmpty(prefferedCountry)) {
countryItem = countrySelectionFragment.getCountryItems().get(0);
- } else {
+ } else if (!prefferedCountry.equals(OsmandSettings.BILLING_USER_DONATION_NONE_PARAMETER)) {
countryItem = countrySelectionFragment.getCountryItem(prefferedCountry);
}
if (countryItem != null) {
diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/SubscriptionFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/SubscriptionFragment.java
index 2b2ecfa9bb..9bf0362f2a 100644
--- a/OsmAnd/src/net/osmand/plus/liveupdates/SubscriptionFragment.java
+++ b/OsmAnd/src/net/osmand/plus/liveupdates/SubscriptionFragment.java
@@ -4,12 +4,14 @@ import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.v4.app.Fragment;
+import android.support.v7.widget.AppCompatCheckBox;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
+import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
@@ -41,10 +43,12 @@ public class SubscriptionFragment extends BaseOsmAndDialogFragment implements In
private static final String EMAIL_ID = "email_id";
private static final String COUNTRY_ITEM_ID = "country_id";
private static final String HIDE_USER_NAME_ID = "hide_user_name_id";
+ private static final String DONATION_ID = "donation_id";
private OsmandSettings settings;
private ProgressDialog dlg;
private boolean editMode;
+ private boolean donation;
private String prevEmail;
private CountryItem selectedCountryItem;
@@ -76,6 +80,8 @@ public class SubscriptionFragment extends BaseOsmAndDialogFragment implements In
outState.putString(EMAIL_ID, emailEdit.getText().toString());
CheckBox hideUserNameCheckbox = (CheckBox) view.findViewById(R.id.hideUserNameCheckbox);
outState.putBoolean(HIDE_USER_NAME_ID, hideUserNameCheckbox.isChecked());
+ CheckBox donationCheckbox = (CheckBox) view.findViewById(R.id.donationCheckbox);
+ outState.putBoolean(DONATION_ID, donationCheckbox.isChecked());
if (selectedCountryItem != null) {
outState.putSerializable(COUNTRY_ITEM_ID, selectedCountryItem);
}
@@ -109,17 +115,20 @@ public class SubscriptionFragment extends BaseOsmAndDialogFragment implements In
String email = settings.BILLING_USER_EMAIL.get();
String countryDownloadName = settings.BILLING_USER_COUNTRY_DOWNLOAD_NAME.get();
boolean hideUserName = settings.BILLING_HIDE_USER_NAME.get();
+ donation = !countryDownloadName.equals(OsmandSettings.BILLING_USER_DONATION_NONE_PARAMETER);
if (savedInstanceState != null) {
userName = savedInstanceState.getString(USER_NAME_ID);
email = savedInstanceState.getString(EMAIL_ID);
hideUserName = savedInstanceState.getBoolean(HIDE_USER_NAME_ID);
+ donation = savedInstanceState.getBoolean(DONATION_ID);
Object obj = savedInstanceState.getSerializable(COUNTRY_ITEM_ID);
if (obj instanceof CountryItem) {
selectedCountryItem = (CountryItem) obj;
countryDownloadName = selectedCountryItem.getDownloadName();
} else {
- countryDownloadName = "";
+ countryDownloadName =
+ donation ? OsmandSettings.BILLING_USER_DONATION_WORLD_PARAMETER : OsmandSettings.BILLING_USER_DONATION_NONE_PARAMETER;
}
}
@@ -144,6 +153,20 @@ public class SubscriptionFragment extends BaseOsmAndDialogFragment implements In
title.setText(getString(R.string.osm_live_subscription));
}
+ final View headerLayout = view.findViewById(R.id.headerLayout);
+ final View paramsLayout = view.findViewById(R.id.paramsLayout);
+ AppCompatCheckBox donationCheckbox = (AppCompatCheckBox) view.findViewById(R.id.donationCheckbox);
+ donationCheckbox.setChecked(donation);
+ donationCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ donation = isChecked;
+ paramsLayout.setVisibility(isChecked ? View.VISIBLE : View.GONE);
+ }
+ });
+ headerLayout.setVisibility(View.VISIBLE);
+ paramsLayout.setVisibility(donation ? View.VISIBLE : View.GONE);
+
final EditText userNameEdit = (EditText) view.findViewById(R.id.userNameEdit);
if (!Algorithms.isEmpty(userName)) {
userNameEdit.setText(userName);
@@ -155,7 +178,7 @@ public class SubscriptionFragment extends BaseOsmAndDialogFragment implements In
}
countrySelectionFragment.initCountries(getMyApplication());
- if (Algorithms.isEmpty(countryDownloadName)) {
+ if (Algorithms.isEmpty(countryDownloadName) || countryDownloadName.equals(OsmandSettings.BILLING_USER_DONATION_NONE_PARAMETER)) {
selectedCountryItem = countrySelectionFragment.getCountryItems().get(0);
} else {
selectedCountryItem = countrySelectionFragment.getCountryItem(countryDownloadName);
@@ -297,16 +320,23 @@ public class SubscriptionFragment extends BaseOsmAndDialogFragment implements In
}
private boolean applySettings(String userName, String email, boolean hideUserName) {
- String countryName = selectedCountryItem != null ? selectedCountryItem.getLocalName() : "";
- String countryDownloadName = selectedCountryItem != null ? selectedCountryItem.getDownloadName() : "";
-
- if (Algorithms.isEmpty(email) || !AndroidUtils.isValidEmail(email)) {
- getMyApplication().showToastMessage(getString(R.string.osm_live_enter_email));
- return false;
- }
- if (Algorithms.isEmpty(userName) && !hideUserName) {
- getMyApplication().showToastMessage(getString(R.string.osm_live_enter_user_name));
- return false;
+ String countryName;
+ String countryDownloadName;
+ if (!donation) {
+ countryName = "";
+ countryDownloadName = OsmandSettings.BILLING_USER_DONATION_NONE_PARAMETER;
+ } else {
+ countryName = selectedCountryItem != null ? selectedCountryItem.getLocalName() : "";
+ countryDownloadName = selectedCountryItem != null ?
+ selectedCountryItem.getDownloadName() : OsmandSettings.BILLING_USER_DONATION_WORLD_PARAMETER;
+ if (Algorithms.isEmpty(email) || !AndroidUtils.isValidEmail(email)) {
+ getMyApplication().showToastMessage(getString(R.string.osm_live_enter_email));
+ return false;
+ }
+ if (Algorithms.isEmpty(userName) && !hideUserName) {
+ getMyApplication().showToastMessage(getString(R.string.osm_live_enter_user_name));
+ return false;
+ }
}
settings.BILLING_USER_NAME.set(userName);