diff --git a/OsmAnd/res/layout-land/dest_reached_menu_fragment.xml b/OsmAnd/res/layout-land/dest_reached_menu_fragment.xml
new file mode 100644
index 0000000000..0114ce6554
--- /dev/null
+++ b/OsmAnd/res/layout-land/dest_reached_menu_fragment.xml
@@ -0,0 +1,121 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/dest_reached_menu_fragment.xml b/OsmAnd/res/layout/dest_reached_menu_fragment.xml
new file mode 100644
index 0000000000..33e34b83e8
--- /dev/null
+++ b/OsmAnd/res/layout/dest_reached_menu_fragment.xml
@@ -0,0 +1,121 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 871b31d398..47b82a856d 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +9,7 @@
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
-->
+ Find a parking
Status
Save changes
E-mail address
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
index 551cb2727f..dc958051a3 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
@@ -35,6 +35,7 @@ import android.widget.Toast;
import net.osmand.Location;
import net.osmand.PlatformUtil;
import net.osmand.StateChangedListener;
+import net.osmand.ValueHolder;
import net.osmand.access.AccessibilityPlugin;
import net.osmand.access.AccessibleActivity;
import net.osmand.access.AccessibleToast;
@@ -72,9 +73,11 @@ import net.osmand.plus.helpers.GpxImportHelper;
import net.osmand.plus.helpers.WakeLockHelper;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.MapContextMenuFragment;
+import net.osmand.plus.mapcontextmenu.other.DestinationReachedMenu;
import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.resources.ResourceManager;
import net.osmand.plus.routing.RoutingHelper;
+import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
import net.osmand.plus.routing.RoutingHelper.RouteCalculationProgressCallback;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.MapControlsLayer;
@@ -98,7 +101,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class MapActivity extends AccessibleActivity implements DownloadEvents,
- ActivityCompat.OnRequestPermissionsResultCallback {
+ ActivityCompat.OnRequestPermissionsResultCallback, IRouteInformationListener {
private static final int SHOW_POSITION_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 1;
private static final int LONG_KEYPRESS_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 2;
private static final int LONG_KEYPRESS_DELAY = 500;
@@ -525,6 +528,13 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
app.getDownloadThread().setUiActivity(this);
+ if (mapViewTrackingUtilities.getShowRouteFinishDialog()) {
+ DestinationReachedMenu.show(this);
+ mapViewTrackingUtilities.setShowRouteFinishDialog(false);
+ }
+
+ routingHelper.addListener(this);
+
getMyApplication().getAppCustomization().resumeActivity(MapActivity.class, this);
if (System.currentTimeMillis() - tm > 50) {
System.err.println("OnCreate for MapActivity took " + (System.currentTimeMillis() - tm) + " ms");
@@ -757,6 +767,7 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
@Override
protected void onPause() {
+ app.getRoutingHelper().removeListener(this);
app.getDownloadThread().resetUiActivity(this);
if (atlasMapRendererView != null) {
atlasMapRendererView.handleOnPause();
@@ -1112,4 +1123,17 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
}
}
+
+ @Override
+ public void newRouteIsCalculated(boolean newRoute, ValueHolder showToast) {
+ }
+
+ @Override
+ public void routeWasCancelled() {
+ }
+
+ @Override
+ public void routeWasFinished() {
+ DestinationReachedMenu.show(this);
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java
index 98b9c29f98..ecd6adbf45 100644
--- a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java
+++ b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java
@@ -17,8 +17,10 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.AutoZoomMap;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
+import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
+import net.osmand.plus.mapcontextmenu.other.DestinationReachedMenu;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
import net.osmand.plus.views.AnimateDraggingMapThread;
@@ -43,6 +45,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
private boolean showViewAngle = false;
private boolean isUserZoomed = false;
private String locationProvider;
+ private boolean showRouteFinishDialog = false;
public MapViewTrackingUtilities(OsmandApplication app){
this.app = app;
@@ -184,7 +187,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
}
mapView.setMapPosition(settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_BEARING
&& !routePlanningMode
- && !settings.CENTER_POSITION_ON_MAP.get() ?
+ && !settings.CENTER_POSITION_ON_MAP.get() ?
OsmandSettings.BOTTOM_CONSTANT : OsmandSettings.CENTER_CONSTANT);
}
registerUnregisterSensor(app.getLocationProvider().getLastKnownLocation());
@@ -363,6 +366,19 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
public void routeWasCancelled() {
}
+ @Override
+ public void routeWasFinished() {
+ showRouteFinishDialog = (mapView == null);
+ }
+
+ public boolean getShowRouteFinishDialog() {
+ return showRouteFinishDialog;
+ }
+
+ public void setShowRouteFinishDialog(boolean showRouteFinishDialog) {
+ this.showRouteFinishDialog = showRouteFinishDialog;
+ }
+
public void setZoomTime(long time) {
lastTimeAutoZooming = time;
isUserZoomed = true;
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
index 44c97c6277..cb1241e787 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
@@ -1233,6 +1233,10 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
public void routeWasCancelled() {
}
+ @Override
+ public void routeWasFinished() {
+ }
+
@Override
public void onWindowVisibilityChanged(int visibility) {
if (visibility != View.VISIBLE && swipeDismissListener != null) {
diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java
index 417c2b4698..8d3fe4d5f7 100644
--- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java
+++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java
@@ -349,7 +349,8 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
laterButton = freeVersionBanner.findViewById(R.id.laterButton);
freeVersionBannerTitle = freeVersionBanner.findViewById(R.id.freeVersionBannerTitle);
- shouldShowFreeVersionBanner = Version.isFreeVersion(application)
+ shouldShowFreeVersionBanner =
+ (Version.isFreeVersion(application) && !application.getSettings().LIVE_UPDATES_PURCHASED.get())
|| application.getSettings().SHOULD_SHOW_FREE_VERSION_BANNER.get();
initFreeVersionBanner();
diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java
index 2b18bab7b7..7599a531af 100644
--- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java
+++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java
@@ -519,7 +519,7 @@ public class DownloadIndexesThread {
}
private boolean validateNotExceedsFreeLimit(IndexItem item) {
- boolean exceed = Version.isFreeVersion(app) &&
+ boolean exceed = Version.isFreeVersion(app) && !app.getSettings().LIVE_UPDATES_PURCHASED.get() &&
DownloadActivityType.isCountedInDownloads(item) && downloads.get() >= DownloadValidationManager.MAXIMUM_AVAILABLE_FREE_DOWNLOADS;
if(exceed) {
String breakDownloadMessage = app.getString(R.string.free_version_message,
diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadValidationManager.java b/OsmAnd/src/net/osmand/plus/download/DownloadValidationManager.java
index 98253e2ce7..06984eb59b 100644
--- a/OsmAnd/src/net/osmand/plus/download/DownloadValidationManager.java
+++ b/OsmAnd/src/net/osmand/plus/download/DownloadValidationManager.java
@@ -89,7 +89,7 @@ public class DownloadValidationManager {
}
protected void downloadFilesCheck_1_FreeVersion(FragmentActivity context, IndexItem[] items) {
- if (Version.isFreeVersion(getMyApplication())) {
+ if (Version.isFreeVersion(getMyApplication()) && !app.getSettings().LIVE_UPDATES_PURCHASED.get()) {
int total = settings.NUMBER_OF_FREE_DOWNLOADS.get();
if (total > MAXIMUM_AVAILABLE_FREE_DOWNLOADS) {
if (context instanceof FragmentActivity) {
diff --git a/OsmAnd/src/net/osmand/plus/inapp/InAppHelper.java b/OsmAnd/src/net/osmand/plus/inapp/InAppHelper.java
index ea43543088..1e0088c00f 100644
--- a/OsmAnd/src/net/osmand/plus/inapp/InAppHelper.java
+++ b/OsmAnd/src/net/osmand/plus/inapp/InAppHelper.java
@@ -8,13 +8,18 @@ import android.util.Log;
import net.osmand.AndroidNetworkUtils;
import net.osmand.AndroidNetworkUtils.OnRequestResultListener;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.inapp.util.IabHelper;
+import net.osmand.plus.inapp.util.IabHelper.OnIabPurchaseFinishedListener;
+import net.osmand.plus.inapp.util.IabHelper.QueryInventoryFinishedListener;
import net.osmand.plus.inapp.util.IabResult;
import net.osmand.plus.inapp.util.Inventory;
import net.osmand.plus.inapp.util.Purchase;
import net.osmand.plus.inapp.util.SkuDetails;
+import net.osmand.plus.liveupdates.CountrySelectionFragment;
+import net.osmand.plus.liveupdates.CountrySelectionFragment.CountryItem;
import net.osmand.util.Algorithms;
import org.json.JSONException;
@@ -45,6 +50,8 @@ public class InAppHelper {
// The helper object
private IabHelper mHelper;
private boolean stopAfterResult = false;
+ private boolean isDeveloperVersion = false;
+ private String token = "";
private OsmandApplication ctx;
private List listeners = new ArrayList<>();
@@ -61,6 +68,10 @@ public class InAppHelper {
void dismissProgress();
}
+ public String getToken() {
+ return token;
+ }
+
public static boolean isSubscribedToLiveUpdates() {
return mSubscribedToLiveUpdates;
}
@@ -82,7 +93,8 @@ public class InAppHelper {
SKU_LIVE_UPDATES = SKU_LIVE_UPDATES_FULL;
}
}
- if (Version.isDeveloperVersion(ctx)) {
+ isDeveloperVersion = Version.isDeveloperVersion(ctx);
+ if (isDeveloperVersion) {
mSubscribedToLiveUpdates = true;
ctx.getSettings().LIVE_UPDATES_PURCHASED.set(true);
}
@@ -136,21 +148,27 @@ public class InAppHelper {
if (mHelper == null) return;
// IAB is fully set up. Now, let's get an inventory of stuff we own if needed.
- if (!mSubscribedToLiveUpdates
- || !ctx.getSettings().BILLING_PURCHASE_TOKEN_SENT.get()
- || System.currentTimeMillis() - lastValidationCheckTime > PURCHASE_VALIDATION_PERIOD_MSEC) {
+ if (!isDeveloperVersion &&
+ (!mSubscribedToLiveUpdates
+ || !ctx.getSettings().BILLING_PURCHASE_TOKEN_SENT.get()
+ || System.currentTimeMillis() - lastValidationCheckTime > PURCHASE_VALIDATION_PERIOD_MSEC)) {
logDebug("Setup successful. Querying inventory.");
List skus = new ArrayList<>();
skus.add(SKU_LIVE_UPDATES);
mHelper.queryInventoryAsync(true, skus, mGotInventoryListener);
+ } else {
+ notifyDismissProgress();
+ if (stopAfterResult) {
+ stop();
+ }
}
}
});
}
// Listener that's called when we finish querying the items and subscriptions we own
- private IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
+ private QueryInventoryFinishedListener mGotInventoryListener = new QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
logDebug("Query inventory finished.");
@@ -177,7 +195,7 @@ public class InAppHelper {
// Do we have the live updates?
Purchase liveUpdatesPurchase = inventory.getPurchase(SKU_LIVE_UPDATES);
- mSubscribedToLiveUpdates = (liveUpdatesPurchase != null) || Version.isDeveloperVersion(ctx);
+ mSubscribedToLiveUpdates = (liveUpdatesPurchase != null && liveUpdatesPurchase.getPurchaseState() == 0);
if (mSubscribedToLiveUpdates) {
ctx.getSettings().LIVE_UPDATES_PURCHASED.set(true);
}
@@ -190,17 +208,44 @@ public class InAppHelper {
mLiveUpdatesPrice = liveUpdatesDetails.getPrice();
}
- if (liveUpdatesPurchase != null && !ctx.getSettings().BILLING_PURCHASE_TOKEN_SENT.get()) {
- sendToken(liveUpdatesPurchase.getToken());
+ boolean needSendToken = false;
+ if (liveUpdatesPurchase != null) {
+ OsmandSettings settings = ctx.getSettings();
+ if (Algorithms.isEmpty(settings.BILLING_USER_ID.get())
+ && !Algorithms.isEmpty(liveUpdatesPurchase.getDeveloperPayload())) {
+ String payload = liveUpdatesPurchase.getDeveloperPayload();
+ if (!Algorithms.isEmpty(payload)) {
+ String[] arr = payload.split(" ");
+ if (arr.length > 0) {
+ settings.BILLING_USER_ID.set(arr[0]);
+ }
+ if (arr.length > 1) {
+ token = arr[1];
+ }
+ }
+ }
+ if (!settings.BILLING_PURCHASE_TOKEN_SENT.get()) {
+ needSendToken = true;
+ }
}
- notifyDismissProgress();
- notifyGetItems();
- if (stopAfterResult) {
- stop();
- }
+ final OnRequestResultListener listener = new OnRequestResultListener() {
+ @Override
+ public void onResult(String result) {
+ notifyDismissProgress();
+ notifyGetItems();
+ if (stopAfterResult) {
+ stop();
+ }
+ logDebug("Initial inapp query finished");
+ }
+ };
- logDebug("Initial inapp query finished");
+ if (needSendToken) {
+ sendToken(liveUpdatesPurchase.getToken(), listener);
+ } else {
+ listener.onResult("OK");
+ }
}
};
@@ -259,6 +304,7 @@ public class InAppHelper {
try {
JSONObject obj = new JSONObject(response);
userId = obj.getString("userid");
+ token = obj.getString("token");
ctx.getSettings().BILLING_USER_ID.set(userId);
logDebug("UserId=" + userId);
} catch (JSONException e) {
@@ -276,7 +322,7 @@ public class InAppHelper {
notifyDismissProgress();
if (!Algorithms.isEmpty(userId)) {
logDebug("Launching purchase flow for live updates subscription for userId=" + userId);
- String payload = userId;
+ String payload = userId + " " + token;
if (mHelper != null) {
mHelper.launchPurchaseFlow(activity,
SKU_LIVE_UPDATES, IabHelper.ITEM_TYPE_SUBS,
@@ -315,7 +361,7 @@ public class InAppHelper {
}
// Callback for when a purchase is finished
- private IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
+ private OnIabPurchaseFinishedListener mPurchaseFinishedListener = new OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
logDebug("Purchase finished: " + result + ", purchase: " + purchase);
@@ -336,18 +382,21 @@ public class InAppHelper {
if (purchase.getSku().equals(SKU_LIVE_UPDATES)) {
// bought live updates
- sendToken(purchase.getToken());
-
logDebug("Live updates subscription purchased.");
- showToast(ctx.getString(R.string.osm_live_thanks));
- mSubscribedToLiveUpdates = true;
- ctx.getSettings().LIVE_UPDATES_PURCHASED.set(true);
+ sendToken(purchase.getToken(), new OnRequestResultListener() {
+ @Override
+ public void onResult(String result) {
+ showToast(ctx.getString(R.string.osm_live_thanks));
+ mSubscribedToLiveUpdates = true;
+ ctx.getSettings().LIVE_UPDATES_PURCHASED.set(true);
- notifyDismissProgress();
- notifyItemPurchased(SKU_LIVE_UPDATES);
- if (stopAfterResult) {
- stop();
- }
+ notifyDismissProgress();
+ notifyItemPurchased(SKU_LIVE_UPDATES);
+ if (stopAfterResult) {
+ stop();
+ }
+ }
+ });
}
}
};
@@ -361,15 +410,16 @@ public class InAppHelper {
}
}
- private void sendToken(String token) {
+ private void sendToken(String purchaseToken, final OnRequestResultListener listener) {
String userId = ctx.getSettings().BILLING_USER_ID.get();
String email = ctx.getSettings().BILLING_USER_EMAIL.get();
try {
Map parameters = new HashMap<>();
parameters.put("userid", userId);
parameters.put("sku", SKU_LIVE_UPDATES);
- parameters.put("purchaseToken", token);
+ parameters.put("purchaseToken", purchaseToken);
parameters.put("email", email);
+ parameters.put("token", token);
AndroidNetworkUtils.sendRequestAsync(ctx,
"http://download.osmand.net/subscription/purchased.php",
@@ -381,18 +431,50 @@ public class InAppHelper {
JSONObject obj = new JSONObject(result);
if (!obj.has("error")) {
ctx.getSettings().BILLING_PURCHASE_TOKEN_SENT.set(true);
+ if (obj.has("visibleName") && !Algorithms.isEmpty(obj.getString("visibleName"))) {
+ ctx.getSettings().BILLING_USER_NAME.set(obj.getString("visibleName"));
+ ctx.getSettings().BILLING_HIDE_USER_NAME.set(false);
+ } else {
+ ctx.getSettings().BILLING_HIDE_USER_NAME.set(true);
+ }
+ if (obj.has("preferredCountry")) {
+ String prefferedCountry = obj.getString("preferredCountry");
+ if (!ctx.getSettings().BILLING_USER_COUNTRY_DOWNLOAD_NAME.get().equals(prefferedCountry)) {
+ ctx.getSettings().BILLING_USER_COUNTRY_DOWNLOAD_NAME.set(prefferedCountry);
+ CountrySelectionFragment countrySelectionFragment = new CountrySelectionFragment();
+ countrySelectionFragment.initCountries(ctx);
+ CountryItem countryItem;
+ if (Algorithms.isEmpty(prefferedCountry)) {
+ countryItem = countrySelectionFragment.getCountryItems().get(0);
+ } else {
+ countryItem = countrySelectionFragment.getCountryItem(prefferedCountry);
+ }
+ if (countryItem != null) {
+ ctx.getSettings().BILLING_USER_COUNTRY.set(countryItem.getLocalName());
+ }
+ }
+ }
+ if (obj.has("email")) {
+ ctx.getSettings().BILLING_USER_EMAIL.set(obj.getString("email"));
+ }
} else {
complain("SendToken Error: " + obj.getString("error"));
}
} catch (JSONException e) {
- logError("sendToken", e);
+ logError("SendToken", e);
complain("SendToken Error: " + (e.getMessage() != null ? e.getMessage() : "JSONException"));
}
}
+ if (listener != null) {
+ listener.onResult("OK");
+ }
}
});
} catch (Exception e) {
- logError("sendToken Error", e);
+ logError("SendToken Error", e);
+ if (listener != null) {
+ listener.onResult("Error");
+ }
}
}
diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java
index 3dc9b54d2b..93e2fe0004 100644
--- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java
+++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java
@@ -119,11 +119,15 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppList
listView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
- final FragmentManager fragmentManager = getChildFragmentManager();
- LiveUpdatesSettingsDialogFragment
- .createInstance(adapter.getChild(groupPosition, childPosition))
- .show(fragmentManager, "settings");
- return true;
+ if (!processing && InAppHelper.isSubscribedToLiveUpdates()) {
+ final FragmentManager fragmentManager = getChildFragmentManager();
+ LiveUpdatesSettingsDialogFragment
+ .createInstance(adapter.getChild(groupPosition, childPosition))
+ .show(fragmentManager, "settings");
+ return true;
+ } else {
+ return false;
+ }
}
});
@@ -236,7 +240,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppList
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == SUBSCRIPTION_SETTINGS) {
+ if (item.getItemId() == SUBSCRIPTION_SETTINGS && !processing) {
SubscriptionFragment subscriptionFragment = new SubscriptionFragment();
subscriptionFragment.setEditMode(true);
subscriptionFragment.show(getChildFragmentManager(), SubscriptionFragment.TAG);
@@ -518,15 +522,19 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppList
lastCheck != DEFAULT_LAST_CHECK ? lastCheck : timestamp);
descriptionTextView.setText(context.getString(R.string.last_update, lastCheckString));
- final View.OnClickListener clickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- final FragmentManager fragmentManager = fragment.getChildFragmentManager();
- LiveUpdatesSettingsDialogFragment.createInstance(item).show(fragmentManager, "settings");
- }
- };
- options.setEnabled(!fragment.isProcessing());
- options.setOnClickListener(clickListener);
+ if (!fragment.isProcessing() && InAppHelper.isSubscribedToLiveUpdates()) {
+ final View.OnClickListener clickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ final FragmentManager fragmentManager = fragment.getChildFragmentManager();
+ LiveUpdatesSettingsDialogFragment.createInstance(item).show(fragmentManager, "settings");
+ }
+ };
+ options.setOnClickListener(clickListener);
+ options.setEnabled(true);
+ } else {
+ options.setEnabled(false);
+ }
if (isLastChild) {
divider.setVisibility(View.GONE);
@@ -591,7 +599,6 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppList
progressBar.setVisibility(View.VISIBLE);
updateSubscriptionHeader();
adapter.notifyDataSetChanged();
- listView.setEnabled(false);
}
private void disableProgress() {
@@ -599,7 +606,6 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppList
progressBar.setVisibility(View.INVISIBLE);
updateSubscriptionHeader();
adapter.notifyDataSetChanged();
- listView.setEnabled(true);
}
public static float dpToPx(final Context context, final float dp) {
diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/SubscriptionFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/SubscriptionFragment.java
index d9d2f2de0c..e89526ac6a 100644
--- a/OsmAnd/src/net/osmand/plus/liveupdates/SubscriptionFragment.java
+++ b/OsmAnd/src/net/osmand/plus/liveupdates/SubscriptionFragment.java
@@ -200,6 +200,7 @@ public class SubscriptionFragment extends BaseOsmAndDialogFragment implements In
parameters.put("email", settings.BILLING_USER_EMAIL.get());
parameters.put("cemail", prevEmail);
parameters.put("userid", settings.BILLING_USER_ID.get());
+ parameters.put("token", getInAppHelper().getToken());
showProgress();
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
index c35a101d2c..d764d87a62 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
@@ -730,17 +730,25 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
if (!menu.isLandscapeLayout()) {
TextView line1 = (TextView) view.findViewById(R.id.context_menu_line1);
TextView line2 = (TextView) view.findViewById(R.id.context_menu_line2);
+ int line2LineCount = 0;
+ int line2LineHeight = 0;
+ int line2MeasuredHeight = 0;
+ if (line2 != null) {
+ line2LineCount = line2.getLineCount();
+ line2LineHeight = line2.getLineHeight();
+ line2MeasuredHeight = line2.getMeasuredHeight();
+ }
if (menuTopViewHeight != 0) {
- int titleHeight = line1.getLineCount() * line1.getLineHeight() + line2.getLineCount() * line2.getLineHeight() + menuTitleTopBottomPadding;
- if (titleHeight < line1.getMeasuredHeight() + line2.getMeasuredHeight()) {
- titleHeight = line1.getMeasuredHeight() + line2.getMeasuredHeight();
+ int titleHeight = line1.getLineCount() * line1.getLineHeight() + line2LineCount * line2LineHeight + menuTitleTopBottomPadding;
+ if (titleHeight < line1.getMeasuredHeight() + line2MeasuredHeight) {
+ titleHeight = line1.getMeasuredHeight() + line2MeasuredHeight;
}
newMenuTopViewHeight = menuTopViewHeightExcludingTitle + titleHeight;
dy = Math.max(0, newMenuTopViewHeight - menuTopViewHeight - (newMenuTopShadowAllHeight - menuTopShadowAllHeight));
} else {
- menuTopViewHeightExcludingTitle = newMenuTopViewHeight - line1.getMeasuredHeight() - line2.getMeasuredHeight();
+ menuTopViewHeightExcludingTitle = newMenuTopViewHeight - line1.getMeasuredHeight() - line2MeasuredHeight;
menuTitleTopBottomPadding = (line1.getMeasuredHeight() - line1.getLineCount() * line1.getLineHeight())
- + (line2.getMeasuredHeight() - line2.getLineCount() * line2.getLineHeight());
+ + (line2MeasuredHeight - line2LineCount * line2LineHeight);
}
}
menuTopViewHeight = newMenuTopViewHeight;
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java
index 8e9cd2d42b..cbc78829e7 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java
@@ -260,7 +260,7 @@ public class MapDataMenuController extends MenuController {
boolean downloadIndexes = getMapActivity().getMyApplication().getSettings().isInternetConnectionAvailable()
&& !downloadThread.getIndexes().isDownloadedFromInternet
&& !downloadThread.getIndexes().downloadFromInternetFailed;
-
+
boolean isDownloading = indexItem != null && downloadThread.isDownloading(indexItem);
if (isDownloading) {
titleProgressController.setMapDownloadMode();
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/DestinationReachedMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/DestinationReachedMenu.java
new file mode 100644
index 0000000000..e0fec04f8d
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/DestinationReachedMenu.java
@@ -0,0 +1,16 @@
+package net.osmand.plus.mapcontextmenu.other;
+
+import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.mapcontextmenu.BaseMenuController;
+
+public class DestinationReachedMenu extends BaseMenuController {
+
+ public DestinationReachedMenu(MapActivity mapActivity) {
+ super(mapActivity);
+ }
+
+ public static void show(MapActivity mapActivity) {
+ DestinationReachedMenu menu = new DestinationReachedMenu(mapActivity);
+ DestinationReachedMenuFragment.showInstance(menu);
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/DestinationReachedMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/DestinationReachedMenuFragment.java
new file mode 100644
index 0000000000..c4a998a2e0
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/DestinationReachedMenuFragment.java
@@ -0,0 +1,145 @@
+package net.osmand.plus.mapcontextmenu.other;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.ImageButton;
+
+import net.osmand.AndroidUtils;
+import net.osmand.plus.IconsCache;
+import net.osmand.plus.R;
+import net.osmand.plus.TargetPointsHelper.TargetPoint;
+import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.activities.search.SearchActivity;
+import net.osmand.plus.activities.search.SearchPOIActivity;
+import net.osmand.plus.poi.PoiFiltersHelper;
+import net.osmand.plus.poi.PoiUIFilter;
+
+public class DestinationReachedMenuFragment extends Fragment {
+ public static final String TAG = "DestinationReachedMenuFragment";
+ private DestinationReachedMenu menu;
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ if (menu == null) {
+ menu = new DestinationReachedMenu(getMapActivity());
+ }
+ }
+
+ @Nullable
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.dest_reached_menu_fragment, container, false);
+ view.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ dismissMenu();
+ }
+ });
+
+ IconsCache iconsCache = getMapActivity().getMyApplication().getIconsCache();
+
+ ImageButton closeImageButton = (ImageButton) view.findViewById(R.id.closeImageButton);
+ closeImageButton.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_action_remove_dark));
+ closeImageButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ dismissMenu();
+ }
+ });
+
+ Button removeDestButton = (Button) view.findViewById(R.id.removeDestButton);
+ removeDestButton.setCompoundDrawablesWithIntrinsicBounds(
+ iconsCache.getContentIcon(R.drawable.ic_action_delete_dark), null, null, null);
+ removeDestButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ getMapActivity().getMyApplication().getTargetPointsHelper().removeWayPoint(true, -1);
+ Object contextMenuObj = getMapActivity().getContextMenu().getObject();
+ if (getMapActivity().getContextMenu().isActive()
+ && contextMenuObj != null && contextMenuObj instanceof TargetPoint) {
+ TargetPoint targetPoint = (TargetPoint) contextMenuObj;
+ if (!targetPoint.start && !targetPoint.intermediate) {
+ getMapActivity().getContextMenu().close();
+ }
+ }
+ dismissMenu();
+ }
+ });
+
+ Button findParkingButton = (Button) view.findViewById(R.id.findParkingButton);
+ findParkingButton.setCompoundDrawablesWithIntrinsicBounds(
+ iconsCache.getContentIcon(R.drawable.ic_action_parking_dark), null, null, null);
+ findParkingButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ PoiFiltersHelper helper = getMapActivity().getMyApplication().getPoiFilters();
+ //PoiType place = getMapActivity().getMyApplication().getPoiTypes().getPoiTypeByKey("parking");
+ PoiUIFilter parkingFilter = helper.getFilterById(PoiUIFilter.STD_PREFIX + "parking");
+ if (parkingFilter != null) {
+ final Intent newIntent = new Intent(getActivity(), SearchPOIActivity.class);
+ newIntent.putExtra(SearchPOIActivity.AMENITY_FILTER, parkingFilter.getFilterId());
+ newIntent.putExtra(SearchActivity.SEARCH_NEARBY, true);
+ startActivityForResult(newIntent, 0);
+ }
+ dismissMenu();
+ }
+ });
+
+ View mainView = view.findViewById(R.id.main_view);
+ if (menu.isLandscapeLayout()) {
+ AndroidUtils.setBackground(view.getContext(), mainView, !menu.isLight(),
+ R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark);
+ } else {
+ AndroidUtils.setBackground(view.getContext(), mainView, !menu.isLight(),
+ R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
+ }
+
+ return view;
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ getMapActivity().getContextMenu().setBaseFragmentVisibility(false);
+ }
+
+ @Override
+ public void onStop() {
+ super.onStop();
+ getMapActivity().getContextMenu().setBaseFragmentVisibility(true);
+ }
+
+
+ public static void showInstance(DestinationReachedMenu menu) {
+ int slideInAnim = menu.getSlideInAnimation();
+ int slideOutAnim = menu.getSlideOutAnimation();
+
+ DestinationReachedMenuFragment fragment = new DestinationReachedMenuFragment();
+ fragment.menu = menu;
+ menu.getMapActivity().getSupportFragmentManager().beginTransaction()
+ .setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim)
+ .add(R.id.fragmentContainer, fragment, TAG)
+ .addToBackStack(TAG).commitAllowingStateLoss();
+ }
+
+ public void dismissMenu() {
+ getMapActivity().getSupportFragmentManager().popBackStack();
+ }
+
+ public MapActivity getMapActivity() {
+ Activity activity = getActivity();
+ if (activity != null && activity instanceof MapActivity) {
+ return (MapActivity) activity;
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java
index 8d84b4030a..8049e5a6cb 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java
@@ -677,6 +677,10 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
// do not hide fragment (needed for use case entering Planning mode without destination)
}
+ @Override
+ public void routeWasFinished() {
+ }
+
public void onDismiss() {
visible = false;
mapActivity.getMapView().setMapPositionX(0);
diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java
index 8c3110401d..c86abd4570 100644
--- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java
+++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java
@@ -15,6 +15,7 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
+import net.osmand.plus.mapcontextmenu.other.DestinationReachedMenu;
import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
import net.osmand.plus.routing.RouteProvider.RouteService;
@@ -38,6 +39,8 @@ public class RoutingHelper {
public void newRouteIsCalculated(boolean newRoute, ValueHolder showToast);
public void routeWasCancelled();
+
+ public void routeWasFinished();
}
private static final float POSITION_TOLERANCE = 60;
@@ -182,7 +185,25 @@ public class RoutingHelper {
setFollowingMode(false);
}
}
-
+
+ private synchronized void finishCurrentRoute() {
+ app.runInUIThread(new Runnable() {
+ @Override
+ public void run() {
+ Iterator> it = listeners.iterator();
+ while(it.hasNext()) {
+ WeakReference ref = it.next();
+ IRouteInformationListener l = ref.get();
+ if(l == null) {
+ it.remove();
+ } else {
+ l.routeWasFinished();
+ }
+ }
+ }
+ });
+ }
+
public GPXRouteParamsBuilder getCurrentGPXRoute() {
return currentGPXRoute;
}
@@ -490,7 +511,7 @@ public class RoutingHelper {
if (currentRoute > routeNodes.size() - 3
&& currentLocation.distanceTo(lastPoint) < (((float)settings.getApplicationMode().getArrivalDistance()) * settings.ARRIVAL_DISTANCE_FACTOR.get())
&& !isRoutePlanningMode) {
- showMessage(app.getString(R.string.arrived_at_destination));
+ //showMessage(app.getString(R.string.arrived_at_destination));
TargetPointsHelper targets = app.getTargetPointsHelper();
TargetPoint tp = targets.getPointToNavigate();
String description = tp == null ? "" : tp.getOnlyName();
@@ -509,6 +530,7 @@ public class RoutingHelper {
settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get());
}
});
+ finishCurrentRoute();
// targets.clearPointToNavigate(false);
return true;
}
diff --git a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java
index c5d7589a39..0d84fbfb30 100644
--- a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java
+++ b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java
@@ -533,6 +533,10 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
public void routeWasCancelled() {
}
+ @Override
+ public void routeWasFinished() {
+ }
+
public static int dpToPx(Context ctx, float dp) {
Resources r = ctx.getResources();
return (int) TypedValue.applyDimension(