Refactor poi filters and add new poi filters
This commit is contained in:
parent
bf21216452
commit
c627bbc27e
12 changed files with 286 additions and 126 deletions
|
@ -74,7 +74,7 @@
|
||||||
<type tag="highway" value="bus_stop" minzoom="15" poi_category="transportation"/>
|
<type tag="highway" value="bus_stop" minzoom="15" poi_category="transportation"/>
|
||||||
<type tag="highway" value="platform" minzoom="15" poi_category="transportation"/>
|
<type tag="highway" value="platform" minzoom="15" poi_category="transportation"/>
|
||||||
<type tag="highway" value="turning_circle" minzoom="16" poi_category="transportation"/>
|
<type tag="highway" value="turning_circle" minzoom="16" poi_category="transportation"/>
|
||||||
<type tag="highway" value="emergency_access_point" minzoom="16" poi_category="transportation"/>
|
<type tag="highway" value="emergency_access_point" minzoom="16" poi_category="emergency"/>
|
||||||
<type tag="highway" value="speed_camera" minzoom="16" poi_category="transportation"/>
|
<type tag="highway" value="speed_camera" minzoom="16" poi_category="transportation"/>
|
||||||
<type tag="highway" value="street_lamp" minzoom="16" />
|
<type tag="highway" value="street_lamp" minzoom="16" />
|
||||||
|
|
||||||
|
@ -379,6 +379,7 @@
|
||||||
<type tag="emergency" value="fire_hose" minzoom="15" />
|
<type tag="emergency" value="fire_hose" minzoom="15" />
|
||||||
<type tag="emergency" value="fire_hydrant" minzoom="15" />
|
<type tag="emergency" value="fire_hydrant" minzoom="15" />
|
||||||
<type tag="emergency" value="phone" minzoom="15" />
|
<type tag="emergency" value="phone" minzoom="15" />
|
||||||
|
<type tag="emergency" value="access_point" minzoom="15" />
|
||||||
<type tag="amenity" value="emergency_phone" target_tag="emergency" target_value="phone" minzoom="15" />
|
<type tag="amenity" value="emergency_phone" target_tag="emergency" target_value="phone" minzoom="15" />
|
||||||
<type tag="emergency" value="siren" minzoom="15" />
|
<type tag="emergency" value="siren" minzoom="15" />
|
||||||
<type tag="amenity" value="fire_station" minzoom="15" poi_category="emergency"/>
|
<type tag="amenity" value="fire_station" minzoom="15" poi_category="emergency"/>
|
||||||
|
|
|
@ -6,8 +6,11 @@
|
||||||
android:paddingLeft="3dp" android:paddingRight="3dp">
|
android:paddingLeft="3dp" android:paddingRight="3dp">
|
||||||
<Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1" android:text="@string/filter_current_poiButton"
|
<Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1" android:text="@string/filter_current_poiButton"
|
||||||
android:id="@+id/filter_currentButton"></Button>
|
android:id="@+id/filter_currentButton"></Button>
|
||||||
<ImageButton android:layout_height="wrap_content" android:layout_marginLeft="4dp" android:layout_width="wrap_content" android:src="@drawable/save_btn"
|
<ImageButton android:layout_height="48dp" android:layout_marginLeft="4dp" android:layout_width="48dp" android:src="@drawable/reset"
|
||||||
android:id="@+id/SaveButton"/>
|
android:contentDescription="@string/default_buttons_reset"
|
||||||
|
android:id="@+id/DeleteButton"/>
|
||||||
|
<ImageButton android:layout_height="wrap_content" android:layout_marginLeft="2dp" android:layout_width="wrap_content" android:src="@drawable/save_btn"
|
||||||
|
android:id="@+id/SaveButton" android:contentDescription="@string/default_buttons_save"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<ListView android:id="@android:id/list" android:layout_width="fill_parent" android:choiceMode="multipleChoice"
|
<ListView android:id="@android:id/list" android:layout_width="fill_parent" android:choiceMode="multipleChoice"
|
||||||
android:layout_height="fill_parent" style="@style/OsmandListView"></ListView>
|
android:layout_height="fill_parent" style="@style/OsmandListView"></ListView>
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
<ImageView android:id="@+id/folder_icon" android:layout_width="37dip"
|
<ImageView android:id="@+id/folder_icon" android:layout_width="37dip"
|
||||||
android:paddingLeft="8dp" android:paddingRight="8dp"
|
android:paddingLeft="8dp" android:paddingRight="8dp"
|
||||||
android:paddingTop="2dp" android:layout_height="fill_parent" />
|
android:paddingTop="2dp" android:layout_height="fill_parent" />
|
||||||
<TextView android:id="@+id/folder_label" android:layout_width="wrap_content"
|
<TextView android:id="@+id/folder_label" android:layout_width="wrap_content" android:layout_weight="1"
|
||||||
android:layout_height="wrap_content" style="@style/ListText"/>
|
android:layout_height="wrap_content" style="@style/ListText"/>
|
||||||
|
|
||||||
|
<ImageView android:id="@+id/folder_edit_icon"
|
||||||
|
android:paddingLeft="4dp" android:paddingRight="8dp" android:src="@android:drawable/ic_input_get"
|
||||||
|
android:layout_width="37dip"
|
||||||
|
android:paddingTop="2dp" android:layout_height="fill_parent" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -11,6 +11,17 @@
|
||||||
-->
|
-->
|
||||||
<string name="btn_add_tag">Add Tag</string>
|
<string name="btn_add_tag">Add Tag</string>
|
||||||
<string name="btn_advanced_mode">Advanced Mode...</string>
|
<string name="btn_advanced_mode">Advanced Mode...</string>
|
||||||
|
<string name="poi_filter_parking">Parking</string>
|
||||||
|
<string name="poi_filter_emergency">Emergency</string>
|
||||||
|
<string name="poi_filter_public_transport">Public Transport</string>
|
||||||
|
<string name="poi_filter_entertainment">Entertainment</string>
|
||||||
|
<string name="poi_filter_accomodation">Accomodation</string>
|
||||||
|
<string name="poi_filter_restaurants">Restaurants</string>
|
||||||
|
<string name="poi_filter_sightseeing">Sightseeing</string>
|
||||||
|
<string name="poi_filter_car_aid">Car aid</string>
|
||||||
|
<string name="poi_filter_food_shop">Food shop</string>
|
||||||
|
<string name="poi_filter_for_tourists">For tourists</string>
|
||||||
|
<string name="poi_filter_fuel">Fuel</string>
|
||||||
<string name="show_warnings_title">Show alarms…</string>
|
<string name="show_warnings_title">Show alarms…</string>
|
||||||
<string name="show_warnings_descr">Show speed limits, speed cameras, speed bumps, and other warnings</string>
|
<string name="show_warnings_descr">Show speed limits, speed cameras, speed bumps, and other warnings</string>
|
||||||
<string name="use_compass_navigation_descr">Use the compass when no heading is detected otherwise</string>
|
<string name="use_compass_navigation_descr">Use the compass when no heading is detected otherwise</string>
|
||||||
|
@ -716,12 +727,8 @@
|
||||||
<string name="km_h">km/h</string>
|
<string name="km_h">km/h</string>
|
||||||
<string name="m">m</string>
|
<string name="m">m</string>
|
||||||
<string name="old_map_index_is_not_supported">Deprecated map data format \'\'{0}\'\' is not supported</string>
|
<string name="old_map_index_is_not_supported">Deprecated map data format \'\'{0}\'\' is not supported</string>
|
||||||
<string name="poi_filter_car_aid">Car aid</string>
|
|
||||||
<string name="poi_filter_closest_poi">Closest POI</string>
|
<string name="poi_filter_closest_poi">Closest POI</string>
|
||||||
<string name="poi_filter_custom_filter">Custom filter</string>
|
<string name="poi_filter_custom_filter">Custom filter</string>
|
||||||
<string name="poi_filter_food_shop">Food shop</string>
|
|
||||||
<string name="poi_filter_for_tourists">For tourists</string>
|
|
||||||
<string name="poi_filter_fuel">Fuel</string>
|
|
||||||
<string name="poi_filter_namefinder">Online NameFinder</string>
|
<string name="poi_filter_namefinder">Online NameFinder</string>
|
||||||
<string name="reading_cached_tiles">Reading cached tiles…</string>
|
<string name="reading_cached_tiles">Reading cached tiles…</string>
|
||||||
<string name="version_index_is_big_for_memory">The index \'\'{0}\'\' did not fit into memory</string>
|
<string name="version_index_is_big_for_memory">The index \'\'{0}\'\' did not fit into memory</string>
|
||||||
|
|
|
@ -153,6 +153,7 @@ public class OsmandApplication extends Application {
|
||||||
public PoiFiltersHelper getPoiFilters() {
|
public PoiFiltersHelper getPoiFilters() {
|
||||||
if (poiFilters == null) {
|
if (poiFilters == null) {
|
||||||
poiFilters = new PoiFiltersHelper(this);
|
poiFilters = new PoiFiltersHelper(this);
|
||||||
|
poiFilters.updateFilters(true);
|
||||||
}
|
}
|
||||||
return poiFilters;
|
return poiFilters;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class PoiFilter {
|
||||||
protected String filterId;
|
protected String filterId;
|
||||||
protected String name;
|
protected String name;
|
||||||
protected String nameFilter;
|
protected String nameFilter;
|
||||||
private final boolean isStandardFilter;
|
protected boolean isStandardFilter;
|
||||||
|
|
||||||
protected final OsmandApplication application;
|
protected final OsmandApplication application;
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public class PoiFilter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// constructor for standard filters
|
// constructor for user defined filters
|
||||||
public PoiFilter(String name, String filterId, Map<AmenityType, LinkedHashSet<String>> acceptedTypes, OsmandApplication app){
|
public PoiFilter(String name, String filterId, Map<AmenityType, LinkedHashSet<String>> acceptedTypes, OsmandApplication app){
|
||||||
application = app;
|
application = app;
|
||||||
isStandardFilter = false;
|
isStandardFilter = false;
|
||||||
|
@ -310,6 +310,10 @@ public class PoiFilter {
|
||||||
return isStandardFilter;
|
return isStandardFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setStandardFilter(boolean isStandardFilter) {
|
||||||
|
this.isStandardFilter = isStandardFilter;
|
||||||
|
}
|
||||||
|
|
||||||
public OsmandApplication getApplication() {
|
public OsmandApplication getApplication() {
|
||||||
return application;
|
return application;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,20 @@ public class PoiFiltersHelper {
|
||||||
private List<PoiFilter> cacheUserDefinedFilters;
|
private List<PoiFilter> cacheUserDefinedFilters;
|
||||||
private List<PoiFilter> cacheOsmDefinedFilters;
|
private List<PoiFilter> cacheOsmDefinedFilters;
|
||||||
|
|
||||||
|
private static final String UDF_CAR_AID = "car_aid";
|
||||||
|
private static final String UDF_FOR_TOURISTS = "for_tourists";
|
||||||
|
private static final String UDF_FOOD_SHOP = "food_shop";
|
||||||
|
private static final String UDF_FUEL = "fuel";
|
||||||
|
private static final String UDF_SIGHTSEEING = "sightseeing";
|
||||||
|
private static final String UDF_EMERGENCY = "emergency";
|
||||||
|
private static final String UDF_PUBLIC_TRANSPORT = "public_transport";
|
||||||
|
private static final String UDF_ENTERTAINMENT = "entertainment";
|
||||||
|
private static final String UDF_ACCOMODATION = "accomodation";
|
||||||
|
private static final String UDF_RESTAURANTS = "restaurants";
|
||||||
|
private static final String UDF_PARKING = "parking";
|
||||||
|
|
||||||
|
private static final String[] DEL = new String[] {};
|
||||||
|
|
||||||
public PoiFiltersHelper(OsmandApplication application){
|
public PoiFiltersHelper(OsmandApplication application){
|
||||||
this.application = application;
|
this.application = application;
|
||||||
}
|
}
|
||||||
|
@ -60,76 +74,125 @@ public class PoiFiltersHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void putAll(Map<AmenityType, LinkedHashSet<String>> types, AmenityType tp){
|
||||||
|
types.put(tp, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void putValues(Map<AmenityType, LinkedHashSet<String>> types, AmenityType tp,String... vls){
|
||||||
|
LinkedHashSet<String> list = new LinkedHashSet<String>();
|
||||||
|
for(String v: vls){
|
||||||
|
list.add(v);
|
||||||
|
}
|
||||||
|
types.put(tp, list);
|
||||||
|
}
|
||||||
|
|
||||||
private List<PoiFilter> getUserDefinedDefaultFilters() {
|
private List<PoiFilter> getUserDefinedDefaultFilters() {
|
||||||
List<PoiFilter> filters = new ArrayList<PoiFilter>();
|
List<PoiFilter> filters = new ArrayList<PoiFilter>();
|
||||||
Map<AmenityType, LinkedHashSet<String>> types = new LinkedHashMap<AmenityType, LinkedHashSet<String>>();
|
filters.add(new PoiFilter(application.getString(R.string.poi_filter_car_aid), PoiFilter.USER_PREFIX + UDF_CAR_AID,
|
||||||
|
configureDefaultUserDefinedFilter(null, UDF_CAR_AID), application));
|
||||||
LinkedHashSet<String> list = new LinkedHashSet<String>();
|
filters.add(new PoiFilter(application.getString(R.string.poi_filter_for_tourists), PoiFilter.USER_PREFIX + UDF_FOR_TOURISTS,
|
||||||
list.add("fuel"); //$NON-NLS-1$
|
configureDefaultUserDefinedFilter(null, UDF_FOR_TOURISTS), application));
|
||||||
list.add("car_wash"); //$NON-NLS-1$
|
filters.add(new PoiFilter(application.getString(R.string.poi_filter_fuel), PoiFilter.USER_PREFIX + UDF_FUEL,
|
||||||
list.add("car_repair"); //$NON-NLS-1$
|
configureDefaultUserDefinedFilter(null, UDF_FUEL), application));
|
||||||
types.put(AmenityType.TRANSPORTATION, list);
|
filters.add(new PoiFilter(application.getString(R.string.poi_filter_food_shop), PoiFilter.USER_PREFIX + UDF_FOOD_SHOP,
|
||||||
list = new LinkedHashSet<String>();
|
configureDefaultUserDefinedFilter(null, UDF_FOOD_SHOP), application));
|
||||||
list.add("car"); //$NON-NLS-1$
|
filters.add(new PoiFilter(application.getString(R.string.poi_filter_sightseeing), PoiFilter.USER_PREFIX + UDF_SIGHTSEEING,
|
||||||
list.add("car_repair"); //$NON-NLS-1$
|
configureDefaultUserDefinedFilter(null, UDF_SIGHTSEEING), application));
|
||||||
types.put(AmenityType.SHOP, list);
|
|
||||||
filters.add(new PoiFilter(application.getString(R.string.poi_filter_car_aid), null, types, application)); //$NON-NLS-1$
|
|
||||||
types.clear();
|
|
||||||
|
|
||||||
|
|
||||||
types.put(AmenityType.HISTORIC, null);
|
|
||||||
types.put(AmenityType.TOURISM, null);
|
|
||||||
list = new LinkedHashSet<String>();
|
|
||||||
list.add("place_of_worship"); //$NON-NLS-1$
|
|
||||||
list.add("internet_access"); //$NON-NLS-1$
|
|
||||||
list.add("embassy"); //$NON-NLS-1$
|
|
||||||
list.add("emergency_phone"); //$NON-NLS-1$
|
|
||||||
list.add("marketplace"); //$NON-NLS-1$
|
|
||||||
list.add("post_office"); //$NON-NLS-1$
|
|
||||||
list.add("telephone"); //$NON-NLS-1$
|
|
||||||
list.add("toilets"); //$NON-NLS-1$
|
|
||||||
types.put(AmenityType.OTHER, list);
|
|
||||||
filters.add(new PoiFilter(application.getString(R.string.poi_filter_for_tourists), null, types, application)); //$NON-NLS-1$
|
|
||||||
types.clear();
|
|
||||||
|
|
||||||
list = new LinkedHashSet<String>();
|
|
||||||
list.add("fuel"); //$NON-NLS-1$
|
|
||||||
types.put(AmenityType.TRANSPORTATION, list);
|
|
||||||
filters.add(new PoiFilter(application.getString(R.string.poi_filter_fuel), null, types, application)); //$NON-NLS-1$
|
|
||||||
types.clear();
|
|
||||||
|
|
||||||
list = new LinkedHashSet<String>();
|
|
||||||
list.add("alcohol"); //$NON-NLS-1$
|
|
||||||
list.add("bakery"); //$NON-NLS-1$
|
|
||||||
list.add("beverages"); //$NON-NLS-1$
|
|
||||||
list.add("butcher"); //$NON-NLS-1$
|
|
||||||
list.add("convenience"); //$NON-NLS-1$
|
|
||||||
list.add("department_store"); //$NON-NLS-1$
|
|
||||||
list.add("convenience"); //$NON-NLS-1$
|
|
||||||
list.add("farm"); //$NON-NLS-1$
|
|
||||||
list.add("general"); //$NON-NLS-1$
|
|
||||||
list.add("ice_cream"); //$NON-NLS-1$
|
|
||||||
list.add("kiosk"); //$NON-NLS-1$
|
|
||||||
list.add("supermarket"); //$NON-NLS-1$
|
|
||||||
list.add("variety_store"); //$NON-NLS-1$
|
|
||||||
types.put(AmenityType.SHOP, list);
|
|
||||||
filters.add(new PoiFilter(application.getString(R.string.poi_filter_food_shop), null, types, application)); //$NON-NLS-1$
|
|
||||||
types.clear();
|
|
||||||
|
|
||||||
|
// UDF_EMERGENCY = "emergency";
|
||||||
|
// UDF_ENTERTAINMENT = "entertainment";
|
||||||
|
filters.add(new PoiFilter(application.getString(R.string.poi_filter_accomodation), PoiFilter.USER_PREFIX + UDF_ACCOMODATION,
|
||||||
|
configureDefaultUserDefinedFilter(null, UDF_ACCOMODATION), application));
|
||||||
|
filters.add(new PoiFilter(application.getString(R.string.poi_filter_restaurants), PoiFilter.USER_PREFIX + UDF_RESTAURANTS,
|
||||||
|
configureDefaultUserDefinedFilter(null, UDF_RESTAURANTS), application));
|
||||||
|
filters.add(new PoiFilter(application.getString(R.string.poi_filter_public_transport),
|
||||||
|
PoiFilter.USER_PREFIX + UDF_PUBLIC_TRANSPORT, configureDefaultUserDefinedFilter(null, UDF_PUBLIC_TRANSPORT), application));
|
||||||
|
filters.add(new PoiFilter(application.getString(R.string.poi_filter_parking), PoiFilter.USER_PREFIX + UDF_PARKING,
|
||||||
|
configureDefaultUserDefinedFilter(null, UDF_PARKING), application));
|
||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<AmenityType, LinkedHashSet<String>> configureDefaultUserDefinedFilter(Map<AmenityType, LinkedHashSet<String>> types, String key) {
|
||||||
|
if(types == null) {
|
||||||
|
types = new LinkedHashMap<AmenityType, LinkedHashSet<String>>();
|
||||||
|
}
|
||||||
|
if(UDF_CAR_AID.equals(key)){
|
||||||
|
putValues(types, AmenityType.TRANSPORTATION, "fuel", "car_wash", "car_repair","car", "car_sharing");
|
||||||
|
putValues(types, AmenityType.SHOP, "fuel", "car_wash", "car_repair","car");
|
||||||
|
} else if(UDF_SIGHTSEEING.equals(key)){
|
||||||
|
putAll(types, AmenityType.HISTORIC);
|
||||||
|
putAll(types, AmenityType.TOURISM);
|
||||||
|
putValues(types, AmenityType.OTHER, "place_of_worship");
|
||||||
|
} else if(UDF_FOR_TOURISTS.equals(key)){
|
||||||
|
putAll(types, AmenityType.HISTORIC);
|
||||||
|
putAll(types, AmenityType.TOURISM);
|
||||||
|
putAll(types, AmenityType.FINANCE);
|
||||||
|
putValues(types, AmenityType.OTHER, "place_of_worship", "internet_access", "embassy","emergency_phone","marketplace",
|
||||||
|
"post_office","telephone", "toilets");
|
||||||
|
} else if(UDF_FUEL.equals(key)){
|
||||||
|
putValues(types, AmenityType.TRANSPORTATION, "fuel");
|
||||||
|
} else if (UDF_FOOD_SHOP.equals(key)) {
|
||||||
|
putValues(types, AmenityType.SHOP, "alcohol", "bakery", "beverages", "butcher", "convenience", "department_store",
|
||||||
|
"convenience", "farm", "general", "ice_cream", "kiosk", "supermarket", "variety_store");
|
||||||
|
} else if (UDF_SIGHTSEEING.equals(key)) {
|
||||||
|
putAll(types, AmenityType.HISTORIC);
|
||||||
|
putValues(types, AmenityType.TOURISM, "attraction",
|
||||||
|
"artwork","zoo","theme_park", "museum","viewpoint");
|
||||||
|
putValues(types, AmenityType.OTHER, "place_of_worship");
|
||||||
|
} else if (UDF_ACCOMODATION.equals(key)) {
|
||||||
|
putValues(types, AmenityType.TOURISM, "camp_site",
|
||||||
|
"caravan_site","picnic_site","alpine_hut", "chalet","guest_house",
|
||||||
|
"hostel", "hotel","motel");
|
||||||
|
} else if (UDF_PARKING.equals(key)) {
|
||||||
|
putValues(types, AmenityType.TRANSPORTATION, "parking",
|
||||||
|
"bicycle_parking");
|
||||||
|
} else if (UDF_PUBLIC_TRANSPORT.equals(key)) {
|
||||||
|
putValues(types, AmenityType.TRANSPORTATION, "public_transport_stop_position", "public_transport_platform",
|
||||||
|
"public_transport_station",
|
||||||
|
// railway
|
||||||
|
"railway_platform", "railway_station", "halt", "tram_stop", "subway_entrance", "railway_buffer_stop",
|
||||||
|
// bus, cars, bicycle
|
||||||
|
"bus_stop", "platform", "ferry_terminal", "taxi", "bicycle_rental", "bus_station", "car_rental", "car_sharing",
|
||||||
|
// aero
|
||||||
|
"airport", "aerodrome", "terminal", "gate",
|
||||||
|
// aerial ways
|
||||||
|
"aerialway_cable_car", "aerialway_gondola", "aerialway_chair_lift", "aerialway_mixed_lift", "aerialway_drag_lift",
|
||||||
|
"aerialway_goods", "aerialway_station",
|
||||||
|
// ways
|
||||||
|
"rail", "tram", "light_rail", "subway", "railway_narrow_gauge", "railway_monorail", "railway_funicular");
|
||||||
|
} else if (UDF_RESTAURANTS.equals(key)) {
|
||||||
|
putValues(types, AmenityType.SUSTENANCE, "restaurant",
|
||||||
|
"cafe", "food_court", "fast_food", "pub", "bar", "biergarten");
|
||||||
|
} else if (UDF_EMERGENCY.equals(key)) {
|
||||||
|
putAll(types, AmenityType.HEALTHCARE);
|
||||||
|
putAll(types, AmenityType.EMERGENCY);
|
||||||
|
} else if (UDF_ENTERTAINMENT.equals(key)) {
|
||||||
|
putAll(types, AmenityType.ENTERTAINMENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<PoiFilter> getUserDefinedPoiFilters(){
|
public List<PoiFilter> getUserDefinedPoiFilters(){
|
||||||
if(cacheUserDefinedFilters == null){
|
if(cacheUserDefinedFilters == null){
|
||||||
////ctx.deleteDatabase(PoiFilterDbHelper.DATABASE_NAME);
|
|
||||||
|
|
||||||
cacheUserDefinedFilters = new ArrayList<PoiFilter>();
|
cacheUserDefinedFilters = new ArrayList<PoiFilter>();
|
||||||
PoiFilter filter = new PoiFilter(application.getString(R.string.poi_filter_custom_filter), PoiFilter.CUSTOM_FILTER_ID, new LinkedHashMap<AmenityType, LinkedHashSet<String>>(), application); //$NON-NLS-1$
|
PoiFilter filter = new PoiFilter(application.getString(R.string.poi_filter_custom_filter), PoiFilter.CUSTOM_FILTER_ID,
|
||||||
|
new LinkedHashMap<AmenityType, LinkedHashSet<String>>(), application); //$NON-NLS-1$
|
||||||
|
filter.setStandardFilter(true);
|
||||||
cacheUserDefinedFilters.add(filter);
|
cacheUserDefinedFilters.add(filter);
|
||||||
filter = new SearchByNameFilter(application);
|
filter = new SearchByNameFilter(application);
|
||||||
cacheUserDefinedFilters.add(filter);
|
cacheUserDefinedFilters.add(filter);
|
||||||
PoiFilterDbHelper helper = openDbHelper();
|
PoiFilterDbHelper helper = openDbHelper();
|
||||||
cacheUserDefinedFilters.addAll(helper.getFilters());
|
List<PoiFilter> userDefined = helper.getFilters(helper.getReadableDatabase());
|
||||||
|
final Collator instance = Collator.getInstance();
|
||||||
|
Collections.sort(userDefined, new Comparator<PoiFilter>() {
|
||||||
|
@Override
|
||||||
|
public int compare(PoiFilter object1, PoiFilter object2) {
|
||||||
|
return instance.compare(object1.getName(), object2.getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cacheUserDefinedFilters.addAll(userDefined);
|
||||||
helper.close();
|
helper.close();
|
||||||
}
|
}
|
||||||
return Collections.unmodifiableList(cacheUserDefinedFilters);
|
return Collections.unmodifiableList(cacheUserDefinedFilters);
|
||||||
|
@ -139,6 +202,12 @@ public class PoiFiltersHelper {
|
||||||
return PoiFilter.STD_PREFIX + t;
|
return PoiFilter.STD_PREFIX + t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateFilters(boolean onlyAddFilters){
|
||||||
|
PoiFilterDbHelper helper = openDbHelper();
|
||||||
|
helper.upgradeFilters(helper.getWritableDatabase(), onlyAddFilters);
|
||||||
|
helper.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<PoiFilter> getOsmDefinedPoiFilters(){
|
public List<PoiFilter> getOsmDefinedPoiFilters(){
|
||||||
if(cacheOsmDefinedFilters == null){
|
if(cacheOsmDefinedFilters == null){
|
||||||
|
@ -171,7 +240,7 @@ public class PoiFiltersHelper {
|
||||||
if(helper == null){
|
if(helper == null){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
boolean res = helper.deleteFilter(filter);
|
boolean res = helper.deleteFilter(helper.getWritableDatabase(), filter);
|
||||||
if(res){
|
if(res){
|
||||||
cacheUserDefinedFilters.remove(filter);
|
cacheUserDefinedFilters.remove(filter);
|
||||||
}
|
}
|
||||||
|
@ -201,7 +270,7 @@ public class PoiFiltersHelper {
|
||||||
}
|
}
|
||||||
PoiFilterDbHelper helper = openDbHelper();
|
PoiFilterDbHelper helper = openDbHelper();
|
||||||
if (helper != null) {
|
if (helper != null) {
|
||||||
boolean res = helper.editFilter(filter);
|
boolean res = helper.editFilter(helper.getWritableDatabase(), filter);
|
||||||
helper.close();
|
helper.close();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -212,7 +281,7 @@ public class PoiFiltersHelper {
|
||||||
public class PoiFilterDbHelper extends SQLiteOpenHelper {
|
public class PoiFilterDbHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
public static final String DATABASE_NAME = "poi_filters"; //$NON-NLS-1$
|
public static final String DATABASE_NAME = "poi_filters"; //$NON-NLS-1$
|
||||||
private static final int DATABASE_VERSION = 1;
|
private static final int DATABASE_VERSION = 2;
|
||||||
private static final String FILTER_NAME = "poi_filters"; //$NON-NLS-1$
|
private static final String FILTER_NAME = "poi_filters"; //$NON-NLS-1$
|
||||||
private static final String FILTER_COL_NAME = "name"; //$NON-NLS-1$
|
private static final String FILTER_COL_NAME = "name"; //$NON-NLS-1$
|
||||||
private static final String FILTER_COL_ID = "id"; //$NON-NLS-1$
|
private static final String FILTER_COL_ID = "id"; //$NON-NLS-1$
|
||||||
|
@ -236,14 +305,45 @@ public class PoiFiltersHelper {
|
||||||
public void onCreate(SQLiteDatabase db) {
|
public void onCreate(SQLiteDatabase db) {
|
||||||
db.execSQL(FILTER_TABLE_CREATE);
|
db.execSQL(FILTER_TABLE_CREATE);
|
||||||
db.execSQL(CATEGORIES_TABLE_CREATE);
|
db.execSQL(CATEGORIES_TABLE_CREATE);
|
||||||
List<PoiFilter> filters = getUserDefinedDefaultFilters();
|
upgradeFilters(db, true);
|
||||||
for(PoiFilter f : filters){
|
|
||||||
addFilter(f, db,false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void upgradeFilters(SQLiteDatabase db, boolean onlyAdd) {
|
||||||
|
List<PoiFilter> filters = PoiFilterDbHelper.this.getFilters(db);
|
||||||
|
List<PoiFilter> def = getUserDefinedDefaultFilters();
|
||||||
|
for(PoiFilter f : filters){
|
||||||
|
PoiFilter std = null;
|
||||||
|
for(PoiFilter d : def){
|
||||||
|
if(f.getFilterId().equals(d.getFilterId())){
|
||||||
|
std = d;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(String toDel : DEL) {
|
||||||
|
if(f.getFilterId().equals(toDel)) {
|
||||||
|
deleteFilter(db, f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(std != null){
|
||||||
|
if(!onlyAdd){
|
||||||
|
editFilter(db, std);
|
||||||
|
} else {
|
||||||
|
updateName(db, std);
|
||||||
|
}
|
||||||
|
def.remove(std);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(PoiFilter d : def){
|
||||||
|
addFilter(d, db, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
if (newVersion == 2 || newVersion == 3) {
|
||||||
|
upgradeFilters(db, false);
|
||||||
|
} else {
|
||||||
|
upgradeFilters(db, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean addFilter(PoiFilter p, SQLiteDatabase db, boolean addOnlyCategories){
|
protected boolean addFilter(PoiFilter p, SQLiteDatabase db, boolean addOnlyCategories){
|
||||||
|
@ -274,8 +374,7 @@ public class PoiFiltersHelper {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<PoiFilter> getFilters(){
|
protected List<PoiFilter> getFilters(SQLiteDatabase db){
|
||||||
SQLiteDatabase db = getReadableDatabase();
|
|
||||||
ArrayList<PoiFilter> list = new ArrayList<PoiFilter>();
|
ArrayList<PoiFilter> list = new ArrayList<PoiFilter>();
|
||||||
if(db != null){
|
if(db != null){
|
||||||
Cursor query = db.rawQuery("SELECT " + CATEGORIES_FILTER_ID +", " + CATEGORIES_COL_CATEGORY +"," + CATEGORIES_COL_SUBCATEGORY +" FROM " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
Cursor query = db.rawQuery("SELECT " + CATEGORIES_FILTER_ID +", " + CATEGORIES_COL_CATEGORY +"," + CATEGORIES_COL_SUBCATEGORY +" FROM " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
|
@ -319,21 +418,23 @@ public class PoiFiltersHelper {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean editFilter(PoiFilter filter) {
|
protected boolean editFilter(SQLiteDatabase db, PoiFilter filter) {
|
||||||
SQLiteDatabase db = getWritableDatabase();
|
|
||||||
if (db != null) {
|
if (db != null) {
|
||||||
db.execSQL("DELETE FROM " + CATEGORIES_NAME + " WHERE " + CATEGORIES_FILTER_ID + " = ?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
db.execSQL("DELETE FROM " + CATEGORIES_NAME + " WHERE " + CATEGORIES_FILTER_ID + " = ?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
new Object[] { filter.getFilterId() });
|
new Object[] { filter.getFilterId() });
|
||||||
addFilter(filter, db, true);
|
addFilter(filter, db, true);
|
||||||
db.execSQL("UPDATE " + FILTER_NAME + " SET " + FILTER_COL_FILTERBYNAME + " = ?, " + FILTER_COL_NAME + " = ? " + " WHERE " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
updateName(db, filter);
|
||||||
+ FILTER_COL_ID + "= ?", new Object[] { filter.getFilterByName(), filter.getName(), filter.getFilterId() }); //$NON-NLS-1$
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean deleteFilter(PoiFilter p){
|
private void updateName(SQLiteDatabase db, PoiFilter filter) {
|
||||||
SQLiteDatabase db = getWritableDatabase();
|
db.execSQL("UPDATE " + FILTER_NAME + " SET " + FILTER_COL_FILTERBYNAME + " = ?, " + FILTER_COL_NAME + " = ? " + " WHERE " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
||||||
|
+ FILTER_COL_ID + "= ?", new Object[] { filter.getFilterByName(), filter.getName(), filter.getFilterId() }); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean deleteFilter(SQLiteDatabase db, PoiFilter p){
|
||||||
if(db != null){
|
if(db != null){
|
||||||
db.execSQL("DELETE FROM " + FILTER_NAME + " WHERE " +FILTER_COL_ID + " = ?",new Object[]{p.getFilterId()}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
db.execSQL("DELETE FROM " + FILTER_NAME + " WHERE " +FILTER_COL_ID + " = ?",new Object[]{p.getFilterId()}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
db.execSQL("DELETE FROM " + CATEGORIES_NAME + " WHERE " +CATEGORIES_FILTER_ID + " = ?", new Object[]{p.getFilterId()}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
db.execSQL("DELETE FROM " + CATEGORIES_NAME + " WHERE " +CATEGORIES_FILTER_ID + " = ?", new Object[]{p.getFilterId()}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
|
|
@ -21,6 +21,7 @@ public class SearchByNameFilter extends PoiFilter {
|
||||||
public SearchByNameFilter(OsmandApplication application) {
|
public SearchByNameFilter(OsmandApplication application) {
|
||||||
super(application.getString(R.string.poi_filter_by_name), FILTER_ID, new LinkedHashMap<AmenityType, LinkedHashSet<String>>(), application);
|
super(application.getString(R.string.poi_filter_by_name), FILTER_ID, new LinkedHashMap<AmenityType, LinkedHashSet<String>>(), application);
|
||||||
this.distanceToSearchValues = new double[] {100, 1000, 5000};
|
this.distanceToSearchValues = new double[] {100, 1000, 5000};
|
||||||
|
this.isStandardFilter = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -108,18 +108,31 @@ public class EditPOIFilterActivity extends OsmandListActivity {
|
||||||
});
|
});
|
||||||
|
|
||||||
((ImageButton) findViewById(R.id.SaveButton)).setOnClickListener(new OnClickListener() {
|
((ImageButton) findViewById(R.id.SaveButton)).setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
savePoiFilter();
|
savePoiFilter();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
((ImageButton) findViewById(R.id.DeleteButton)).setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
removePoiFilter();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Bundle bundle = this.getIntent().getExtras();
|
Bundle bundle = this.getIntent().getExtras();
|
||||||
String filterId = bundle.getString(AMENITY_FILTER);
|
String filterId = bundle.getString(AMENITY_FILTER);
|
||||||
|
|
||||||
helper = ((OsmandApplication)getApplication()).getPoiFilters();
|
helper = ((OsmandApplication)getApplication()).getPoiFilters();
|
||||||
filter = helper.getFilterById(filterId);
|
filter = helper.getFilterById(filterId);
|
||||||
|
if(filter.isStandardFilter()){
|
||||||
|
((ImageButton) findViewById(R.id.DeleteButton)).setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
((ImageButton) findViewById(R.id.DeleteButton)).setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
titleBar.getTitleView().setText(getString(R.string.filterpoi_activity) + " - " + filter.getName());
|
titleBar.getTitleView().setText(getString(R.string.filterpoi_activity) + " - " + filter.getName());
|
||||||
|
|
||||||
setListAdapter(new AmenityAdapter(AmenityType.getCategories()));
|
setListAdapter(new AmenityAdapter(AmenityType.getCategories()));
|
||||||
|
@ -160,6 +173,17 @@ public class EditPOIFilterActivity extends OsmandListActivity {
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
if (item.getItemId() == R.id.edit_filter_delete) {
|
if (item.getItemId() == R.id.edit_filter_delete) {
|
||||||
|
removePoiFilter();
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.edit_filter_save_as) {
|
||||||
|
savePoiFilter();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void removePoiFilter() {
|
||||||
Builder builder = new AlertDialog.Builder(this);
|
Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setMessage(R.string.edit_filter_delete_dialog_title);
|
builder.setMessage(R.string.edit_filter_delete_dialog_title);
|
||||||
builder.setNegativeButton(R.string.default_buttons_no, null);
|
builder.setNegativeButton(R.string.default_buttons_no, null);
|
||||||
|
@ -177,12 +201,6 @@ public class EditPOIFilterActivity extends OsmandListActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
return true;
|
|
||||||
} else if (item.getItemId() == R.id.edit_filter_save_as) {
|
|
||||||
savePoiFilter();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showDialog(final AmenityType amenity) {
|
private void showDialog(final AmenityType amenity) {
|
||||||
|
|
|
@ -55,9 +55,12 @@ public class SearchPoiFilterActivity extends ListActivity {
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
|
public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
|
||||||
PoiFilter poi = ((AmenityAdapter) getListAdapter()).getItem(pos);
|
PoiFilter poi = ((AmenityAdapter) getListAdapter()).getItem(pos);
|
||||||
|
if(!poi.isStandardFilter() || poi.getFilterId().equals(PoiFilter.CUSTOM_FILTER_ID)) {
|
||||||
showEditActivity(poi);
|
showEditActivity(poi);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
@ -97,14 +100,12 @@ public class SearchPoiFilterActivity extends ListActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showEditActivity(PoiFilter poi) {
|
private void showEditActivity(PoiFilter poi) {
|
||||||
if(!poi.isStandardFilter()) {
|
|
||||||
Intent newIntent = new Intent(SearchPoiFilterActivity.this, EditPOIFilterActivity.class);
|
Intent newIntent = new Intent(SearchPoiFilterActivity.this, EditPOIFilterActivity.class);
|
||||||
// folder selected
|
// folder selected
|
||||||
newIntent.putExtra(EditPOIFilterActivity.AMENITY_FILTER, poi.getFilterId());
|
newIntent.putExtra(EditPOIFilterActivity.AMENITY_FILTER, poi.getFilterId());
|
||||||
updateIntentToLaunch(newIntent);
|
updateIntentToLaunch(newIntent);
|
||||||
startActivityForResult(newIntent, 0);
|
startActivityForResult(newIntent, 0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onListItemClick(ListView parent, View v, int position, long id) {
|
public void onListItemClick(ListView parent, View v, int position, long id) {
|
||||||
|
@ -131,16 +132,19 @@ public class SearchPoiFilterActivity extends ListActivity {
|
||||||
|
|
||||||
class AmenityAdapter extends ArrayAdapter<PoiFilter> {
|
class AmenityAdapter extends ArrayAdapter<PoiFilter> {
|
||||||
AmenityAdapter(List<PoiFilter> list) {
|
AmenityAdapter(List<PoiFilter> list) {
|
||||||
super(SearchPoiFilterActivity.this, R.layout.searchpoi_list, list);
|
super(SearchPoiFilterActivity.this, R.layout.searchpoifolder_list, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
View row = convertView;
|
||||||
|
if(row == null) {
|
||||||
LayoutInflater inflater = getLayoutInflater();
|
LayoutInflater inflater = getLayoutInflater();
|
||||||
View row = inflater.inflate(R.layout.searchpoifolder_list, parent, false);
|
row = inflater.inflate(R.layout.searchpoifolder_list, parent, false);
|
||||||
|
}
|
||||||
TextView label = (TextView) row.findViewById(R.id.folder_label);
|
TextView label = (TextView) row.findViewById(R.id.folder_label);
|
||||||
ImageView icon = (ImageView) row.findViewById(R.id.folder_icon);
|
ImageView icon = (ImageView) row.findViewById(R.id.folder_icon);
|
||||||
PoiFilter model = getItem(position);
|
final PoiFilter model = getItem(position);
|
||||||
label.setText(model.getName());
|
label.setText(model.getName());
|
||||||
if(model.getFilterId().equals(PoiFilter.CUSTOM_FILTER_ID)) {
|
if(model.getFilterId().equals(PoiFilter.CUSTOM_FILTER_ID)) {
|
||||||
icon.setImageResource(android.R.drawable.ic_input_get);
|
icon.setImageResource(android.R.drawable.ic_input_get);
|
||||||
|
@ -151,6 +155,20 @@ public class SearchPoiFilterActivity extends ListActivity {
|
||||||
// label.setTypeface(Typeface.DEFAULT);
|
// label.setTypeface(Typeface.DEFAULT);
|
||||||
icon.setImageResource(model.isStandardFilter() ? R.drawable.folder : R.drawable.tab_icon_favourite_menu);
|
icon.setImageResource(model.isStandardFilter() ? R.drawable.folder : R.drawable.tab_icon_favourite_menu);
|
||||||
}
|
}
|
||||||
|
ImageView editIcon = (ImageView) row.findViewById(R.id.folder_edit_icon);
|
||||||
|
if (model.isStandardFilter()) {
|
||||||
|
editIcon.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
editIcon.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
editIcon.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
showEditActivity(model);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return (row);
|
return (row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -221,45 +221,46 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
view.getContext(), view.getSettings());
|
view.getContext(), view.getSettings());
|
||||||
// register right stack
|
// register right stack
|
||||||
EnumSet<ApplicationMode> all = EnumSet.allOf(ApplicationMode.class);
|
EnumSet<ApplicationMode> all = EnumSet.allOf(ApplicationMode.class);
|
||||||
|
EnumSet<ApplicationMode> carDefault = EnumSet.of(ApplicationMode.CAR, ApplicationMode.DEFAULT);
|
||||||
EnumSet<ApplicationMode> bicyclePedestrian = EnumSet.of(ApplicationMode.BICYCLE, ApplicationMode.PEDESTRIAN);
|
EnumSet<ApplicationMode> bicyclePedestrian = EnumSet.of(ApplicationMode.BICYCLE, ApplicationMode.PEDESTRIAN);
|
||||||
EnumSet<ApplicationMode> exceptCar = EnumSet.of(ApplicationMode.BICYCLE, ApplicationMode.PEDESTRIAN, ApplicationMode.DEFAULT);
|
EnumSet<ApplicationMode> exceptCar = EnumSet.of(ApplicationMode.BICYCLE, ApplicationMode.PEDESTRIAN, ApplicationMode.DEFAULT);
|
||||||
EnumSet<ApplicationMode> none = EnumSet.noneOf(ApplicationMode.class);
|
EnumSet<ApplicationMode> none = EnumSet.noneOf(ApplicationMode.class);
|
||||||
RoutingHelper routingHelper = view.getApplication().getRoutingHelper();
|
RoutingHelper routingHelper = view.getApplication().getRoutingHelper();
|
||||||
NextTurnInfoControl bigInfoControl = ric.createNextInfoControl(routingHelper, view.getApplication(), view.getSettings(), paintText,
|
NextTurnInfoControl bigInfoControl = ric.createNextInfoControl(routingHelper, view.getApplication(), view.getSettings(), paintText,
|
||||||
paintSubText, false);
|
paintSubText, false);
|
||||||
mapInfoControls.registerSideWidget(bigInfoControl, R.drawable.widget_next_turn, R.string.map_widget_next_turn,"next_turn", true, all, none, 5);
|
mapInfoControls.registerSideWidget(bigInfoControl, R.drawable.widget_next_turn, R.string.map_widget_next_turn,"next_turn", true, carDefault, none, 5);
|
||||||
NextTurnInfoControl smallInfoControl = ric.createNextInfoControl(routingHelper, view.getApplication(), view.getSettings(),
|
NextTurnInfoControl smallInfoControl = ric.createNextInfoControl(routingHelper, view.getApplication(), view.getSettings(),
|
||||||
paintSmallText, paintSmallSubText, true);
|
paintSmallText, paintSmallSubText, true);
|
||||||
mapInfoControls.registerSideWidget(smallInfoControl, R.drawable.widget_next_turn, R.string.map_widget_next_turn_small, "next_turn_small", true, bicyclePedestrian, none, 10);
|
mapInfoControls.registerSideWidget(smallInfoControl, R.drawable.widget_next_turn, R.string.map_widget_next_turn_small, "next_turn_small", true, bicyclePedestrian, none, 10);
|
||||||
NextTurnInfoControl nextNextInfoControl = ric.createNextNextInfoControl(routingHelper, view.getApplication(), view.getSettings(),
|
NextTurnInfoControl nextNextInfoControl = ric.createNextNextInfoControl(routingHelper, view.getApplication(), view.getSettings(),
|
||||||
paintSmallText, paintSmallSubText, true);
|
paintSmallText, paintSmallSubText, true);
|
||||||
mapInfoControls.registerSideWidget(nextNextInfoControl, R.drawable.widget_next_turn, R.string.map_widget_next_next_turn, "next_next_turn",true, all, none, 15);
|
mapInfoControls.registerSideWidget(nextNextInfoControl, R.drawable.widget_next_turn, R.string.map_widget_next_next_turn, "next_next_turn",true, carDefault, none, 15);
|
||||||
//MiniMapControl miniMap = ric.createMiniMapControl(routingHelper, view);
|
//MiniMapControl miniMap = ric.createMiniMapControl(routingHelper, view);
|
||||||
//mapInfoControls.registerSideWidget(miniMap, R.drawable.widget_next_turn, R.string.map_widget_mini_route, "mini_route", true, none, none, 20);
|
//mapInfoControls.registerSideWidget(miniMap, R.drawable.widget_next_turn, R.string.map_widget_mini_route, "mini_route", true, none, none, 20);
|
||||||
// right stack
|
// right stack
|
||||||
TextInfoControl dist = ric.createDistanceControl(map, paintText, paintSubText);
|
TextInfoControl dist = ric.createDistanceControl(map, paintText, paintSubText);
|
||||||
mapInfoControls.registerSideWidget(dist, R.drawable.widget_target, R.string.map_widget_distance, "distance", false, all, none, 5);
|
mapInfoControls.registerSideWidget(dist, R.drawable.widget_target, R.string.map_widget_distance, "distance", false, carDefault, none, 5);
|
||||||
TextInfoControl time = ric.createTimeControl(map, paintText, paintSubText);
|
TextInfoControl time = ric.createTimeControl(map, paintText, paintSubText);
|
||||||
mapInfoControls.registerSideWidget(time, R.drawable.widget_time, R.string.map_widget_time, "time",false, all, none, 10);
|
mapInfoControls.registerSideWidget(time, R.drawable.widget_time, R.string.map_widget_time, "time",false, carDefault, none, 10);
|
||||||
TextInfoControl speed = ric.createSpeedControl(map, paintText, paintSubText);
|
TextInfoControl speed = ric.createSpeedControl(map, paintText, paintSubText);
|
||||||
mapInfoControls.registerSideWidget(speed, R.drawable.widget_speed, R.string.map_widget_speed, "speed", false, all, none, 15);
|
mapInfoControls.registerSideWidget(speed, R.drawable.widget_speed, R.string.map_widget_speed, "speed", false, carDefault, none, 15);
|
||||||
TextInfoControl alt = ric.createAltitudeControl(map, paintText, paintSubText);
|
TextInfoControl alt = ric.createAltitudeControl(map, paintText, paintSubText);
|
||||||
mapInfoControls.registerSideWidget(alt, R.drawable.widget_altitude, R.string.map_widget_altitude, "altitude", false, EnumSet.of(ApplicationMode.PEDESTRIAN), none, 20);
|
mapInfoControls.registerSideWidget(alt, R.drawable.widget_altitude, R.string.map_widget_altitude, "altitude", false, EnumSet.of(ApplicationMode.PEDESTRIAN), none, 20);
|
||||||
|
|
||||||
// Top widgets
|
// Top widgets
|
||||||
ImageViewControl compassView = createCompassView(map);
|
ImageViewControl compassView = createCompassView(map);
|
||||||
mapInfoControls.registerTopWidget(compassView, R.drawable.compass, R.string.map_widget_compass, "compass", MapInfoControls.LEFT_CONTROL, all, 5);
|
mapInfoControls.registerTopWidget(compassView, R.drawable.compass, R.string.map_widget_compass, "compass", MapInfoControls.LEFT_CONTROL, carDefault, 5);
|
||||||
View config = createConfiguration();
|
View config = createConfiguration();
|
||||||
mapInfoControls.registerTopWidget(config, R.drawable.widget_config, R.string.map_widget_config, "config", MapInfoControls.RIGHT_CONTROL, all, 10).required(ApplicationMode.DEFAULT);
|
mapInfoControls.registerTopWidget(config, R.drawable.widget_config, R.string.map_widget_config, "config", MapInfoControls.RIGHT_CONTROL, carDefault, 10).required(ApplicationMode.DEFAULT);
|
||||||
ImageView lockView = lockInfoControl.createLockScreenWidget(view, map);
|
ImageView lockView = lockInfoControl.createLockScreenWidget(view, map);
|
||||||
mapInfoControls.registerTopWidget(lockView, R.drawable.lock_enabled, R.string.bg_service_screen_lock, "bgService", MapInfoControls.LEFT_CONTROL, exceptCar, 15);
|
mapInfoControls.registerTopWidget(lockView, R.drawable.lock_enabled, R.string.bg_service_screen_lock, "bgService", MapInfoControls.LEFT_CONTROL, exceptCar, 15);
|
||||||
backToLocation = createBackToLocation(map);
|
backToLocation = createBackToLocation(map);
|
||||||
mapInfoControls.registerTopWidget(backToLocation, R.drawable.default_location, R.string.map_widget_back_to_loc, "back_to_location", MapInfoControls.RIGHT_CONTROL, all, 5);
|
mapInfoControls.registerTopWidget(backToLocation, R.drawable.default_location, R.string.map_widget_back_to_loc, "back_to_location", MapInfoControls.RIGHT_CONTROL, carDefault, 5);
|
||||||
View globus = createGlobus();
|
View globus = createGlobus();
|
||||||
mapInfoControls.registerTopWidget(globus, R.drawable.globus, R.string.map_widget_map_select, "progress", MapInfoControls.RIGHT_CONTROL, none, 15);
|
mapInfoControls.registerTopWidget(globus, R.drawable.globus, R.string.map_widget_map_select, "progress", MapInfoControls.RIGHT_CONTROL, none, 15);
|
||||||
|
|
||||||
topText = new TopTextView(routingHelper, map);
|
topText = new TopTextView(routingHelper, map);
|
||||||
mapInfoControls.registerTopWidget(topText, R.drawable.street_name, R.string.map_widget_top_text, "street_name", MapInfoControls.MAIN_CONTROL, all, 100);
|
mapInfoControls.registerTopWidget(topText, R.drawable.street_name, R.string.map_widget_top_text, "street_name", MapInfoControls.MAIN_CONTROL, carDefault, 100);
|
||||||
|
|
||||||
// Register appearance widgets
|
// Register appearance widgets
|
||||||
registerAppearanceWidgets();
|
registerAppearanceWidgets();
|
||||||
|
|
Loading…
Reference in a new issue