Add the ability to show poi types from notification
This commit is contained in:
parent
3b9e3d2b56
commit
a9cf25ad64
4 changed files with 90 additions and 3 deletions
|
@ -861,9 +861,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
boolean night = app.getDaynightHelper().isNightModeForMapControls();
|
boolean night = app.getDaynightHelper().isNightModeForMapControls();
|
||||||
boolean quickSearchTopBar = getTopToolbarController(TopToolbarControllerType.QUICK_SEARCH) != null;
|
boolean quickSearchTopBar = getTopToolbarController(TopToolbarControllerType.QUICK_SEARCH) != null;
|
||||||
boolean contextMenuTopBar = getTopToolbarController(TopToolbarControllerType.CONTEXT_MENU) != null;
|
boolean contextMenuTopBar = getTopToolbarController(TopToolbarControllerType.CONTEXT_MENU) != null;
|
||||||
|
boolean poiFilterTopBar = getTopToolbarController(TopToolbarControllerType.POI_FILTER) != null;
|
||||||
boolean mapTopBar = findViewById(R.id.map_top_bar).getVisibility() == View.VISIBLE;
|
boolean mapTopBar = findViewById(R.id.map_top_bar).getVisibility() == View.VISIBLE;
|
||||||
boolean markerTopBar = findViewById(R.id.map_markers_top_bar).getVisibility() == View.VISIBLE;
|
boolean markerTopBar = findViewById(R.id.map_markers_top_bar).getVisibility() == View.VISIBLE;
|
||||||
if (((quickSearchTopBar || mapTopBar) && mapControlsVisible) || contextMenuTopBar) {
|
if (((quickSearchTopBar || poiFilterTopBar || mapTopBar) && mapControlsVisible) || contextMenuTopBar) {
|
||||||
colorId = night ? R.color.status_bar_route_dark : R.color.status_bar_route_light;
|
colorId = night ? R.color.status_bar_route_dark : R.color.status_bar_route_light;
|
||||||
} else if (markerTopBar && mapControlsVisible) {
|
} else if (markerTopBar && mapControlsVisible) {
|
||||||
colorId = R.color.status_bar_dark;
|
colorId = R.color.status_bar_dark;
|
||||||
|
|
|
@ -15,6 +15,10 @@ import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import net.osmand.AndroidNetworkUtils;
|
import net.osmand.AndroidNetworkUtils;
|
||||||
|
import net.osmand.osm.AbstractPoiType;
|
||||||
|
import net.osmand.osm.MapPoiTypes;
|
||||||
|
import net.osmand.osm.PoiCategory;
|
||||||
|
import net.osmand.osm.PoiType;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -23,6 +27,8 @@ import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
|
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
|
||||||
import net.osmand.plus.dialogs.XMasDialogFragment;
|
import net.osmand.plus.dialogs.XMasDialogFragment;
|
||||||
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
||||||
|
import net.osmand.plus.poi.PoiFiltersHelper;
|
||||||
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
||||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
|
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -33,6 +39,7 @@ import org.json.JSONObject;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class DiscountHelper {
|
public class DiscountHelper {
|
||||||
|
@ -43,10 +50,12 @@ public class DiscountHelper {
|
||||||
private static long mLastCheckTime;
|
private static long mLastCheckTime;
|
||||||
private static ControllerData mData;
|
private static ControllerData mData;
|
||||||
private static boolean mBannerVisible;
|
private static boolean mBannerVisible;
|
||||||
|
private static PoiUIFilter mFilter;
|
||||||
|
private static boolean mFilterVisible;
|
||||||
private static final String URL = "https://osmand.net/api/motd";
|
private static final String URL = "https://osmand.net/api/motd";
|
||||||
private static final String INAPP_PREFIX = "osmand-in-app:";
|
private static final String INAPP_PREFIX = "osmand-in-app:";
|
||||||
private static final String SEARCH_QUERY_PREFIX = "osmand-search-query:";
|
private static final String SEARCH_QUERY_PREFIX = "osmand-search-query:";
|
||||||
|
private static final String SHOW_POI_PREFIX = "osmand-show-poi:";
|
||||||
|
|
||||||
public static void checkAndDisplay(final MapActivity mapActivity) {
|
public static void checkAndDisplay(final MapActivity mapActivity) {
|
||||||
OsmandApplication app = mapActivity.getMyApplication();
|
OsmandApplication app = mapActivity.getMyApplication();
|
||||||
|
@ -56,6 +65,8 @@ public class DiscountHelper {
|
||||||
}
|
}
|
||||||
if (mBannerVisible) {
|
if (mBannerVisible) {
|
||||||
showDiscountBanner(mapActivity, mData);
|
showDiscountBanner(mapActivity, mData);
|
||||||
|
} else if (mFilterVisible) {
|
||||||
|
showPoiFilter(mapActivity, mFilter);
|
||||||
}
|
}
|
||||||
if (System.currentTimeMillis() - mLastCheckTime < 1000 * 60 * 60 * 24
|
if (System.currentTimeMillis() - mLastCheckTime < 1000 * 60 * 60 * 24
|
||||||
|| !settings.isInternetConnectionAvailable()) {
|
|| !settings.isInternetConnectionAvailable()) {
|
||||||
|
@ -216,6 +227,42 @@ public class DiscountHelper {
|
||||||
mapActivity.showTopToolbar(toolbarController);
|
mapActivity.showTopToolbar(toolbarController);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void showPoiFilter(final MapActivity mapActivity, final PoiUIFilter poiFilter) {
|
||||||
|
final TopToolbarController controller = new PoiFilterBarController();
|
||||||
|
View.OnClickListener listener = new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
hideToolbar(mapActivity, controller);
|
||||||
|
mapActivity.showQuickSearch(poiFilter);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
controller.setOnBackButtonClickListener(listener);
|
||||||
|
controller.setOnTitleClickListener(listener);
|
||||||
|
controller.setOnCloseButtonClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
hideToolbar(mapActivity, controller);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
controller.setTitle(poiFilter.getName());
|
||||||
|
PoiFiltersHelper helper = mapActivity.getMyApplication().getPoiFilters();
|
||||||
|
helper.clearSelectedPoiFilters();
|
||||||
|
helper.addSelectedPoiFilter(poiFilter);
|
||||||
|
|
||||||
|
mFilter = poiFilter;
|
||||||
|
mFilterVisible = true;
|
||||||
|
|
||||||
|
mapActivity.showTopToolbar(controller);
|
||||||
|
mapActivity.refreshMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void hideToolbar(MapActivity mapActivity, TopToolbarController controller) {
|
||||||
|
mFilterVisible = false;
|
||||||
|
mapActivity.hideTopToolbar(controller);
|
||||||
|
mapActivity.getMyApplication().getPoiFilters().clearSelectedPoiFilters();
|
||||||
|
mapActivity.refreshMap();
|
||||||
|
}
|
||||||
|
|
||||||
private static void openUrl(final MapActivity mapActivity, String url) {
|
private static void openUrl(final MapActivity mapActivity, String url) {
|
||||||
if (url.startsWith(INAPP_PREFIX)) {
|
if (url.startsWith(INAPP_PREFIX)) {
|
||||||
if (url.contains(InAppPurchaseHelper.SKU_FULL_VERSION_PRICE)) {
|
if (url.contains(InAppPurchaseHelper.SKU_FULL_VERSION_PRICE)) {
|
||||||
|
@ -233,6 +280,33 @@ public class DiscountHelper {
|
||||||
if (!query.isEmpty()) {
|
if (!query.isEmpty()) {
|
||||||
mapActivity.showQuickSearch(query);
|
mapActivity.showQuickSearch(query);
|
||||||
}
|
}
|
||||||
|
} else if (url.startsWith(SHOW_POI_PREFIX)) {
|
||||||
|
String names = url.substring(SHOW_POI_PREFIX.length());
|
||||||
|
if (!names.isEmpty()) {
|
||||||
|
OsmandApplication app = mapActivity.getMyApplication();
|
||||||
|
MapPoiTypes poiTypes = app.getPoiTypes();
|
||||||
|
Map<PoiCategory, LinkedHashSet<String>> acceptedTypes = new LinkedHashMap<>();
|
||||||
|
for (String name : names.split(",")) {
|
||||||
|
AbstractPoiType abstractType = poiTypes.getAnyPoiTypeByKey(name);
|
||||||
|
if (abstractType instanceof PoiCategory) {
|
||||||
|
acceptedTypes.put((PoiCategory) abstractType, null);
|
||||||
|
} else if (abstractType instanceof PoiType) {
|
||||||
|
PoiType type = (PoiType) abstractType;
|
||||||
|
PoiCategory category = type.getCategory();
|
||||||
|
LinkedHashSet<String> set = acceptedTypes.get(category);
|
||||||
|
if (set == null) {
|
||||||
|
set = new LinkedHashSet<>();
|
||||||
|
acceptedTypes.put(category, set);
|
||||||
|
}
|
||||||
|
set.add(type.getKeyName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!acceptedTypes.isEmpty()) {
|
||||||
|
PoiUIFilter filter = new PoiUIFilter("", null, acceptedTypes, app);
|
||||||
|
filter.setName(filter.getTypesName());
|
||||||
|
showPoiFilter(mapActivity, filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
intent.setData(Uri.parse(url));
|
intent.setData(Uri.parse(url));
|
||||||
|
@ -278,6 +352,13 @@ public class DiscountHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class PoiFilterBarController extends TopToolbarController {
|
||||||
|
|
||||||
|
public PoiFilterBarController() {
|
||||||
|
super(TopToolbarControllerType.POI_FILTER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class DiscountBarController extends TopToolbarController {
|
private static class DiscountBarController extends TopToolbarController {
|
||||||
|
|
||||||
DiscountBarController() {
|
DiscountBarController() {
|
||||||
|
|
|
@ -484,6 +484,10 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
public String getGeneratedName(int chars) {
|
public String getGeneratedName(int chars) {
|
||||||
if (!filterId.equals(CUSTOM_FILTER_ID) ||
|
if (!filterId.equals(CUSTOM_FILTER_ID) ||
|
||||||
areAllTypesAccepted() || acceptedTypes.isEmpty()) {
|
areAllTypesAccepted() || acceptedTypes.isEmpty()) {
|
||||||
|
|
|
@ -55,7 +55,8 @@ public class MapInfoWidgetsFactory {
|
||||||
CONTEXT_MENU,
|
CONTEXT_MENU,
|
||||||
TRACK_DETAILS,
|
TRACK_DETAILS,
|
||||||
DISCOUNT,
|
DISCOUNT,
|
||||||
MEASUREMENT_TOOL
|
MEASUREMENT_TOOL,
|
||||||
|
POI_FILTER
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextInfoWidget createAltitudeControl(final MapActivity map) {
|
public TextInfoWidget createAltitudeControl(final MapActivity map) {
|
||||||
|
|
Loading…
Reference in a new issue