Merge
This commit is contained in:
commit
474154dadd
18 changed files with 558 additions and 342 deletions
|
@ -317,6 +317,8 @@ public class GPXUtilities {
|
||||||
public static class Metadata extends GPXExtensions {
|
public static class Metadata extends GPXExtensions {
|
||||||
public String desc;
|
public String desc;
|
||||||
|
|
||||||
|
public String link;
|
||||||
|
|
||||||
public String getArticleTitle() {
|
public String getArticleTitle() {
|
||||||
return getExtensionsToRead().get("article_title");
|
return getExtensionsToRead().get("article_title");
|
||||||
}
|
}
|
||||||
|
@ -1404,6 +1406,7 @@ public class GPXUtilities {
|
||||||
writeNotNullText(serializer, "name", trackName);
|
writeNotNullText(serializer, "name", trackName);
|
||||||
if (file.metadata != null) {
|
if (file.metadata != null) {
|
||||||
writeNotNullText(serializer, "desc", file.metadata.desc);
|
writeNotNullText(serializer, "desc", file.metadata.desc);
|
||||||
|
writeNotNullTextWithAttribute(serializer, "link", "href", file.metadata.link);
|
||||||
writeExtensions(serializer, file.metadata);
|
writeExtensions(serializer, file.metadata);
|
||||||
}
|
}
|
||||||
serializer.endTag(null, "metadata");
|
serializer.endTag(null, "metadata");
|
||||||
|
@ -1472,6 +1475,14 @@ public class GPXUtilities {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void writeNotNullTextWithAttribute(XmlSerializer serializer, String tag, String attribute, String value) throws IOException {
|
||||||
|
if (value != null) {
|
||||||
|
serializer.startTag(null, tag);
|
||||||
|
serializer.attribute(null, attribute, value);
|
||||||
|
serializer.endTag(null, tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void writeNotNullText(XmlSerializer serializer, String tag, String value) throws IOException {
|
private static void writeNotNullText(XmlSerializer serializer, String tag, String value) throws IOException {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
serializer.startTag(null, tag);
|
serializer.startTag(null, tag);
|
||||||
|
@ -1502,11 +1513,7 @@ public class GPXUtilities {
|
||||||
}
|
}
|
||||||
writeNotNullText(serializer, "name", p.name);
|
writeNotNullText(serializer, "name", p.name);
|
||||||
writeNotNullText(serializer, "desc", p.desc);
|
writeNotNullText(serializer, "desc", p.desc);
|
||||||
if (p.link != null) {
|
writeNotNullTextWithAttribute(serializer, "link", "href", p.link);
|
||||||
serializer.startTag(null, "link");
|
|
||||||
serializer.attribute(null, "href", p.link);
|
|
||||||
serializer.endTag(null, "link");
|
|
||||||
}
|
|
||||||
writeNotNullText(serializer, "type", p.category);
|
writeNotNullText(serializer, "type", p.category);
|
||||||
if (p.comment != null) {
|
if (p.comment != null) {
|
||||||
writeNotNullText(serializer, "cmt", p.comment);
|
writeNotNullText(serializer, "cmt", p.comment);
|
||||||
|
@ -1697,6 +1704,9 @@ public class GPXUtilities {
|
||||||
if (tag.equals("desc")) {
|
if (tag.equals("desc")) {
|
||||||
((Metadata) parse).desc = readText(parser, "desc");
|
((Metadata) parse).desc = readText(parser, "desc");
|
||||||
}
|
}
|
||||||
|
if (tag.equals("link")) {
|
||||||
|
((Metadata) parse).link = parser.getAttributeValue("", "href");
|
||||||
|
}
|
||||||
} else if (parse instanceof Route) {
|
} else if (parse instanceof Route) {
|
||||||
if (tag.equals("name")) {
|
if (tag.equals("name")) {
|
||||||
((Route) parse).name = readText(parser, "name");
|
((Route) parse).name = readText(parser, "name");
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class TransportStop extends MapObject {
|
||||||
private static final int DELETED_STOP = -1;
|
private static final int DELETED_STOP = -1;
|
||||||
|
|
||||||
private int[] referencesToRoutes = null;
|
private int[] referencesToRoutes = null;
|
||||||
private Amenity amenity;
|
private TransportStopAggregated transportStopAggregated;
|
||||||
public int distance;
|
public int distance;
|
||||||
public int x31;
|
public int x31;
|
||||||
public int y31;
|
public int y31;
|
||||||
|
@ -37,11 +37,53 @@ public class TransportStop extends MapObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Amenity getAmenity() {
|
public Amenity getAmenity() {
|
||||||
return amenity;
|
if (transportStopAggregated != null) {
|
||||||
|
return transportStopAggregated.getAmenity();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAmenity(Amenity amenity) {
|
public void setAmenity(Amenity amenity) {
|
||||||
this.amenity = amenity;
|
if (transportStopAggregated == null) {
|
||||||
|
transportStopAggregated = new TransportStopAggregated();
|
||||||
|
}
|
||||||
|
transportStopAggregated.setAmenity(amenity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TransportStop> getLocalTransportStops() {
|
||||||
|
if (transportStopAggregated != null) {
|
||||||
|
return transportStopAggregated.getLocalTransportStops();
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLocalTransportStop(TransportStop stop) {
|
||||||
|
if (transportStopAggregated == null) {
|
||||||
|
transportStopAggregated = new TransportStopAggregated();
|
||||||
|
}
|
||||||
|
transportStopAggregated.addLocalTransportStop(stop);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TransportStop> getNearbyTransportStops() {
|
||||||
|
if (transportStopAggregated != null) {
|
||||||
|
return transportStopAggregated.getNearbyTransportStops();
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addNearbyTransportStop(TransportStop stop) {
|
||||||
|
if (transportStopAggregated == null) {
|
||||||
|
transportStopAggregated = new TransportStopAggregated();
|
||||||
|
}
|
||||||
|
transportStopAggregated.addNearbyTransportStop(stop);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TransportStopAggregated getTransportStopAggregated() {
|
||||||
|
return transportStopAggregated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransportStopAggregated(TransportStopAggregated stopAggregated) {
|
||||||
|
transportStopAggregated = stopAggregated;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
package net.osmand.data;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TransportStopAggregated {
|
||||||
|
|
||||||
|
private Amenity amenity;
|
||||||
|
private List<TransportStop> localTransportStops;
|
||||||
|
private List<TransportStop> nearbyTransportStops;
|
||||||
|
|
||||||
|
public TransportStopAggregated() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Amenity getAmenity() {
|
||||||
|
return amenity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAmenity(Amenity amenity) {
|
||||||
|
this.amenity = amenity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TransportStop> getLocalTransportStops() {
|
||||||
|
if (localTransportStops == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return this.localTransportStops;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLocalTransportStop(TransportStop stop) {
|
||||||
|
if (localTransportStops == null) {
|
||||||
|
localTransportStops = new ArrayList<>();
|
||||||
|
}
|
||||||
|
localTransportStops.add(stop);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLocalTransportStops(List<TransportStop> stops) {
|
||||||
|
if (localTransportStops == null) {
|
||||||
|
localTransportStops = new ArrayList<>();
|
||||||
|
}
|
||||||
|
localTransportStops.addAll(stops);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TransportStop> getNearbyTransportStops() {
|
||||||
|
if (nearbyTransportStops == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return this.nearbyTransportStops;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addNearbyTransportStop(TransportStop stop) {
|
||||||
|
if (nearbyTransportStops == null) {
|
||||||
|
nearbyTransportStops = new ArrayList<>();
|
||||||
|
}
|
||||||
|
nearbyTransportStops.add(stop);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addNearbyTransportStops(List<TransportStop> stops) {
|
||||||
|
if (nearbyTransportStops == null) {
|
||||||
|
nearbyTransportStops = new ArrayList<>();
|
||||||
|
}
|
||||||
|
nearbyTransportStops.addAll(stops);
|
||||||
|
}
|
||||||
|
}
|
|
@ -404,7 +404,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/edit_profile_configure_map"
|
android:text="@string/configure_map"
|
||||||
android:textColor="?attr/main_font_color_basic"
|
android:textColor="?attr/main_font_color_basic"
|
||||||
android:textSize="@dimen/default_list_text_size"/>
|
android:textSize="@dimen/default_list_text_size"/>
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/edit_profile_configure_screen_title"
|
android:text="@string/map_widget_config"
|
||||||
android:textColor="?attr/main_font_color_basic"
|
android:textColor="?attr/main_font_color_basic"
|
||||||
android:textSize="@dimen/default_list_text_size"/>
|
android:textSize="@dimen/default_list_text_size"/>
|
||||||
|
|
||||||
|
@ -502,7 +502,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/edit_profile_nav_settings_title"
|
android:text="@string/routing_settings_2"
|
||||||
android:textColor="?attr/main_font_color_basic"
|
android:textColor="?attr/main_font_color_basic"
|
||||||
android:textSize="@dimen/default_list_text_size"/>
|
android:textSize="@dimen/default_list_text_size"/>
|
||||||
|
|
||||||
|
|
|
@ -108,10 +108,11 @@
|
||||||
android:layout_height="match_parent" >
|
android:layout_height="match_parent" >
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
android:id="@+id/selector_shadow"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/abp__shadow_height"
|
||||||
android:scaleType="fitXY"
|
android:src="@drawable/preference_activity_action_bar_shadow"
|
||||||
android:src="@drawable/bg_shadow_list_bottom"/>
|
android:visibility="invisible"/>
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@android:id/list"
|
android:id="@android:id/list"
|
||||||
|
|
|
@ -1465,8 +1465,7 @@
|
||||||
<string name="waypoint_visit_before">Відвідати, перш ніж</string>
|
<string name="waypoint_visit_before">Відвідати, перш ніж</string>
|
||||||
<string name="simulate_your_location">Моделювання вашого місця розташування</string>
|
<string name="simulate_your_location">Моделювання вашого місця розташування</string>
|
||||||
<string name="drawer">Суцільним списком</string>
|
<string name="drawer">Суцільним списком</string>
|
||||||
<string name="short_location_on_map">Шир %1$s↵
|
<string name="short_location_on_map">Шир %1$s\nДов %2$s</string>
|
||||||
Дов %2$s</string>
|
|
||||||
<string name="tips_and_tricks_descr">Запитання та відповіді, останні зміни та інше.</string>
|
<string name="tips_and_tricks_descr">Запитання та відповіді, останні зміни та інше.</string>
|
||||||
<string name="routing_settings_2">Налаштування навігації</string>
|
<string name="routing_settings_2">Налаштування навігації</string>
|
||||||
<string name="general_settings_2">Загальні параметри</string>
|
<string name="general_settings_2">Загальні параметри</string>
|
||||||
|
|
|
@ -14,11 +14,8 @@
|
||||||
<string name="app_mode_offroad">Offroad</string>
|
<string name="app_mode_offroad">Offroad</string>
|
||||||
<string name="edit_profile_setup_title">Setup Profile</string>
|
<string name="edit_profile_setup_title">Setup Profile</string>
|
||||||
<string name="edit_profile_setup_subtitle">Profile keeps its own settings</string>
|
<string name="edit_profile_setup_subtitle">Profile keeps its own settings</string>
|
||||||
<string name="edit_profile_configure_map">Configure map</string>
|
|
||||||
<string name="edit_profile_setup_map_subtitle">Select default map options for profile</string>
|
<string name="edit_profile_setup_map_subtitle">Select default map options for profile</string>
|
||||||
<string name="edit_profile_configure_screen_title">Configure screen</string>
|
|
||||||
<string name="edit_profile_screen_options_subtitle">Select default screen options for profile</string>
|
<string name="edit_profile_screen_options_subtitle">Select default screen options for profile</string>
|
||||||
<string name="edit_profile_nav_settings_title">Navigation settings</string>
|
|
||||||
<string name="edit_profile_nav_settings_subtitle">Select default navigation settings for profile</string>
|
<string name="edit_profile_nav_settings_subtitle">Select default navigation settings for profile</string>
|
||||||
<string name="routing_attr_max_num_changes_description">Specify max number of changes</string>
|
<string name="routing_attr_max_num_changes_description">Specify max number of changes</string>
|
||||||
<string name="routing_attr_max_num_changes_name">Number of changes</string>
|
<string name="routing_attr_max_num_changes_name">Number of changes</string>
|
||||||
|
|
|
@ -46,11 +46,14 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
|
||||||
|
|
||||||
private static final Log LOG = PlatformUtil.getLog(SettingsBaseActivity.class);
|
private static final Log LOG = PlatformUtil.getLog(SettingsBaseActivity.class);
|
||||||
public static final String INTENT_APP_MODE = "INTENT_APP_MODE";
|
public static final String INTENT_APP_MODE = "INTENT_APP_MODE";
|
||||||
|
private static final String PREV_MODE_KEY = "previous_mode";
|
||||||
|
private static final String SELECTED_MODE_KEY = "selected_mode";
|
||||||
|
|
||||||
protected OsmandSettings settings;
|
protected OsmandSettings settings;
|
||||||
protected final boolean profileSettings;
|
protected final boolean profileSettings;
|
||||||
protected List<ApplicationMode> modes = new ArrayList<ApplicationMode>();
|
protected List<ApplicationMode> modes = new ArrayList<ApplicationMode>();
|
||||||
private ApplicationMode previousAppMode;
|
private ApplicationMode previousAppMode;
|
||||||
|
protected ApplicationMode selectedAppMode;
|
||||||
|
|
||||||
private Map<String, Preference> screenPreferences = new LinkedHashMap<String, Preference>();
|
private Map<String, Preference> screenPreferences = new LinkedHashMap<String, Preference>();
|
||||||
private Map<String, OsmandPreference<Boolean>> booleanPreferences = new LinkedHashMap<String, OsmandPreference<Boolean>>();
|
private Map<String, OsmandPreference<Boolean>> booleanPreferences = new LinkedHashMap<String, OsmandPreference<Boolean>>();
|
||||||
|
@ -333,6 +336,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
|
||||||
|
|
||||||
if (profileSettings) {
|
if (profileSettings) {
|
||||||
modes.clear();
|
modes.clear();
|
||||||
|
findViewById(R.id.selector_shadow).setVisibility(View.VISIBLE);
|
||||||
for (ApplicationMode a : ApplicationMode.values(app)) {
|
for (ApplicationMode a : ApplicationMode.values(app)) {
|
||||||
if (a != ApplicationMode.DEFAULT) {
|
if (a != ApplicationMode.DEFAULT) {
|
||||||
modes.add(a);
|
modes.add(a);
|
||||||
|
@ -358,7 +362,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
|
||||||
final List<ProfileDataObject> activeModes = new ArrayList<>();
|
final List<ProfileDataObject> activeModes = new ArrayList<>();
|
||||||
for (ApplicationMode am : ApplicationMode.values(getMyApplication())) {
|
for (ApplicationMode am : ApplicationMode.values(getMyApplication())) {
|
||||||
boolean isSelected = false;
|
boolean isSelected = false;
|
||||||
if (previousAppMode != null && previousAppMode == am) {
|
if (am == selectedAppMode) {
|
||||||
isSelected = true;
|
isSelected = true;
|
||||||
}
|
}
|
||||||
if (am != ApplicationMode.DEFAULT) {
|
if (am != ApplicationMode.DEFAULT) {
|
||||||
|
@ -411,8 +415,8 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
|
||||||
getModeTitleTV().setText(title);
|
getModeTitleTV().setText(title);
|
||||||
getModeSubTitleTV().setText(getAppModeDescription(mode));
|
getModeSubTitleTV().setText(getAppModeDescription(mode));
|
||||||
settings.APPLICATION_MODE.set(mode);
|
settings.APPLICATION_MODE.set(mode);
|
||||||
previousAppMode = mode;
|
selectedAppMode = mode;
|
||||||
getModeIconIV().setImageDrawable(app.getUIUtilities().getIcon(mode.getIconRes(),
|
getModeIconIV().setImageDrawable(getMyApplication().getUIUtilities().getIcon(mode.getIconRes(),
|
||||||
mode.getIconColorInfo().getColor(nightMode)));
|
mode.getIconColorInfo().getColor(nightMode)));
|
||||||
getDropDownArrow().setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down, !nightMode));
|
getDropDownArrow().setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down, !nightMode));
|
||||||
isModeSelected = true;
|
isModeSelected = true;
|
||||||
|
@ -438,33 +442,28 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if (profileSettings) {
|
if (profileSettings) {
|
||||||
|
if (previousAppMode == null) {
|
||||||
previousAppMode = settings.getApplicationMode();
|
previousAppMode = settings.getApplicationMode();
|
||||||
boolean found;
|
}
|
||||||
if (getIntent() != null && getIntent().hasExtra(INTENT_APP_MODE)) {
|
if (getIntent() != null && getIntent().hasExtra(INTENT_APP_MODE)) {
|
||||||
String modeStr = getIntent().getStringExtra(INTENT_APP_MODE);
|
String modeStr = getIntent().getStringExtra(INTENT_APP_MODE);
|
||||||
ApplicationMode mode = ApplicationMode.valueOfStringKey(modeStr, previousAppMode);
|
ApplicationMode mode = ApplicationMode.valueOfStringKey(modeStr, previousAppMode);
|
||||||
found = setSelectedAppMode(mode);
|
setSelectedAppMode(mode);
|
||||||
} else {
|
} else {
|
||||||
found = setSelectedAppMode(previousAppMode);
|
setSelectedAppMode(selectedAppMode);
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
getSpinner().setSelection(0);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
updateAllSettings();
|
updateAllSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean setSelectedAppMode(ApplicationMode am) {
|
protected void setSelectedAppMode(ApplicationMode am) {
|
||||||
boolean found = false;
|
|
||||||
for (ApplicationMode a : modes) {
|
for (ApplicationMode a : modes) {
|
||||||
if (am == a) {
|
if (am != null && am == a) {
|
||||||
updateModeButton(a);
|
updateModeButton(a);
|
||||||
found = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return found;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -475,6 +474,35 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
if (profileSettings) {
|
||||||
|
if (previousAppMode != null) {
|
||||||
|
outState.putString(PREV_MODE_KEY, previousAppMode.getStringKey());
|
||||||
|
}
|
||||||
|
if (selectedAppMode != null) {
|
||||||
|
outState.putString(SELECTED_MODE_KEY, selectedAppMode.getStringKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRestoreInstanceState(Bundle state) {
|
||||||
|
super.onRestoreInstanceState(state);
|
||||||
|
if (state != null) {
|
||||||
|
if (profileSettings && state.containsKey(SELECTED_MODE_KEY) && state.containsKey(PREV_MODE_KEY)) {
|
||||||
|
for (ApplicationMode am : ApplicationMode.values(getMyApplication())) {
|
||||||
|
if (am.getStringKey() == state.get(SELECTED_MODE_KEY)) {
|
||||||
|
setSelectedAppMode(am);
|
||||||
|
}
|
||||||
|
if (am.getStringKey() == state.get(PREV_MODE_KEY)) {
|
||||||
|
previousAppMode = am;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void updateAllSettings() {
|
public void updateAllSettings() {
|
||||||
for (OsmandPreference<Boolean> b : booleanPreferences.values()) {
|
for (OsmandPreference<Boolean> b : booleanPreferences.values()) {
|
||||||
|
|
|
@ -85,6 +85,16 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
createUI();
|
createUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
if(getIntent() != null && getIntent().hasExtra(INTENT_SKIP_DIALOG)) {
|
||||||
|
setSelectedAppMode(settings.getApplicationMode());
|
||||||
|
} else if (selectedAppMode == null) {
|
||||||
|
selectAppModeDialog().show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void createUI() {
|
private void createUI() {
|
||||||
addPreferencesFromResource(R.xml.navigation_settings);
|
addPreferencesFromResource(R.xml.navigation_settings);
|
||||||
PreferenceScreen screen = getPreferenceScreen();
|
PreferenceScreen screen = getPreferenceScreen();
|
||||||
|
@ -181,11 +191,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
// registerListPreference(settings.DELAY_TO_START_NAVIGATION, screen, delayIntervalNames, delayIntervals);
|
// registerListPreference(settings.DELAY_TO_START_NAVIGATION, screen, delayIntervalNames, delayIntervals);
|
||||||
|
|
||||||
|
|
||||||
if(getIntent() != null && getIntent().hasExtra(INTENT_SKIP_DIALOG)) {
|
|
||||||
setSelectedAppMode(settings.getApplicationMode());
|
|
||||||
} else {
|
|
||||||
selectAppModeDialog().show();
|
|
||||||
}
|
|
||||||
|
|
||||||
addVoicePrefs((PreferenceGroup) screen.findPreference("voice"));
|
addVoicePrefs((PreferenceGroup) screen.findPreference("voice"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.osmand.plus.activities.actions;
|
package net.osmand.plus.activities.actions;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.support.annotation.LayoutRes;
|
import android.support.annotation.LayoutRes;
|
||||||
|
@ -8,11 +9,14 @@ import android.support.v4.content.ContextCompat;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||||
|
import android.widget.HorizontalScrollView;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.LinearLayout.LayoutParams;
|
import android.widget.LinearLayout.LayoutParams;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
@ -21,9 +25,12 @@ import net.osmand.plus.R;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
public class AppModeDialog {
|
public class AppModeDialog {
|
||||||
|
|
||||||
|
private static final Log LOG = PlatformUtil.getLog(AppModeDialog.class);
|
||||||
|
|
||||||
public static View prepareAppModeView(Activity a, final Set<ApplicationMode> selected, boolean showDefault,
|
public static View prepareAppModeView(Activity a, final Set<ApplicationMode> selected, boolean showDefault,
|
||||||
ViewGroup parent, final boolean singleSelection, boolean useListBg, boolean useMapTheme, final View.OnClickListener onClickListener) {
|
ViewGroup parent, final boolean singleSelection, boolean useListBg, boolean useMapTheme, final View.OnClickListener onClickListener) {
|
||||||
OsmandApplication app = (OsmandApplication) a.getApplication();
|
OsmandApplication app = (OsmandApplication) a.getApplication();
|
||||||
|
@ -58,7 +65,7 @@ public class AppModeDialog {
|
||||||
|
|
||||||
public static View prepareAppModeView(Activity a, final List<ApplicationMode> values, final Set<ApplicationMode> selected,
|
public static View prepareAppModeView(Activity a, final List<ApplicationMode> values, final Set<ApplicationMode> selected,
|
||||||
ViewGroup parent, final boolean singleSelection, boolean useListBg, boolean useMapTheme, final View.OnClickListener onClickListener, boolean nightMode) {
|
ViewGroup parent, final boolean singleSelection, boolean useListBg, boolean useMapTheme, final View.OnClickListener onClickListener, boolean nightMode) {
|
||||||
View ll = a.getLayoutInflater().inflate(R.layout.mode_toggles, parent);
|
final View ll = a.getLayoutInflater().inflate(R.layout.mode_toggles, parent);
|
||||||
if (useListBg) {
|
if (useListBg) {
|
||||||
AndroidUtils.setListItemBackground(a, ll, nightMode);
|
AndroidUtils.setListItemBackground(a, ll, nightMode);
|
||||||
} else {
|
} else {
|
||||||
|
@ -73,6 +80,23 @@ public class AppModeDialog {
|
||||||
updateButtonState((OsmandApplication) a.getApplication(), values, selected, onClickListener, buttons, i,
|
updateButtonState((OsmandApplication) a.getApplication(), values, selected, onClickListener, buttons, i,
|
||||||
singleSelection, useMapTheme, nightMode);
|
singleSelection, useMapTheme, nightMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ApplicationMode activeMode = ((OsmandApplication) a.getApplication()).getSettings().getApplicationMode();
|
||||||
|
final int idx = values.indexOf(activeMode);
|
||||||
|
|
||||||
|
OnGlobalLayoutListener globalListener = new OnGlobalLayoutListener() {
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
HorizontalScrollView scrollView = ll.findViewById(R.id.app_modes_scroll_container);
|
||||||
|
LinearLayout container = ll.findViewById(R.id.app_modes_content);
|
||||||
|
int s = container.getChildAt(idx) != null ? container.getChildAt(idx).getRight() : 0;
|
||||||
|
scrollView.scrollTo(s - scrollView.getWidth() > 0 ? s - scrollView.getWidth() : 0, 0);
|
||||||
|
ll.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ll.getViewTreeObserver().addOnGlobalLayoutListener(globalListener);
|
||||||
|
|
||||||
return ll;
|
return ll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,11 +108,13 @@ public class AppModeDialog {
|
||||||
View tb = buttons[i];
|
View tb = buttons[i];
|
||||||
final ApplicationMode mode = visible.get(i);
|
final ApplicationMode mode = visible.get(i);
|
||||||
final boolean checked = selected.contains(mode);
|
final boolean checked = selected.contains(mode);
|
||||||
|
final View selection = tb.findViewById(R.id.selection);
|
||||||
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
|
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
|
||||||
if (checked) {
|
if (checked) {
|
||||||
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
|
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
|
||||||
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_checked)));
|
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_checked)));
|
||||||
tb.findViewById(R.id.selection).setVisibility(View.VISIBLE);
|
selection.setBackgroundResource(mode.getIconColorInfo().getColor(nightMode));
|
||||||
|
selection.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
if (useMapTheme) {
|
if (useMapTheme) {
|
||||||
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
|
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
|
||||||
|
@ -97,7 +123,7 @@ public class AppModeDialog {
|
||||||
iv.setImageDrawable(ctx.getUIUtilities().getThemedIcon(mode.getIconRes()));
|
iv.setImageDrawable(ctx.getUIUtilities().getThemedIcon(mode.getIconRes()));
|
||||||
}
|
}
|
||||||
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_unchecked)));
|
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_unchecked)));
|
||||||
tb.findViewById(R.id.selection).setVisibility(View.INVISIBLE);
|
selection.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
iv.setOnClickListener(new View.OnClickListener() {
|
iv.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
@ -39,12 +38,12 @@ import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.QuadRect;
|
import net.osmand.data.QuadRect;
|
||||||
import net.osmand.osm.PoiCategory;
|
import net.osmand.osm.PoiCategory;
|
||||||
import net.osmand.plus.UiUtilities;
|
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.helpers.FontCache;
|
import net.osmand.plus.helpers.FontCache;
|
||||||
import net.osmand.plus.mapcontextmenu.builders.cards.AbstractCard;
|
import net.osmand.plus.mapcontextmenu.builders.cards.AbstractCard;
|
||||||
|
@ -53,8 +52,8 @@ import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard;
|
||||||
import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask;
|
import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask;
|
||||||
import net.osmand.plus.mapcontextmenu.builders.cards.NoImagesCard;
|
import net.osmand.plus.mapcontextmenu.builders.cards.NoImagesCard;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController;
|
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController;
|
||||||
import net.osmand.plus.transport.TransportStopRoute;
|
|
||||||
import net.osmand.plus.render.RenderingIcons;
|
import net.osmand.plus.render.RenderingIcons;
|
||||||
|
import net.osmand.plus.transport.TransportStopRoute;
|
||||||
import net.osmand.plus.views.TransportStopsLayer;
|
import net.osmand.plus.views.TransportStopsLayer;
|
||||||
import net.osmand.plus.widgets.TextViewEx;
|
import net.osmand.plus.widgets.TextViewEx;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -67,8 +66,7 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
|
import static net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask.GetImageCardsListener;
|
||||||
import static net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask.*;
|
|
||||||
|
|
||||||
public class MenuBuilder {
|
public class MenuBuilder {
|
||||||
|
|
||||||
|
@ -91,7 +89,6 @@ public class MenuBuilder {
|
||||||
private boolean showOnlinePhotos = true;
|
private boolean showOnlinePhotos = true;
|
||||||
protected List<Amenity> nearestWiki = new ArrayList<>();
|
protected List<Amenity> nearestWiki = new ArrayList<>();
|
||||||
private List<OsmandPlugin> menuPlugins = new ArrayList<>();
|
private List<OsmandPlugin> menuPlugins = new ArrayList<>();
|
||||||
private List<TransportStopRoute> routes = new ArrayList<>();
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private CardsRowBuilder onlinePhotoCardsRow;
|
private CardsRowBuilder onlinePhotoCardsRow;
|
||||||
private List<AbstractCard> onlinePhotoCards;
|
private List<AbstractCard> onlinePhotoCards;
|
||||||
|
@ -235,10 +232,6 @@ public class MenuBuilder {
|
||||||
this.collapseExpandListener = collapseExpandListener;
|
this.collapseExpandListener = collapseExpandListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRoutes(List<TransportStopRoute> routes) {
|
|
||||||
this.routes = routes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPreferredMapLang() {
|
public String getPreferredMapLang() {
|
||||||
return preferredMapLang;
|
return preferredMapLang;
|
||||||
}
|
}
|
||||||
|
@ -324,7 +317,7 @@ public class MenuBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean showTransportRoutes() {
|
private boolean showTransportRoutes() {
|
||||||
return routes.size() > 0;
|
return showLocalTransportRoutes() || showNearbyTransportRoutes();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean showLocalTransportRoutes() {
|
private boolean showLocalTransportRoutes() {
|
||||||
|
@ -460,7 +453,6 @@ public class MenuBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void buildTopInternal(View view) {
|
protected void buildTopInternal(View view) {
|
||||||
if (showTransportRoutes()) {
|
|
||||||
if (showLocalTransportRoutes()) {
|
if (showLocalTransportRoutes()) {
|
||||||
buildRow(view, 0, null, app.getString(R.string.transport_Routes), 0, true, getCollapsableTransportStopRoutesView(view.getContext(), false, false),
|
buildRow(view, 0, null, app.getString(R.string.transport_Routes), 0, true, getCollapsableTransportStopRoutesView(view.getContext(), false, false),
|
||||||
false, 0, false, null, true);
|
false, 0, false, null, true);
|
||||||
|
@ -472,7 +464,6 @@ public class MenuBuilder {
|
||||||
false, 0, false, null, true);
|
false, 0, false, null, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected void buildAfter(View view) {
|
protected void buildAfter(View view) {
|
||||||
buildRowDivider(view);
|
buildRowDivider(view);
|
||||||
|
|
|
@ -7,45 +7,32 @@ import android.text.TextUtils;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.QuadRect;
|
|
||||||
import net.osmand.data.TransportRoute;
|
|
||||||
import net.osmand.data.TransportStop;
|
import net.osmand.data.TransportStop;
|
||||||
import net.osmand.osm.PoiCategory;
|
import net.osmand.osm.PoiCategory;
|
||||||
import net.osmand.osm.PoiFilter;
|
import net.osmand.osm.PoiFilter;
|
||||||
import net.osmand.osm.PoiType;
|
import net.osmand.osm.PoiType;
|
||||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||||
import net.osmand.plus.wikipedia.WikipediaDialogFragment;
|
|
||||||
import net.osmand.plus.mapcontextmenu.builders.AmenityMenuBuilder;
|
import net.osmand.plus.mapcontextmenu.builders.AmenityMenuBuilder;
|
||||||
import net.osmand.plus.render.RenderingIcons;
|
import net.osmand.plus.render.RenderingIcons;
|
||||||
import net.osmand.plus.resources.TransportIndexRepository;
|
|
||||||
import net.osmand.plus.transport.TransportStopRoute;
|
import net.osmand.plus.transport.TransportStopRoute;
|
||||||
import net.osmand.plus.transport.TransportStopType;
|
import net.osmand.plus.wikipedia.WikipediaDialogFragment;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
import net.osmand.util.MapUtils;
|
|
||||||
import net.osmand.util.OpeningHoursParser;
|
import net.osmand.util.OpeningHoursParser;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import gnu.trove.list.array.TLongArrayList;
|
|
||||||
import gnu.trove.map.hash.TLongObjectHashMap;
|
|
||||||
|
|
||||||
public class AmenityMenuController extends MenuController {
|
public class AmenityMenuController extends MenuController {
|
||||||
|
|
||||||
private Amenity amenity;
|
private Amenity amenity;
|
||||||
private List<TransportStopRoute> routes = new ArrayList<>();
|
|
||||||
|
|
||||||
private MapMarker marker;
|
private MapMarker marker;
|
||||||
|
|
||||||
|
private TransportStopController transportStopController;
|
||||||
|
|
||||||
public AmenityMenuController(@NonNull MapActivity mapActivity,
|
public AmenityMenuController(@NonNull MapActivity mapActivity,
|
||||||
@NonNull PointDescription pointDescription,
|
@NonNull PointDescription pointDescription,
|
||||||
@NonNull final Amenity amenity) {
|
@NonNull final Amenity amenity) {
|
||||||
|
@ -63,7 +50,11 @@ public class AmenityMenuController extends MenuController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (showTransportStops) {
|
if (showTransportStops) {
|
||||||
processTransportStop();
|
TransportStop transportStop = TransportStopController.findBestTransportStopForAmenity(mapActivity.getMyApplication(), amenity);
|
||||||
|
if (transportStop != null) {
|
||||||
|
transportStopController = new TransportStopController(mapActivity, pointDescription, transportStop);
|
||||||
|
transportStopController.processRoutes();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,23 +204,16 @@ public class AmenityMenuController extends MenuController {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TransportStopRoute> getTransportStopRoutes() {
|
public List<TransportStopRoute> getTransportStopRoutes() {
|
||||||
return routes;
|
if (transportStopController != null) {
|
||||||
|
return transportStopController.getTransportStopRoutes();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<TransportStopRoute> getSubTransportStopRoutes(boolean nearby) {
|
protected List<TransportStopRoute> getSubTransportStopRoutes(boolean nearby) {
|
||||||
List<TransportStopRoute> allRoutes = getTransportStopRoutes();
|
if (transportStopController != null) {
|
||||||
if (allRoutes != null) {
|
return transportStopController.getSubTransportStopRoutes(nearby);
|
||||||
List<TransportStopRoute> res = new ArrayList<>();
|
|
||||||
for (TransportStopRoute route : allRoutes) {
|
|
||||||
boolean isCurrentRouteLocal = route.refStop != null && route.refStop.getName().equals(route.stop.getName());
|
|
||||||
if (!nearby && isCurrentRouteLocal) {
|
|
||||||
res.add(route);
|
|
||||||
} else if (nearby && route.refStop == null) {
|
|
||||||
res.add(route);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -264,77 +248,4 @@ public class AmenityMenuController extends MenuController {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processTransportStop() {
|
|
||||||
routes = new ArrayList<>();
|
|
||||||
MapActivity mapActivity = getMapActivity();
|
|
||||||
if (mapActivity != null) {
|
|
||||||
OsmandApplication app = mapActivity.getMyApplication();
|
|
||||||
List<TransportIndexRepository> reps = app
|
|
||||||
.getResourceManager().searchTransportRepositories(amenity.getLocation().getLatitude(),
|
|
||||||
amenity.getLocation().getLongitude());
|
|
||||||
|
|
||||||
boolean useEnglishNames = app.getSettings().usingEnglishNames();
|
|
||||||
boolean isSubwayEntrance = amenity.getSubType().equals("subway_entrance");
|
|
||||||
|
|
||||||
TLongArrayList addedTransportStops = new TLongArrayList();
|
|
||||||
for (TransportIndexRepository t : reps) {
|
|
||||||
ArrayList<TransportStop> ls = new ArrayList<>();
|
|
||||||
QuadRect ll = MapUtils.calculateLatLonBbox(amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(),
|
|
||||||
isSubwayEntrance ? 400 : 150);
|
|
||||||
t.searchTransportStops(ll.top, ll.left, ll.bottom, ll.right, -1, ls, null);
|
|
||||||
for (TransportStop tstop : ls) {
|
|
||||||
if (!addedTransportStops.contains(tstop.getId())) {
|
|
||||||
addedTransportStops.add(tstop.getId());
|
|
||||||
if (!tstop.isDeleted()) {
|
|
||||||
addRoutes(useEnglishNames, t, tstop,
|
|
||||||
(int) MapUtils.getDistance(tstop.getLocation(), amenity.getLocation()), isSubwayEntrance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Collections.sort(routes, new Comparator<TransportStopRoute>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compare(TransportStopRoute o1, TransportStopRoute o2) {
|
|
||||||
// int radEqual = 50;
|
|
||||||
// int dist1 = o1.distance / radEqual;
|
|
||||||
// int dist2 = o2.distance / radEqual;
|
|
||||||
// if (dist1 != dist2) {
|
|
||||||
// return Algorithms.compare(dist1, dist2);
|
|
||||||
// }
|
|
||||||
int i1 = Algorithms.extractFirstIntegerNumber(o1.route.getRef());
|
|
||||||
int i2 = Algorithms.extractFirstIntegerNumber(o2.route.getRef());
|
|
||||||
if (i1 != i2) {
|
|
||||||
return Algorithms.compare(i1, i2);
|
|
||||||
}
|
|
||||||
return o1.desc.compareTo(o2.desc);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
builder.setRoutes(routes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addRoutes(boolean useEnglishNames, TransportIndexRepository t, TransportStop s, int dist, boolean isSubwayEntrance) {
|
|
||||||
Collection<TransportRoute> rts = t.getRouteForStop(s);
|
|
||||||
if (rts != null) {
|
|
||||||
for (TransportRoute rs : rts) {
|
|
||||||
TransportStopType type = TransportStopType.findType(rs.getType());
|
|
||||||
if (isSubwayEntrance && type != TransportStopType.SUBWAY && dist > 150) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
TransportStopRoute r = new TransportStopRoute();
|
|
||||||
r.type = type;
|
|
||||||
r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName();
|
|
||||||
r.route = rs;
|
|
||||||
r.stop = s;
|
|
||||||
if (amenity.getLocation().equals(s.getLocation()) || (isSubwayEntrance && type == TransportStopType.SUBWAY)) {
|
|
||||||
r.refStop = s;
|
|
||||||
}
|
|
||||||
r.distance = dist;
|
|
||||||
this.routes.add(r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -21,14 +21,13 @@ import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragment;
|
||||||
import net.osmand.plus.transport.TransportStopRoute;
|
import net.osmand.plus.transport.TransportStopRoute;
|
||||||
import net.osmand.util.OpeningHoursParser;
|
import net.osmand.util.OpeningHoursParser;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class FavouritePointMenuController extends MenuController {
|
public class FavouritePointMenuController extends MenuController {
|
||||||
|
|
||||||
private FavouritePoint fav;
|
private FavouritePoint fav;
|
||||||
private MapMarker mapMarker;
|
private MapMarker mapMarker;
|
||||||
private List<TransportStopRoute> routes = new ArrayList<>();
|
|
||||||
private TransportStopController transportStopController;
|
private TransportStopController transportStopController;
|
||||||
|
|
||||||
public FavouritePointMenuController(@NonNull MapActivity mapActivity, @NonNull PointDescription pointDescription, final @NonNull FavouritePoint fav) {
|
public FavouritePointMenuController(@NonNull MapActivity mapActivity, @NonNull PointDescription pointDescription, final @NonNull FavouritePoint fav) {
|
||||||
|
@ -49,8 +48,7 @@ public class FavouritePointMenuController extends MenuController {
|
||||||
if (getObject() instanceof TransportStop) {
|
if (getObject() instanceof TransportStop) {
|
||||||
TransportStop stop = (TransportStop) getObject();
|
TransportStop stop = (TransportStop) getObject();
|
||||||
transportStopController = new TransportStopController(mapActivity, pointDescription, stop);
|
transportStopController = new TransportStopController(mapActivity, pointDescription, stop);
|
||||||
routes = transportStopController.processTransportStop();
|
transportStopController.processRoutes();
|
||||||
builder.setRoutes(routes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Object originObject = getBuilder().getOriginObject();
|
Object originObject = getBuilder().getOriginObject();
|
||||||
|
@ -73,7 +71,10 @@ public class FavouritePointMenuController extends MenuController {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TransportStopRoute> getTransportStopRoutes() {
|
public List<TransportStopRoute> getTransportStopRoutes() {
|
||||||
return routes;
|
if (transportStopController != null) {
|
||||||
|
return transportStopController.getTransportStopRoutes();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.osmand.plus.mapcontextmenu.controllers;
|
package net.osmand.plus.mapcontextmenu.controllers;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
@ -8,6 +9,9 @@ import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.QuadRect;
|
import net.osmand.data.QuadRect;
|
||||||
import net.osmand.data.TransportRoute;
|
import net.osmand.data.TransportRoute;
|
||||||
import net.osmand.data.TransportStop;
|
import net.osmand.data.TransportStop;
|
||||||
|
import net.osmand.data.TransportStopAggregated;
|
||||||
|
import net.osmand.data.TransportStopExit;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||||
|
@ -29,9 +33,11 @@ import gnu.trove.list.array.TLongArrayList;
|
||||||
public class TransportStopController extends MenuController {
|
public class TransportStopController extends MenuController {
|
||||||
|
|
||||||
public static final int SHOW_STOPS_RADIUS_METERS = 150;
|
public static final int SHOW_STOPS_RADIUS_METERS = 150;
|
||||||
|
public static final int SHOW_SUBWAY_STOPS_FROM_ENTRANCES_RADIUS_METERS = 400;
|
||||||
|
|
||||||
private TransportStop transportStop;
|
private TransportStop transportStop;
|
||||||
private List<TransportStopRoute> routes = new ArrayList<>();
|
private List<TransportStopRoute> routesNearby = new ArrayList<>();
|
||||||
|
private List<TransportStopRoute> routesOnTheSameExit = new ArrayList<>();
|
||||||
private TransportStopType topType;
|
private TransportStopType topType;
|
||||||
|
|
||||||
public TransportStopController(@NonNull MapActivity mapActivity,
|
public TransportStopController(@NonNull MapActivity mapActivity,
|
||||||
|
@ -50,9 +56,10 @@ public class TransportStopController extends MenuController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processRoutes() {
|
public void processRoutes() {
|
||||||
routes = processTransportStop();
|
routesOnTheSameExit.clear();
|
||||||
builder.setRoutes(routes);
|
routesNearby.clear();
|
||||||
|
processTransportStop(routesOnTheSameExit, routesNearby);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -71,23 +78,14 @@ public class TransportStopController extends MenuController {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TransportStopRoute> getTransportStopRoutes() {
|
public List<TransportStopRoute> getTransportStopRoutes() {
|
||||||
|
List<TransportStopRoute> routes = new ArrayList<>(routesOnTheSameExit);
|
||||||
|
routes.addAll(routesNearby);
|
||||||
return routes;
|
return routes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<TransportStopRoute> getSubTransportStopRoutes(boolean nearby) {
|
protected List<TransportStopRoute> getSubTransportStopRoutes(boolean nearby) {
|
||||||
List<TransportStopRoute> allRoutes = getTransportStopRoutes();
|
return nearby ? routesNearby : routesOnTheSameExit;
|
||||||
if (allRoutes != null) {
|
|
||||||
List<TransportStopRoute> res = new ArrayList<>();
|
|
||||||
for (TransportStopRoute route : allRoutes) {
|
|
||||||
boolean isCurrentRouteNearby = route.stop != null && !route.stop.equals(transportStop);
|
|
||||||
if ((nearby && isCurrentRouteNearby) || (!nearby && !isCurrentRouteNearby)) {
|
|
||||||
res.add(route);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -112,8 +110,17 @@ public class TransportStopController extends MenuController {
|
||||||
return getPointDescription().getTypeName();
|
return getPointDescription().getTypeName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TransportStopRoute> processTransportStop() {
|
@Override
|
||||||
ArrayList<TransportStopRoute> routes = new ArrayList<>();
|
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
|
||||||
|
Amenity amenity = transportStop.getAmenity();
|
||||||
|
if (amenity != null) {
|
||||||
|
AmenityMenuController.addTypeMenuItem(amenity, builder);
|
||||||
|
} else {
|
||||||
|
super.addPlainMenuItems(typeStr, pointDescription, latLon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processTransportStop(List<TransportStopRoute> routesOnTheSameExit, List<TransportStopRoute> routesNearby) {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
List<TransportIndexRepository> reps = mapActivity.getMyApplication()
|
List<TransportIndexRepository> reps = mapActivity.getMyApplication()
|
||||||
|
@ -122,27 +129,21 @@ public class TransportStopController extends MenuController {
|
||||||
|
|
||||||
boolean useEnglishNames = mapActivity.getMyApplication().getSettings().usingEnglishNames();
|
boolean useEnglishNames = mapActivity.getMyApplication().getSettings().usingEnglishNames();
|
||||||
|
|
||||||
TLongArrayList addedTransportStops = new TLongArrayList();
|
|
||||||
for (TransportIndexRepository t : reps) {
|
for (TransportIndexRepository t : reps) {
|
||||||
if (t.acceptTransportStop(transportStop)) {
|
if (t.acceptTransportStop(transportStop)) {
|
||||||
boolean empty = transportStop.getReferencesToRoutes() == null || transportStop.getReferencesToRoutes().length == 0;
|
ArrayList<TransportStop> transportStopsSameExit = new ArrayList<TransportStop>(transportStop.getLocalTransportStops());
|
||||||
if (!empty) {
|
ArrayList<TransportStop> nearbyTransportStops = new ArrayList<TransportStop>(transportStop.getNearbyTransportStops());
|
||||||
addRoutes(routes, useEnglishNames, t, transportStop, transportStop, 0);
|
|
||||||
}
|
addTransportStopRoutes(transportStopsSameExit, routesOnTheSameExit, useEnglishNames, t);
|
||||||
ArrayList<TransportStop> ls = new ArrayList<>();
|
addTransportStopRoutes(nearbyTransportStops, routesNearby, useEnglishNames, t);
|
||||||
QuadRect ll = MapUtils.calculateLatLonBbox(transportStop.getLocation().getLatitude(), transportStop.getLocation().getLongitude(), SHOW_STOPS_RADIUS_METERS);
|
|
||||||
t.searchTransportStops(ll.top, ll.left, ll.bottom, ll.right, -1, ls, null);
|
|
||||||
for (TransportStop tstop : ls) {
|
|
||||||
if (!addedTransportStops.contains(tstop.getId())) {
|
|
||||||
addedTransportStops.add(tstop.getId());
|
|
||||||
if (!tstop.isDeleted() && (tstop.getId().longValue() != transportStop.getId().longValue() || empty)) {
|
|
||||||
addRoutes(routes, useEnglishNames, t, tstop, transportStop,
|
|
||||||
(int) MapUtils.getDistance(tstop.getLocation(), transportStop.getLocation()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sortTransportStopRoutes(routesOnTheSameExit);
|
||||||
|
sortTransportStopRoutes(routesNearby);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sortTransportStopRoutes(List<TransportStopRoute> routes) {
|
||||||
Collections.sort(routes, new Comparator<TransportStopRoute>() {
|
Collections.sort(routes, new Comparator<TransportStopRoute>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -162,13 +163,23 @@ public class TransportStopController extends MenuController {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return routes;
|
|
||||||
|
private void addTransportStopRoutes(List<TransportStop> stops, List<TransportStopRoute> routes, boolean useEnglishNames, TransportIndexRepository t) {
|
||||||
|
for (TransportStop tstop : stops) {
|
||||||
|
if (!tstop.isDeleted()) {
|
||||||
|
addRoutes(routes, useEnglishNames, t, tstop, transportStop, (int) MapUtils.getDistance(tstop.getLocation(), transportStop.getLocation()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRoutes(List<TransportStopRoute> routes, boolean useEnglishNames, TransportIndexRepository t, TransportStop s, TransportStop refStop, int dist) {
|
private void addRoutes(List<TransportStopRoute> routes, boolean useEnglishNames, TransportIndexRepository t, TransportStop s, TransportStop refStop, int dist) {
|
||||||
Collection<TransportRoute> rts = t.getRouteForStop(s);
|
Collection<TransportRoute> rts = t.getRouteForStop(s);
|
||||||
if (rts != null) {
|
if (rts != null) {
|
||||||
for (TransportRoute rs : rts) {
|
for (TransportRoute rs : rts) {
|
||||||
|
boolean routeAlreadyAdded = checkSameRoute(routes, rs);
|
||||||
|
if (routeAlreadyAdded) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
TransportStopType type = TransportStopType.findType(rs.getType());
|
TransportStopType type = TransportStopType.findType(rs.getType());
|
||||||
if (topType == null && type != null && type.isTopType()) {
|
if (topType == null && type != null && type.isTopType()) {
|
||||||
topType = type;
|
topType = type;
|
||||||
|
@ -185,13 +196,112 @@ public class TransportStopController extends MenuController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void sortTransportStops(@NonNull LatLon latLon, List<TransportStop> transportStops) {
|
||||||
|
for (TransportStop transportStop : transportStops) {
|
||||||
|
transportStop.distance = (int) MapUtils.getDistance(latLon, transportStop.getLocation());
|
||||||
|
}
|
||||||
|
Collections.sort(transportStops, new Comparator<TransportStop>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
|
public int compare(TransportStop s1, TransportStop s2) {
|
||||||
Amenity amenity = transportStop.getAmenity();
|
return Algorithms.compare(s1.distance, s2.distance);
|
||||||
if (amenity != null) {
|
}
|
||||||
AmenityMenuController.addTypeMenuItem(amenity, builder);
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public static List<TransportStop> findTransportStopsAt(OsmandApplication app, double latitude, double longitude, int radiusMeters) {
|
||||||
|
ArrayList<TransportStop> transportStops = new ArrayList<>();
|
||||||
|
List<TransportIndexRepository> reps = app.getResourceManager().searchTransportRepositories(latitude, longitude);
|
||||||
|
|
||||||
|
TLongArrayList addedTransportStops = new TLongArrayList();
|
||||||
|
for (TransportIndexRepository t : reps) {
|
||||||
|
ArrayList<TransportStop> stops = new ArrayList<>();
|
||||||
|
QuadRect ll = MapUtils.calculateLatLonBbox(latitude, longitude, radiusMeters);
|
||||||
|
t.searchTransportStops(ll.top, ll.left, ll.bottom, ll.right, -1, stops, null);
|
||||||
|
for (TransportStop transportStop : stops) {
|
||||||
|
if (!addedTransportStops.contains(transportStop.getId())) {
|
||||||
|
addedTransportStops.add(transportStop.getId());
|
||||||
|
if (!transportStop.isDeleted()) {
|
||||||
|
transportStops.add(transportStop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return transportStops;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static TransportStop findBestTransportStopForAmenity(OsmandApplication app, Amenity amenity) {
|
||||||
|
TransportStopAggregated stopAggregated;
|
||||||
|
boolean isSubwayEntrance = amenity.getSubType().equals("subway_entrance");
|
||||||
|
|
||||||
|
LatLon loc = amenity.getLocation();
|
||||||
|
int radiusMeters = isSubwayEntrance ? SHOW_SUBWAY_STOPS_FROM_ENTRANCES_RADIUS_METERS : SHOW_STOPS_RADIUS_METERS;
|
||||||
|
List<TransportStop> transportStops = findTransportStopsAt(app, loc.getLatitude(), loc.getLongitude(), radiusMeters);
|
||||||
|
sortTransportStops(loc, transportStops);
|
||||||
|
|
||||||
|
if (isSubwayEntrance) {
|
||||||
|
stopAggregated = processTransportStopsForAmenity(transportStops, amenity);
|
||||||
} else {
|
} else {
|
||||||
super.addPlainMenuItems(typeStr, pointDescription, latLon);
|
stopAggregated = new TransportStopAggregated();
|
||||||
|
stopAggregated.setAmenity(amenity);
|
||||||
|
TransportStop nearestStop = null;
|
||||||
|
for (TransportStop stop : transportStops) {
|
||||||
|
stop.setTransportStopAggregated(stopAggregated);
|
||||||
|
if ((stop.getName().startsWith(amenity.getName())
|
||||||
|
&& (nearestStop == null
|
||||||
|
|| nearestStop.getLocation().equals(stop.getLocation())))
|
||||||
|
|| stop.getLocation().equals(loc)) {
|
||||||
|
stopAggregated.addLocalTransportStop(stop);
|
||||||
|
if (nearestStop == null) {
|
||||||
|
nearestStop = stop;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
stopAggregated.addNearbyTransportStop(stop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<TransportStop> localStops = stopAggregated.getLocalTransportStops();
|
||||||
|
List<TransportStop> nearbyStops = stopAggregated.getNearbyTransportStops();
|
||||||
|
if (!localStops.isEmpty()) {
|
||||||
|
return localStops.get(0);
|
||||||
|
} else if (!nearbyStops.isEmpty()) {
|
||||||
|
return nearbyStops.get(0);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TransportStopAggregated processTransportStopsForAmenity(List<TransportStop> transportStops, Amenity amenity) {
|
||||||
|
TransportStopAggregated stopAggregated = new TransportStopAggregated();
|
||||||
|
stopAggregated.setAmenity(amenity);
|
||||||
|
|
||||||
|
for (TransportStop stop : transportStops) {
|
||||||
|
stop.setTransportStopAggregated(stopAggregated);
|
||||||
|
List<TransportStopExit> stopExits = stop.getExits();
|
||||||
|
boolean stopOnSameExitAdded = false;
|
||||||
|
for (TransportStopExit exit : stopExits) {
|
||||||
|
if (exit.getLocation().equals(amenity.getLocation())) {
|
||||||
|
stopOnSameExitAdded = true;
|
||||||
|
stopAggregated.addLocalTransportStop(stop);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!stopOnSameExitAdded && MapUtils.getDistance(stop.getLocation(), amenity.getLocation()) <= SHOW_STOPS_RADIUS_METERS) {
|
||||||
|
stopAggregated.addNearbyTransportStop(stop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return stopAggregated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean checkSameRoute(List<TransportStopRoute> stopRoutes, TransportRoute route) {
|
||||||
|
for (TransportStopRoute stopRoute : stopRoutes) {
|
||||||
|
if (stopRoute.route.compareRoute(route)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -32,15 +32,15 @@ import com.squareup.picasso.Picasso;
|
||||||
import com.squareup.picasso.RequestCreator;
|
import com.squareup.picasso.RequestCreator;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.GPXUtilities;
|
||||||
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
import net.osmand.PicassoUtils;
|
import net.osmand.PicassoUtils;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.QuadRect;
|
import net.osmand.data.QuadRect;
|
||||||
import net.osmand.plus.GPXDatabase;
|
import net.osmand.plus.GPXDatabase;
|
||||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||||
import net.osmand.GPXUtilities;
|
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
|
||||||
import net.osmand.plus.GpxSelectionHelper;
|
import net.osmand.plus.GpxSelectionHelper;
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
|
||||||
|
@ -64,6 +64,7 @@ import net.osmand.render.RenderingRulesStorage;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import gnu.trove.list.array.TIntArrayList;
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
|
|
||||||
|
@ -459,13 +460,60 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
return createTravelArticleCard(context, article);
|
return createTravelArticleCard(context, article);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(gpx.metadata.desc)) {
|
final String description = getMetadataDescription(gpx.metadata);
|
||||||
return createDescriptionCard(context, gpx.metadata.desc);
|
|
||||||
|
if (!TextUtils.isEmpty(description)) {
|
||||||
|
String link = getMetadataImageLink(gpx.metadata);
|
||||||
|
if (!TextUtils.isEmpty(link)) {
|
||||||
|
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
openGpxDescriptionDialog(description);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return createArticleCard(context, null, description, null, link, onClickListener);
|
||||||
|
} else {
|
||||||
|
return createDescriptionCard(context, description);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private String getMetadataDescription(@NonNull GPXUtilities.Metadata metadata) {
|
||||||
|
String descHtml = metadata.desc;
|
||||||
|
if (TextUtils.isEmpty(descHtml)) {
|
||||||
|
Map<String, String> extensions = metadata.getExtensionsToRead();
|
||||||
|
if (!extensions.isEmpty() && extensions.containsKey("desc")) {
|
||||||
|
descHtml = extensions.get("desc");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (descHtml != null) {
|
||||||
|
String content = WikiArticleHelper.getPartialContent(descHtml);
|
||||||
|
if (!TextUtils.isEmpty(content)) {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return descHtml;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private String getMetadataImageLink(@NonNull GPXUtilities.Metadata metadata) {
|
||||||
|
String link = metadata.link;
|
||||||
|
if (!TextUtils.isEmpty(link)) {
|
||||||
|
String lowerCaseLink = link.toLowerCase();
|
||||||
|
if (lowerCaseLink.contains(".jpg")
|
||||||
|
|| lowerCaseLink.contains(".jpeg")
|
||||||
|
|| lowerCaseLink.contains(".png")
|
||||||
|
|| lowerCaseLink.contains(".bmp")
|
||||||
|
|| lowerCaseLink.contains(".webp")) {
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private TravelArticle getTravelArticle(@NonNull GPXUtilities.Metadata metadata) {
|
private TravelArticle getTravelArticle(@NonNull GPXUtilities.Metadata metadata) {
|
||||||
String title = metadata.getArticleTitle();
|
String title = metadata.getArticleTitle();
|
||||||
|
@ -482,34 +530,11 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private View createTravelArticleCard(final Context context, @NonNull final TravelArticle article) {
|
private View createTravelArticleCard(final Context context, @NonNull final TravelArticle article) {
|
||||||
View card = LayoutInflater.from(context).inflate(R.layout.wikivoyage_article_card, null);
|
String title = article.getTitle();
|
||||||
card.findViewById(R.id.background_view).setBackgroundColor(ContextCompat.getColor(context,
|
String content = WikiArticleHelper.getPartialContent(article.getContent());
|
||||||
app.getSettings().isLightContent() ? R.color.list_background_color_light : R.color.list_background_color_dark));
|
String geoDescription = article.getGeoDescription();
|
||||||
((TextView) card.findViewById(R.id.title)).setText(article.getTitle());
|
String imageUrl = TravelArticle.getImageUrl(article.getImageTitle(), false);
|
||||||
((TextView) card.findViewById(R.id.content)).setText(WikiArticleHelper.getPartialContent(article.getContent()));
|
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||||
((TextView) card.findViewById(R.id.part_of)).setText(article.getGeoDescription());
|
|
||||||
final ImageView icon = (ImageView) card.findViewById(R.id.icon);
|
|
||||||
final String url = TravelArticle.getImageUrl(article.getImageTitle(), false);
|
|
||||||
final PicassoUtils picassoUtils = PicassoUtils.getPicasso(app);
|
|
||||||
RequestCreator rc = Picasso.get().load(url);
|
|
||||||
WikivoyageUtils.setupNetworkPolicy(app.getSettings(), rc);
|
|
||||||
rc.transform(new CropCircleTransformation())
|
|
||||||
.into(icon, new Callback() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess() {
|
|
||||||
icon.setVisibility(View.VISIBLE);
|
|
||||||
picassoUtils.setResultLoaded(url, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Exception e) {
|
|
||||||
picassoUtils.setResultLoaded(url, false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
TextView readBtn = (TextView) card.findViewById(R.id.left_button);
|
|
||||||
readBtn.setText(app.getString(R.string.shared_string_read));
|
|
||||||
readBtn.setCompoundDrawablesWithIntrinsicBounds(getReadIcon(), null, null, null);
|
|
||||||
readBtn.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
TrackActivity activity = getTrackActivity();
|
TrackActivity activity = getTrackActivity();
|
||||||
|
@ -518,7 +543,44 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
activity.getSupportFragmentManager(), article.getTripId(), article.getLang());
|
activity.getSupportFragmentManager(), article.getTripId(), article.getLang());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
return createArticleCard(context, title, content, geoDescription, imageUrl, onClickListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private View createArticleCard(final Context context, String title, String content, String geoDescription, final String imageUrl, View.OnClickListener readBtnClickListener) {
|
||||||
|
View card = LayoutInflater.from(context).inflate(R.layout.wikivoyage_article_card, null);
|
||||||
|
card.findViewById(R.id.background_view).setBackgroundColor(ContextCompat.getColor(context,
|
||||||
|
app.getSettings().isLightContent() ? R.color.list_background_color_light : R.color.list_background_color_dark));
|
||||||
|
|
||||||
|
if (!TextUtils.isEmpty(title)) {
|
||||||
|
((TextView) card.findViewById(R.id.title)).setText(title);
|
||||||
|
} else {
|
||||||
|
card.findViewById(R.id.title).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
((TextView) card.findViewById(R.id.content)).setText(content);
|
||||||
|
((TextView) card.findViewById(R.id.part_of)).setText(geoDescription);
|
||||||
|
|
||||||
|
final ImageView icon = (ImageView) card.findViewById(R.id.icon);
|
||||||
|
final PicassoUtils picassoUtils = PicassoUtils.getPicasso(app);
|
||||||
|
RequestCreator rc = Picasso.get().load(imageUrl);
|
||||||
|
WikivoyageUtils.setupNetworkPolicy(app.getSettings(), rc);
|
||||||
|
rc.transform(new CropCircleTransformation())
|
||||||
|
.into(icon, new Callback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
icon.setVisibility(View.VISIBLE);
|
||||||
|
picassoUtils.setResultLoaded(imageUrl, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Exception e) {
|
||||||
|
picassoUtils.setResultLoaded(imageUrl, false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
TextView readBtn = (TextView) card.findViewById(R.id.left_button);
|
||||||
|
readBtn.setText(app.getString(R.string.shared_string_read));
|
||||||
|
readBtn.setCompoundDrawablesWithIntrinsicBounds(getReadIcon(), null, null, null);
|
||||||
|
readBtn.setOnClickListener(readBtnClickListener);
|
||||||
card.findViewById(R.id.right_button).setVisibility(View.GONE);
|
card.findViewById(R.id.right_button).setVisibility(View.GONE);
|
||||||
card.findViewById(R.id.divider).setVisibility(View.GONE);
|
card.findViewById(R.id.divider).setVisibility(View.GONE);
|
||||||
card.findViewById(R.id.list_item_divider).setVisibility(View.VISIBLE);
|
card.findViewById(R.id.list_item_divider).setVisibility(View.VISIBLE);
|
||||||
|
@ -537,6 +599,15 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
readBtn.setOnClickListener(new View.OnClickListener() {
|
readBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
openGpxDescriptionDialog(descHtml);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return card;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openGpxDescriptionDialog(@NonNull final String descHtml) {
|
||||||
TrackActivity activity = getTrackActivity();
|
TrackActivity activity = getTrackActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
|
@ -546,11 +617,6 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
fragment.show(activity.getSupportFragmentManager(), GpxDescriptionDialogFragment.TAG);
|
fragment.show(activity.getSupportFragmentManager(), GpxDescriptionDialogFragment.TAG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
return card;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isGpxFileSelected(GPXFile gpxFile) {
|
public boolean isGpxFileSelected(GPXFile gpxFile) {
|
||||||
return gpxFile != null &&
|
return gpxFile != null &&
|
||||||
|
|
|
@ -1113,12 +1113,14 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
|
||||||
|
|
||||||
private TrkSegment getTrkSegment() {
|
private TrkSegment getTrkSegment() {
|
||||||
for (Track t : gpxItem.group.getGpx().tracks) {
|
for (Track t : gpxItem.group.getGpx().tracks) {
|
||||||
|
if (!t.generalTrack) {
|
||||||
for (TrkSegment s : t.segments) {
|
for (TrkSegment s : t.segments) {
|
||||||
if (s.points.size() > 0 && s.points.get(0).equals(gpxItem.analysis.locationStart)) {
|
if (s.points.size() > 0 && s.points.get(0).equals(gpxItem.analysis.locationStart)) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.routepreparationmenu;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface.OnDismissListener;
|
import android.content.DialogInterface.OnDismissListener;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
@ -21,6 +22,7 @@ import android.support.v7.widget.AppCompatImageView;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.HorizontalScrollView;
|
import android.widget.HorizontalScrollView;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
@ -30,6 +32,7 @@ import android.widget.TextView;
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.StateChangedListener;
|
import net.osmand.StateChangedListener;
|
||||||
import net.osmand.ValueHolder;
|
import net.osmand.ValueHolder;
|
||||||
import net.osmand.binary.RouteDataObject;
|
import net.osmand.binary.RouteDataObject;
|
||||||
|
@ -103,9 +106,12 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
public class MapRouteInfoMenu implements IRouteInformationListener, CardListener {
|
public class MapRouteInfoMenu implements IRouteInformationListener, CardListener {
|
||||||
|
|
||||||
|
private static final Log LOG = PlatformUtil.getLog(MapRouteInfoMenu.class);
|
||||||
|
|
||||||
private static final int BUTTON_ANIMATION_DELAY = 2000;
|
private static final int BUTTON_ANIMATION_DELAY = 2000;
|
||||||
public static final int DEFAULT_MENU_STATE = 0;
|
public static final int DEFAULT_MENU_STATE = 0;
|
||||||
private static final int MAX_PEDESTRIAN_ROUTE_DURATION = 30 * 60;
|
private static final int MAX_PEDESTRIAN_ROUTE_DURATION = 30 * 60;
|
||||||
|
@ -804,15 +810,15 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
updateApplicationMode(am, next);
|
updateApplicationMode(am, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
View ll = mapActivity.getLayoutInflater().inflate(R.layout.mode_toggles, vg);
|
final View ll = mapActivity.getLayoutInflater().inflate(R.layout.mode_toggles, vg);
|
||||||
ll.setBackgroundColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.card_and_list_background_dark : R.color.card_and_list_background_light));
|
ll.setBackgroundColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.card_and_list_background_dark : R.color.card_and_list_background_light));
|
||||||
|
|
||||||
HorizontalScrollView scrollView = ll.findViewById(R.id.app_modes_scroll_container);
|
final HorizontalScrollView scrollView = ll.findViewById(R.id.app_modes_scroll_container);
|
||||||
scrollView.setVerticalScrollBarEnabled(false);
|
scrollView.setVerticalScrollBarEnabled(false);
|
||||||
scrollView.setHorizontalScrollBarEnabled(false);
|
scrollView.setHorizontalScrollBarEnabled(false);
|
||||||
|
|
||||||
int leftTogglePadding = AndroidUtils.dpToPx(mapActivity, 8f);
|
int leftTogglePadding = AndroidUtils.dpToPx(mapActivity, 8f);
|
||||||
int rightTogglePadding = mapActivity.getResources().getDimensionPixelSize(R.dimen.content_padding);
|
final int rightTogglePadding = mapActivity.getResources().getDimensionPixelSize(R.dimen.content_padding);
|
||||||
final View[] buttons = new View[values.size()];
|
final View[] buttons = new View[values.size()];
|
||||||
int k = 0;
|
int k = 0;
|
||||||
Iterator<ApplicationMode> iterator = values.iterator();
|
Iterator<ApplicationMode> iterator = values.iterator();
|
||||||
|
@ -837,6 +843,21 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
for (int i = 0; i < buttons.length; i++) {
|
for (int i = 0; i < buttons.length; i++) {
|
||||||
AppModeDialog.updateButtonStateForRoute((OsmandApplication) mapActivity.getApplication(), values, selected, listener, buttons, i, true, true, nightMode);
|
AppModeDialog.updateButtonStateForRoute((OsmandApplication) mapActivity.getApplication(), values, selected, listener, buttons, i, true, true, nightMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final ApplicationMode activeMode = app.getSettings().getApplicationMode();
|
||||||
|
final int idx = values.indexOf(activeMode);
|
||||||
|
|
||||||
|
OnGlobalLayoutListener globalListener = new OnGlobalLayoutListener() {
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
LinearLayout container = ll.findViewById(R.id.app_modes_content);
|
||||||
|
int s = container.getChildAt(idx) != null ? container.getChildAt(idx).getRight() + rightTogglePadding : 0;
|
||||||
|
scrollView.scrollTo(s - scrollView.getWidth() > 0 ? s - scrollView.getWidth() : 0, 0);
|
||||||
|
ll.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ll.getViewTreeObserver().addOnGlobalLayoutListener(globalListener);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateOptionsButtons() {
|
private void updateOptionsButtons() {
|
||||||
|
|
|
@ -43,7 +43,6 @@ import net.osmand.core.jni.Utilities;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.QuadRect;
|
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.data.TransportStop;
|
import net.osmand.data.TransportStop;
|
||||||
import net.osmand.osm.PoiCategory;
|
import net.osmand.osm.PoiCategory;
|
||||||
|
@ -56,10 +55,10 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.MapActivityActions;
|
import net.osmand.plus.activities.MapActivityActions;
|
||||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||||
|
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController;
|
||||||
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu;
|
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu;
|
||||||
import net.osmand.plus.render.MapRenderRepositories;
|
import net.osmand.plus.render.MapRenderRepositories;
|
||||||
import net.osmand.plus.render.NativeOsmandLibrary;
|
import net.osmand.plus.render.NativeOsmandLibrary;
|
||||||
import net.osmand.plus.resources.TransportIndexRepository;
|
|
||||||
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
|
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
|
||||||
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint;
|
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint;
|
||||||
import net.osmand.plus.views.corenative.NativeCoreContext;
|
import net.osmand.plus.views.corenative.NativeCoreContext;
|
||||||
|
@ -67,8 +66,6 @@ import net.osmand.util.Algorithms;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -76,10 +73,8 @@ import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import gnu.trove.list.array.TIntArrayList;
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
import gnu.trove.list.array.TLongArrayList;
|
|
||||||
|
|
||||||
import static net.osmand.plus.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_CHANGE_MARKER_POSITION;
|
import static net.osmand.plus.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_CHANGE_MARKER_POSITION;
|
||||||
import static net.osmand.plus.mapcontextmenu.controllers.TransportStopController.SHOW_STOPS_RADIUS_METERS;
|
|
||||||
|
|
||||||
public class ContextMenuLayer extends OsmandMapLayer {
|
public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
//private static final Log LOG = PlatformUtil.getLog(ContextMenuLayer.class);
|
//private static final Log LOG = PlatformUtil.getLog(ContextMenuLayer.class);
|
||||||
|
@ -864,31 +859,12 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (transportStopAmenities.size() > 0) {
|
if (transportStopAmenities.size() > 0) {
|
||||||
List<TransportStop> transportStops = findTransportStopsAt(latLon.getLatitude(), latLon.getLongitude());
|
|
||||||
List<TransportStop> transportStopsReplacement = new ArrayList<>();
|
|
||||||
for (Amenity amenity : transportStopAmenities) {
|
for (Amenity amenity : transportStopAmenities) {
|
||||||
List<TransportStop> amenityTransportStops = new ArrayList<>();
|
TransportStop transportStop = TransportStopController.findBestTransportStopForAmenity(activity.getMyApplication(), amenity);
|
||||||
for (TransportStop transportStop : transportStops) {
|
if (transportStop != null) {
|
||||||
if (transportStop.getName().startsWith(amenity.getName())) {
|
|
||||||
amenityTransportStops.add(transportStop);
|
|
||||||
transportStop.setAmenity(amenity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (amenityTransportStops.size() > 0) {
|
|
||||||
selectedObjects.remove(amenity);
|
|
||||||
if (amenityTransportStops.size() > 1) {
|
|
||||||
sortTransportStops(amenity.getLocation(), amenityTransportStops);
|
|
||||||
}
|
|
||||||
TransportStop amenityTransportStop = amenityTransportStops.get(0);
|
|
||||||
if (!transportStopsReplacement.contains(amenityTransportStop)) {
|
|
||||||
transportStopsReplacement.add(amenityTransportStop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (transportStopsReplacement.size() > 0) {
|
|
||||||
TransportStopsLayer transportStopsLayer = activity.getMapLayers().getTransportStopsLayer();
|
TransportStopsLayer transportStopsLayer = activity.getMapLayers().getTransportStopsLayer();
|
||||||
if (transportStopsLayer != null) {
|
if (transportStopsLayer != null) {
|
||||||
for (TransportStop transportStop : transportStopsReplacement) {
|
selectedObjects.remove(amenity);
|
||||||
selectedObjects.put(transportStop, transportStopsLayer);
|
selectedObjects.put(transportStop, transportStopsLayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -897,42 +873,6 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sortTransportStops(@NonNull LatLon latLon, List<TransportStop> transportStops) {
|
|
||||||
for (TransportStop transportStop : transportStops) {
|
|
||||||
transportStop.distance = (int) MapUtils.getDistance(latLon, transportStop.getLocation());
|
|
||||||
}
|
|
||||||
Collections.sort(transportStops, new Comparator<TransportStop>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compare(TransportStop s1, TransportStop s2) {
|
|
||||||
return Algorithms.compare(s1.distance, s2.distance);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
private List<TransportStop> findTransportStopsAt(double latitude, double longitude) {
|
|
||||||
ArrayList<TransportStop> transportStops = new ArrayList<>();
|
|
||||||
List<TransportIndexRepository> reps =
|
|
||||||
activity.getMyApplication().getResourceManager().searchTransportRepositories(latitude, longitude);
|
|
||||||
|
|
||||||
TLongArrayList addedTransportStops = new TLongArrayList();
|
|
||||||
for (TransportIndexRepository t : reps) {
|
|
||||||
ArrayList<TransportStop> ls = new ArrayList<>();
|
|
||||||
QuadRect ll = MapUtils.calculateLatLonBbox(latitude, longitude, SHOW_STOPS_RADIUS_METERS);
|
|
||||||
t.searchTransportStops(ll.top, ll.left, ll.bottom, ll.right, -1, ls, null);
|
|
||||||
for (TransportStop tstop : ls) {
|
|
||||||
if (!addedTransportStops.contains(tstop.getId())) {
|
|
||||||
addedTransportStops.add(tstop.getId());
|
|
||||||
if (!tstop.isDeleted()) {
|
|
||||||
transportStops.add(tstop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return transportStops;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private Map<Object, IContextMenuProvider> selectObjectsForContextMenu(RotatedTileBox tileBox,
|
private Map<Object, IContextMenuProvider> selectObjectsForContextMenu(RotatedTileBox tileBox,
|
||||||
PointF point, boolean acquireObjLatLon,
|
PointF point, boolean acquireObjLatLon,
|
||||||
|
|
Loading…
Reference in a new issue