diff --git a/OsmAnd-java/src/net/osmand/data/Amenity.java b/OsmAnd-java/src/net/osmand/data/Amenity.java
index 4bc6df691e..28fa2fa6b5 100644
--- a/OsmAnd-java/src/net/osmand/data/Amenity.java
+++ b/OsmAnd-java/src/net/osmand/data/Amenity.java
@@ -26,6 +26,7 @@ public class Amenity extends MapObject {
public static final String WEBSITE = "website";
public static final String PHONE = "phone";
public static final String DESCRIPTION = "description";
+ public static final String ROUTE = "route";
public static final String OPENING_HOURS = "opening_hours";
public static final String CONTENT = "content";
public static final String CUISINE = "cuisine";
diff --git a/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java b/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java
index ddc0e5589c..9bfc24476c 100644
--- a/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java
+++ b/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java
@@ -28,6 +28,10 @@ public class OpeningHoursParser {
private static final String[] monthsStr;
private static final String[] localMothsStr;
+ private static final int LOW_TIME_LIMIT = 120;
+ private static final int HIGH_TIME_LIMIT = 300;
+ private static final int WITHOUT_TIME_LIMIT = -1;
+
static {
DateFormatSymbols dateFormatSymbols = DateFormatSymbols.getInstance(Locale.US);
monthsStr = dateFormatSymbols.getShortMonths();
@@ -186,6 +190,76 @@ public class OpeningHoursParser {
return isOpenDay || isOpenPrevious;
}
+ public boolean isOpened24_7() {
+ boolean opened24_7 = false;
+ for (OpeningHoursRule r : rules) {
+ opened24_7 = r.isOpened24_7();
+ }
+ return opened24_7;
+ }
+
+ public String getNearToOpeningTime(Calendar cal) {
+ return getTime(cal, LOW_TIME_LIMIT, true);
+ }
+
+ public String getOpeningTime(Calendar cal) {
+ return getTime(cal, HIGH_TIME_LIMIT, true);
+ }
+
+ public String getNearToClosingTime(Calendar cal) {
+ return getTime(cal, LOW_TIME_LIMIT, false);
+ }
+
+ public String getClosingTime(Calendar cal) {
+ return getTime(cal, WITHOUT_TIME_LIMIT, false);
+ }
+
+ public String getOpeningDay(Calendar calendar) {
+ Calendar cal = (Calendar) calendar.clone();
+ String openingTime = "";
+ for (int i = 0; i < 7; i++) {
+ cal.add(Calendar.DAY_OF_MONTH, 1);
+ for (OpeningHoursRule r : rules) {
+ if (r.containsDay(cal) && r.containsMonth(cal)) {
+ openingTime = r.getTime(cal, false, WITHOUT_TIME_LIMIT, true);
+ }
+ }
+ if (!Algorithms.isEmpty(openingTime)) {
+ openingTime += " " + localDaysStr[cal.get(Calendar.DAY_OF_WEEK)];
+ break;
+ }
+ }
+ return openingTime;
+ }
+
+ private String getTime(Calendar cal, int limit, boolean opening) {
+ String time = getTimeDay(cal, limit, opening);
+ if (Algorithms.isEmpty(time)) {
+ time = getTimeAnotherDay(cal, limit, opening);
+ }
+ return time;
+ }
+
+ private String getTimeDay(Calendar cal, int limit, boolean opening) {
+ String atTime = "";
+ for (OpeningHoursRule r : rules) {
+ if (r.containsDay(cal) && r.containsMonth(cal)) {
+ atTime = r.getTime(cal, false, limit, opening);
+ }
+ }
+ return atTime;
+ }
+
+ private String getTimeAnotherDay(Calendar cal, int limit, boolean opening) {
+ String atTime = "";
+ for (OpeningHoursRule r : rules) {
+ if (((opening && r.containsPreviousDay(cal)) || (!opening && r.containsNextDay(cal))) && r.containsMonth(cal)) {
+ atTime = r.getTime(cal, true, limit, opening);
+ }
+ }
+ return atTime;
+ }
+
public String getCurrentRuleTime(Calendar cal) {
// make exception for overlapping times i.e.
// (1) Mo 14:00-16:00; Tu off
@@ -318,6 +392,14 @@ public class OpeningHoursParser {
*/
public boolean containsDay(Calendar cal);
+ /**
+ * Check if the next day after "cal" is part of this rule
+ *
+ * @param cal the time to check
+ * @return true if the next day is part of the rule
+ */
+ boolean containsNextDay(Calendar cal);
+
/**
* Check if the month of "cal" is part of this rule
*
@@ -341,6 +423,10 @@ public class OpeningHoursParser {
public String toRuleString();
public String toLocalRuleString();
+
+ boolean isOpened24_7();
+
+ String getTime(Calendar cal, boolean checkAnotherDay, int limit, boolean opening);
}
/**
@@ -558,6 +644,16 @@ public class OpeningHoursParser {
return false;
}
+ @Override
+ public boolean containsNextDay(Calendar cal) {
+ int i = cal.get(Calendar.DAY_OF_WEEK);
+ int p = (i + 6) % 7;
+ if (days[p]) {
+ return true;
+ }
+ return false;
+ }
+
/**
* Check if the previous weekday of time "cal" is part of this rule
*
@@ -597,14 +693,10 @@ public class OpeningHoursParser {
*/
@Override
public boolean isOpenedForTime(Calendar cal, boolean checkPrevious) {
- int i = cal.get(Calendar.DAY_OF_WEEK);
- int d = (i + 5) % 7;
- int p = d - 1;
- if (p < 0) {
- p += 7;
- }
- int time = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE); // Time in minutes
- for (i = 0; i < startTimes.size(); i++) {
+ int d = getCurrentDay(cal);
+ int p = getPreviousDay(d);
+ int time = getCurrentTimeInMinutes(cal); // Time in minutes
+ for (int i = 0; i < startTimes.size(); i++) {
int startTime = this.startTimes.get(i);
int endTime = this.endTimes.get(i);
if (startTime < endTime || endTime == -1) {
@@ -628,6 +720,30 @@ public class OpeningHoursParser {
return false;
}
+ private int getCurrentDay(Calendar cal) {
+ int i = cal.get(Calendar.DAY_OF_WEEK);
+ return (i + 5) % 7;
+ }
+
+ private int getPreviousDay(int currentDay) {
+ int p = currentDay - 1;
+ if (p < 0) {
+ p += 7;
+ }
+ return p;
+ }
+
+ private int getNextDay(int currentDay) {
+ int n = currentDay + 1;
+ if (n > 6) {
+ n -= 7;
+ }
+ return n;
+ }
+
+ private int getCurrentTimeInMinutes(Calendar cal) {
+ return cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
+ }
@Override
public String toRuleString() {
@@ -658,24 +774,17 @@ public class OpeningHoursParser {
addArray(dayMonths, null, b);
}
// Day
- boolean open24_7 = true;
- for (int i = 0; i < 7; i++) {
- if (!days[i]) {
- open24_7 = false;
- break;
- }
- }
appendDaysString(b, dayNames);
// Time
if (startTimes == null || startTimes.size() == 0) {
b.append("off");
} else {
+ if (isOpened24_7()) {
+ return "24/7";
+ }
for (int i = 0; i < startTimes.size(); i++) {
int startTime = startTimes.get(i);
int endTime = endTimes.get(i);
- if (open24_7 && startTime == 0 && endTime / 60 == 24) {
- return "24/7";
- }
if(i > 0) {
b.append(", ");
}
@@ -725,6 +834,84 @@ public class OpeningHoursParser {
return toRuleString(localDaysStr, localMothsStr);
}
+ @Override
+ public boolean isOpened24_7() {
+ boolean opened24_7 = true;
+ for (int i = 0; i < 7; i++) {
+ if (!days[i]) {
+ opened24_7 = false;
+ break;
+ }
+ }
+
+ if (opened24_7 && startTimes != null && startTimes.size() > 0) {
+ for (int i = 0; i < startTimes.size(); i++) {
+ int startTime = startTimes.get(i);
+ int endTime = endTimes.get(i);
+ if (startTime == 0 && endTime / 60 == 24) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String getTime(Calendar cal, boolean checkAnotherDay, int limit, boolean opening) {
+ StringBuilder sb = new StringBuilder();
+ int d = getCurrentDay(cal);
+ int ad = opening ? getNextDay(d) : getPreviousDay(d);
+ int time = getCurrentTimeInMinutes(cal);
+ for (int i = 0; i < startTimes.size(); i++) {
+ int startTime = startTimes.get(i);
+ int endTime = endTimes.get(i);
+ if (opening) {
+ if (startTime < endTime || endTime == -1) {
+ if (days[d] && !checkAnotherDay) {
+ int diff = startTime - time;
+ if (limit == WITHOUT_TIME_LIMIT || ((time <= startTime) && (diff <= limit))) {
+ formatTime(startTime, sb);
+ break;
+ }
+ }
+ } else {
+ int diff = -1;
+ if (time <= startTime && days[d] && !checkAnotherDay) {
+ diff = startTime - time;
+ } else if (time > endTime && days[ad] && checkAnotherDay) {
+ diff = 24 * 60 - endTime + time;
+ }
+ if (limit == WITHOUT_TIME_LIMIT || ((diff != -1) && (diff <= limit))) {
+ formatTime(startTime, sb);
+ break;
+ }
+ }
+ } else {
+ if (startTime < endTime && endTime != -1) {
+ if (days[d] && !checkAnotherDay) {
+ int diff = endTime - time;
+ if (limit == WITHOUT_TIME_LIMIT || ((time <= endTime) && (diff <= limit))) {
+ formatTime(endTime, sb);
+ break;
+ }
+ }
+ } else {
+ int diff = -1;
+ if (time <= endTime && days[d] && !checkAnotherDay) {
+ diff = 24 * 60 - time + endTime;
+ } else if (time < endTime && days[ad] && checkAnotherDay) {
+ diff = startTime - time;
+ }
+ if (limit == WITHOUT_TIME_LIMIT || ((diff != -1) && (diff <= limit))) {
+ formatTime(endTime, sb);
+ break;
+ }
+ }
+ }
+ }
+ return sb.toString();
+ }
+
@Override
public String toString() {
return toRuleString();
@@ -900,6 +1087,11 @@ public class OpeningHoursParser {
return false;
}
+ @Override
+ public boolean containsNextDay(Calendar cal) {
+ return false;
+ }
+
@Override
public boolean containsMonth(Calendar cal) {
return false;
@@ -915,6 +1107,16 @@ public class OpeningHoursParser {
return toRuleString();
}
+ @Override
+ public boolean isOpened24_7() {
+ return false;
+ }
+
+ @Override
+ public String getTime(Calendar cal, boolean checkAnotherDay, int limit, boolean opening) {
+ return "";
+ }
+
@Override
public String toString() {
return toRuleString();
@@ -1260,6 +1462,11 @@ public class OpeningHoursParser {
b.append(t);
}
+ private static void formatTime(int minutes, StringBuilder sb) {
+ int hour = minutes / 60;
+ int time = minutes - hour * 60;
+ formatTime(hour, time, sb);
+ }
/**
* test if the calculated opening hours are what you expect
diff --git a/OsmAnd/res/drawable/bg_map_context_menu_dark.xml b/OsmAnd/res/drawable/bg_map_context_menu_dark.xml
index c584b75e83..1e7add2c05 100644
--- a/OsmAnd/res/drawable/bg_map_context_menu_dark.xml
+++ b/OsmAnd/res/drawable/bg_map_context_menu_dark.xml
@@ -6,7 +6,7 @@
-
+ android:color="@color/ctx_menu_bg_dark" />
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/bg_map_context_menu_light.xml b/OsmAnd/res/drawable/bg_map_context_menu_light.xml
index dd3d7d2a98..60af50f23c 100644
--- a/OsmAnd/res/drawable/bg_map_context_menu_light.xml
+++ b/OsmAnd/res/drawable/bg_map_context_menu_light.xml
@@ -6,7 +6,7 @@
-
+ android:color="@color/ctx_menu_bg_light" />
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/context_menu_controller_bg_dark.xml b/OsmAnd/res/drawable/context_menu_controller_bg_dark.xml
new file mode 100644
index 0000000000..913ba55c2e
--- /dev/null
+++ b/OsmAnd/res/drawable/context_menu_controller_bg_dark.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/context_menu_controller_bg_dark_n.xml b/OsmAnd/res/drawable/context_menu_controller_bg_dark_n.xml
new file mode 100644
index 0000000000..b9d62bc429
--- /dev/null
+++ b/OsmAnd/res/drawable/context_menu_controller_bg_dark_n.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/context_menu_controller_bg_dark_p.xml b/OsmAnd/res/drawable/context_menu_controller_bg_dark_p.xml
new file mode 100644
index 0000000000..2cbe3de5a5
--- /dev/null
+++ b/OsmAnd/res/drawable/context_menu_controller_bg_dark_p.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/context_menu_controller_bg_dark_selected.xml b/OsmAnd/res/drawable/context_menu_controller_bg_dark_selected.xml
new file mode 100644
index 0000000000..c6cb2f2464
--- /dev/null
+++ b/OsmAnd/res/drawable/context_menu_controller_bg_dark_selected.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/context_menu_controller_bg_dark_show_all.xml b/OsmAnd/res/drawable/context_menu_controller_bg_dark_show_all.xml
new file mode 100644
index 0000000000..6fdfc0775a
--- /dev/null
+++ b/OsmAnd/res/drawable/context_menu_controller_bg_dark_show_all.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/context_menu_controller_bg_dark_show_all_n.xml b/OsmAnd/res/drawable/context_menu_controller_bg_dark_show_all_n.xml
new file mode 100644
index 0000000000..a46539b80e
--- /dev/null
+++ b/OsmAnd/res/drawable/context_menu_controller_bg_dark_show_all_n.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/context_menu_controller_bg_dark_show_all_p.xml b/OsmAnd/res/drawable/context_menu_controller_bg_dark_show_all_p.xml
new file mode 100644
index 0000000000..482f79662f
--- /dev/null
+++ b/OsmAnd/res/drawable/context_menu_controller_bg_dark_show_all_p.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/context_menu_controller_bg_light.xml b/OsmAnd/res/drawable/context_menu_controller_bg_light.xml
new file mode 100644
index 0000000000..d2e8148967
--- /dev/null
+++ b/OsmAnd/res/drawable/context_menu_controller_bg_light.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/context_menu_controller_bg_light_n.xml b/OsmAnd/res/drawable/context_menu_controller_bg_light_n.xml
new file mode 100644
index 0000000000..eaddd95f5e
--- /dev/null
+++ b/OsmAnd/res/drawable/context_menu_controller_bg_light_n.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/context_menu_controller_bg_light_p.xml b/OsmAnd/res/drawable/context_menu_controller_bg_light_p.xml
new file mode 100644
index 0000000000..db337bcee9
--- /dev/null
+++ b/OsmAnd/res/drawable/context_menu_controller_bg_light_p.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/context_menu_controller_bg_light_selected.xml b/OsmAnd/res/drawable/context_menu_controller_bg_light_selected.xml
new file mode 100644
index 0000000000..6f169dd925
--- /dev/null
+++ b/OsmAnd/res/drawable/context_menu_controller_bg_light_selected.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/context_menu_controller_bg_light_show_all.xml b/OsmAnd/res/drawable/context_menu_controller_bg_light_show_all.xml
new file mode 100644
index 0000000000..2235057832
--- /dev/null
+++ b/OsmAnd/res/drawable/context_menu_controller_bg_light_show_all.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/context_menu_controller_bg_light_show_all_n.xml b/OsmAnd/res/drawable/context_menu_controller_bg_light_show_all_n.xml
new file mode 100644
index 0000000000..6165ae7053
--- /dev/null
+++ b/OsmAnd/res/drawable/context_menu_controller_bg_light_show_all_n.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/context_menu_controller_bg_light_show_all_p.xml b/OsmAnd/res/drawable/context_menu_controller_bg_light_show_all_p.xml
new file mode 100644
index 0000000000..d7a8a18369
--- /dev/null
+++ b/OsmAnd/res/drawable/context_menu_controller_bg_light_show_all_p.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/context_menu_controller_text_color_dark.xml b/OsmAnd/res/drawable/context_menu_controller_text_color_dark.xml
new file mode 100644
index 0000000000..9ba8a5ee2f
--- /dev/null
+++ b/OsmAnd/res/drawable/context_menu_controller_text_color_dark.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/context_menu_controller_text_color_light.xml b/OsmAnd/res/drawable/context_menu_controller_text_color_light.xml
new file mode 100644
index 0000000000..8abe7a91ce
--- /dev/null
+++ b/OsmAnd/res/drawable/context_menu_controller_text_color_light.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/route_info_go_btn_bg_dark.xml b/OsmAnd/res/drawable/route_info_go_btn_bg_dark.xml
new file mode 100644
index 0000000000..ffda2162f3
--- /dev/null
+++ b/OsmAnd/res/drawable/route_info_go_btn_bg_dark.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/route_info_go_btn_bg_dark_n.xml b/OsmAnd/res/drawable/route_info_go_btn_bg_dark_n.xml
new file mode 100644
index 0000000000..41b2d87e64
--- /dev/null
+++ b/OsmAnd/res/drawable/route_info_go_btn_bg_dark_n.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/route_info_go_btn_bg_dark_p.xml b/OsmAnd/res/drawable/route_info_go_btn_bg_dark_p.xml
new file mode 100644
index 0000000000..541cc4b4c8
--- /dev/null
+++ b/OsmAnd/res/drawable/route_info_go_btn_bg_dark_p.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/route_info_go_btn_bg_light.xml b/OsmAnd/res/drawable/route_info_go_btn_bg_light.xml
new file mode 100644
index 0000000000..22650894e3
--- /dev/null
+++ b/OsmAnd/res/drawable/route_info_go_btn_bg_light.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/route_info_go_btn_bg_light_n.xml b/OsmAnd/res/drawable/route_info_go_btn_bg_light_n.xml
new file mode 100644
index 0000000000..3091141170
--- /dev/null
+++ b/OsmAnd/res/drawable/route_info_go_btn_bg_light_n.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/route_info_go_btn_bg_light_p.xml b/OsmAnd/res/drawable/route_info_go_btn_bg_light_p.xml
new file mode 100644
index 0000000000..19b018171c
--- /dev/null
+++ b/OsmAnd/res/drawable/route_info_go_btn_bg_light_p.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/route_info_menu_bg_dark.xml b/OsmAnd/res/drawable/route_info_menu_bg_dark.xml
new file mode 100644
index 0000000000..d70013e6ab
--- /dev/null
+++ b/OsmAnd/res/drawable/route_info_menu_bg_dark.xml
@@ -0,0 +1,11 @@
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/route_info_menu_bg_left_dark.xml b/OsmAnd/res/drawable/route_info_menu_bg_left_dark.xml
new file mode 100644
index 0000000000..49659f9130
--- /dev/null
+++ b/OsmAnd/res/drawable/route_info_menu_bg_left_dark.xml
@@ -0,0 +1,12 @@
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/route_info_menu_bg_left_light.xml b/OsmAnd/res/drawable/route_info_menu_bg_left_light.xml
new file mode 100644
index 0000000000..6737137cbf
--- /dev/null
+++ b/OsmAnd/res/drawable/route_info_menu_bg_left_light.xml
@@ -0,0 +1,12 @@
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/route_info_menu_bg_light.xml b/OsmAnd/res/drawable/route_info_menu_bg_light.xml
new file mode 100644
index 0000000000..994263f690
--- /dev/null
+++ b/OsmAnd/res/drawable/route_info_menu_bg_light.xml
@@ -0,0 +1,11 @@
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/transport_stop_route_bg.xml b/OsmAnd/res/drawable/transport_stop_route_bg.xml
new file mode 100644
index 0000000000..ac8defb11b
--- /dev/null
+++ b/OsmAnd/res/drawable/transport_stop_route_bg.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout-land/menu_obj_selection_fragment.xml b/OsmAnd/res/layout-land/menu_obj_selection_fragment.xml
index 854dac8947..600e297f8c 100644
--- a/OsmAnd/res/layout-land/menu_obj_selection_fragment.xml
+++ b/OsmAnd/res/layout-land/menu_obj_selection_fragment.xml
@@ -5,16 +5,49 @@
android:layout_width="@dimen/dashboard_land_width"
android:layout_height="match_parent"
android:layout_gravity="bottom"
- android:background="?attr/left_menu_view_bg"
- android:orientation="vertical">
+ tools:background="?attr/left_menu_view_bg"
+ android:orientation="vertical"
+ xmlns:tools="http://schemas.android.com/tools">
-
+ android:layout_height="match_parent">
-
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout-land/plan_route_info.xml b/OsmAnd/res/layout-land/plan_route_info.xml
index 2dfadcb870..3ef7ec87a4 100644
--- a/OsmAnd/res/layout-land/plan_route_info.xml
+++ b/OsmAnd/res/layout-land/plan_route_info.xml
@@ -5,14 +5,15 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_transparent"
- android:clickable="true">
+ android:clickable="true"
+ xmlns:tools="http://schemas.android.com/tools">
@@ -24,7 +25,7 @@
-
-
-
+
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
-
-
-
+ android:layout_height="@dimen/list_item_height"
+ android:orientation="horizontal">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_height="match_parent"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
diff --git a/OsmAnd/res/layout/bottom_sheet_dialog_fragment_divider.xml b/OsmAnd/res/layout/bottom_sheet_dialog_fragment_divider.xml
new file mode 100644
index 0000000000..05cc926985
--- /dev/null
+++ b/OsmAnd/res/layout/bottom_sheet_dialog_fragment_divider.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/bottom_sheet_dialog_fragment_item.xml b/OsmAnd/res/layout/bottom_sheet_dialog_fragment_item.xml
new file mode 100644
index 0000000000..b0b4855034
--- /dev/null
+++ b/OsmAnd/res/layout/bottom_sheet_dialog_fragment_item.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/bottom_sheet_dialog_fragment_title.xml b/OsmAnd/res/layout/bottom_sheet_dialog_fragment_title.xml
new file mode 100644
index 0000000000..a70510f0d2
--- /dev/null
+++ b/OsmAnd/res/layout/bottom_sheet_dialog_fragment_title.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/ctx_menu_transport_route_layout.xml b/OsmAnd/res/layout/ctx_menu_transport_route_layout.xml
new file mode 100644
index 0000000000..ea5082b912
--- /dev/null
+++ b/OsmAnd/res/layout/ctx_menu_transport_route_layout.xml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/fragment_context_menu_actions_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_context_menu_actions_bottom_sheet_dialog.xml
new file mode 100644
index 0000000000..bfbcb1756b
--- /dev/null
+++ b/OsmAnd/res/layout/fragment_context_menu_actions_bottom_sheet_dialog.xml
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml
index bf1a78ede6..4a2ad7c61d 100644
--- a/OsmAnd/res/layout/map_context_menu_fragment.xml
+++ b/OsmAnd/res/layout/map_context_menu_fragment.xml
@@ -5,7 +5,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@android:color/transparent">
+ android:background="@android:color/transparent"
+ xmlns:osmand="http://schemas.android.com/apk/res-auto">
-
-
-
-
-
-
-
-
-
-
-
+ android:text="@string/search_address_building"
+ style="@style/TextAppearance.ContextMenuTitle"/>
-
+
-
-
-
-
-
-
-
-
-
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:text="@string/amenity_type_finance"
+ style="@style/TextAppearance.ContextMenuSubtitle"/>
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_gravity="center_vertical"
+ android:layout_marginLeft="2dp"
+ android:layout_marginStart="2dp"
+ tools:textColor="?android:textColorSecondary"
+ android:textSize="@dimen/default_desc_text_size"
+ tools:text="100500 km"/>
@@ -168,145 +147,187 @@
android:id="@+id/title_button_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/context_menu_buttons_top_margin"
android:clickable="true"
- android:minHeight="@dimen/context_menu_action_buttons_h"
- android:orientation="vertical"
- android:paddingBottom="@dimen/context_menu_buttons_padding_bottom"
- android:paddingLeft="62dp"
- android:paddingRight="2dp"
+ android:orientation="horizontal"
+ android:paddingBottom="@dimen/context_menu_padding_margin_small"
android:visibility="gone"
tools:visibility="visible">
+ android:layout_marginLeft="@dimen/context_menu_padding_margin_small"
+ android:layout_marginRight="@dimen/context_menu_padding_margin_small"
+ android:id="@+id/title_button_view"
+ android:background="?attr/ctx_menu_controller_bg"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="@dimen/context_menu_controller_height"
+ android:orientation="horizontal">
-
-
-
-
+ android:id="@+id/download_button_left_view"
+ android:background="?attr/ctx_menu_controller_bg"
+ android:layout_marginLeft="@dimen/context_menu_padding_margin_small"
+ android:layout_marginRight="@dimen/context_menu_padding_margin_small"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="@dimen/context_menu_controller_height">
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -358,74 +379,194 @@
android:id="@+id/buttons_top_border"
android:layout_width="match_parent"
android:layout_height="1dp"
- android:background="?attr/dashboard_divider"/>
+ android:background="?attr/ctx_menu_divider"/>
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
-
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingTop="@dimen/context_menu_main_actions_padding_top"
+ android:paddingBottom="@dimen/context_menu_main_actions_padding_bottom">
-
+
-
+
+
+
+
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingTop="@dimen/context_menu_main_actions_padding_top"
+ android:paddingBottom="@dimen/context_menu_main_actions_padding_bottom">
-
+
-
+
+
+
+
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingTop="@dimen/context_menu_main_actions_padding_top"
+ android:paddingBottom="@dimen/context_menu_main_actions_padding_bottom">
-
+
-
+
+
+
+
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingTop="@dimen/context_menu_main_actions_padding_top"
+ android:paddingBottom="@dimen/context_menu_main_actions_padding_bottom">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -441,13 +582,13 @@
android:id="@+id/context_menu_bottom_scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="?attr/ctx_menu_info_view_bg">
+ tools:background="?attr/ctx_menu_info_view_bg">
@@ -460,7 +601,8 @@
+ android:layout_height="match_parent"
+ tools:visibility="gone">
-
-
\ No newline at end of file
diff --git a/OsmAnd/res/layout/map_route_prepare_bottom.xml b/OsmAnd/res/layout/map_route_prepare_bottom.xml
index 666b306c50..c0d81bab9c 100644
--- a/OsmAnd/res/layout/map_route_prepare_bottom.xml
+++ b/OsmAnd/res/layout/map_route_prepare_bottom.xml
@@ -1,16 +1,22 @@
+ android:layout_height="wrap_content"
+ tools:background="@color/route_info_bottom_view_bg_dark"
+ android:layout_gravity="bottom">
@@ -19,13 +25,20 @@
android:id="@+id/dividerBtn1"
android:layout_width="1dp"
android:layout_height="match_parent"
- android:background="@color/dashboard_divider_dark"/>
+ android:layout_marginTop="@dimen/route_info_buttons_padding_top_bottom"
+ android:layout_marginBottom="@dimen/route_info_buttons_padding_top_bottom"
+ android:layout_gravity="center"
+ tools:background="@color/route_info_divider_dark"/>
@@ -34,34 +47,41 @@
android:id="@+id/dividerBtn2"
android:layout_width="1dp"
android:layout_height="match_parent"
- android:background="@color/dashboard_divider_dark"/>
+ android:layout_marginTop="@dimen/route_info_buttons_padding_top_bottom"
+ android:layout_marginBottom="@dimen/route_info_buttons_padding_top_bottom"
+ android:layout_gravity="center"
+ tools:background="@color/route_info_divider_dark"/>
-
-
+ android:textStyle="bold"
+ tools:background="@drawable/route_info_go_btn_bg_dark"/>
\ No newline at end of file
diff --git a/OsmAnd/res/layout/menu_obj_list_item.xml b/OsmAnd/res/layout/menu_obj_list_item.xml
index 976ee05520..c012235eb6 100644
--- a/OsmAnd/res/layout/menu_obj_list_item.xml
+++ b/OsmAnd/res/layout/menu_obj_list_item.xml
@@ -2,78 +2,68 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
-
+ android:paddingBottom="@dimen/content_padding_small"
+ android:paddingTop="@dimen/list_content_padding"
+ android:layout_weight="1"
+ android:orientation="vertical">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/menu_obj_selection_fragment.xml b/OsmAnd/res/layout/menu_obj_selection_fragment.xml
index 94cc9bf412..2412846f31 100644
--- a/OsmAnd/res/layout/menu_obj_selection_fragment.xml
+++ b/OsmAnd/res/layout/menu_obj_selection_fragment.xml
@@ -5,16 +5,49 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
- android:background="?attr/bottom_menu_view_bg"
- android:orientation="vertical">
+ tools:background="?attr/bottom_menu_view_bg"
+ android:orientation="vertical"
+ xmlns:tools="http://schemas.android.com/tools">
-
+ android:layout_height="wrap_content">
-
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/menu_obj_selection_header.xml b/OsmAnd/res/layout/menu_obj_selection_header.xml
new file mode 100644
index 0000000000..3941361cf1
--- /dev/null
+++ b/OsmAnd/res/layout/menu_obj_selection_header.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/mode_view.xml b/OsmAnd/res/layout/mode_view.xml
index 5d00a75539..4e53f468f7 100644
--- a/OsmAnd/res/layout/mode_view.xml
+++ b/OsmAnd/res/layout/mode_view.xml
@@ -1,17 +1,16 @@
+ android:layout_width="@dimen/route_info_modes_height"
+ android:layout_height="@dimen/route_info_modes_height"
+ xmlns:tools="http://schemas.android.com/tools">
+ android:scaleType="center"/>
+ android:clickable="true"
+ xmlns:tools="http://schemas.android.com/tools">
@@ -24,7 +25,7 @@
-
-
-
+
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
-
-
-
+ android:layout_height="@dimen/list_item_height"
+ android:orientation="horizontal">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_height="match_parent"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
diff --git a/OsmAnd/res/layout/transport_stop_route_item.xml b/OsmAnd/res/layout/transport_stop_route_item.xml
new file mode 100644
index 0000000000..8d186872a8
--- /dev/null
+++ b/OsmAnd/res/layout/transport_stop_route_item.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/values-large/sizes.xml b/OsmAnd/res/values-large/sizes.xml
index f8ce4c32be..d321306578 100644
--- a/OsmAnd/res/values-large/sizes.xml
+++ b/OsmAnd/res/values-large/sizes.xml
@@ -58,6 +58,29 @@
80dp
66dp
80dp
+ 36dp
+ 63dp
+ 30dp
+ 24dp
+ 15dp
+ 12dp
+ 9dp
+ 23dp
+ 54dp
+ 27dp
+ 3dp
+ 84dp
+ 5dp
+ 18dp
+ 24dp
+ 11dp
+ 9dp
+ 5dp
+ 6dp
+ 48dp
+ 27dp
+ 24dp
+ 18dp
90dp
18dp
@@ -73,6 +96,7 @@
18sp
16sp
14sp
+ 12sp
27sp
24sp
@@ -137,5 +161,18 @@
8dp
42dp
-
+
+
+ 24dp
+ 33dp
+ 5dp
+ 21dp
+ 72dp
+ 18dp
+ 24dp
+ 66dp
+ 72dp
+
+ 78dp
+
\ No newline at end of file
diff --git a/OsmAnd/res/values/attrs.xml b/OsmAnd/res/values/attrs.xml
index 9690d6d7a6..229b01fd7f 100644
--- a/OsmAnd/res/values/attrs.xml
+++ b/OsmAnd/res/values/attrs.xml
@@ -24,6 +24,9 @@
+
+
+
diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml
index b88874473b..dd9eae0d60 100644
--- a/OsmAnd/res/values/colors.xml
+++ b/OsmAnd/res/values/colors.xml
@@ -311,4 +311,64 @@
#fac403
#ee5622
+ #ffffff
+ #17191a
+ #212121
+ #cccccc
+ #727272
+ #536dfe
+ #e69122
+ #536dfe
+ #e69122
+ #ffffff
+ #cccccc
+ #e6e6e6
+ #4c63e6
+ #2d3133
+ #b36a0b
+ #fafafa
+ #6d82fc
+ #222526
+ #d28521
+ #f2f2f2
+ #222526
+ #e6e6e6
+ #2d3133
+ #727272
+ #727272
+ #536dfe
+ #e69122
+ #ffffff
+ #17191a
+ #b3b3b3
+ #536dfe
+ #212121
+ #cccccc
+ #a6a6a6
+ #595959
+ #5baf3f
+ #c66545
+ #f2f2f2
+ #536dfe
+ #536dfe
+ #d28521
+
+ #ffffff
+ #17191a
+ #f2f2f2
+ #222526
+ #e6e6e6
+ #2d3133
+ #505050
+ #727272
+ #4c63e6
+ #d28521
+ #6d82fc
+ #4c63e6
+ #b36a0b
+ #d28521
+ #ff8800
+ #d28521
+ #727272
+
\ No newline at end of file
diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml
index 43d393bf79..df731e7313 100644
--- a/OsmAnd/res/values/phrases.xml
+++ b/OsmAnd/res/values/phrases.xml
@@ -2099,6 +2099,7 @@
Monorail
Funicular
Ferry
+ Subway
Route of a railroad
diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml
index 76a1309b52..8f73163ed6 100644
--- a/OsmAnd/res/values/sizes.xml
+++ b/OsmAnd/res/values/sizes.xml
@@ -129,6 +129,29 @@
54dp
44dp
54dp
+ 24dp
+ 48dp
+ 20dp
+ 16dp
+ 10dp
+ 8dp
+ 6dp
+ 15dp
+ 36dp
+ 18dp
+ 2dp
+ 56dp
+ 3dp
+ 12dp
+ 16dp
+ 7dp
+ 6dp
+ 3dp
+ 4dp
+ 32dp
+ 18dp
+ 16dp
+ 12dp
62dp
12dp
@@ -138,6 +161,7 @@
16sp
14sp
12sp
+ 10sp
23sp
13sp
@@ -210,4 +234,17 @@
28dp
88dp
+
+
+ 16dp
+ 22dp
+ 3dp
+ 14dp
+ 56dp
+ 12dp
+ 16dp
+ 52dp
+ 48dp
+
+ 52dp
\ No newline at end of file
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 61bfe7f88c..bb1b048ded 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,14 +9,29 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
+ What\'s here:
+ parked at
+ Pick up till
+ Without time limit
+ Read full article
+ Read article
+ All points of group
+ Opened from
+ Opened till
+ Will be closed at
+ Will be opened at
+ Will be opened on
+ Additional actions
GPX file with coordinates and data of the selected notes.
GPX file with coordinates and data of all notes.
-
+
\u2022 Detection of stop signs now considers driving direction\n\n
\u2022 New algorithm providing meaningful ascent/descent values for GPX tracks\n\n
\u2022 Terrain (ascent) aware hiking time (Naismith\'s rule)\n\n
Modify the search query.
+ Actions
+ Marker
Create or modify OSM objects
Create or modify OSM POI, open or comment OSM Notes, and contribute recorded GPX files.
Deleted
diff --git a/OsmAnd/res/values/styles.xml b/OsmAnd/res/values/styles.xml
index bf31b96ede..a5dd7bc149 100644
--- a/OsmAnd/res/values/styles.xml
+++ b/OsmAnd/res/values/styles.xml
@@ -131,6 +131,9 @@
- @color/divider_color
- @drawable/dashboard_button_light
- @color/ctx_menu_info_view_bg_light
+ - @drawable/context_menu_controller_bg_light
+ - @drawable/context_menu_controller_text_color_light
+ - @color/ctx_menu_buttons_divider_light
- @color/search_background_dark
- @drawable/ic_action_mode_back
- @style/WhiteActionMode
@@ -316,6 +319,9 @@
- @color/dashboard_divider_dark
- @drawable/dashboard_button_dark
- @color/ctx_menu_info_view_bg_dark
+ - @drawable/context_menu_controller_bg_dark
+ - @drawable/context_menu_controller_text_color_dark
+ - @color/ctx_menu_buttons_divider_dark
- @color/color_white
- @drawable/switch_ex_background_dark
- @color/switch_ex_button_text_dark
diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java
index c0535bcf66..04b6e89195 100644
--- a/OsmAnd/src/net/osmand/AndroidUtils.java
+++ b/OsmAnd/src/net/osmand/AndroidUtils.java
@@ -188,7 +188,11 @@ public class AndroidUtils {
public static void addStatusBarPadding21v(Context ctx, View view) {
if (Build.VERSION.SDK_INT >= 21) {
- view.setPadding(0, getStatusBarHeight(ctx), 0, 0);
+ int paddingLeft = view.getPaddingLeft();
+ int paddingTop = view.getPaddingTop();
+ int paddingRight = view.getPaddingRight();
+ int paddingBottom = view.getPaddingBottom();
+ view.setPadding(paddingLeft, paddingTop + getStatusBarHeight(ctx), paddingRight, paddingBottom);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java
index 1adac0a2e7..4a85abb3ba 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java
@@ -459,7 +459,7 @@ public abstract class OsmandPlugin {
if (adapter.length() > itemsCount) {
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setPosition(itemsCount)
- .setLayout(R.layout.context_menu_list_divider)
+ .setLayout(R.layout.bottom_sheet_dialog_fragment_divider)
.createItem());
}
}
diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java
index 93f0275ae2..292f8e0fe3 100644
--- a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java
+++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java
@@ -8,7 +8,6 @@ import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
-import android.os.Build;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.FileProvider;
@@ -191,6 +190,13 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
getGroupExpandedPreference(groupName).set(true);
}
});
+ String groupNameToShow = ((FavoritesActivity) getActivity()).getGroupNameToShow();
+ if (groupNameToShow != null) {
+ int position = favouritesAdapter.getGroupPosition(groupNameToShow);
+ if (position != -1) {
+ listView.setSelectedGroup(position);
+ }
+ }
return view;
}
@@ -967,6 +973,16 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
public void setFilterResults(Set> values) {
this.filter = values;
}
+
+ public int getGroupPosition(String groupName) {
+ for (int i = 0; i < getGroupCount(); i++) {
+ FavoriteGroup group = getGroup(i);
+ if (group.name.equals(groupName)) {
+ return i;
+ }
+ }
+ return -1;
+ }
}
public class FavoritesFilter extends Filter {
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
index cf7e510eb2..8e805f6056 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
@@ -93,6 +93,7 @@ import net.osmand.plus.helpers.GpxImportHelper;
import net.osmand.plus.helpers.GpxImportHelper.ImportGpxBottomSheetDialogFragment;
import net.osmand.plus.helpers.WakeLockHelper;
import net.osmand.plus.inapp.InAppHelper;
+import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.MapContextMenuFragment;
import net.osmand.plus.mapcontextmenu.builders.cards.dialogs.ContextMenuCardDialogFragment;
@@ -345,6 +346,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
mapLayers.getMapControlsLayer().getTrackDetailsMenu().hide();
}
removeFragment(ImportGpxBottomSheetDialogFragment.TAG);
+ removeFragment(AdditionalActionsBottomSheetDialogFragment.TAG);
super.onSaveInstanceState(outState);
}
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java
index ab56118d2c..631068103e 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java
@@ -50,6 +50,7 @@ import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.dialogs.FavoriteDialogs;
import net.osmand.plus.download.IndexItem;
import net.osmand.plus.liveupdates.OsmLiveActivity;
+import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment;
import net.osmand.plus.mapmarkers.MapMarkersDialogFragment;
import net.osmand.plus.mapmarkers.MarkersPlanRouteContext;
import net.osmand.plus.measurementtool.MeasurementToolFragment;
@@ -312,19 +313,18 @@ public class MapActivityActions implements DialogProvider {
}
}
- final AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
final ArrayAdapter listAdapter =
adapter.createListAdapter(mapActivity, getMyApplication().getSettings().isLightContent());
- builder.setTitle(R.string.shared_string_more_actions);
- builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
+ AdditionalActionsBottomSheetDialogFragment actionsBottomSheetDialogFragment = new AdditionalActionsBottomSheetDialogFragment();
+ actionsBottomSheetDialogFragment.setAdapter(adapter, new AdditionalActionsBottomSheetDialogFragment.ContextMenuItemClickListener() {
@Override
- public void onClick(DialogInterface dialog, int which) {
- ContextMenuItem item = adapter.getItem(which);
+ public void onItemClick(int position) {
+ ContextMenuItem item = adapter.getItem(position);
int standardId = item.getTitleId();
ItemClickListener click = item.getItemClickListener();
if (click != null) {
- click.onContextMenuClick(listAdapter, standardId, which, false, null);
+ click.onContextMenuClick(listAdapter, standardId, position, false, null);
} else if (standardId == R.string.context_menu_item_last_intermediate_point) {
mapActivity.getContextMenu().addAsLastIntermediate();
} else if (standardId == R.string.context_menu_item_search) {
@@ -345,8 +345,7 @@ public class MapActivityActions implements DialogProvider {
}
}
});
- builder.setNegativeButton(R.string.shared_string_cancel, null);
- builder.create().show();
+ actionsBottomSheetDialogFragment.show(mapActivity.getSupportFragmentManager(), AdditionalActionsBottomSheetDialogFragment.TAG);
}
public void setGPXRouteParams(GPXFile result) {
diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java b/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java
index 9beed11c0c..985bd9eac2 100644
--- a/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java
+++ b/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java
@@ -1,6 +1,7 @@
package net.osmand.plus.activities.actions;
import android.app.Activity;
+import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -46,17 +47,12 @@ public class AppModeDialog {
public static View prepareAppModeView(Activity a, final List values , final Set selected,
ViewGroup parent, final boolean singleSelection, boolean drawer, boolean useMapTheme, final View.OnClickListener onClickListener) {
View ll = a.getLayoutInflater().inflate(R.layout.mode_toggles, parent);
- if (useMapTheme) {
- AndroidUtils.setListItemBackground(a, ll,
- ((OsmandApplication) a.getApplication()).getDaynightHelper().isNightModeForMapControls());
- } else {
- AndroidUtils.setListItemBackground(a, ll,
- !((OsmandApplication) a.getApplication()).getSettings().isLightContent());
- }
+ boolean nightMode = isNightMode(((OsmandApplication) a.getApplication()), useMapTheme);
+ ll.setBackgroundColor(ContextCompat.getColor(a, nightMode ? R.color.route_info_bg_dark : R.color.route_info_bg_light));
final View[] buttons = new View[values.size()];
int k = 0;
for(ApplicationMode ma : values) {
- buttons[k++] = createToggle(a.getLayoutInflater(), (OsmandApplication) a.getApplication(), (LinearLayout) ll.findViewById(R.id.app_modes_content), ma);
+ buttons[k++] = createToggle(a.getLayoutInflater(), (OsmandApplication) a.getApplication(), (LinearLayout) ll.findViewById(R.id.app_modes_content), ma, useMapTheme);
}
for (int i = 0; i < buttons.length; i++) {
updateButtonState((OsmandApplication) a.getApplication(), values, selected, onClickListener, buttons, i,
@@ -74,14 +70,14 @@ public class AppModeDialog {
final ApplicationMode mode = visible.get(i);
final boolean checked = selected.contains(mode);
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
+ boolean nightMode = isNightMode(ctx, useMapTheme);
if (checked) {
- iv.setImageDrawable(ctx.getIconsCache().getIcon(mode.getSmallIconDark(), R.color.osmand_orange));
+ iv.setImageDrawable(ctx.getIconsCache().getIcon(mode.getSmallIconDark(), nightMode ? R.color.route_info_checked_mode_icon_color_dark : R.color.route_info_checked_mode_icon_color_light));
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_checked)));
tb.findViewById(R.id.selection).setVisibility(View.VISIBLE);
} else {
if (useMapTheme) {
- boolean nightMode = ctx.getDaynightHelper().isNightModeForMapControls();
- iv.setImageDrawable(ctx.getIconsCache().getIcon(mode.getSmallIconDark(), !nightMode));
+ iv.setImageDrawable(ctx.getIconsCache().getIcon(mode.getSmallIconDark(), R.color.route_info_unchecked_mode_icon_color));
AndroidUtils.setBackground(ctx, iv, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
} else {
iv.setImageDrawable(ctx.getIconsCache().getThemedIcon(mode.getSmallIconDark()));
@@ -118,12 +114,12 @@ public class AppModeDialog {
}
- static private View createToggle(LayoutInflater layoutInflater, OsmandApplication ctx, LinearLayout layout, ApplicationMode mode){
- int metricsX = (int) ctx.getResources().getDimension(R.dimen.map_mode_button_width);
- int metricsY = (int) ctx.getResources().getDimension(R.dimen.map_mode_button_width);
+ static private View createToggle(LayoutInflater layoutInflater, OsmandApplication ctx, LinearLayout layout, ApplicationMode mode, boolean useMapTheme){
+ int metricsX = (int) ctx.getResources().getDimension(R.dimen.route_info_modes_height);
+ int metricsY = (int) ctx.getResources().getDimension(R.dimen.route_info_modes_height);
View tb = layoutInflater.inflate(R.layout.mode_view, null);
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
- iv.setImageDrawable(ctx.getIconsCache().getIcon(mode.getSmallIconDark(), R.color.osmand_orange));
+ iv.setImageDrawable(ctx.getIconsCache().getIcon(mode.getSmallIconDark(), isNightMode(ctx, useMapTheme) ? R.color.route_info_checked_mode_icon_color_dark : R.color.route_info_checked_mode_icon_color_light));
iv.setContentDescription(mode.toHumanString(ctx));
// tb.setCompoundDrawablesWithIntrinsicBounds(null, ctx.getIconsCache().getIcon(mode.getIconId(), R.color.app_mode_icon_color), null, null);
LayoutParams lp = new LinearLayout.LayoutParams(metricsX, metricsY);
@@ -131,4 +127,14 @@ public class AppModeDialog {
layout.addView(tb, lp);
return tb;
}
+
+ private static boolean isNightMode(OsmandApplication ctx, boolean useMapTheme) {
+ boolean nightMode;
+ if (useMapTheme) {
+ nightMode = ctx.getDaynightHelper().isNightModeForMapControls();
+ } else {
+ nightMode = !ctx.getSettings().isLightContent();
+ }
+ return nightMode;
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNoteMenuBuilder.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNoteMenuBuilder.java
index 5362db7acc..1b213df41e 100644
--- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNoteMenuBuilder.java
+++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNoteMenuBuilder.java
@@ -43,7 +43,7 @@ public class AudioVideoNoteMenuBuilder extends MenuBuilder {
DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(view.getContext());
Date date = new Date(recording.getFile().lastModified());
buildRow(view, R.drawable.ic_action_data, dateFormat.format(date) + " — " + timeFormat.format(date),
- 0, false, null, false, 0, false, null);
+ 0, false, null, false, 0, false, null, false);
buildPlainMenuItems(view);
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashLocationFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashLocationFragment.java
index 474a6638bc..0feefaa5a9 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/DashLocationFragment.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashLocationFragment.java
@@ -111,6 +111,12 @@ public abstract class DashLocationFragment extends DashBaseFragment {
}
}
+ public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
+ ImageView arrow, int imgColor, TextView txt, int textColor, double toLat, double toLon,
+ int screenOrientation, OsmandApplication app, Context ctx) {
+ updateLocationView(useCenter, fromLoc, h, arrow, 0, imgColor, txt, textColor, new LatLon(toLat, toLon), screenOrientation, app, ctx, true);
+ }
+
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, TextView txt, double toLat, double toLon,
int screenOrientation, OsmandApplication app, Context ctx) {
@@ -120,11 +126,17 @@ public abstract class DashLocationFragment extends DashBaseFragment {
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, int arrowResId, TextView txt, LatLon toLoc,
int screenOrientation, OsmandApplication app, Context ctx, boolean paint) {
- updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, 0, txt, toLoc, screenOrientation, app, ctx, paint);
+ updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, 0, txt, 0, toLoc, screenOrientation, app, ctx, paint);
}
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
- ImageView arrow, int arrowResId, int color, TextView txt, LatLon toLoc,
+ ImageView arrow, int arrowResId, int imgColor, TextView txt, LatLon toLoc,
+ int screenOrientation, OsmandApplication app, Context ctx, boolean paint) {
+ updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, imgColor, txt, 0, toLoc, screenOrientation, app, ctx, paint);
+ }
+
+ public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
+ ImageView arrow, int arrowResId, int imgColor, TextView txt, int textColor, LatLon toLoc,
int screenOrientation, OsmandApplication app, Context ctx, boolean paint) {
float[] mes = new float[2];
if (fromLoc != null && toLoc != null) {
@@ -142,7 +154,7 @@ public abstract class DashLocationFragment extends DashBaseFragment {
} else {
dd = (DirectionDrawable) arrow.getDrawable();
}
- dd.setImage(arrowResId, color == 0 ? useCenter ? R.color.color_distance : R.color.color_myloc_distance : color);
+ dd.setImage(arrowResId, imgColor == 0 ? useCenter ? R.color.color_distance : R.color.color_myloc_distance : imgColor);
if (fromLoc == null || h == null || toLoc == null) {
dd.setAngle(0);
} else {
@@ -157,7 +169,7 @@ public abstract class DashLocationFragment extends DashBaseFragment {
if (fromLoc != null && toLoc != null) {
if (paint) {
txt.setTextColor(app.getResources().getColor(
- useCenter ? R.color.color_distance : R.color.color_myloc_distance));
+ textColor == 0 ? useCenter ? R.color.color_distance : R.color.color_myloc_distance : textColor));
}
txt.setText(OsmAndFormatter.getFormattedDistance(mes[0], app));
} else {
diff --git a/OsmAnd/src/net/osmand/plus/helpers/FontCache.java b/OsmAnd/src/net/osmand/plus/helpers/FontCache.java
index 1e076553e0..4edf39c96f 100644
--- a/OsmAnd/src/net/osmand/plus/helpers/FontCache.java
+++ b/OsmAnd/src/net/osmand/plus/helpers/FontCache.java
@@ -16,6 +16,10 @@ public class FontCache {
public static Typeface getRobotoMedium(Context context) {
return getFont(context, ROBOTO_MEDIUM);
}
+
+ public static Typeface getRobotoRegular(Context context) {
+ return getFont(context, ROBOTO_REGULAR);
+ }
public static Typeface getFont(Context context, String fontName) {
Typeface typeface = fontMap.get(fontName);
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/AdditionalActionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/AdditionalActionsBottomSheetDialogFragment.java
new file mode 100644
index 0000000000..4b9d379ef9
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/AdditionalActionsBottomSheetDialogFragment.java
@@ -0,0 +1,143 @@
+package net.osmand.plus.mapcontextmenu;
+
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.graphics.drawable.Drawable;
+import android.support.annotation.DrawableRes;
+import android.support.design.widget.BottomSheetBehavior;
+import android.support.design.widget.BottomSheetDialog;
+import android.support.design.widget.BottomSheetDialogFragment;
+import android.support.v4.content.ContextCompat;
+import android.view.ContextThemeWrapper;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import net.osmand.AndroidUtils;
+import net.osmand.plus.ContextMenuAdapter;
+import net.osmand.plus.ContextMenuItem;
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.OsmandSettings;
+import net.osmand.plus.R;
+import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.helpers.AndroidUiHelper;
+
+public class AdditionalActionsBottomSheetDialogFragment extends BottomSheetDialogFragment {
+
+ public static final String TAG = "AdditionalActionsBottomSheetDialogFragment";
+
+ private boolean nightMode;
+ private boolean portrait;
+ private ContextMenuAdapter adapter;
+ private ContextMenuItemClickListener listener;
+
+ public void setAdapter(ContextMenuAdapter adapter, ContextMenuItemClickListener listener) {
+ this.adapter = adapter;
+ this.listener = listener;
+ }
+
+ @Override
+ public void setupDialog(Dialog dialog, int style) {
+ super.setupDialog(dialog, style);
+
+ if (getMyApplication().getSettings().DO_NOT_USE_ANIMATIONS.get()) {
+ dialog.getWindow().setWindowAnimations(R.style.Animations_NoAnimation);
+ }
+
+ nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
+ portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
+ final OsmandSettings settings = getMyApplication().getSettings();
+ final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
+
+ View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_context_menu_actions_bottom_sheet_dialog, null);
+
+ AndroidUtils.setBackground(getActivity(), mainView, nightMode,
+ portrait ? R.drawable.bg_bottom_menu_light : R.drawable.bg_bottom_sheet_topsides_landscape_light,
+ portrait ? R.drawable.bg_bottom_menu_dark : R.drawable.bg_bottom_sheet_topsides_landscape_dark);
+
+ mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ dismiss();
+ }
+ });
+
+ TextView headerTitle = (TextView) mainView.findViewById(R.id.header_title);
+ if (nightMode) {
+ headerTitle.setTextColor(ContextCompat.getColor(getActivity(), R.color.ctx_menu_info_text_dark));
+ }
+ headerTitle.setText(getString(R.string.additional_actions));
+
+ if (!portrait) {
+ dialog.setOnShowListener(new DialogInterface.OnShowListener() {
+ @Override
+ public void onShow(DialogInterface dialogInterface) {
+ BottomSheetDialog dialog = (BottomSheetDialog) dialogInterface;
+ FrameLayout bottomSheet = (FrameLayout) dialog.findViewById(android.support.design.R.id.design_bottom_sheet);
+ BottomSheetBehavior.from(bottomSheet).setState(BottomSheetBehavior.STATE_EXPANDED);
+ }
+ });
+ }
+
+ View.OnClickListener onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (listener != null) {
+ listener.onItemClick((int) view.getTag());
+ }
+ dismiss();
+ }
+ };
+
+ LinearLayout itemsLinearLayout = (LinearLayout) mainView.findViewById(R.id.context_menu_items_container);
+ for (int i = 0; i < adapter.length(); i++) {
+ ContextMenuItem item = adapter.getItem(i);
+ int layoutResId = item.getLayout();
+ layoutResId = layoutResId != ContextMenuItem.INVALID_ID ? layoutResId : R.layout.bottom_sheet_dialog_fragment_item;
+ View row = View.inflate(new ContextThemeWrapper(getContext(), themeRes), layoutResId, null);
+ if (layoutResId != R.layout.bottom_sheet_dialog_fragment_divider) {
+ if (item.getIcon() != ContextMenuItem.INVALID_ID) {
+ ((ImageView) row.findViewById(R.id.icon)).setImageDrawable(getContentIcon(item.getIcon()));
+ }
+ ((TextView) row.findViewById(R.id.title)).setText(item.getTitle());
+ }
+ row.setTag(i);
+ row.setOnClickListener(onClickListener);
+ itemsLinearLayout.addView(row);
+ }
+
+ dialog.setContentView(mainView);
+ ((View) mainView.getParent()).setBackgroundResource(0);
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ if (!portrait) {
+ final Window window = getDialog().getWindow();
+ WindowManager.LayoutParams params = window.getAttributes();
+ params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
+ window.setAttributes(params);
+ }
+ }
+
+ private OsmandApplication getMyApplication() {
+ return ((MapActivity) getActivity()).getMyApplication();
+ }
+
+ private Drawable getContentIcon(@DrawableRes int id) {
+ return getMyApplication().getIconsCache().getIcon(id, nightMode ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
+ }
+
+ public interface ContextMenuItemClickListener {
+ void onItemClick(int position);
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java
index 0d7236c23a..f6f7788041 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java
@@ -37,6 +37,7 @@ import net.osmand.plus.mapcontextmenu.MenuController.MenuType;
import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController;
import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController;
import net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController;
+import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute;
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor;
import net.osmand.plus.mapcontextmenu.editors.PointEditor;
import net.osmand.plus.mapcontextmenu.editors.RtePtEditor;
@@ -46,6 +47,7 @@ import net.osmand.plus.mapcontextmenu.other.ShareMenu;
import net.osmand.plus.mapmarkers.MapMarkersDialogFragment;
import net.osmand.plus.mapmarkers.RenameMarkerBottomSheetDialogFragment;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
+import net.osmand.plus.parkingpoint.ParkingPositionMenuController;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.ContextMenuLayer;
import net.osmand.plus.views.OsmandMapLayer;
@@ -415,6 +417,10 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
init(latLon, pointDescription, object);
}
+ public boolean navigateInPedestrianMode() {
+ return menuController instanceof ParkingPositionMenuController;
+ }
+
public boolean close() {
boolean result = false;
if (active) {
@@ -710,7 +716,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
public int getFavActionStringId() {
if (menuController != null)
return menuController.getFavActionStringId();
- return R.string.shared_string_add_to_favorites;
+ return R.string.shared_string_add;
}
public int getWaypointActionIconId() {
@@ -753,8 +759,18 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
}
}
- public void fabPressed() {
- mapActivity.getMapLayers().getMapControlsLayer().navigateFab();
+ public List getTransportStopRoutes() {
+ if (menuController != null) {
+ return menuController.getTransportStopRoutes();
+ }
+ return null;
+ }
+
+ public void navigateButtonPressed() {
+ if (navigateInPedestrianMode()) {
+ settings.APPLICATION_MODE.set(ApplicationMode.PEDESTRIAN);
+ }
+ mapActivity.getMapLayers().getMapControlsLayer().navigateButton();
}
public boolean zoomInPressed() {
@@ -1063,17 +1079,9 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
}
}
- public TitleButtonController getTopRightTitleButtonController() {
+ public TitleButtonController getBottomTitleButtonController() {
if (menuController != null) {
- return menuController.getTopRightTitleButtonController();
- } else {
- return null;
- }
- }
-
- public TitleButtonController getLeftSubtitleButtonController() {
- if (menuController != null) {
- return menuController.getLeftSubtitleButtonController();
+ return menuController.getBottomTitleButtonController();
} else {
return null;
}
@@ -1107,8 +1115,8 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
return menuController == null || menuController.supportZoomIn();
}
- public boolean fabVisible() {
- return menuController == null || menuController.fabVisible();
+ public boolean navigateButtonVisible() {
+ return menuController == null || menuController.navigateButtonVisible();
}
public boolean zoomButtonsVisible() {
@@ -1127,6 +1135,17 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
return menuController != null && menuController.displayDistanceDirection();
}
+ public boolean displayAdditionalTypeStrInHours() {
+ return menuController != null && menuController.displayAdditionalTypeStrInHours();
+ }
+
+ public int getTimeStrColor() {
+ if (menuController != null) {
+ return menuController.getTimeStrColor();
+ }
+ return 0;
+ }
+
public boolean isMapDownloaded() {
return menuController != null && menuController.isMapDownloaded();
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
index 2ecedf2e9a..ab48cf98a1 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
@@ -9,6 +9,8 @@ import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
+import android.support.v4.content.ContextCompat;
+import android.text.TextUtils;
import android.util.TypedValue;
import android.view.GestureDetector;
import android.view.LayoutInflater;
@@ -20,8 +22,8 @@ import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.ViewTreeObserver;
import android.view.animation.DecelerateInterpolator;
-import android.widget.Button;
import android.widget.FrameLayout;
+import android.widget.GridView;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -30,12 +32,9 @@ import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.Location;
-import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox;
-import net.osmand.plus.GPXUtilities.WptPt;
-import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
@@ -46,6 +45,7 @@ import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.mapcontextmenu.MenuController.MenuState;
import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController;
import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController;
+import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.OsmandMapTileView;
@@ -53,6 +53,8 @@ import net.osmand.plus.views.controls.HorizontalSwipeConfirm;
import net.osmand.plus.views.controls.SingleTapConfirm;
import net.osmand.util.Algorithms;
+import java.util.List;
+
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
import static net.osmand.plus.mapcontextmenu.MenuBuilder.SHADOW_HEIGHT_TOP_DP;
@@ -68,7 +70,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private View view;
private View mainView;
- private ImageView fabView;
private View zoomButtonsView;
private ImageButton zoomInButtonView;
private ImageButton zoomOutButtonView;
@@ -77,7 +78,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private OnLayoutChangeListener containerLayoutListener;
private int menuTopViewHeight;
- private int menuTopShadowHeight;
private int menuTopShadowAllHeight;
private int menuTitleHeight;
private int menuBottomViewHeight;
@@ -90,7 +90,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private int viewHeight;
private int zoomButtonsHeight;
- private int fabPaddingTopPx;
private int markerPaddingPx;
private int markerPaddingXPx;
@@ -112,14 +111,12 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private int screenOrientation;
private boolean created;
- @TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
processScreenHeight(container);
- fabPaddingTopPx = dpToPx(FAB_PADDING_TOP_DP);
markerPaddingPx = dpToPx(MARKER_PADDING_DP);
markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP);
@@ -152,8 +149,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
}
// Left title button
- final Button leftTitleButton = (Button) view.findViewById(R.id.title_button);
- leftTitleButton.setOnClickListener(new View.OnClickListener() {
+ final View leftTitleButtonView = view.findViewById(R.id.title_button_view);
+ leftTitleButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TitleButtonController leftTitleButtonController = menu.getLeftTitleButtonController();
@@ -164,8 +161,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
});
// Right title button
- final Button rightTitleButton = (Button) view.findViewById(R.id.title_button_right);
- rightTitleButton.setOnClickListener(new View.OnClickListener() {
+ final View rightTitleButtonView = view.findViewById(R.id.title_button_right_view);
+ rightTitleButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TitleButtonController rightTitleButtonController = menu.getRightTitleButtonController();
@@ -175,21 +172,9 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
}
});
- // Left subtitle button
- final Button leftSubtitleButton = (Button) view.findViewById(R.id.subtitle_button);
- leftSubtitleButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- TitleButtonController leftSubtitleButtonController = menu.getLeftSubtitleButtonController();
- if (leftSubtitleButtonController != null) {
- leftSubtitleButtonController.buttonPressed();
- }
- }
- });
-
// Left download button
- final Button leftDownloadButton = (Button) view.findViewById(R.id.download_button_left);
- leftDownloadButton.setOnClickListener(new View.OnClickListener() {
+ final View leftDownloadButtonView = view.findViewById(R.id.download_button_left_view);
+ leftDownloadButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TitleButtonController leftDownloadButtonController = menu.getLeftDownloadButtonController();
@@ -200,8 +185,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
});
// Right download button
- final Button rightDownloadButton = (Button) view.findViewById(R.id.download_button_right);
- rightDownloadButton.setOnClickListener(new View.OnClickListener() {
+ final View rightDownloadButtonView = (View) view.findViewById(R.id.download_button_right_view);
+ rightDownloadButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TitleButtonController rightDownloadButtonController = menu.getRightDownloadButtonController();
@@ -211,14 +196,14 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
}
});
- // Top Right title button
- final Button topRightTitleButton = (Button) view.findViewById(R.id.title_button_top_right);
- topRightTitleButton.setOnClickListener(new View.OnClickListener() {
+ // Bottom title button
+ final View bottomTitleButton = view.findViewById(R.id.title_button_bottom_view);
+ bottomTitleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- TitleButtonController topRightTitleButtonController = menu.getTopRightTitleButtonController();
- if (topRightTitleButtonController != null) {
- topRightTitleButtonController.buttonPressed();
+ TitleButtonController bottomTitleButtonController = menu.getBottomTitleButtonController();
+ if (bottomTitleButtonController != null) {
+ bottomTitleButtonController.buttonPressed();
}
}
});
@@ -306,12 +291,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
setViewY((int) newY, false, false);
menuFullHeight = view.getHeight() - (int) newY + 10;
- if (!oldAndroid()) {
- ViewGroup.LayoutParams lp = mainView.getLayoutParams();
- lp.height = Math.max(menuFullHeight, menuTitleHeight);
- mainView.setLayoutParams(lp);
- mainView.requestLayout();
- }
+ ViewGroup.LayoutParams lp = mainView.getLayoutParams();
+ lp.height = Math.max(menuFullHeight, menuTitleHeight);
+ mainView.setLayoutParams(lp);
+ mainView.requestLayout();
velocity.addMovement(event);
velocity.computeCurrentVelocity(1000);
@@ -345,8 +328,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
View topView = view.findViewById(R.id.context_menu_top_view);
topView.setOnTouchListener(slideTouchListener);
- View topShadowView = view.findViewById(R.id.context_menu_top_shadow);
- topShadowView.setOnTouchListener(slideTouchListener);
View topShadowAllView = view.findViewById(R.id.context_menu_top_shadow_all);
AndroidUtils.setBackground(getMapActivity(), topShadowAllView, nightMode, R.drawable.bg_map_context_menu_light,
R.drawable.bg_map_context_menu_dark);
@@ -362,46 +343,21 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
buildHeader();
- AndroidUtils.setTextPrimaryColor(getMapActivity(),
- (TextView) view.findViewById(R.id.context_menu_line1), nightMode);
+ ((TextView) view.findViewById(R.id.context_menu_line1)).setTextColor(ContextCompat.getColor(getContext(),
+ nightMode ? R.color.ctx_menu_title_color_dark : R.color.ctx_menu_title_color_light));
View menuLine2 = view.findViewById(R.id.context_menu_line2);
if (menuLine2 != null) {
- AndroidUtils.setTextSecondaryColor(getMapActivity(), (TextView) menuLine2, nightMode);
+ ((TextView) menuLine2).setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_subtitle_color));
}
- ((Button) view.findViewById(R.id.title_button_top_right))
- .setTextColor(!nightMode ? getResources().getColor(R.color.map_widget_blue) : getResources().getColor(R.color.osmand_orange));
- AndroidUtils.setTextSecondaryColor(getMapActivity(),
- (TextView) view.findViewById(R.id.distance), nightMode);
+ ((TextView) view.findViewById(R.id.distance)).setTextColor(ContextCompat.getColor(getContext(),
+ nightMode ? R.color.ctx_menu_direction_color_dark : R.color.ctx_menu_direction_color_light));
- ((Button) view.findViewById(R.id.title_button))
- .setTextColor(!nightMode ? getResources().getColor(R.color.map_widget_blue) : getResources().getColor(R.color.osmand_orange));
AndroidUtils.setTextSecondaryColor(getMapActivity(),
(TextView) view.findViewById(R.id.title_button_right_text), nightMode);
- ((Button) view.findViewById(R.id.title_button_right))
- .setTextColor(!nightMode ? getResources().getColor(R.color.map_widget_blue) : getResources().getColor(R.color.osmand_orange));
AndroidUtils.setTextSecondaryColor(getMapActivity(),
(TextView) view.findViewById(R.id.progressTitle), nightMode);
- // FAB
- fabView = (ImageView) view.findViewById(R.id.context_menu_fab_view);
- if (menu.fabVisible()) {
- fabView.setImageDrawable(getIcon(menu.getFabIconId(), 0));
- if (menu.isLandscapeLayout()) {
- FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) fabView.getLayoutParams();
- params.setMargins(0, 0, dpToPx(28f), 0);
- fabView.setLayoutParams(params);
- }
- fabView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- menu.fabPressed();
- }
- });
- } else {
- fabView.setVisibility(View.GONE);
- }
-
// Zoom buttons
zoomButtonsView = view.findViewById(R.id.context_menu_zoom_buttons);
zoomInButtonView = (ImageButton) view.findViewById(R.id.context_menu_zoom_in_button);
@@ -428,94 +384,129 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
zoomButtonsView.setVisibility(View.GONE);
}
+ GridView transportStopRoutesGrid = (GridView) view.findViewById(R.id.transport_stop_routes_grid);
+ List transportStopRoutes = menu.getTransportStopRoutes();
+ if (transportStopRoutes != null && transportStopRoutes.size() > 0) {
+ TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getContext(), transportStopRoutes);
+ transportStopRoutesGrid.setAdapter(adapter);
+ transportStopRoutesGrid.setVisibility(View.VISIBLE);
+ } else {
+ transportStopRoutesGrid.setVisibility(View.GONE);
+ }
+
+ View buttonsBottomBorder = view.findViewById(R.id.buttons_bottom_border);
View buttonsTopBorder = view.findViewById(R.id.buttons_top_border);
- AndroidUtils.setBackground(getMapActivity(), buttonsTopBorder, nightMode,
- R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
+ buttonsBottomBorder.setBackgroundColor(ContextCompat.getColor(getContext(), nightMode ? R.color.ctx_menu_buttons_divider_dark : R.color.ctx_menu_buttons_divider_light));
+ buttonsTopBorder.setBackgroundColor(ContextCompat.getColor(getContext(), nightMode ? R.color.ctx_menu_buttons_divider_dark : R.color.ctx_menu_buttons_divider_light));
+ View buttons = view.findViewById(R.id.context_menu_buttons);
+ buttons.setBackgroundColor(ContextCompat.getColor(getContext(), nightMode ? R.color.ctx_menu_buttons_bg_dark : R.color.ctx_menu_buttons_bg_light));
if (!menu.buttonsVisible()) {
- View buttons = view.findViewById(R.id.context_menu_buttons);
buttonsTopBorder.setVisibility(View.GONE);
buttons.setVisibility(View.GONE);
}
-
- AndroidUtils.setBackground(getMapActivity(), mainView.findViewById(R.id.divider_hor_1), nightMode,
- R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
- AndroidUtils.setBackground(getMapActivity(), mainView.findViewById(R.id.divider_hor_2), nightMode,
- R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
- AndroidUtils.setBackground(getMapActivity(), mainView.findViewById(R.id.divider_hor_3), nightMode,
- R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
+ View bottomButtons = view.findViewById(R.id.context_menu_bottom_buttons);
+ bottomButtons.setBackgroundColor(ContextCompat.getColor(getContext(), nightMode ? R.color.ctx_menu_buttons_bg_dark : R.color.ctx_menu_buttons_bg_light));
+ if (!menu.navigateButtonVisible()) {
+ bottomButtons.findViewById(R.id.context_menu_directions_button).setVisibility(View.GONE);
+ }
// Action buttons
- final ImageButton buttonFavorite = (ImageButton) view.findViewById(R.id.context_menu_fav_button);
- buttonFavorite.setImageDrawable(getIcon(menu.getFavActionIconId(),
- !nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
- AndroidUtils.setDashButtonBackground(getMapActivity(), buttonFavorite, nightMode);
- buttonFavorite.setContentDescription(getString(menu.getFavActionStringId()));
- buttonFavorite.setOnClickListener(new View.OnClickListener() {
+ final ImageView imageFavorite = (ImageView) view.findViewById(R.id.context_menu_fav_image_view);
+ imageFavorite.setImageDrawable(getIcon(menu.getFavActionIconId(),
+ R.color.ctx_menu_buttons_icon_color));
+ imageFavorite.setContentDescription(getString(menu.getFavActionStringId()));
+ ((TextView) view.findViewById(R.id.context_menu_fav_text_view)).setText(menu.getFavActionStringId());
+ View favView = view.findViewById(R.id.context_menu_fav_view);
+ favView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
menu.buttonFavoritePressed();
}
});
- final ImageButton buttonWaypoint = (ImageButton) view.findViewById(R.id.context_menu_route_button);
- buttonWaypoint.setImageDrawable(getIcon(menu.getWaypointActionIconId(),
- !nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
- buttonWaypoint.setContentDescription(getString(menu.getWaypointActionStringId()));
- AndroidUtils.setDashButtonBackground(getMapActivity(), buttonWaypoint, nightMode);
+ final ImageView imageWaypoint = (ImageView) view.findViewById(R.id.context_menu_route_image_view);
+ imageWaypoint.setImageDrawable(getIcon(menu.getWaypointActionIconId(),
+ R.color.ctx_menu_buttons_icon_color));
+ imageWaypoint.setContentDescription(getString(menu.getWaypointActionStringId()));
+ View waypointView = view.findViewById(R.id.context_menu_route_view);
if (menu.isButtonWaypointEnabled()) {
- buttonWaypoint.setOnClickListener(new View.OnClickListener() {
+ waypointView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
menu.buttonWaypointPressed();
}
});
} else {
- deactivate(buttonWaypoint);
+ deactivate(waypointView);
}
- final ImageButton buttonShare = (ImageButton) view.findViewById(R.id.context_menu_share_button);
- buttonShare.setImageDrawable(getIcon(R.drawable.map_action_gshare_dark,
- !nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
- AndroidUtils.setDashButtonBackground(getMapActivity(), buttonShare, nightMode);
- buttonShare.setOnClickListener(new View.OnClickListener() {
+ final ImageView imageShare = (ImageView) view.findViewById(R.id.context_menu_share_image_view);
+ imageShare.setImageDrawable(getIcon(R.drawable.map_action_gshare_dark,
+ R.color.ctx_menu_buttons_icon_color));
+ View shareView = view.findViewById(R.id.context_menu_share_view);
+ shareView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
menu.buttonSharePressed();
}
});
- final ImageButton buttonMore = (ImageButton) view.findViewById(R.id.context_menu_more_button);
- buttonMore.setImageDrawable(getIcon(R.drawable.map_overflow_menu_white,
- !nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
- AndroidUtils.setDashButtonBackground(getMapActivity(), buttonMore, nightMode);
- buttonMore.setOnClickListener(new View.OnClickListener() {
+ final ImageView imageMore = (ImageView) view.findViewById(R.id.context_menu_more_image_view);
+ imageMore.setImageDrawable(getIcon(R.drawable.map_overflow_menu_white,
+ R.color.ctx_menu_buttons_icon_color));
+ View moreView = view.findViewById(R.id.context_menu_more_view);
+ moreView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
menu.buttonMorePressed();
}
});
+ //Bottom buttons
+ int bottomButtonsColor = nightMode ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n;
+ TextView detailsButton = (TextView) view.findViewById(R.id.context_menu_details_button);
+ detailsButton.setTextColor(ContextCompat.getColor(getContext(), bottomButtonsColor));
+ detailsButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ menu.openMenuFullScreen();
+ }
+ });
+ TextView directionsButton = (TextView) view.findViewById(R.id.context_menu_directions_button);
+ int iconResId = R.drawable.map_directions;
+ if (menu.navigateInPedestrianMode()) {
+ iconResId = R.drawable.map_action_pedestrian_dark;
+ }
+ Drawable drawable = getIcon(iconResId, bottomButtonsColor);
+ directionsButton.setTextColor(ContextCompat.getColor(getContext(), bottomButtonsColor));
+ directionsButton.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null);
+ directionsButton.setCompoundDrawablePadding(dpToPx(8));
+ directionsButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ menu.navigateButtonPressed();
+ }
+ });
+
buildBottomView();
- view.findViewById(R.id.context_menu_bottom_scroll).setBackgroundColor(nightMode ?
- getResources().getColor(R.color.ctx_menu_info_view_bg_dark) : getResources().getColor(R.color.ctx_menu_info_view_bg_light));
- view.findViewById(R.id.context_menu_bottom_view).setBackgroundColor(nightMode ?
- getResources().getColor(R.color.ctx_menu_info_view_bg_dark) : getResources().getColor(R.color.ctx_menu_info_view_bg_light));
+ view.findViewById(R.id.context_menu_bottom_scroll).setBackgroundColor(getResources()
+ .getColor(nightMode ? R.color.ctx_menu_bottom_view_bg_dark : R.color.ctx_menu_bottom_view_bg_light));
+ view.findViewById(R.id.context_menu_bottom_view).setBackgroundColor(getResources()
+ .getColor(nightMode ? R.color.ctx_menu_bottom_view_bg_dark : R.color.ctx_menu_bottom_view_bg_light));
//getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(false);
- if (Build.VERSION.SDK_INT >= 11) {
- containerLayoutListener = new OnLayoutChangeListener() {
- @Override
- public void onLayoutChange(View view, int left, int top, int right, int bottom,
- int oldLeft, int oldTop, int oldRight, int oldBottom) {
- if (bottom != oldBottom) {
- processScreenHeight(view.getParent());
- runLayoutListener();
- }
+ containerLayoutListener = new OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View view, int left, int top, int right, int bottom,
+ int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ if (bottom != oldBottom) {
+ processScreenHeight(view.getParent());
+ runLayoutListener();
}
- };
- }
+ }
+ };
created = true;
return view;
@@ -546,11 +537,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private void processScreenHeight(ViewParent parent) {
View container = (View)parent;
- if (Build.VERSION.SDK_INT >= 11) {
- screenHeight = container.getHeight() + AndroidUtils.getStatusBarHeight(getActivity());
- } else {
- screenHeight = AndroidUtils.getScreenHeight(getActivity());
- }
+ screenHeight = container.getHeight() + AndroidUtils.getStatusBarHeight(getActivity());
skipHalfScreenStateLimit = screenHeight * SKIP_HALF_SCREEN_STATE_KOEF;
viewHeight = screenHeight - AndroidUtils.getStatusBarHeight(getMapActivity());
}
@@ -639,58 +626,41 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
updateMainViewLayout(posY);
}
- if (!oldAndroid()) {
- mainView.animate().y(posY)
- .setDuration(200)
- .setInterpolator(new DecelerateInterpolator())
- .setListener(new AnimatorListenerAdapter() {
+ mainView.animate().y(posY)
+ .setDuration(200)
+ .setInterpolator(new DecelerateInterpolator())
+ .setListener(new AnimatorListenerAdapter() {
- boolean canceled = false;
+ boolean canceled = false;
- @Override
- public void onAnimationCancel(Animator animation) {
- canceled = true;
- }
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ canceled = true;
+ }
- @Override
- public void onAnimationEnd(Animator animation) {
- if (!canceled) {
- if (needCloseMenu) {
- menu.close();
- } else {
- updateMainViewLayout(posY);
- if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) {
- doAfterMenuStateChange(previousMenuState, newMenuState);
- }
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ if (!canceled) {
+ if (needCloseMenu) {
+ menu.close();
+ } else {
+ updateMainViewLayout(posY);
+ if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) {
+ doAfterMenuStateChange(previousMenuState, newMenuState);
}
}
}
- })
- .start();
+ }
+ })
+ .start();
- fabView.animate().y(getFabY(posY))
- .setDuration(200)
- .setInterpolator(new DecelerateInterpolator())
- .start();
+ zoomButtonsView.animate().y(getZoomButtonsY(posY))
+ .setDuration(200)
+ .setInterpolator(new DecelerateInterpolator())
+ .start();
- zoomButtonsView.animate().y(getZoomButtonsY(posY))
- .setDuration(200)
- .setInterpolator(new DecelerateInterpolator())
- .start();
-
- if (needMapAdjust) {
- adjustMapPosition(posY, true, centered, dZoom);
- }
- } else {
- setViewY(posY, false, needMapAdjust);
- if (needCloseMenu) {
- menu.close();
- } else {
- updateMainViewLayout(posY);
- if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) {
- doAfterMenuStateChange(previousMenuState, newMenuState);
- }
- }
+ if (needMapAdjust) {
+ adjustMapPosition(posY, true, centered, dZoom);
}
}
}
@@ -708,82 +678,70 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
if (view != null) {
TitleButtonController leftTitleButtonController = menu.getLeftTitleButtonController();
TitleButtonController rightTitleButtonController = menu.getRightTitleButtonController();
- TitleButtonController topRightTitleButtonController = menu.getTopRightTitleButtonController();
- TitleButtonController leftSubtitleButtonController = menu.getLeftSubtitleButtonController();
+ TitleButtonController bottomTitleButtonController = menu.getBottomTitleButtonController();
TitleButtonController leftDownloadButtonController = menu.getLeftDownloadButtonController();
TitleButtonController rightDownloadButtonController = menu.getRightDownloadButtonController();
TitleProgressController titleProgressController = menu.getTitleProgressController();
// Title buttons
boolean showTitleButtonsContainer = (leftTitleButtonController != null || rightTitleButtonController != null);
- boolean showTitleDivider = leftSubtitleButtonController != null;
final View titleButtonsContainer = view.findViewById(R.id.title_button_container);
titleButtonsContainer.setVisibility(showTitleButtonsContainer ? View.VISIBLE : View.GONE);
- view.findViewById(R.id.title_divider).setVisibility(showTitleDivider ? View.VISIBLE : View.GONE);
// Left title button
- final Button leftTitleButton = (Button) view.findViewById(R.id.title_button);
+ final View leftTitleButtonView = view.findViewById(R.id.title_button_view);
+ final TextView leftTitleButton = (TextView) view.findViewById(R.id.title_button);
final TextView titleButtonRightText = (TextView) view.findViewById(R.id.title_button_right_text);
if (leftTitleButtonController != null) {
leftTitleButton.setText(leftTitleButtonController.caption);
- leftTitleButton.setVisibility(leftTitleButtonController.visible ? View.VISIBLE : View.GONE);
+ if (leftTitleButtonController.visible) {
+ leftTitleButtonView.setVisibility(View.VISIBLE);
+ Drawable leftIcon = leftTitleButtonController.getLeftIcon();
+ if (leftIcon != null) {
+ leftTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
+ leftTitleButton.setCompoundDrawablePadding(dpToPx(8f));
+ }
- Drawable leftIcon = leftTitleButtonController.getLeftIcon();
- if (leftIcon != null) {
- leftTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
- leftTitleButton.setCompoundDrawablePadding(dpToPx(8f));
- }
-
- if (leftTitleButtonController.needRightText) {
- titleButtonRightText.setText(leftTitleButtonController.rightTextCaption);
- titleButtonRightText.setVisibility(View.VISIBLE);
+ if (leftTitleButtonController.needRightText) {
+ titleButtonRightText.setText(leftTitleButtonController.rightTextCaption);
+ titleButtonRightText.setVisibility(View.VISIBLE);
+ } else {
+ titleButtonRightText.setVisibility(View.GONE);
+ }
} else {
- titleButtonRightText.setVisibility(View.GONE);
+ leftTitleButtonView.setVisibility(View.INVISIBLE);
}
} else {
- leftTitleButton.setVisibility(View.GONE);
+ leftTitleButtonView.setVisibility(View.INVISIBLE);
titleButtonRightText.setVisibility(View.GONE);
}
// Right title button
- final Button rightTitleButton = (Button) view.findViewById(R.id.title_button_right);
+ final View rightTitleButtonView = view.findViewById(R.id.title_button_right_view);
+ final TextView rightTitleButton = (TextView) view.findViewById(R.id.title_button_right);
if (rightTitleButtonController != null) {
rightTitleButton.setText(rightTitleButtonController.caption);
- rightTitleButton.setVisibility(rightTitleButtonController.visible ? View.VISIBLE : View.GONE);
+ rightTitleButtonView.setVisibility(rightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE);
Drawable leftIcon = rightTitleButtonController.getLeftIcon();
rightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
rightTitleButton.setCompoundDrawablePadding(dpToPx(8f));
} else {
- rightTitleButton.setVisibility(View.GONE);
+ rightTitleButtonView.setVisibility(View.INVISIBLE);
}
- // Top Right title button
- final Button topRightTitleButton = (Button) view.findViewById(R.id.title_button_top_right);
- if (topRightTitleButtonController != null) {
- topRightTitleButton.setText(topRightTitleButtonController.caption);
- topRightTitleButton.setVisibility(topRightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE);
+ // Bottom title button
+ final View bottomTitleButtonView = view.findViewById(R.id.title_button_bottom_view);
+ final TextView bottomTitleButton = (TextView) view.findViewById(R.id.title_button_bottom);
+ if (bottomTitleButtonController != null) {
+ bottomTitleButton.setText(bottomTitleButtonController.caption);
+ bottomTitleButtonView.setVisibility(bottomTitleButtonController.visible ? View.VISIBLE : View.GONE);
- Drawable leftIcon = topRightTitleButtonController.getLeftIcon();
- topRightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
- topRightTitleButton.setCompoundDrawablePadding(dpToPx(8f));
+ Drawable leftIcon = bottomTitleButtonController.getLeftIcon();
+ bottomTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
+ bottomTitleButton.setCompoundDrawablePadding(dpToPx(8f));
} else {
- topRightTitleButton.setVisibility(View.GONE);
- }
-
- // Left subtitle button
- final Button leftSubtitleButton = (Button) view.findViewById(R.id.subtitle_button);
- if (leftSubtitleButtonController != null) {
- leftSubtitleButton.setText(leftSubtitleButtonController.caption);
- leftSubtitleButton.setVisibility(leftSubtitleButtonController.visible ? View.VISIBLE : View.GONE);
-
- Drawable leftIcon = leftSubtitleButtonController.getLeftIcon();
- if (leftIcon != null) {
- leftSubtitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
- leftSubtitleButton.setCompoundDrawablePadding(dpToPx(8f));
- }
- } else {
- leftSubtitleButton.setVisibility(View.GONE);
+ bottomTitleButtonView.setVisibility(View.GONE);
}
// Download buttons
@@ -794,21 +752,12 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
final View downloadButtonsContainer = view.findViewById(R.id.download_buttons_container);
downloadButtonsContainer.setVisibility(showDownloadButtonsContainer ? View.VISIBLE : View.GONE);
- if (showDownloadButtonsContainer) {
- view.findViewById(R.id.download_buttons_top_border).setVisibility(showTitleButtonsContainer ? View.VISIBLE : View.INVISIBLE);
- if (showTitleButtonsContainer) {
- LinearLayout.LayoutParams ll = (LinearLayout.LayoutParams) downloadButtonsContainer.getLayoutParams();
- if (ll.topMargin != 0) {
- ll.setMargins(0, 0, 0, 0);
- }
- }
- }
-
// Left download button
- final Button leftDownloadButton = (Button) view.findViewById(R.id.download_button_left);
+ final View leftDownloadButtonView = view.findViewById(R.id.download_button_left_view);
+ final TextView leftDownloadButton = (TextView) view.findViewById(R.id.download_button_left);
if (leftDownloadButtonController != null) {
leftDownloadButton.setText(leftDownloadButtonController.caption);
- leftDownloadButton.setVisibility(leftDownloadButtonController.visible ? View.VISIBLE : View.GONE);
+ leftDownloadButtonView.setVisibility(leftDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE);
Drawable leftIcon = leftDownloadButtonController.getLeftIcon();
if (leftIcon != null) {
@@ -816,20 +765,21 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
leftDownloadButton.setCompoundDrawablePadding(dpToPx(8f));
}
} else {
- leftDownloadButton.setVisibility(View.GONE);
+ leftDownloadButtonView.setVisibility(View.INVISIBLE);
}
// Right download button
- final Button rightDownloadButton = (Button) view.findViewById(R.id.download_button_right);
+ final View rightDownloadButtonView = view.findViewById(R.id.download_button_right_view);
+ final TextView rightDownloadButton = (TextView) view.findViewById(R.id.download_button_right);
if (rightDownloadButtonController != null) {
rightDownloadButton.setText(rightDownloadButtonController.caption);
- rightDownloadButton.setVisibility(rightDownloadButtonController.visible ? View.VISIBLE : View.GONE);
+ rightDownloadButtonView.setVisibility(rightDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE);
Drawable leftIcon = rightDownloadButtonController.getLeftIcon();
rightDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
rightDownloadButton.setCompoundDrawablePadding(dpToPx(8f));
} else {
- rightDownloadButton.setVisibility(View.GONE);
+ rightDownloadButtonView.setVisibility(View.INVISIBLE);
}
// Progress bar
@@ -861,19 +811,18 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private void buildHeader() {
OsmandApplication app = getMyApplication();
if (app != null && view != null) {
- final View iconLayout = view.findViewById(R.id.context_menu_icon_layout);
final ImageView iconView = (ImageView) view.findViewById(R.id.context_menu_icon_view);
Drawable icon = menu.getLeftIcon();
int iconId = menu.getLeftIconId();
if (icon != null) {
iconView.setImageDrawable(icon);
- iconLayout.setVisibility(View.VISIBLE);
+ iconView.setVisibility(View.VISIBLE);
} else if (iconId != 0) {
iconView.setImageDrawable(getIcon(iconId,
!nightMode ? R.color.osmand_orange : R.color.osmand_orange_dark));
- iconLayout.setVisibility(View.VISIBLE);
+ iconView.setVisibility(View.VISIBLE);
} else {
- iconLayout.setVisibility(View.GONE);
+ iconView.setVisibility(View.GONE);
}
setAddressLocation();
}
@@ -956,10 +905,12 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
public void rebuildMenu(boolean centered) {
OsmandApplication app = getMyApplication();
if (app != null && view != null) {
- final ImageButton buttonFavorite = (ImageButton) view.findViewById(R.id.context_menu_fav_button);
+ final ImageView buttonFavorite = (ImageView) view.findViewById(R.id.context_menu_fav_image_view);
buttonFavorite.setImageDrawable(getIcon(menu.getFavActionIconId(),
!nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
- buttonFavorite.setContentDescription(getString(menu.getFavActionStringId()));
+ String favActionString = getString(menu.getFavActionStringId());
+ buttonFavorite.setContentDescription(favActionString);
+ ((TextView) view.findViewById(R.id.context_menu_fav_text_view)).setText(favActionString);
buildHeader();
@@ -997,7 +948,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
}
int newMenuTopViewHeight = view.findViewById(R.id.context_menu_top_view).getHeight();
- menuTopShadowHeight = view.findViewById(R.id.context_menu_top_shadow).getHeight();
int newMenuTopShadowAllHeight = view.findViewById(R.id.context_menu_top_shadow_all).getHeight();
menuFullHeight = view.findViewById(R.id.context_menu_main).getHeight();
zoomButtonsHeight = zoomButtonsView.getHeight();
@@ -1015,35 +965,28 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
line2MeasuredHeight = line2.getMeasuredHeight();
}
- int dp16 = dpToPx(16f);
- boolean has16margin = false;
int titleButtonHeight = 0;
View titleButtonContainer = view.findViewById(R.id.title_button_container);
if (titleButtonContainer.getVisibility() == View.VISIBLE) {
- titleButtonHeight = titleButtonContainer.getMeasuredHeight() - dp16;
- if (titleButtonHeight < 0) {
- titleButtonHeight = 0;
- } else {
- has16margin = true;
- }
+ titleButtonHeight = titleButtonContainer.getMeasuredHeight();
}
+
int downloadButtonsHeight = 0;
View downloadButtonsContainer = view.findViewById(R.id.download_buttons_container);
if (downloadButtonsContainer.getVisibility() == View.VISIBLE) {
- downloadButtonsHeight = downloadButtonsContainer.getMeasuredHeight() - (has16margin ? 0 : dp16);
- if (downloadButtonsHeight < 0) {
- downloadButtonsHeight = 0;
- } else {
- has16margin = true;
- }
+ downloadButtonsHeight = downloadButtonsContainer.getMeasuredHeight();
}
+
+ int titleBottomButtonHeight = 0;
+ View titleBottomButtonContainer = view.findViewById(R.id.title_bottom_button_container);
+ if (titleBottomButtonContainer.getVisibility() == View.VISIBLE) {
+ titleBottomButtonHeight = titleBottomButtonContainer.getMeasuredHeight();
+ }
+
int titleProgressHeight = 0;
View titleProgressContainer = view.findViewById(R.id.title_progress_container);
if (titleProgressContainer.getVisibility() == View.VISIBLE) {
- titleProgressHeight = titleProgressContainer.getMeasuredHeight() - (has16margin ? 0 : dp16);
- if (titleProgressHeight < 0) {
- titleProgressHeight = 0;
- }
+ titleProgressHeight = titleProgressContainer.getMeasuredHeight();
}
if (menuTopViewHeight != 0) {
@@ -1051,17 +994,17 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
if (titleHeight < line1.getMeasuredHeight() + line2MeasuredHeight) {
titleHeight = line1.getMeasuredHeight() + line2MeasuredHeight;
}
- newMenuTopViewHeight = menuTopViewHeightExcludingTitle + titleHeight + titleButtonHeight + downloadButtonsHeight + titleProgressHeight;
+ newMenuTopViewHeight = menuTopViewHeightExcludingTitle + titleHeight + titleButtonHeight + downloadButtonsHeight + titleBottomButtonHeight + titleProgressHeight;
dy = Math.max(0, newMenuTopViewHeight - menuTopViewHeight - (newMenuTopShadowAllHeight - menuTopShadowAllHeight));
} else {
- menuTopViewHeightExcludingTitle = newMenuTopViewHeight - line1.getMeasuredHeight() - line2MeasuredHeight - titleButtonHeight - downloadButtonsHeight - titleProgressHeight;
+ menuTopViewHeightExcludingTitle = newMenuTopViewHeight - line1.getMeasuredHeight() - line2MeasuredHeight - titleButtonHeight - downloadButtonsHeight - titleBottomButtonHeight - titleProgressHeight;
menuTitleTopBottomPadding = (line1.getMeasuredHeight() - line1.getLineCount() * line1.getLineHeight())
+ (line2MeasuredHeight - line2LineCount * line2LineHeight);
}
}
menuTopViewHeight = newMenuTopViewHeight;
menuTopShadowAllHeight = newMenuTopShadowAllHeight;
- menuTitleHeight = menuTopShadowHeight + menuTopShadowAllHeight + dy;
+ menuTitleHeight = menuTopShadowAllHeight + dy;
menuBottomViewHeight = view.findViewById(R.id.context_menu_bottom_view).getHeight();
menuFullHeightMax = menuTitleHeight + menuBottomViewHeight;
@@ -1168,6 +1111,60 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
}
line2.setText(line2Str.toString());
}
+
+ TextView line3 = (TextView) view.findViewById(R.id.context_menu_line3);
+ String additionalTypeStr = menu.getAdditionalTypeStr();
+ boolean displayAdditionalTypeStrInHours = menu.displayAdditionalTypeStrInHours();
+ boolean emptyAdditionalTypeStr = TextUtils.isEmpty(additionalTypeStr);
+ if (emptyAdditionalTypeStr || displayAdditionalTypeStrInHours) {
+ line3.setVisibility(View.GONE);
+ } else {
+ line3.setVisibility(View.VISIBLE);
+ line3.setText(additionalTypeStr);
+ Drawable icon = menu.getAdditionalLineTypeIcon();
+ line3.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
+ line3.setCompoundDrawablePadding(dpToPx(5f));
+ }
+
+ TextView openingHoursTextView = (TextView) view.findViewById(R.id.opening_hours_text_view);
+ OpeningHoursInfo openingHoursInfo = menu.getOpeningHoursInfo();
+ boolean containsOpeningHours = openingHoursInfo != null && openingHoursInfo.containsInfo();
+ if (containsOpeningHours || (displayAdditionalTypeStrInHours && !emptyAdditionalTypeStr)) {
+ int colorId;
+ if (containsOpeningHours) {
+ colorId = openingHoursInfo.isOpened() ? R.color.ctx_menu_amenity_opened_text_color : R.color.ctx_menu_amenity_closed_text_color;
+ } else {
+ colorId = menu.getTimeStrColor();
+ }
+ String timeInfo = "";
+ if (containsOpeningHours) {
+ if (openingHoursInfo.isOpened24_7()) {
+ timeInfo = getString(R.string.shared_string_is_open_24_7);
+ } else if (!Algorithms.isEmpty(openingHoursInfo.getNearToOpeningTime())) {
+ timeInfo = getString(R.string.will_be_opened_at) + " " + openingHoursInfo.getNearToOpeningTime();
+ } else if (!Algorithms.isEmpty(openingHoursInfo.getOpeningTime())) {
+ timeInfo = getString(R.string.opened_from) + " " + openingHoursInfo.getOpeningTime();
+ } else if (!Algorithms.isEmpty(openingHoursInfo.getNearToClosingTime())) {
+ timeInfo = getString(R.string.will_be_closed_at) + " " + openingHoursInfo.getNearToClosingTime();
+ } else if (!Algorithms.isEmpty(openingHoursInfo.getClosingTime())) {
+ timeInfo = getString(R.string.opened_till) + " " + openingHoursInfo.getClosingTime();
+ } else if (!Algorithms.isEmpty(openingHoursInfo.getOpeningDay())) {
+ timeInfo = getString(R.string.will_be_opened_on) + " " + openingHoursInfo.getOpeningDay() + ".";
+ }
+ } else {
+ timeInfo = additionalTypeStr;
+ }
+ if (colorId != 0) {
+ openingHoursTextView.setTextColor(ContextCompat.getColor(getContext(), colorId));
+ Drawable drawable = getIcon(R.drawable.ic_action_opening_hour_16, colorId);
+ openingHoursTextView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
+ openingHoursTextView.setCompoundDrawablePadding(dpToPx(8));
+ }
+ openingHoursTextView.setText(timeInfo);
+ openingHoursTextView.setVisibility(View.VISIBLE);
+ } else {
+ openingHoursTextView.setVisibility(View.GONE);
+ }
}
updateCompassVisibility();
}
@@ -1181,11 +1178,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
updateDistanceDirection();
compassView.setVisibility(View.VISIBLE);
} else {
- if (!menu.displayDistanceDirection()) {
- compassView.setVisibility(View.GONE);
- } else {
- compassView.setVisibility(View.INVISIBLE);
- }
+ compassView.setVisibility(View.INVISIBLE);
}
}
}
@@ -1197,8 +1190,9 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
TextView distanceText = (TextView) view.findViewById(R.id.distance);
ImageView direction = (ImageView) view.findViewById(R.id.direction);
float myHeading = menu.getHeading() == null ? 0f : menu.getHeading();
- DashLocationFragment.updateLocationView(false, menu.getMyLocation(), myHeading, direction, distanceText,
- menu.getLatLon().getLatitude(), menu.getLatLon().getLongitude(), screenOrientation, app, activity);
+ int color = nightMode ? R.color.ctx_menu_direction_color_dark : R.color.ctx_menu_direction_color_light;
+ DashLocationFragment.updateLocationView(false, menu.getMyLocation(), myHeading, direction, color, distanceText,
+ color, menu.getLatLon().getLatitude(), menu.getLatLon().getLongitude(), screenOrientation, app, activity);
}
}
@@ -1231,7 +1225,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
posY = Math.max(posY, minHalfY);
break;
case MenuState.FULL_SCREEN:
- posY = -menuTopShadowHeight - dpToPx(SHADOW_HEIGHT_TOP_DP);
+ posY = -dpToPx(SHADOW_HEIGHT_TOP_DP);
posY = addStatusBarHeightIfNeeded(posY);
break;
default:
@@ -1254,33 +1248,20 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private void updateMainViewLayout(int posY) {
if (view != null) {
menuFullHeight = view.getHeight() - posY;
- if (!oldAndroid()) {
- ViewGroup.LayoutParams lp = mainView.getLayoutParams();
- lp.height = Math.max(menuFullHeight, menuTitleHeight);
- mainView.setLayoutParams(lp);
- mainView.requestLayout();
- }
+ ViewGroup.LayoutParams lp = mainView.getLayoutParams();
+ lp.height = Math.max(menuFullHeight, menuTitleHeight);
+ mainView.setLayoutParams(lp);
+ mainView.requestLayout();
}
}
private int getViewY() {
- if (!oldAndroid()) {
- return (int) mainView.getY();
- } else {
- return mainView.getPaddingTop();
- }
+ return (int) mainView.getY();
}
private void setViewY(int y, boolean animated, boolean adjustMapPos) {
- if (!oldAndroid()) {
- mainView.setY(y);
- fabView.setY(getFabY(y));
- zoomButtonsView.setY(getZoomButtonsY(y));
- } else {
- mainView.setPadding(0, y, 0, 0);
- fabView.setPadding(0, getFabY(y), 0, 0);
- zoomButtonsView.setPadding(0, getZoomButtonsY(y), 0, 0);
- }
+ mainView.setY(y);
+ zoomButtonsView.setY(getZoomButtonsY(y));
if (!customMapCenter) {
if (adjustMapPos) {
adjustMapPosition(y, animated, centered, 0);
@@ -1372,21 +1353,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
return latlon;
}
- private int getFabY(int y) {
- int fabY = y + fabPaddingTopPx;
- if (fabY < fabPaddingTopPx) {
- fabY = fabPaddingTopPx;
- fabY = addStatusBarHeightIfNeeded(fabY);
- }
- return fabY;
- }
-
private int getZoomButtonsY(int y) {
- return y - zoomButtonsHeight - fabPaddingTopPx;
- }
-
- private boolean oldAndroid() {
- return (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH);
+ return y - zoomButtonsHeight;
}
private void doLayoutMenu() {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java
index 99145667c0..1fb6c2d977 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java
@@ -3,20 +3,21 @@ package net.osmand.plus.mapcontextmenu;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
+import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
-import android.os.Build;
import android.support.annotation.NonNull;
+import android.support.v4.content.ContextCompat;
import android.support.v7.view.ContextThemeWrapper;
-import android.support.v7.widget.AppCompatButton;
import android.text.ClipboardManager;
import android.text.TextUtils;
import android.text.util.Linkify;
import android.util.TypedValue;
import android.view.Gravity;
+import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
@@ -28,22 +29,33 @@ import android.widget.Toast;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.Amenity;
+import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect;
import net.osmand.osm.PoiCategory;
+import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
+import net.osmand.plus.GPXUtilities.GPXFile;
+import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.IconsCache;
+import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.activities.TrackActivity;
+import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.mapcontextmenu.builders.cards.AbstractCard;
import net.osmand.plus.mapcontextmenu.builders.cards.CardsRowBuilder;
import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard;
import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask;
import net.osmand.plus.mapcontextmenu.builders.cards.NoImagesCard;
+import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute;
+import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.render.RenderingIcons;
+import net.osmand.plus.views.TransportStopsLayer;
+import net.osmand.plus.widgets.TextViewEx;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
@@ -67,6 +79,7 @@ public class MenuBuilder {
protected OsmandApplication app;
protected LinkedList plainMenuItems;
private boolean firstRow;
+ protected boolean matchWidthDivider;
protected boolean light;
private long objectId;
private LatLon latLon;
@@ -76,6 +89,7 @@ public class MenuBuilder {
private boolean showOnlinePhotos = true;
protected List nearestWiki = new ArrayList<>();
private List menuPlugins = new ArrayList<>();
+ private List routes = new ArrayList<>();
private CardsRowBuilder onlinePhotoCardsRow;
private List onlinePhotoCards;
@@ -199,6 +213,10 @@ public class MenuBuilder {
transliterateNames = app.getSettings().MAP_TRANSLITERATE_NAMES.get();
}
+ public void setRoutes(List routes) {
+ this.routes = routes;
+ }
+
public String getPreferredMapLang() {
return preferredMapLang;
}
@@ -270,6 +288,10 @@ public class MenuBuilder {
if (showTitleIfTruncated) {
buildTitleRow(view);
}
+ if (showTransportRoutes()) {
+ buildRow(view, 0, app.getString(R.string.transport_Routes), 0, true, getCollapsableTransportStopRoutesView(view.getContext(), false),
+ false, 0, false, null, true);
+ }
buildNearestWikiRow(view);
if (needBuildPlainMenuItems()) {
buildPlainMenuItems(view);
@@ -282,6 +304,10 @@ public class MenuBuilder {
buildAfter(view);
}
+ private boolean showTransportRoutes() {
+ return routes.size() > 0;
+ }
+
void onHide() {
hidden = true;
}
@@ -299,7 +325,7 @@ public class MenuBuilder {
protected void buildPlainMenuItems(View view) {
for (PlainMenuItem item : plainMenuItems) {
buildRow(view, item.getIconId(), item.getText(), 0, item.collapsable, item.collapsableView,
- item.isNeedLinks(), 0, item.isUrl(), item.getOnClickListener());
+ item.isNeedLinks(), 0, item.isUrl(), item.getOnClickListener(), false);
}
}
@@ -323,7 +349,7 @@ public class MenuBuilder {
if (mapContextMenu != null) {
String title = mapContextMenu.getTitleStr();
if (title.length() > TITLE_LIMIT) {
- buildRow(view, R.drawable.ic_action_note_dark, title, 0, false, null, false, 0, false, null);
+ buildRow(view, R.drawable.ic_action_note_dark, title, 0, false, null, false, 0, false, null, false);
}
}
}
@@ -332,7 +358,7 @@ public class MenuBuilder {
if (processNearstWiki() && nearestWiki.size() > 0) {
buildRow(view, R.drawable.ic_action_wikipedia, app.getString(R.string.wiki_around) + " (" + nearestWiki.size()+")", 0,
true, getCollapsableWikiView(view.getContext(), true),
- false, 0, false, null);
+ false, 0, false, null, false);
}
}
@@ -355,7 +381,7 @@ public class MenuBuilder {
}
});
buildRow(view, R.drawable.ic_action_photo_dark, app.getString(R.string.online_photos), 0, true,
- collapsableView, false, 1, false, null);
+ collapsableView, false, 1, false, null, false);
if (needUpdateOnly && onlinePhotoCards != null) {
onlinePhotoCardsRow.setCards(onlinePhotoCards);
@@ -400,7 +426,7 @@ public class MenuBuilder {
}
protected void buildAfter(View view) {
- buildRowDivider(view, false);
+ buildRowDivider(view);
}
public boolean isFirstRow() {
@@ -413,17 +439,17 @@ public class MenuBuilder {
public View buildRow(View view, int iconId, String text, int textColor,
boolean collapsable, final CollapsableView collapsableView,
- boolean needLinks, int textLinesLimit, boolean isUrl, OnClickListener onClickListener) {
- return buildRow(view, getRowIcon(iconId), text, textColor, collapsable, collapsableView,
- needLinks, textLinesLimit, isUrl, onClickListener);
+ boolean needLinks, int textLinesLimit, boolean isUrl, OnClickListener onClickListener, boolean matchWidthDivider) {
+ return buildRow(view, iconId == 0 ? null : getRowIcon(iconId), text, textColor, null, collapsable, collapsableView,
+ needLinks, textLinesLimit, isUrl, onClickListener, matchWidthDivider);
}
- public View buildRow(final View view, Drawable icon, final String text, int textColor,
+ public View buildRow(final View view, Drawable icon, final String text, int textColor, String secondaryText,
boolean collapsable, final CollapsableView collapsableView, boolean needLinks,
- int textLinesLimit, boolean isUrl, OnClickListener onClickListener) {
+ int textLinesLimit, boolean isUrl, OnClickListener onClickListener, boolean matchWidthDivider) {
if (!isFirstRow()) {
- buildRowDivider(view, false);
+ buildRowDivider(view);
}
LinearLayout baseView = new LinearLayout(view.getContext());
@@ -447,35 +473,44 @@ public class MenuBuilder {
baseView.addView(ll);
// Icon
- LinearLayout llIcon = new LinearLayout(view.getContext());
- llIcon.setOrientation(LinearLayout.HORIZONTAL);
- llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(72f), dpToPx(48f)));
- llIcon.setGravity(Gravity.CENTER_VERTICAL);
- ll.addView(llIcon);
+ if (icon != null) {
+ LinearLayout llIcon = new LinearLayout(view.getContext());
+ llIcon.setOrientation(LinearLayout.HORIZONTAL);
+ llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(64f), dpToPx(48f)));
+ llIcon.setGravity(Gravity.CENTER_VERTICAL);
+ ll.addView(llIcon);
- ImageView iconView = new ImageView(view.getContext());
- LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(dpToPx(24f), dpToPx(24f));
- llIconParams.setMargins(dpToPx(16f), dpToPx(12f), dpToPx(32f), dpToPx(12f));
- llIconParams.gravity = Gravity.CENTER_VERTICAL;
- iconView.setLayoutParams(llIconParams);
- iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
- iconView.setImageDrawable(icon);
- llIcon.addView(iconView);
+ ImageView iconView = new ImageView(view.getContext());
+ LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(dpToPx(24f), dpToPx(24f));
+ llIconParams.setMargins(dpToPx(16f), dpToPx(12f), dpToPx(24f), dpToPx(12f));
+ llIconParams.gravity = Gravity.CENTER_VERTICAL;
+ iconView.setLayoutParams(llIconParams);
+ iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
+ iconView.setImageDrawable(icon);
+ llIcon.addView(iconView);
+ }
// Text
LinearLayout llText = new LinearLayout(view.getContext());
llText.setOrientation(LinearLayout.VERTICAL);
+ LinearLayout.LayoutParams llTextViewParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
+ llTextViewParams.weight = 1f;
+ llTextViewParams.setMargins(0, 0, dpToPx(10f), 0);
+ llTextViewParams.gravity = Gravity.CENTER_VERTICAL;
+ llText.setLayoutParams(llTextViewParams);
ll.addView(llText);
- TextView textView = new TextView(view.getContext());
+ // Primary text
+ TextViewEx textView = new TextViewEx(view.getContext());
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
- llTextParams.setMargins(0, dpToPx(8f), 0, dpToPx(8f));
+ llTextParams.setMargins(icon != null ? 0 : dpToPx(16f), dpToPx(secondaryText != null ? 10f : 8f), 0, dpToPx(secondaryText != null ? 6f : 8f));
textView.setLayoutParams(llTextParams);
+ textView.setTypeface(FontCache.getRobotoRegular(view.getContext()));
textView.setTextSize(16);
- textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
+ textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark));
if (isUrl) {
- textView.setTextColor(textView.getLinkTextColors());
+ textView.setTextColor(ContextCompat.getColor(view.getContext(), light ? R.color.ctx_menu_bottom_view_url_color_light : R.color.ctx_menu_bottom_view_url_color_dark));
} else if (needLinks) {
textView.setAutoLinkMask(Linkify.ALL);
textView.setLinksClickable(true);
@@ -488,14 +523,21 @@ public class MenuBuilder {
if (textColor > 0) {
textView.setTextColor(view.getResources().getColor(textColor));
}
-
- LinearLayout.LayoutParams llTextViewParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
- llTextViewParams.weight = 1f;
- llTextViewParams.setMargins(0, 0, dpToPx(10f), 0);
- llTextViewParams.gravity = Gravity.CENTER_VERTICAL;
- llText.setLayoutParams(llTextViewParams);
llText.addView(textView);
+ // Secondary text
+ if (!TextUtils.isEmpty(secondaryText)) {
+ TextViewEx textViewSecondary = new TextViewEx(view.getContext());
+ LinearLayout.LayoutParams llTextSecondaryParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+ llTextSecondaryParams.setMargins(icon != null ? 0 : dpToPx(16f), 0, 0, dpToPx(6f));
+ textViewSecondary.setLayoutParams(llTextSecondaryParams);
+ textViewSecondary.setTypeface(FontCache.getRobotoRegular(view.getContext()));
+ textViewSecondary.setTextSize(14);
+ textViewSecondary.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_secondary_text_color_light: R.color.ctx_menu_bottom_view_secondary_text_color_dark));
+ textViewSecondary.setText(secondaryText);
+ llText.addView(textViewSecondary);
+ }
+
final ImageView iconViewCollapse = new ImageView(view.getContext());
if (collapsable && collapsableView != null) {
// Icon
@@ -506,12 +548,12 @@ public class MenuBuilder {
ll.addView(llIconCollapse);
LinearLayout.LayoutParams llIconCollapseParams = new LinearLayout.LayoutParams(dpToPx(24f), dpToPx(24f));
- llIconCollapseParams.setMargins(0, dpToPx(12f), dpToPx(32f), dpToPx(12f));
+ llIconCollapseParams.setMargins(0, dpToPx(12f), dpToPx(24f), dpToPx(12f));
llIconCollapseParams.gravity = Gravity.CENTER_VERTICAL;
iconViewCollapse.setLayoutParams(llIconCollapseParams);
iconViewCollapse.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
- iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(collapsableView.getContenView().getVisibility() == View.GONE ?
- R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up));
+ iconViewCollapse.setImageDrawable(app.getIconsCache().getIcon(collapsableView.getContenView().getVisibility() == View.GONE ?
+ R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up, light ? R.color.ctx_menu_bottom_view_icon_light : R.color.ctx_menu_bottom_view_icon_dark));
llIconCollapse.addView(iconViewCollapse);
ll.setOnClickListener(new View.OnClickListener() {
@Override
@@ -519,17 +561,17 @@ public class MenuBuilder {
if (collapsableView.getContenView().getVisibility() == View.VISIBLE) {
collapsableView.setCollapsed(true);
collapsableView.getContenView().setVisibility(View.GONE);
- iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_arrow_down));
+ iconViewCollapse.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_arrow_down, light ? R.color.ctx_menu_bottom_view_icon_light : R.color.ctx_menu_bottom_view_icon_dark));
} else {
collapsableView.setCollapsed(false);
collapsableView.getContenView().setVisibility(View.VISIBLE);
- iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_arrow_up));
+ iconViewCollapse.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_arrow_up, light ? R.color.ctx_menu_bottom_view_icon_light : R.color.ctx_menu_bottom_view_icon_dark));
}
}
});
if (collapsableView.isCollapsed()) {
collapsableView.getContenView().setVisibility(View.GONE);
- iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_arrow_down));
+ iconViewCollapse.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_arrow_down, light ? R.color.ctx_menu_bottom_view_icon_light : R.color.ctx_menu_bottom_view_icon_dark));
}
baseView.addView(collapsableView.getContenView());
}
@@ -551,9 +593,15 @@ public class MenuBuilder {
rowBuilt();
+ setDividerWidth(matchWidthDivider);
+
return ll;
}
+ protected void setDividerWidth(boolean matchWidthDivider) {
+ this.matchWidthDivider = matchWidthDivider;
+ }
+
protected void copyToClipboard(String text, Context ctx) {
((ClipboardManager) app.getSystemService(Activity.CLIPBOARD_SERVICE)).setText(text);
Toast.makeText(ctx,
@@ -603,15 +651,15 @@ public class MenuBuilder {
rowBuilt();
}
- public void buildRowDivider(View view, boolean matchWidth) {
+ public void buildRowDivider(View view) {
View horizontalLine = new View(view.getContext());
LinearLayout.LayoutParams llHorLineParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(1f));
llHorLineParams.gravity = Gravity.BOTTOM;
- if (!matchWidth) {
- llHorLineParams.setMargins(dpToPx(72f), 0, 0, 0);
+ if (!matchWidthDivider) {
+ llHorLineParams.setMargins(dpToPx(64f), 0, 0, 0);
}
horizontalLine.setLayoutParams(llHorLineParams);
- horizontalLine.setBackgroundColor(app.getResources().getColor(light ? R.color.ctx_menu_info_divider_light : R.color.ctx_menu_info_divider_dark));
+ horizontalLine.setBackgroundColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_divider_light : R.color.ctx_menu_bottom_view_divider_dark));
((LinearLayout) view).addView(horizontalLine);
}
@@ -638,15 +686,13 @@ public class MenuBuilder {
public Drawable getRowIcon(int iconId) {
IconsCache iconsCache = app.getIconsCache();
- return iconsCache.getIcon(iconId,
- light ? R.color.icon_color : R.color.icon_color_light);
+ return iconsCache.getIcon(iconId, light ? R.color.ctx_menu_bottom_view_icon_light : R.color.ctx_menu_bottom_view_icon_dark);
}
public Drawable getRowIcon(Context ctx, String fileName) {
Drawable d = RenderingIcons.getBigIcon(ctx, fileName);
if (d != null) {
- d.setColorFilter(app.getResources()
- .getColor(light ? R.color.icon_color : R.color.icon_color_light), PorterDuff.Mode.SRC_IN);
+ d.setColorFilter(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_icon_light : R.color.ctx_menu_bottom_view_icon_dark), PorterDuff.Mode.SRC_IN);
return d;
} else {
return null;
@@ -668,53 +714,260 @@ public class MenuBuilder {
);
}
+ private void buildTransportRouteRow(ViewGroup parent, TransportStopRoute r, OnClickListener listener) {
+ if (!isFirstRow()) {
+ buildRowDivider(parent);
+ }
+
+ View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.ctx_menu_transport_route_layout, parent, false);
+ TextView routeDesc = (TextView) view.findViewById(R.id.route_desc);
+ routeDesc.setText(r.getDescription(getMapActivity().getMyApplication(), true));
+ routeDesc.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark));
+ int drawableResId = r.type == null ? R.drawable.ic_action_polygom_dark : r.type.getResourceId();
+ ((ImageView) view.findViewById(R.id.route_type_icon)).setImageDrawable(getRowIcon(drawableResId));
+ ((TextView) view.findViewById(R.id.route_ref)).setText(r.route.getRef());
+ view.setOnClickListener(listener);
+ int typeResId;
+ switch (r.type) {
+ case BUS:
+ typeResId = R.string.poi_route_bus_ref;
+ break;
+ case TRAM:
+ typeResId = R.string.poi_route_tram_ref;
+ break;
+ case FERRY:
+ typeResId = R.string.poi_route_ferry_ref;
+ break;
+ case TRAIN:
+ typeResId = R.string.poi_route_train_ref;
+ break;
+ case SHARE_TAXI:
+ typeResId = R.string.poi_route_share_taxi_ref;
+ break;
+ case FUNICULAR:
+ typeResId = R.string.poi_route_funicular_ref;
+ break;
+ case LIGHT_RAIL:
+ typeResId = R.string.poi_route_light_rail_ref;
+ break;
+ case MONORAIL:
+ typeResId = R.string.poi_route_monorail_ref;
+ break;
+ case TROLLEYBUS:
+ typeResId = R.string.poi_route_trolleybus_ref;
+ break;
+ case RAILWAY:
+ typeResId = R.string.poi_route_railway_ref;
+ break;
+ case SUBWAY:
+ typeResId = R.string.poi_route_subway_ref;
+ break;
+ default:
+ typeResId = R.string.poi_filter_public_transport;
+ break;
+ }
+ ((TextView) view.findViewById(R.id.route_type_text)).setText(typeResId);
+
+ parent.addView(view);
+
+ rowBuilt();
+ }
+
+ private CollapsableView getCollapsableTransportStopRoutesView(final Context context, boolean collapsed) {
+ LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, false);
+
+ for (final TransportStopRoute r : routes) {
+ View.OnClickListener listener = new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ MapContextMenu mm = getMapActivity().getContextMenu();
+ PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE,
+ r.getDescription(getMapActivity().getMyApplication(), false));
+ mm.show(latLon, pd, r);
+ TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
+ stopsLayer.setRoute(r.route);
+ int cz = r.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox());
+ getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom());
+ }
+ };
+ buildTransportRouteRow(view, r, listener);
+ }
+
+ return new CollapsableView(view, collapsed);
+ }
+
protected CollapsableView getCollapsableTextView(Context context, boolean collapsed, String text) {
- final TextView textView = new TextView(context);
+ final TextViewEx textView = new TextViewEx(context);
textView.setVisibility(collapsed ? View.GONE : View.VISIBLE);
LinearLayout.LayoutParams llTextDescParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
- llTextDescParams.setMargins(dpToPx(72f), 0, dpToPx(40f), dpToPx(13f));
+ llTextDescParams.setMargins(dpToPx(64f), 0, dpToPx(40f), dpToPx(13f));
textView.setLayoutParams(llTextDescParams);
+ textView.setTypeface(FontCache.getRobotoRegular(context));
textView.setTextSize(16);
- textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
+ textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark));
textView.setText(text);
return new CollapsableView(textView, collapsed);
}
+ protected CollapsableView getCollapsableFavouritesView(final Context context, boolean collapsed, @NonNull final FavoriteGroup group, FavouritePoint selectedPoint) {
+ LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
+
+ List points = group.points;
+ for (int i = 0; i < points.size() && i < 10; i++) {
+ final FavouritePoint point = points.get(i);
+ boolean selected = selectedPoint != null && selectedPoint.equals(point);
+ TextViewEx button = buildButtonInCollapsableView(context, selected, false);
+ String name = point.getName();
+ button.setText(name);
+
+ if (!selected) {
+ button.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ LatLon latLon = new LatLon(point.getLatitude(), point.getLongitude());
+ PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName());
+ mapActivity.getContextMenu().show(latLon, pointDescription, point);
+ }
+ });
+ }
+ view.addView(button);
+ }
+
+ if (points.size() > 10) {
+ TextViewEx button = buildButtonInCollapsableView(context, false, true);
+ button.setText(context.getString(R.string.shared_string_show_all));
+ button.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ OsmAndAppCustomization appCustomization = app.getAppCustomization();
+ final Intent intent = new Intent(context, appCustomization.getFavoritesActivity());
+ intent.putExtra(FavoritesActivity.OPEN_FAVOURITES_TAB, true);
+ intent.putExtra(FavoritesActivity.GROUP_NAME_TO_SHOW, group.name);
+ intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
+ context.startActivity(intent);
+ }
+ });
+ view.addView(button);
+ }
+
+ return new CollapsableView(view, collapsed);
+ }
+
+ protected CollapsableView getCollapsableWaypointsView(final Context context, boolean collapsed, @NonNull final GPXFile gpxFile, WptPt selectedPoint) {
+ LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
+
+ List points = gpxFile.getPoints();
+ for (int i = 0; i < points.size() && i < 10; i++) {
+ final WptPt point = points.get(i);
+ boolean selected = selectedPoint != null && selectedPoint.equals(point);
+ TextViewEx button = buildButtonInCollapsableView(context, selected, false);
+ button.setText(point.name);
+
+ if (!selected) {
+ button.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ LatLon latLon = new LatLon(point.getLatitude(), point.getLongitude());
+ PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_WPT, point.name);
+ mapActivity.getContextMenu().show(latLon, pointDescription, point);
+ }
+ });
+ }
+ view.addView(button);
+ }
+
+ if (points.size() > 10) {
+ TextViewEx button = buildButtonInCollapsableView(context, false, true);
+ button.setText(context.getString(R.string.shared_string_show_all));
+ button.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ OsmAndAppCustomization appCustomization = app.getAppCustomization();
+ final Intent intent = new Intent(context, appCustomization.getTrackActivity());
+ intent.putExtra(TrackActivity.TRACK_FILE_NAME, gpxFile.path);
+ intent.putExtra(TrackActivity.OPEN_POINTS_TAB, true);
+ intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
+ context.startActivity(intent);
+ }
+ });
+ view.addView(button);
+ }
+
+ return new CollapsableView(view, collapsed);
+ }
+
protected CollapsableView getCollapsableWikiView(Context context, boolean collapsed) {
+ LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
+
+ for (final Amenity wiki : nearestWiki) {
+ TextViewEx button = buildButtonInCollapsableView(context, false, false);
+ String name = wiki.getName(preferredMapAppLang, transliterateNames);
+ button.setText(name);
+
+ button.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ LatLon latLon = new LatLon(wiki.getLocation().getLatitude(), wiki.getLocation().getLongitude());
+ PointDescription pointDescription = mapActivity.getMapLayers().getPoiMapLayer().getObjectName(wiki);
+ mapActivity.getContextMenu().show(latLon, pointDescription, wiki);
+ }
+ });
+ view.addView(button);
+ }
+
+ return new CollapsableView(view, collapsed);
+ }
+
+ protected LinearLayout buildCollapsableContentView(Context context, boolean collapsed, boolean needMargin) {
final LinearLayout view = new LinearLayout(context);
view.setOrientation(LinearLayout.VERTICAL);
view.setVisibility(collapsed ? View.GONE : View.VISIBLE);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
- llParams.setMargins(dpToPx(68f), 0, dpToPx(12f), dpToPx(13f));
- view.setLayoutParams(llParams);
-
- for (final Amenity wiki : nearestWiki) {
- AppCompatButton wikiButton = new AppCompatButton(
- new ContextThemeWrapper(view.getContext(), light ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme));
- LinearLayout.LayoutParams llWikiButtonParams =
- new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
- wikiButton.setLayoutParams(llWikiButtonParams);
- wikiButton.setPadding(dpToPx(14f), 0, dpToPx(14f), 0);
- wikiButton.setTextColor(app.getResources()
- .getColor(light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark));
- wikiButton.setText(wiki.getName(preferredMapAppLang, transliterateNames));
-
- wikiButton.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
- wikiButton.setSingleLine(true);
- wikiButton.setEllipsize(TextUtils.TruncateAt.END);
- wikiButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- PointDescription pointDescription = mapActivity.getMapLayers().getPoiMapLayer().getObjectName(wiki);
- mapActivity.getContextMenu().show(
- new LatLon(wiki.getLocation().getLatitude(), wiki.getLocation().getLongitude()),
- pointDescription, wiki);
- }
- });
- view.addView(wikiButton);
+ if (needMargin) {
+ llParams.setMargins(dpToPx(64f), 0, dpToPx(12f), 0);
}
+ view.setLayoutParams(llParams);
+ return view;
+ }
- return new CollapsableView(view, collapsed);
+ protected TextViewEx buildButtonInCollapsableView(Context context, boolean selected, boolean showAll) {
+ TextViewEx button = new TextViewEx(new ContextThemeWrapper(context, light ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme));
+ LinearLayout.LayoutParams llWikiButtonParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(36f));
+ llWikiButtonParams.setMargins(0, 0, 0, dpToPx(8f));
+ button.setLayoutParams(llWikiButtonParams);
+ button.setTypeface(FontCache.getRobotoRegular(context));
+ int bg;
+ if (selected) {
+ bg = light ? R.drawable.context_menu_controller_bg_light_selected: R.drawable.context_menu_controller_bg_dark_selected;
+ } else if (showAll) {
+ bg = light ? R.drawable.context_menu_controller_bg_light_show_all : R.drawable.context_menu_controller_bg_dark_show_all;
+ } else {
+ bg = light ? R.drawable.context_menu_controller_bg_light : R.drawable.context_menu_controller_bg_dark;
+ }
+ button.setBackgroundResource(bg);
+ button.setTextSize(14);
+ int paddingSides = dpToPx(10f);
+ button.setPadding(paddingSides, 0, paddingSides, 0);
+ if (!selected) {
+ ColorStateList buttonColorStateList = new ColorStateList(
+ new int[][] {
+ new int[]{android.R.attr.state_pressed},
+ new int[]{}
+ },
+ new int[] {
+ context.getResources().getColor(light ? R.color.ctx_menu_controller_button_text_color_light_p : R.color.ctx_menu_controller_button_text_color_dark_p),
+ context.getResources().getColor(light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n)
+ }
+ );
+ button.setTextColor(buttonColorStateList);
+ } else {
+ button.setTextColor(ContextCompat.getColor(context, light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark));
+ }
+ button.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
+ button.setSingleLine(true);
+ button.setEllipsize(TextUtils.TruncateAt.END);
+
+ return button;
}
protected boolean processNearstWiki() {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java
index 6000f3e106..42b4612988 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java
@@ -98,8 +98,7 @@ public abstract class MenuController extends BaseMenuController {
protected TitleButtonController leftTitleButtonController;
protected TitleButtonController rightTitleButtonController;
- protected TitleButtonController topRightTitleButtonController;
- protected TitleButtonController leftSubtitleButtonController;
+ protected TitleButtonController bottomTitleButtonController;
protected TitleButtonController leftDownloadButtonController;
protected TitleButtonController rightDownloadButtonController;
@@ -319,12 +318,8 @@ public abstract class MenuController extends BaseMenuController {
return rightTitleButtonController;
}
- public TitleButtonController getTopRightTitleButtonController() {
- return topRightTitleButtonController;
- }
-
- public TitleButtonController getLeftSubtitleButtonController() {
- return leftSubtitleButtonController;
+ public TitleButtonController getBottomTitleButtonController() {
+ return bottomTitleButtonController;
}
public TitleButtonController getLeftDownloadButtonController() {
@@ -355,7 +350,7 @@ public abstract class MenuController extends BaseMenuController {
return true;
}
- public boolean fabVisible() {
+ public boolean navigateButtonVisible() {
return true;
}
@@ -391,6 +386,10 @@ public abstract class MenuController extends BaseMenuController {
return false;
}
+ public boolean displayAdditionalTypeStrInHours() {
+ return false;
+ }
+
public int getLeftIconId() {
return 0;
}
@@ -403,12 +402,16 @@ public abstract class MenuController extends BaseMenuController {
return null;
}
+ public Drawable getAdditionalLineTypeIcon() {
+ return null;
+ }
+
public int getFavActionIconId() {
return R.drawable.map_action_fav_dark;
}
public int getFavActionStringId() {
- return R.string.shared_string_add_to_favorites;
+ return R.string.shared_string_add;
}
public int getWaypointActionIconId() {
@@ -429,6 +432,18 @@ public abstract class MenuController extends BaseMenuController {
return "";
}
+ public String getAdditionalTypeStr() {
+ return "";
+ }
+
+ public int getTimeStrColor() {
+ return 0;
+ }
+
+ public OpeningHoursInfo getOpeningHoursInfo() {
+ return null;
+ }
+
public String getCommonTypeStr() {
return "";
}
@@ -437,6 +452,10 @@ public abstract class MenuController extends BaseMenuController {
return pointDescription.getName();
}
+ public List getTransportStopRoutes() {
+ return null;
+ }
+
public void share(LatLon latLon, String title, String address) {
ShareMenu.show(latLon, title, address, getMapActivity());
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java
index 108aeb78b9..f5c5689798 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java
@@ -15,9 +15,12 @@ public abstract class MenuTitleController {
protected Drawable leftIcon;
protected String nameStr = "";
protected String typeStr = "";
+ protected String additionalTypeStr = "";
protected String commonTypeStr = "";
protected Drawable secondLineTypeIcon;
+ protected Drawable additionalLineTypeIcon;
protected String streetStr = "";
+ protected OpeningHoursInfo openingHoursInfo;
private AddressLookupRequest addressLookupRequest;
@@ -77,6 +80,10 @@ public abstract class MenuTitleController {
return secondLineTypeIcon;
}
+ public Drawable getAdditionalLineTypeIcon() {
+ return additionalLineTypeIcon;
+ }
+
public String getTypeStr() {
MenuController menuController = getMenuController();
if (menuController != null && menuController.needTypeStr()) {
@@ -86,6 +93,15 @@ public abstract class MenuTitleController {
}
}
+ public String getAdditionalTypeStr() {
+ MenuController menuController = getMenuController();
+ if (menuController != null) {
+ return additionalTypeStr;
+ } else {
+ return "";
+ }
+ }
+
public String getStreetStr() {
if (needStreetName()) {
if (searchingAddress()) {
@@ -98,6 +114,10 @@ public abstract class MenuTitleController {
}
}
+ public OpeningHoursInfo getOpeningHoursInfo() {
+ return openingHoursInfo;
+ }
+
protected void initTitle() {
searchAddressStr = PointDescription.getSearchAddressStr(getMapActivity());
addressNotFoundStr = PointDescription.getAddressNotFoundStr(getMapActivity());
@@ -111,6 +131,8 @@ public abstract class MenuTitleController {
if (needStreetName()) {
acquireStreetName();
}
+
+ acquireOpeningHoursInfo();
}
protected boolean needStreetName() {
@@ -128,11 +150,13 @@ public abstract class MenuTitleController {
leftIconId = 0;
leftIcon = null;
secondLineTypeIcon = null;
+ additionalLineTypeIcon = null;
if (menuController != null) {
leftIconId = menuController.getLeftIconId();
leftIcon = menuController.getLeftIcon();
secondLineTypeIcon = menuController.getSecondLineTypeIcon();
+ additionalLineTypeIcon = menuController.getAdditionalLineTypeIcon();
}
}
@@ -146,6 +170,7 @@ public abstract class MenuTitleController {
if (menuController != null) {
nameStr = menuController.getNameStr();
typeStr = menuController.getTypeStr();
+ additionalTypeStr = menuController.getAdditionalTypeStr();
commonTypeStr = menuController.getCommonTypeStr();
}
@@ -186,6 +211,13 @@ public abstract class MenuTitleController {
getMapActivity().getMyApplication().getGeocodingLookupService().lookupAddress(addressLookupRequest);
}
+ protected void acquireOpeningHoursInfo() {
+ MenuController menuController = getMenuController();
+ if (menuController != null) {
+ openingHoursInfo = menuController.getOpeningHoursInfo();
+ }
+ }
+
protected void onSearchAddressDone() {
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/OpeningHoursInfo.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/OpeningHoursInfo.java
new file mode 100644
index 0000000000..3802a21c52
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/OpeningHoursInfo.java
@@ -0,0 +1,79 @@
+package net.osmand.plus.mapcontextmenu;
+
+import net.osmand.util.Algorithms;
+
+public class OpeningHoursInfo {
+
+ private boolean opened;
+ private boolean opened24_7;
+ private String openingTime = "";
+ private String nearToOpeningTime = "";
+ private String closingTime = "";
+ private String nearToClosingTime = "";
+ private String openingDay = "";
+
+ public boolean isOpened() {
+ return opened;
+ }
+
+ public void setOpened(boolean opened) {
+ this.opened = opened;
+ }
+
+ public boolean isOpened24_7() {
+ return opened24_7;
+ }
+
+ public void setOpened24_7(boolean opened24_7) {
+ this.opened24_7 = opened24_7;
+ }
+
+ public String getOpeningTime() {
+ return openingTime;
+ }
+
+ public void setOpeningTime(String openFromTime) {
+ this.openingTime = openFromTime;
+ }
+
+ public String getNearToOpeningTime() {
+ return nearToOpeningTime;
+ }
+
+ public void setNearToOpeningTime(String nearToOpeningTime) {
+ this.nearToOpeningTime = nearToOpeningTime;
+ }
+
+ public String getClosingTime() {
+ return closingTime;
+ }
+
+ public void setClosingTime(String closingTime) {
+ this.closingTime = closingTime;
+ }
+
+ public String getNearToClosingTime() {
+ return nearToClosingTime;
+ }
+
+ public void setNearToClosingTime(String nearToClosingTime) {
+ this.nearToClosingTime = nearToClosingTime;
+ }
+
+ public String getOpeningDay() {
+ return openingDay;
+ }
+
+ public void setOpeningDay(String openingDay) {
+ this.openingDay = openingDay;
+ }
+
+ public boolean containsInfo() {
+ return opened24_7
+ || !Algorithms.isEmpty(openingTime)
+ || !Algorithms.isEmpty(nearToOpeningTime)
+ || !Algorithms.isEmpty(closingTime)
+ || !Algorithms.isEmpty(nearToClosingTime)
+ || !Algorithms.isEmpty(openingDay);
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java
new file mode 100644
index 0000000000..fbc1da30a4
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java
@@ -0,0 +1,34 @@
+package net.osmand.plus.mapcontextmenu;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+
+import net.osmand.plus.R;
+import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute;
+
+import java.util.List;
+
+public class TransportStopRouteAdapter extends ArrayAdapter {
+
+ public TransportStopRouteAdapter(@NonNull Context context, @NonNull List objects) {
+ super(context, 0, objects);
+ }
+
+ @NonNull
+ @Override
+ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
+ if (convertView == null) {
+ convertView = LayoutInflater.from(getContext()).inflate(R.layout.transport_stop_route_item, parent, false);
+ }
+
+ ((TextView) convertView.findViewById(R.id.transport_stop_route_text)).setText(getItem(position).route.getRef());
+
+ return convertView;
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java
index 8d1bdeef6d..67a88c9b70 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java
@@ -2,11 +2,11 @@ package net.osmand.plus.mapcontextmenu.builders;
import android.content.DialogInterface;
import android.content.Intent;
-import android.graphics.Color;
+import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.support.v7.app.AlertDialog;
-import android.support.v7.widget.AppCompatButton;
+import android.support.v7.view.ContextThemeWrapper;
import android.text.Html;
import android.text.SpannableString;
import android.text.TextUtils;
@@ -29,9 +29,11 @@ import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.plus.views.POIMapLayer;
+import net.osmand.plus.widgets.TextViewEx;
import net.osmand.util.Algorithms;
import net.osmand.util.OpeningHoursParser;
@@ -60,18 +62,18 @@ public class AmenityMenuBuilder extends MenuBuilder {
private void buildRow(View view, int iconId, String text, String textPrefix,
boolean collapsable, final CollapsableView collapsableView,
int textColor, boolean isWiki, boolean isText, boolean needLinks,
- boolean isPhoneNumber, boolean isUrl) {
- buildRow(view, getRowIcon(iconId), text, textPrefix, collapsable, collapsableView, textColor,
- isWiki, isText, needLinks, isPhoneNumber, isUrl);
+ boolean isPhoneNumber, boolean isUrl, boolean matchWidthDivider) {
+ buildRow(view, iconId == 0 ? null : getRowIcon(iconId), text, textPrefix, collapsable, collapsableView, textColor,
+ isWiki, isText, needLinks, isPhoneNumber, isUrl, matchWidthDivider);
}
protected void buildRow(final View view, Drawable icon, final String text, final String textPrefix,
boolean collapsable, final CollapsableView collapsableView,
int textColor, boolean isWiki, boolean isText, boolean needLinks,
- boolean isPhoneNumber, boolean isUrl) {
+ boolean isPhoneNumber, boolean isUrl, boolean matchWidthDivider) {
if (!isFirstRow()) {
- buildRowDivider(view, false);
+ buildRowDivider(view);
}
final String txt;
@@ -102,20 +104,22 @@ public class AmenityMenuBuilder extends MenuBuilder {
baseView.addView(ll);
// Icon
- LinearLayout llIcon = new LinearLayout(view.getContext());
- llIcon.setOrientation(LinearLayout.HORIZONTAL);
- llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(72f), dpToPx(48f)));
- llIcon.setGravity(Gravity.CENTER_VERTICAL);
- ll.addView(llIcon);
+ if (icon != null) {
+ LinearLayout llIcon = new LinearLayout(view.getContext());
+ llIcon.setOrientation(LinearLayout.HORIZONTAL);
+ llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(64f), dpToPx(48f)));
+ llIcon.setGravity(Gravity.CENTER_VERTICAL);
+ ll.addView(llIcon);
- ImageView iconView = new ImageView(view.getContext());
- LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(dpToPx(24f), dpToPx(24f));
- llIconParams.setMargins(dpToPx(16f), dpToPx(12f), dpToPx(32f), dpToPx(12f));
- llIconParams.gravity = Gravity.CENTER_VERTICAL;
- iconView.setLayoutParams(llIconParams);
- iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
- iconView.setImageDrawable(icon);
- llIcon.addView(iconView);
+ ImageView iconView = new ImageView(view.getContext());
+ LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(dpToPx(24f), dpToPx(24f));
+ llIconParams.setMargins(dpToPx(16f), dpToPx(12f), dpToPx(24f), dpToPx(12f));
+ llIconParams.gravity = Gravity.CENTER_VERTICAL;
+ iconView.setLayoutParams(llIconParams);
+ iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
+ iconView.setImageDrawable(icon);
+ llIcon.addView(iconView);
+ }
// Text
LinearLayout llText = new LinearLayout(view.getContext());
@@ -124,7 +128,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
TextView textView = new TextView(view.getContext());
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
- llTextParams.setMargins(0, collapsable ? dpToPx(13f) : dpToPx(8f), 0, collapsable ? dpToPx(13f) : dpToPx(8f));
+ llTextParams.setMargins(icon == null ? dpToPx(16f) : 0, collapsable ? dpToPx(13f) : dpToPx(8f), 0, collapsable ? dpToPx(13f) : dpToPx(8f));
textView.setLayoutParams(llTextParams);
textView.setTextSize(16);
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
@@ -175,7 +179,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
ll.addView(llIconCollapse);
LinearLayout.LayoutParams llIconCollapseParams = new LinearLayout.LayoutParams(dpToPx(24f), dpToPx(24f));
- llIconCollapseParams.setMargins(0, dpToPx(12f), dpToPx(32f), dpToPx(12f));
+ llIconCollapseParams.setMargins(0, dpToPx(12f), dpToPx(24f), dpToPx(12f));
llIconCollapseParams.gravity = Gravity.CENTER_VERTICAL;
iconViewCollapse.setLayoutParams(llIconCollapseParams);
iconViewCollapse.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
@@ -204,21 +208,41 @@ public class AmenityMenuBuilder extends MenuBuilder {
}
if (isWiki) {
- AppCompatButton wikiButton = new AppCompatButton(view.getContext());
- LinearLayout.LayoutParams llWikiButtonParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
- llWikiButtonParams.setMargins(0, dpToPx(10f), dpToPx(2f), dpToPx(10f));
- wikiButton.setLayoutParams(llWikiButtonParams);
- wikiButton.setPadding(dpToPx(14f), 0, dpToPx(14f), 0);
- wikiButton.setBackgroundResource(R.drawable.blue_button_drawable);
- wikiButton.setTextColor(Color.WHITE);
- wikiButton.setText(app.getString(R.string.read_more));
- wikiButton.setOnClickListener(new View.OnClickListener() {
+ TextViewEx button = new TextViewEx(new ContextThemeWrapper(view.getContext(), light ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme));
+ LinearLayout.LayoutParams llWikiButtonParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, dpToPx(36f));
+ llWikiButtonParams.setMargins(dpToPx(16f), 0, 0, dpToPx(16f));
+ button.setLayoutParams(llWikiButtonParams);
+ button.setTypeface(FontCache.getRobotoMedium(app));
+ button.setBackgroundResource(light ? R.drawable.context_menu_controller_bg_light : R.drawable.context_menu_controller_bg_dark);
+ button.setTextSize(14);
+ int paddingSides = dpToPx(10f);
+ button.setPadding(paddingSides, 0, paddingSides, 0);
+ ColorStateList buttonColorStateList = new ColorStateList(
+ new int[][] {
+ new int[]{android.R.attr.state_pressed},
+ new int[]{}
+ },
+ new int[] {
+ view.getResources().getColor(light ? R.color.ctx_menu_controller_button_text_color_light_p : R.color.ctx_menu_controller_button_text_color_dark_p),
+ view.getResources().getColor(light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n)
+ }
+ );
+ button.setTextColor(buttonColorStateList);
+ button.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
+ button.setSingleLine(true);
+ button.setEllipsize(TextUtils.TruncateAt.END);
+ button.setOnClickListener(new View.OnClickListener() {
@Override
- public void onClick(View v) {
+ public void onClick(View view) {
POIMapLayer.showWikipediaDialog(view.getContext(), app, amenity);
}
});
- llText.addView(wikiButton);
+ button.setAllCaps(true);
+ button.setText(R.string.context_menu_read_full_article);
+ Drawable compoundDrawable = app.getIconsCache().getIcon(R.drawable.ic_action_note_dark, light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n);
+ button.setCompoundDrawablesWithIntrinsicBounds(compoundDrawable, null, null, null);
+ button.setCompoundDrawablePadding(dpToPx(8f));
+ llText.addView(button);
}
((LinearLayout) view).addView(baseView);
@@ -273,6 +297,8 @@ public class AmenityMenuBuilder extends MenuBuilder {
}
rowBuilt();
+
+ setDividerWidth(matchWidthDivider);
}
@Override
@@ -284,7 +310,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
List descriptions = new LinkedList<>();
for (Map.Entry e : amenity.getAdditionalInfo().entrySet()) {
- int iconId;
+ int iconId = 0;
Drawable icon = null;
int textColor = 0;
String key = e.getKey();
@@ -322,7 +348,6 @@ public class AmenityMenuBuilder extends MenuBuilder {
if (amenity.getType().isWiki()) {
if (!hasWiki) {
- iconId = R.drawable.ic_action_note_dark;
String lng = amenity.getContentLanguage("content", preferredLang, "en");
if (Algorithms.isEmpty(lng)) {
lng = "en";
@@ -378,6 +403,8 @@ public class AmenityMenuBuilder extends MenuBuilder {
sb.append(poiTypes.getPoiTranslation("cuisine_" + c).toLowerCase());
}
vl = sb.toString();
+ } else if (key.contains(Amenity.ROUTE)) {
+ continue;
} else {
if (key.contains(Amenity.DESCRIPTION)) {
iconId = R.drawable.ic_action_note_dark;
@@ -421,15 +448,16 @@ public class AmenityMenuBuilder extends MenuBuilder {
isUrl = true;
}
+ boolean matchWidthDivider = !isDescription && isWiki;
if (isDescription) {
descriptions.add(new AmenityInfoRow(key, R.drawable.ic_action_note_dark, textPrefix,
- vl, collapsable, collapsableView, 0, false, true, true, 0, "", false, false));
+ vl, collapsable, collapsableView, 0, false, true, true, 0, "", false, false, matchWidthDivider));
} else if (icon != null) {
infoRows.add(new AmenityInfoRow(key, icon, textPrefix, vl, collapsable, collapsableView,
- textColor, isWiki, isText, needLinks, poiTypeOrder, poiTypeKeyName, isPhoneNumber, isUrl));
+ textColor, isWiki, isText, needLinks, poiTypeOrder, poiTypeKeyName, isPhoneNumber, isUrl, matchWidthDivider));
} else {
infoRows.add(new AmenityInfoRow(key, iconId, textPrefix, vl, collapsable, collapsableView,
- textColor, isWiki, isText, needLinks, poiTypeOrder, poiTypeKeyName, isPhoneNumber, isUrl));
+ textColor, isWiki, isText, needLinks, poiTypeOrder, poiTypeKeyName, isPhoneNumber, isUrl, matchWidthDivider));
}
}
@@ -472,7 +500,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
AmenityInfoRow wikiInfo = new AmenityInfoRow(
"nearest_wiki", R.drawable.ic_action_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size() + ")", true,
getCollapsableWikiView(view.getContext(), true),
- 0, false, false, false, 1000, null, false, false);
+ 0, false, false, false, 1000, null, false, false, false);
buildAmenityRow(view, wikiInfo);
}
@@ -489,11 +517,11 @@ public class AmenityMenuBuilder extends MenuBuilder {
link = "https://www.openstreetmap.org/way/";
}
buildRow(view, R.drawable.ic_action_info_dark, link + (amenity.getId() >> 1),
- 0, false, null, true, 0, true, null);
+ 0, false, null, true, 0, true, null, false);
}
buildRow(view, R.drawable.ic_action_get_my_location, PointDescription.getLocationName(app,
amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(), true)
- .replaceAll("\n", " "), 0, false, null, false, 0, false, null);
+ .replaceAll("\n", " "), 0, false, null, false, 0, false, null, false);
//if (st.COORDINATES_FORMAT.get() != PointDescription.OLC_FORMAT)
// buildRow(view, R.drawable.ic_action_get_my_location, PointDescription.getLocationOlcName(
// amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude())
@@ -504,10 +532,10 @@ public class AmenityMenuBuilder extends MenuBuilder {
public void buildAmenityRow(View view, AmenityInfoRow info) {
if (info.icon != null) {
buildRow(view, info.icon, info.text, info.textPrefix, info.collapsable, info.collapsableView,
- info.textColor, info.isWiki, info.isText, info.needLinks, info.isPhoneNumber, info.isUrl);
- } else if (info.iconId != 0) {
+ info.textColor, info.isWiki, info.isText, info.needLinks, info.isPhoneNumber, info.isUrl, info.matchWidthDivider);
+ } else {
buildRow(view, info.iconId, info.text, info.textPrefix, info.collapsable, info.collapsableView,
- info.textColor, info.isWiki, info.isText, info.needLinks, info.isPhoneNumber, info.isUrl);
+ info.textColor, info.isWiki, info.isText, info.needLinks, info.isPhoneNumber, info.isUrl, info.matchWidthDivider);
}
}
@@ -542,11 +570,12 @@ public class AmenityMenuBuilder extends MenuBuilder {
private boolean isUrl;
private int order;
private String name;
+ private boolean matchWidthDivider;
public AmenityInfoRow(String key, Drawable icon, String textPrefix, String text,
boolean collapsable, CollapsableView collapsableView,
int textColor, boolean isWiki, boolean isText, boolean needLinks,
- int order, String name, boolean isPhoneNumber, boolean isUrl) {
+ int order, String name, boolean isPhoneNumber, boolean isUrl, boolean matchWidthDivider) {
this.key = key;
this.icon = icon;
this.textPrefix = textPrefix;
@@ -561,12 +590,13 @@ public class AmenityMenuBuilder extends MenuBuilder {
this.name = name;
this.isPhoneNumber = isPhoneNumber;
this.isUrl = isUrl;
+ this.matchWidthDivider = matchWidthDivider;
}
public AmenityInfoRow(String key, int iconId, String textPrefix, String text,
boolean collapsable, CollapsableView collapsableView,
int textColor, boolean isWiki, boolean isText, boolean needLinks,
- int order, String name, boolean isPhoneNumber, boolean isUrl) {
+ int order, String name, boolean isPhoneNumber, boolean isUrl, boolean matchWidthDivider) {
this.key = key;
this.iconId = iconId;
this.textPrefix = textPrefix;
@@ -581,6 +611,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
this.name = name;
this.isPhoneNumber = isPhoneNumber;
this.isUrl = isUrl;
+ this.matchWidthDivider = matchWidthDivider;
}
}
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java
index e430ac5a0c..05097d55f2 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java
@@ -1,18 +1,25 @@
package net.osmand.plus.mapcontextmenu.builders;
+import android.graphics.Color;
+import android.text.TextUtils;
+import android.view.Gravity;
import android.view.View;
+import android.widget.LinearLayout;
import net.osmand.ResultMatcher;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.Amenity;
import net.osmand.data.FavouritePoint;
+import net.osmand.data.LatLon;
+import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect;
import net.osmand.data.TransportStop;
import net.osmand.osm.PoiCategory;
+import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
-import net.osmand.plus.mapillary.MapillaryPlugin;
+import net.osmand.plus.widgets.TextViewEx;
import net.osmand.util.MapUtils;
import java.util.List;
@@ -60,6 +67,21 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
builder.setLight(light);
builder.buildInternal(view);
}
+ buildGroupFavouritesView(view);
+ }
+
+ private void buildGroupFavouritesView(View view) {
+ FavoriteGroup favoriteGroup = app.getFavorites().getGroup(fav);
+ List groupFavourites = favoriteGroup.points;
+ if (groupFavourites.size() > 0) {
+ int color = favoriteGroup.color == 0 || favoriteGroup.color == Color.BLACK ? view.getResources().getColor(R.color.color_favorite) : favoriteGroup.color;
+ int disabledColor = light ? R.color.secondary_text_light : R.color.secondary_text_dark;
+ color = favoriteGroup.visible ? (color | 0xff000000) : view.getResources().getColor(disabledColor);
+ String name = view.getContext().getString(R.string.context_menu_points_of_group);
+ buildRow(view, app.getIconsCache().getPaintedIcon(R.drawable.ic_action_folder, color), name, 0, null,
+ true, getCollapsableFavouritesView(view.getContext(), true, favoriteGroup, fav),
+ false, 0, false, null, false);
+ }
}
private Amenity findAmenity(String nameStringEn, double lat, double lon) {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/GpxItemMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/GpxItemMenuBuilder.java
index 3e60a8952d..10d61daf3e 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/GpxItemMenuBuilder.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/GpxItemMenuBuilder.java
@@ -34,7 +34,7 @@ public class GpxItemMenuBuilder extends MenuBuilder {
String description = GpxUiHelper.getDescription(app, item.analysis, false);
String[] lines = description.split("\n");
for (String line : lines) {
- buildRow(view, R.drawable.ic_action_info_dark, line, 0, false, null, false, 0, false, null);
+ buildRow(view, R.drawable.ic_action_info_dark, line, 0, false, null, false, 0, false, null, false);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java
index 94de99c006..9553e96d39 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java
@@ -1,8 +1,14 @@
package net.osmand.plus.mapcontextmenu.builders;
+import android.support.annotation.ColorInt;
+import android.support.annotation.NonNull;
+import android.support.v4.content.ContextCompat;
import android.view.View;
+import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.WptPt;
+import net.osmand.plus.GpxSelectionHelper;
+import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@@ -11,8 +17,10 @@ import net.osmand.plus.mapillary.MapillaryPlugin;
import net.osmand.plus.views.POIMapLayer;
import net.osmand.util.Algorithms;
+import java.io.File;
import java.text.DateFormat;
import java.util.Date;
+import java.util.List;
public class WptPtMenuBuilder extends MenuBuilder {
@@ -36,23 +44,23 @@ public class WptPtMenuBuilder extends MenuBuilder {
DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(view.getContext());
Date date = new Date(wpt.time);
buildRow(view, R.drawable.ic_action_data,
- dateFormat.format(date) + " — " + timeFormat.format(date), 0, false, null, false, 0, false, null);
+ dateFormat.format(date) + " — " + timeFormat.format(date), 0, false, null, false, 0, false, null, false);
}
if (wpt.speed > 0) {
buildRow(view, R.drawable.ic_action_speed,
- OsmAndFormatter.getFormattedSpeed((float)wpt.speed, app), 0, false, null, false, 0, false, null);
+ OsmAndFormatter.getFormattedSpeed((float)wpt.speed, app), 0, false, null, false, 0, false, null, false);
}
if (!Double.isNaN(wpt.ele)) {
buildRow(view, R.drawable.ic_action_altitude,
- OsmAndFormatter.getFormattedDistance((float) wpt.ele, app), 0, false, null, false, 0, false, null);
+ OsmAndFormatter.getFormattedDistance((float) wpt.ele, app), 0, false, null, false, 0, false, null, false);
}
if (!Double.isNaN(wpt.hdop)) {
buildRow(view, R.drawable.ic_action_gps_info,
Algorithms.capitalizeFirstLetterAndLowercase(app.getString(R.string.plugin_distance_point_hdop)) + ": " + (int)wpt.hdop, 0,
- false, null, false, 0, false, null);
+ false, null, false, 0, false, null, false);
}
if (!Algorithms.isEmpty(wpt.desc)) {
- final View row = buildRow(view, R.drawable.ic_action_note_dark, wpt.desc, 0, false, null, true, 10, false, null);
+ final View row = buildRow(view, R.drawable.ic_action_note_dark, wpt.desc, 0, false, null, true, 10, false, null, false);
row.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -63,7 +71,7 @@ public class WptPtMenuBuilder extends MenuBuilder {
}
if (!Algorithms.isEmpty(wpt.comment)) {
final View rowc = buildRow(view, R.drawable.ic_action_note_dark, wpt.comment, 0,
- false, null, true, 10, false, null);
+ false, null, true, 10, false, null, false);
rowc.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -73,6 +81,44 @@ public class WptPtMenuBuilder extends MenuBuilder {
});
}
+ buildWaypointsView(view);
buildPlainMenuItems(view);
}
+
+ private void buildWaypointsView(View view) {
+ GpxSelectionHelper gpxSelectionHelper = app.getSelectedGpxHelper();
+ SelectedGpxFile selectedGpxFile = gpxSelectionHelper.getSelectedGPXFile(wpt);
+ if (selectedGpxFile != null) {
+ List points = selectedGpxFile.getGpxFile().getPoints();
+ GPXUtilities.GPXFile gpx = selectedGpxFile.getGpxFile();
+ if (points.size() > 0) {
+ String title = view.getContext().getString(R.string.context_menu_points_of_group);
+ File file = new File(gpx.path);
+ String gpxName = file.getName().replace(".gpx", "").replace("/", " ").replace("_", " ");
+ int color = getPointColor(wpt, getFileColor(selectedGpxFile));
+ buildRow(view, app.getIconsCache().getPaintedIcon(R.drawable.ic_type_waypoints_group, color), title, 0, gpxName,
+ true, getCollapsableWaypointsView(view.getContext(), true, gpx, wpt),
+ false, 0, false, null, false);
+ }
+ }
+ }
+
+ private int getFileColor(@NonNull SelectedGpxFile g) {
+ return g.getColor() == 0 ? ContextCompat.getColor(app, R.color.gpx_color_point) : g.getColor();
+ }
+
+ @ColorInt
+ private int getPointColor(WptPt o, @ColorInt int fileColor) {
+ boolean visit = isPointVisited(o);
+ return visit ? ContextCompat.getColor(app, R.color.color_ok) : o.getColor(fileColor);
+ }
+
+ private boolean isPointVisited(WptPt o) {
+ boolean visit = false;
+ String visited = o.getExtensionsToRead().get("VISITED_KEY");
+ if (visited != null && !visited.equals("0")) {
+ visit = true;
+ }
+ return visit;
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java
index 1b4a2e5ce4..67529b57f5 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java
@@ -17,15 +17,19 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController;
+import net.osmand.plus.mapcontextmenu.OpeningHoursInfo;
import net.osmand.plus.mapcontextmenu.builders.AmenityMenuBuilder;
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute;
import net.osmand.plus.render.RenderingIcons;
import net.osmand.plus.resources.TransportIndexRepository;
+import net.osmand.plus.views.POIMapLayer;
import net.osmand.plus.views.TransportStopsLayer;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
+import net.osmand.util.OpeningHoursParser;
import java.util.ArrayList;
+import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
@@ -38,7 +42,7 @@ public class AmenityMenuController extends MenuController {
private MapMarker marker;
- public AmenityMenuController(MapActivity mapActivity, PointDescription pointDescription, Amenity amenity) {
+ public AmenityMenuController(final MapActivity mapActivity, PointDescription pointDescription, final Amenity amenity) {
super(new AmenityMenuBuilder(mapActivity, amenity), pointDescription, mapActivity);
this.amenity = amenity;
if (amenity.getType().getKeyName().equals("transportation")) {
@@ -62,7 +66,16 @@ public class AmenityMenuController extends MenuController {
MapMarkerMenuController markerMenuController =
new MapMarkerMenuController(mapActivity, marker.getPointDescription(mapActivity), marker);
leftTitleButtonController = markerMenuController.getLeftTitleButtonController();
- leftSubtitleButtonController = markerMenuController.getLeftSubtitleButtonController();
+ rightTitleButtonController = markerMenuController.getRightTitleButtonController();
+ } else if (amenity.getType().isWiki()) {
+ leftTitleButtonController = new TitleButtonController() {
+ @Override
+ public void buttonPressed() {
+ POIMapLayer.showWikipediaDialog(mapActivity, mapActivity.getMyApplication(), amenity);
+ }
+ };
+ leftTitleButtonController.caption = getMapActivity().getString(R.string.context_menu_read_article);
+ leftTitleButtonController.leftIcon = getIcon(R.drawable.ic_action_note_dark, isLight() ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n);
}
}
@@ -132,6 +145,11 @@ public class AmenityMenuController extends MenuController {
return getTypeStr(amenity);
}
+ @Override
+ public OpeningHoursInfo getOpeningHoursInfo() {
+ return processOpeningHours(amenity);
+ }
+
public static String getTypeStr(Amenity amenity) {
PoiCategory pc = amenity.getType();
PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType());
@@ -144,37 +162,41 @@ public class AmenityMenuController extends MenuController {
return typeStr;
}
+ public static OpeningHoursInfo processOpeningHours(Amenity amenity) {
+ OpeningHoursParser.OpeningHours openingHours = OpeningHoursParser.parseOpenedHours(amenity.getOpeningHours());
+ if (openingHours == null) {
+ return null;
+ } else {
+ OpeningHoursInfo info = new OpeningHoursInfo();
+ Calendar cal = Calendar.getInstance();
+ boolean opened = openingHours.isOpenedForTime(cal);
+ info.setOpened(opened);
+ if (opened) {
+ info.setOpened24_7(openingHours.isOpened24_7());
+ info.setClosingTime(openingHours.getClosingTime(cal));
+ info.setNearToClosingTime(openingHours.getNearToClosingTime(cal));
+ } else {
+ info.setOpeningTime(openingHours.getOpeningTime(cal));
+ info.setNearToOpeningTime(openingHours.getNearToOpeningTime(cal));
+ info.setOpeningDay(openingHours.getOpeningDay(cal));
+ }
+ return info;
+ }
+ }
+
@Override
public String getCommonTypeStr() {
PoiCategory pc = amenity.getType();
return pc.getTranslation();
}
+ @Override
+ public List getTransportStopRoutes() {
+ return routes;
+ }
+
@Override
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
- addPlainMenuItems(amenity, typeStr, builder);
- for (final TransportStopRoute r : routes) {
- View.OnClickListener listener = new View.OnClickListener() {
- @Override
- public void onClick(View arg0) {
- MapContextMenu mm = getMapActivity().getContextMenu();
- PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE,
- r.getDescription(getMapActivity().getMyApplication(), false));
- mm.show(amenity.getLocation(), pd, r);
- TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
- stopsLayer.setRoute(r.route);
- int cz = r.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox());
- getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom());
- }
- };
- if (r.type == null) {
- builder.addPlainMenuItem(R.drawable.ic_action_polygom_dark, r.getDescription(getMapActivity().getMyApplication(), true),
- false, false, listener);
- } else {
- builder.addPlainMenuItem(r.type.getResourceId(), r.getDescription(getMapActivity().getMyApplication(), true),
- false, false, listener);
- }
- }
}
public static void addPlainMenuItems(Amenity amenity, String typeStr, MenuBuilder builder) {
@@ -223,21 +245,34 @@ public class AmenityMenuController extends MenuController {
return o1.desc.compareTo(o2.desc);
}
});
+
+ builder.setRoutes(routes);
}
private void addRoutes(boolean useEnglishNames, TransportIndexRepository t, TransportStop s, int dist) {
Collection rts = t.getRouteForStop(s);
if (rts != null) {
for (TransportRoute rs : rts) {
- TransportStopController.TransportStopType type = TransportStopController.TransportStopType.findType(rs.getType());
- TransportStopRoute r = new TransportStopRoute();
- r.type = type;
- r.desc = rs.getRef() + " " + (useEnglishNames ? rs.getEnName(true) : rs.getName());
- r.route = rs;
- r.stop = s;
- r.distance = dist;
- this.routes.add(r);
+ if (!containsRef(rs)) {
+ TransportStopController.TransportStopType type = TransportStopController.TransportStopType.findType(rs.getType());
+ TransportStopRoute r = new TransportStopRoute();
+ r.type = type;
+ r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName();
+ r.route = rs;
+ r.stop = s;
+ r.distance = dist;
+ this.routes.add(r);
+ }
}
}
}
+
+ private boolean containsRef(TransportRoute transportRoute) {
+ for (TransportStopRoute route : routes) {
+ if (route.route.getRef().equals(transportRoute.getRef())) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java
index 96dec7c05c..81da068960 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java
@@ -14,15 +14,20 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.mapcontextmenu.MenuController;
+import net.osmand.plus.mapcontextmenu.OpeningHoursInfo;
import net.osmand.plus.mapcontextmenu.builders.FavouritePointMenuBuilder;
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor;
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragment;
import net.osmand.util.Algorithms;
+import java.util.ArrayList;
+import java.util.List;
+
public class FavouritePointMenuController extends MenuController {
private FavouritePoint fav;
private MapMarker mapMarker;
+ private List routes = new ArrayList<>();
public FavouritePointMenuController(MapActivity mapActivity, PointDescription pointDescription, final FavouritePoint fav) {
super(new FavouritePointMenuBuilder(mapActivity, fav), pointDescription, mapActivity);
@@ -37,7 +42,13 @@ public class FavouritePointMenuController extends MenuController {
MapMarkerMenuController markerMenuController =
new MapMarkerMenuController(mapActivity, mapMarker.getPointDescription(mapActivity), mapMarker);
leftTitleButtonController = markerMenuController.getLeftTitleButtonController();
- leftSubtitleButtonController = markerMenuController.getLeftSubtitleButtonController();
+ rightTitleButtonController = markerMenuController.getRightTitleButtonController();
+ }
+ if (getObject() instanceof TransportStop) {
+ TransportStop stop = (TransportStop) getObject();
+ TransportStopController transportStopController = new TransportStopController(getMapActivity(), pointDescription, stop);
+ routes = transportStopController.processTransportStop();
+ builder.setRoutes(routes);
}
}
@@ -53,6 +64,11 @@ public class FavouritePointMenuController extends MenuController {
return fav;
}
+ @Override
+ public List getTransportStopRoutes() {
+ return routes;
+ }
+
@Override
public boolean handleSingleTapOnMap() {
Fragment fragment = getMapActivity().getSupportFragmentManager().findFragmentByTag(FavoritePointEditor.TAG);
@@ -90,7 +106,7 @@ public class FavouritePointMenuController extends MenuController {
@Override
public Drawable getSecondLineTypeIcon() {
- return getIcon(R.drawable.map_small_group);
+ return getIcon(R.drawable.ic_action_group_name_16);
}
@Override
@@ -100,7 +116,7 @@ public class FavouritePointMenuController extends MenuController {
@Override
public int getFavActionStringId() {
- return R.string.favourites_context_menu_edit;
+ return R.string.shared_string_edit;
}
@Override
@@ -123,15 +139,18 @@ public class FavouritePointMenuController extends MenuController {
if (originObject instanceof Amenity) {
Amenity amenity = (Amenity) originObject;
AmenityMenuController.addPlainMenuItems(amenity, AmenityMenuController.getTypeStr(amenity), builder);
- } else if (originObject instanceof TransportStop) {
- TransportStop stop = (TransportStop) originObject;
- TransportStopController transportStopController =
- new TransportStopController(getMapActivity(), pointDescription, stop);
- transportStopController.addPlainMenuItems(builder, latLon);
- addMyLocationToPlainItems(latLon);
}
} else {
addMyLocationToPlainItems(latLon);
}
}
+
+ @Override
+ public OpeningHoursInfo getOpeningHoursInfo() {
+ Object originObject = getBuilder().getOriginObject();
+ if (originObject instanceof Amenity) {
+ return AmenityMenuController.processOpeningHours((Amenity) originObject);
+ }
+ return null;
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java
index 3f17551e8f..4cb6cf67fb 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java
@@ -134,7 +134,7 @@ public class MapDataMenuController extends MenuController {
rightDownloadButtonController.caption = getMapActivity().getString(R.string.shared_string_delete);
rightDownloadButtonController.leftIconId = R.drawable.ic_action_delete_dark;
- topRightTitleButtonController = new TitleButtonController() {
+ bottomTitleButtonController = new TitleButtonController() {
@Override
public void buttonPressed() {
getMapActivity().getContextMenu().close();
@@ -158,7 +158,7 @@ public class MapDataMenuController extends MenuController {
mapActivity.getContextMenu().getLatLon(), selectedObjects);
}
};
- topRightTitleButtonController.caption = getMapActivity().getString(R.string.download_select_map_types);
+ bottomTitleButtonController.caption = getMapActivity().getString(R.string.download_select_map_types);
titleProgressController = new TitleProgressController() {
@Override
@@ -300,7 +300,7 @@ public class MapDataMenuController extends MenuController {
}
@Override
- public boolean fabVisible() {
+ public boolean navigateButtonVisible() {
return false;
}
@@ -350,7 +350,7 @@ public class MapDataMenuController extends MenuController {
}
rightDownloadButtonController.visible = downloaded;
- topRightTitleButtonController.visible = (otherIndexItems != null && otherIndexItems.size() > 0)
+ bottomTitleButtonController.visible = (otherIndexItems != null && otherIndexItems.size() > 0)
|| (otherLocalIndexInfos != null && otherLocalIndexInfos.size() > 0);
boolean internetConnectionAvailable =
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java
index 2194101513..ce7d2b33ea 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java
@@ -38,7 +38,7 @@ public class MapMarkerMenuController extends MenuController {
leftTitleButtonController.caption = getMapActivity().getString(R.string.mark_passed);
leftTitleButtonController.leftIconId = isLight() ? R.drawable.passed_icon_light : R.drawable.passed_icon_dark;
- leftSubtitleButtonController = new TitleButtonController() {
+ rightTitleButtonController = new TitleButtonController() {
@Override
public void buttonPressed() {
OsmandSettings.OsmandPreference indication = app.getSettings().MARKERS_DISTANCE_INDICATION_ENABLED;
@@ -50,8 +50,8 @@ public class MapMarkerMenuController extends MenuController {
getMapActivity().getContextMenu().close();
}
};
- leftSubtitleButtonController.caption = getMapActivity().getString(R.string.make_active);
- leftSubtitleButtonController.leftIcon = createShowOnTopbarIcon();
+ rightTitleButtonController.caption = getMapActivity().getString(R.string.make_active);
+ rightTitleButtonController.leftIcon = createShowOnTopbarIcon();
}
private Drawable createShowOnTopbarIcon() {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java
index 3d0756e490..fe4e748fcf 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java
@@ -78,7 +78,7 @@ public class TransportRouteController extends MenuController {
}
@Override
- public boolean fabVisible() {
+ public boolean navigateButtonVisible() {
return false;
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java
index 2799d4c602..a0bc74cab8 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java
@@ -82,14 +82,16 @@ public class TransportStopController extends MenuController {
PointDescription pointDescription, TransportStop transportStop) {
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
this.transportStop = transportStop;
- processTransportStop();
+ routes = processTransportStop();
+ builder.setRoutes(routes);
}
@Override
protected void setObject(Object object) {
if (object instanceof TransportStop) {
this.transportStop = (TransportStop) object;
- processTransportStop();
+ routes = processTransportStop();
+ builder.setRoutes(routes);
}
}
@@ -107,6 +109,11 @@ public class TransportStopController extends MenuController {
}
}
+ @Override
+ public List getTransportStopRoutes() {
+ return routes;
+ }
+
@Override
public boolean needStreetName() {
return Algorithms.isEmpty(getNameStr());
@@ -122,39 +129,8 @@ public class TransportStopController extends MenuController {
return getPointDescription().getTypeName();
}
- @Override
- public void addPlainMenuItems(String typeStr, PointDescription pointDescription, final LatLon latLon) {
- addPlainMenuItems(builder, latLon);
- super.addPlainMenuItems(typeStr, pointDescription, latLon);
- }
-
- public void addPlainMenuItems(MenuBuilder builder, final LatLon latLon) {
- for (final TransportStopRoute r : routes) {
- OnClickListener listener = new OnClickListener() {
- @Override
- public void onClick(View arg0) {
- MapContextMenu mm = getMapActivity().getContextMenu();
- PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE,
- r.getDescription(getMapActivity().getMyApplication(), false));
- mm.show(latLon, pd, r);
- TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
- stopsLayer.setRoute(r.route);
- int cz = r.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox());
- getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom());
- }
- };
- if (r.type == null) {
- builder.addPlainMenuItem(R.drawable.ic_action_polygom_dark, r.getDescription(getMapActivity().getMyApplication(), true),
- false, false, listener );
- } else {
- builder.addPlainMenuItem(r.type.getResourceId(), r.getDescription(getMapActivity().getMyApplication(), true),
- false, false, listener);
- }
- }
- }
-
- private void processTransportStop() {
- routes.clear();
+ public List processTransportStop() {
+ ArrayList routes = new ArrayList<>();
List reps = getMapActivity().getMyApplication()
.getResourceManager().searchTransportRepositories(transportStop.getLocation().getLatitude(),
transportStop.getLocation().getLongitude());
@@ -165,14 +141,14 @@ public class TransportStopController extends MenuController {
if (t.acceptTransportStop(transportStop)) {
boolean empty = transportStop.getReferencesToRoutes() == null || transportStop.getReferencesToRoutes().length == 0;
if(!empty) {
- addRoutes(useEnglishNames, t, transportStop, transportStop, 0);
+ addRoutes(routes, useEnglishNames, t, transportStop, transportStop, 0);
}
ArrayList ls = new ArrayList<>();
QuadRect ll = MapUtils.calculateLatLonBbox(transportStop.getLocation().getLatitude(), transportStop.getLocation().getLongitude(), 150);
t.searchTransportStops(ll.top, ll.left, ll.bottom, ll.right, -1, ls, null);
for(TransportStop tstop : ls) {
if(tstop.getId().longValue() != transportStop.getId().longValue() || empty) {
- addRoutes(useEnglishNames, t, tstop, transportStop,
+ addRoutes(routes, useEnglishNames, t, tstop, transportStop,
(int) MapUtils.getDistance(tstop.getLocation(), transportStop.getLocation()));
}
}
@@ -193,28 +169,41 @@ public class TransportStopController extends MenuController {
return o1.desc.compareTo(o2.desc);
}
});
+
+ return routes;
}
- private void addRoutes(boolean useEnglishNames, TransportIndexRepository t, TransportStop s, TransportStop refStop, int dist) {
+ private void addRoutes(List routes, boolean useEnglishNames, TransportIndexRepository t, TransportStop s, TransportStop refStop, int dist) {
Collection rts = t.getRouteForStop(s);
if (rts != null) {
for (TransportRoute rs : rts) {
TransportStopType type = TransportStopType.findType(rs.getType());
- TransportStopRoute r = new TransportStopRoute();
if (topType == null && type != null && type.isTopType()) {
topType = type;
}
- r.type = type;
- r.desc = rs.getRef() + " " + (useEnglishNames ? rs.getEnName(true) : rs.getName());
- r.route = rs;
- r.refStop = refStop;
- r.stop = s;
- r.distance = dist;
- this.routes.add(r);
+ if (!containsRef(routes, rs)) {
+ TransportStopRoute r = new TransportStopRoute();
+ r.type = type;
+ r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName();
+ r.route = rs;
+ r.refStop = refStop;
+ r.stop = s;
+ r.distance = dist;
+ routes.add(r);
+ }
}
}
}
+ private boolean containsRef(List routes, TransportRoute transportRoute) {
+ for (TransportStopRoute route : routes) {
+ if (route.route.getRef().equals(transportRoute.getRef())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
public static class TransportStopRoute {
public TransportStop refStop;
public TransportStopType type;
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java
index 74c7fe2d44..bef7636dc5 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java
@@ -6,6 +6,8 @@ import android.support.v4.content.ContextCompat;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.GPXUtilities.WptPt;
+import net.osmand.plus.GpxSelectionHelper;
+import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.R;
@@ -15,6 +17,8 @@ import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.mapcontextmenu.builders.WptPtMenuBuilder;
import net.osmand.util.Algorithms;
+import java.io.File;
+
public class WptPtMenuController extends MenuController {
private WptPt wpt;
@@ -33,7 +37,7 @@ public class WptPtMenuController extends MenuController {
MapMarkerMenuController markerMenuController =
new MapMarkerMenuController(mapActivity, mapMarker.getPointDescription(mapActivity), mapMarker);
leftTitleButtonController = markerMenuController.getLeftTitleButtonController();
- leftSubtitleButtonController = markerMenuController.getLeftSubtitleButtonController();
+ rightTitleButtonController = markerMenuController.getRightTitleButtonController();
}
}
@@ -78,11 +82,11 @@ public class WptPtMenuController extends MenuController {
}
@Override
- public Drawable getSecondLineTypeIcon() {
- if (Algorithms.isEmpty(getTypeStr())) {
+ public Drawable getAdditionalLineTypeIcon() {
+ if (Algorithms.isEmpty(getAdditionalTypeStr())) {
return null;
} else {
- return getIcon(R.drawable.map_small_group);
+ return getIcon(R.drawable.ic_action_group_name_16);
}
}
@@ -93,6 +97,21 @@ public class WptPtMenuController extends MenuController {
@Override
public String getTypeStr() {
+ GpxSelectionHelper helper = getMapActivity().getMyApplication().getSelectedGpxHelper();
+ SelectedGpxFile selectedGpxFile = helper.getSelectedGPXFile(wpt);
+ StringBuilder sb = new StringBuilder();
+ sb.append(getMapActivity().getString(R.string.gpx_wpt));
+ sb.append(", ");
+ if (selectedGpxFile != null) {
+ File file = new File(selectedGpxFile.getGpxFile().path);
+ String gpxName = file.getName().replace(".gpx", "").replace("/", " ").replace("_", " ");
+ sb.append(gpxName);
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public String getAdditionalTypeStr() {
return wpt.category != null ? wpt.category : "";
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java
index 76c19aaa5a..3ca0063588 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java
@@ -1,40 +1,29 @@
package net.osmand.plus.mapcontextmenu.other;
-import android.annotation.SuppressLint;
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
-import android.util.DisplayMetrics;
-import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.ImageView;
import android.widget.ListView;
-import android.widget.TextView;
import net.osmand.AndroidUtils;
-import net.osmand.plus.IconsCache;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu.MenuObject;
+import net.osmand.plus.widgets.TextViewEx;
import java.util.LinkedList;
import java.util.List;
-import static android.util.TypedValue.COMPLEX_UNIT_DIP;
-
-public class MapMultiSelectionMenuFragment extends Fragment implements AdapterView.OnItemClickListener {
+public class MapMultiSelectionMenuFragment extends Fragment implements MultiSelectionArrayAdapter.OnClickListener {
public static final String TAG = "MapMultiSelectionMenuFragment";
private View view;
- private ArrayAdapter listAdapter;
+ private MultiSelectionArrayAdapter listAdapter;
private MapMultiSelectionMenu menu;
private boolean dismissing = false;
private boolean wasDrawerDisabled;
@@ -57,15 +46,25 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi
ListView listView = (ListView) view.findViewById(R.id.list);
if (menu.isLandscapeLayout() && Build.VERSION.SDK_INT >= 21) {
AndroidUtils.addStatusBarPadding21v(getActivity(), listView);
- listView.setClipToPadding(false);
}
+ View headerView = inflater.inflate(R.layout.menu_obj_selection_header, listView, false);
+ if (!menu.isLight()) {
+ ((TextViewEx) headerView.findViewById(R.id.header_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
+ }
+ headerView.setOnClickListener(null);
+ listView.addHeaderView(headerView);
listAdapter = createAdapter();
+ listAdapter.setListener(this);
listView.setAdapter(listAdapter);
- listView.setOnItemClickListener(this);
- if (!oldAndroid()) {
- runLayoutListener();
- }
+ runLayoutListener();
+
+ view.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ dismissMenu();
+ }
+ });
return view;
}
@@ -140,8 +139,25 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi
@Override
public void onGlobalLayout() {
- int maxHeight = (int) (getScreenHeight() * menu.getHalfScreenMaxHeightKoef());
- int height = view.findViewById(R.id.main_view).getHeight();
+ if (!menu.isLandscapeLayout() && listAdapter.getCount() > 3) {
+ View contentView = view.findViewById(R.id.content);
+ float headerHeight = contentView.getResources().getDimension(R.dimen.multi_selection_header_height);
+ float cancelRowHeight = contentView.getResources().getDimension(R.dimen.bottom_sheet_cancel_button_height);
+ int maxHeight = (int) (headerHeight + cancelRowHeight);
+ for (int i = 0; i < 3; i++) {
+ View childView = listAdapter.getView(0, null, (ListView) contentView.findViewById(R.id.list));
+ childView.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
+ maxHeight += childView.getMeasuredHeight();
+ }
+ int height = contentView.getHeight();
+
+ if (height > maxHeight) {
+ ViewGroup.LayoutParams lp = contentView.getLayoutParams();
+ lp.height = maxHeight;
+ contentView.setLayoutParams(lp);
+ contentView.requestLayout();
+ }
+ }
ViewTreeObserver obs = view.getViewTreeObserver();
@@ -150,71 +166,21 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi
} else {
obs.removeGlobalOnLayoutListener(this);
}
-
- if (!menu.isLandscapeLayout() && height > maxHeight) {
- ViewGroup.LayoutParams lp = view.getLayoutParams();
- lp.height = maxHeight;
- view.setLayoutParams(lp);
- view.requestLayout();
- }
}
});
}
- private ArrayAdapter createAdapter() {
+ private MultiSelectionArrayAdapter createAdapter() {
final List items = new LinkedList<>(menu.getObjects());
- return new ArrayAdapter(menu.getMapActivity(), R.layout.menu_obj_list_item, items) {
-
- @SuppressLint("InflateParams")
- @Override
- public View getView(final int position, View convertView, ViewGroup parent) {
- View v = convertView;
- if (v == null) {
- v = menu.getMapActivity().getLayoutInflater().inflate(R.layout.menu_obj_list_item, null);
- }
- final MenuObject item = getItem(position);
- buildHeader(v, item, menu.getMapActivity());
- return v;
- }
- };
- }
-
- private void buildHeader(View view, MenuObject item, MapActivity mapActivity) {
-
- AndroidUtils.setBackground(mapActivity, view, !menu.isLight(), R.drawable.expandable_list_item_background_light, R.drawable.expandable_list_item_background_dark);
- IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
- final View iconLayout = view.findViewById(R.id.context_menu_icon_layout);
- final ImageView iconView = (ImageView) view.findViewById(R.id.context_menu_icon_view);
- Drawable icon = item.getLeftIcon();
- int iconId = item.getLeftIconId();
- if (icon != null) {
- iconView.setImageDrawable(icon);
- iconLayout.setVisibility(View.VISIBLE);
- } else if (iconId != 0) {
- iconView.setImageDrawable(iconsCache.getIcon(iconId,
- menu.isLight() ? R.color.osmand_orange : R.color.osmand_orange_dark));
- iconLayout.setVisibility(View.VISIBLE);
- } else {
- iconLayout.setVisibility(View.GONE);
- }
-
- // Text line 1
- TextView line1 = (TextView) view.findViewById(R.id.context_menu_line1);
- AndroidUtils.setTextPrimaryColor(mapActivity, line1, !menu.isLight());
- line1.setText(item.getTitleStr());
-
- // Text line 2
- TextView line2 = (TextView) view.findViewById(R.id.context_menu_line2);
- AndroidUtils.setTextSecondaryColor(mapActivity, line2, !menu.isLight());
- line2.setText(item.getTypeStr());
- Drawable slIcon = item.getTypeIcon();
- line2.setCompoundDrawablesWithIntrinsicBounds(slIcon, null, null, null);
- line2.setCompoundDrawablePadding(dpToPx(5f));
+ return new MultiSelectionArrayAdapter(menu, R.layout.menu_obj_list_item, items);
}
@Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- menu.openContextMenu(listAdapter.getItem(position));
+ public void onClick(int position) {
+ MenuObject menuObject = listAdapter.getItem(position);
+ if (menuObject != null) {
+ menu.openContextMenu(menuObject);
+ }
}
public void dismissMenu() {
@@ -225,23 +191,4 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi
menu.getMapActivity().getSupportFragmentManager().popBackStack();
}
}
-
- private int dpToPx(float dp) {
- Resources r = getActivity().getResources();
- return (int) TypedValue.applyDimension(
- COMPLEX_UNIT_DIP,
- dp,
- r.getDisplayMetrics()
- );
- }
-
- private int getScreenHeight() {
- DisplayMetrics dm = new DisplayMetrics();
- getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
- return dm.heightPixels;
- }
-
- private boolean oldAndroid() {
- return (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH);
- }
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java
index 4d14ea6601..627fa10fde 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java
@@ -19,6 +19,7 @@ import android.widget.Spinner;
import android.widget.TextView;
import net.osmand.AndroidUtils;
+import net.osmand.Location;
import net.osmand.ValueHolder;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
@@ -258,10 +259,22 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
private void updateViaView(final View parentView) {
String via = generateViaDescription();
View viaLayout = parentView.findViewById(R.id.ViaLayout);
+ View fromLayoutEmptyView = parentView.findViewById(R.id.from_layout_empty_view);
+ View toLayoutEmptyView = parentView.findViewById(R.id.to_layout_empty_view);
+ View dividerFromDropDownEmpty = parentView.findViewById(R.id.divider_from_drop_down_empty);
+ ImageView swapDirectionView = (ImageView) parentView.findViewById(R.id.swap_direction_image_view);
if (via.length() == 0) {
viaLayout.setVisibility(View.GONE);
parentView.findViewById(R.id.viaLayoutDivider).setVisibility(View.GONE);
+ dividerFromDropDownEmpty.setVisibility(View.GONE);
+ fromLayoutEmptyView.setVisibility(View.VISIBLE);
+ toLayoutEmptyView.setVisibility(View.VISIBLE);
+ swapDirectionView.setVisibility(View.VISIBLE);
} else {
+ fromLayoutEmptyView.setVisibility(View.GONE);
+ toLayoutEmptyView.setVisibility(View.GONE);
+ swapDirectionView.setVisibility(View.GONE);
+ dividerFromDropDownEmpty.setVisibility(View.VISIBLE);
viaLayout.setVisibility(View.VISIBLE);
parentView.findViewById(R.id.viaLayoutDivider).setVisibility(View.VISIBLE);
((TextView) parentView.findViewById(R.id.ViaView)).setText(via);
@@ -278,6 +291,36 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
ImageView viaIcon = (ImageView) parentView.findViewById(R.id.viaIcon);
viaIcon.setImageDrawable(getIconOrig(R.drawable.list_intermediate));
+
+ swapDirectionView.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_change_navigation_points,
+ isLight() ? R.color.route_info_control_icon_color_light : R.color.route_info_control_icon_color_dark));
+ AndroidUtils.setBackground(mapActivity, swapDirectionView, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
+ swapDirectionView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ TargetPointsHelper targetPointsHelper = getTargets();
+ TargetPoint startPoint = targetPointsHelper.getPointToStart();
+ TargetPoint endPoint = targetPointsHelper.getPointToNavigate();
+
+ if (startPoint == null) {
+ Location loc = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
+ if (loc != null) {
+ startPoint = TargetPoint.createStartPoint(new LatLon(loc.getLatitude(), loc.getLongitude()),
+ new PointDescription(PointDescription.POINT_TYPE_MY_LOCATION,
+ mapActivity.getString(R.string.shared_string_my_location)));
+ }
+ }
+
+ if (startPoint != null) {
+ targetPointsHelper.navigateToPoint(startPoint.point, false, -1, startPoint.getPointDescription(mapActivity));
+ targetPointsHelper.setStartPoint(endPoint.point, false, endPoint.getPointDescription(mapActivity));
+ targetPointsHelper.updateRouteAndRefresh(true);
+
+ updateFromIcon();
+ updateToIcon(parentView);
+ }
+ }
+ });
}
private void updateToSpinner(final View parentView) {
@@ -593,9 +636,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
infoDurationView.setVisibility(View.GONE);
textView.setVisibility(View.VISIBLE);
} else {
- infoIcon.setImageDrawable(ctx.getIconsCache().getIcon(R.drawable.ic_action_polygom_dark, isLight()));
+ infoIcon.setImageDrawable(ctx.getIconsCache().getIcon(R.drawable.ic_action_route_distance, R.color.route_info_unchecked_mode_icon_color));
infoIcon.setVisibility(View.VISIBLE);
- durationIcon.setImageDrawable(ctx.getIconsCache().getIcon(R.drawable.ic_action_time, isLight()));
+ durationIcon.setImageDrawable(ctx.getIconsCache().getIcon(R.drawable.ic_action_time, R.color.route_info_unchecked_mode_icon_color));
durationIcon.setVisibility(View.VISIBLE);
infoDistanceView.setVisibility(View.VISIBLE);
infoDurationView.setVisibility(View.VISIBLE);
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java
index ca359b1fcc..f55010cfad 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java
@@ -139,27 +139,30 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
boolean landscapeLayout = !portraitMode;
boolean nightMode = ctx.getMyApplication().getDaynightHelper().isNightModeForMapControls();
if (!landscapeLayout) {
- AndroidUtils.setBackground(ctx, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
+ AndroidUtils.setBackground(ctx, mainView, nightMode, R.drawable.route_info_menu_bg_light, R.drawable.route_info_menu_bg_dark);
} else {
- AndroidUtils.setBackground(ctx, mainView, nightMode, R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark);
+ AndroidUtils.setBackground(ctx, mainView, nightMode, R.drawable.route_info_menu_bg_left_light, R.drawable.route_info_menu_bg_left_dark);
}
+ AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.map_route_prepare_bottom_view), nightMode,
+ R.color.route_info_bottom_view_bg_light, R.color.route_info_bottom_view_bg_dark);
+
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerModesLayout), nightMode,
- R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
+ R.color.route_info_divider_light, R.color.route_info_divider_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerFromDropDown), nightMode,
- R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
+ R.color.route_info_divider_light, R.color.route_info_divider_dark);
+ AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.divider_from_drop_down_empty), nightMode,
+ R.color.route_info_divider_light, R.color.route_info_divider_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.viaLayoutDivider), nightMode,
- R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
+ R.color.route_info_divider_light, R.color.route_info_divider_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerToDropDown), nightMode,
- R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
+ R.color.route_info_divider_light, R.color.route_info_divider_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerButtons), nightMode,
- R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
+ R.color.route_info_divider_light, R.color.route_info_divider_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerBtn1), nightMode,
- R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
+ R.color.route_info_divider_light, R.color.route_info_divider_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerBtn2), nightMode,
- R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
- AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerBtn3), nightMode,
- R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
+ R.color.route_info_divider_light, R.color.route_info_divider_dark);
AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.ViaView), nightMode);
AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.ViaSubView), nightMode);
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java
new file mode 100644
index 0000000000..79fe4c1d08
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java
@@ -0,0 +1,91 @@
+package net.osmand.plus.mapcontextmenu.other;
+
+import android.graphics.drawable.Drawable;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.v4.content.ContextCompat;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import net.osmand.AndroidUtils;
+import net.osmand.plus.IconsCache;
+import net.osmand.plus.R;
+
+import java.util.List;
+
+public class MultiSelectionArrayAdapter extends ArrayAdapter {
+
+ private MapMultiSelectionMenu menu;
+ private OnClickListener listener;
+
+ MultiSelectionArrayAdapter(@NonNull MapMultiSelectionMenu menu, int resource, @NonNull List objects) {
+ super(menu.getMapActivity(), resource, objects);
+ this.menu = menu;
+ }
+
+ public void setListener(OnClickListener listener) {
+ this.listener = listener;
+ }
+
+ @NonNull
+ @Override
+ public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
+ if (convertView == null) {
+ convertView = menu.getMapActivity().getLayoutInflater().inflate(R.layout.menu_obj_list_item, parent, false);
+ }
+ final MapMultiSelectionMenu.MenuObject item = getItem(position);
+ if (item != null) {
+ AndroidUtils.setBackground(menu.getMapActivity(), convertView, !menu.isLight(), R.drawable.expandable_list_item_background_light, R.drawable.expandable_list_item_background_dark);
+ convertView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (listener != null) {
+ listener.onClick(position);
+ }
+ }
+ });
+ IconsCache iconsCache = menu.getMapActivity().getMyApplication().getIconsCache();
+ final View iconLayout = convertView.findViewById(R.id.context_menu_icon_layout);
+ final ImageView iconView = (ImageView) convertView.findViewById(R.id.context_menu_icon_view);
+ Drawable icon = item.getLeftIcon();
+ int iconId = item.getLeftIconId();
+ if (icon != null) {
+ iconView.setImageDrawable(icon);
+ iconLayout.setVisibility(View.VISIBLE);
+ } else if (iconId != 0) {
+ iconView.setImageDrawable(iconsCache.getIcon(iconId,
+ menu.isLight() ? R.color.osmand_orange : R.color.osmand_orange_dark));
+ iconLayout.setVisibility(View.VISIBLE);
+ } else {
+ iconLayout.setVisibility(View.GONE);
+ }
+
+ // Text line 1
+ TextView line1 = (TextView) convertView.findViewById(R.id.context_menu_line1);
+ ((TextView) convertView.findViewById(R.id.context_menu_line1)).setTextColor(ContextCompat.getColor(getContext(),
+ !menu.isLight() ? R.color.ctx_menu_title_color_dark : R.color.ctx_menu_title_color_light));
+ line1.setText(item.getTitleStr());
+
+ // Text line 2
+ TextView line2 = (TextView) convertView.findViewById(R.id.context_menu_line2);
+ ((TextView) line2).setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_subtitle_color));
+ line2.setText(item.getTypeStr());
+ Drawable slIcon = item.getTypeIcon();
+ line2.setCompoundDrawablesWithIntrinsicBounds(slIcon, null, null, null);
+ line2.setCompoundDrawablePadding(AndroidUtils.dpToPx(menu.getMapActivity(), 5f));
+
+ // Divider
+ View divider = convertView.findViewById(R.id.divider);
+ divider.setVisibility(position != getCount() - 1 ? View.VISIBLE : View.GONE);
+ }
+
+ return convertView;
+ }
+
+ public interface OnClickListener {
+ void onClick(int position);
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/myplaces/FavoritesActivity.java b/OsmAnd/src/net/osmand/plus/myplaces/FavoritesActivity.java
index c290ac70bf..c7738766ad 100644
--- a/OsmAnd/src/net/osmand/plus/myplaces/FavoritesActivity.java
+++ b/OsmAnd/src/net/osmand/plus/myplaces/FavoritesActivity.java
@@ -44,6 +44,8 @@ public class FavoritesActivity extends TabActivity {
private static final int OPEN_GPX_DOCUMENT_REQUEST = 1006;
private static final int IMPORT_FAVOURITES_REQUEST = 1007;
+ public static final String GROUP_NAME_TO_SHOW = "group_name_to_show";
+
public static final String OPEN_FAVOURITES_TAB = "open_favourites_tab";
public static final String OPEN_MY_PLACES_TAB = "open_my_places_tab";
@@ -52,6 +54,7 @@ public class FavoritesActivity extends TabActivity {
protected List> fragList = new ArrayList<>();
private int tabSize;
private GpxImportHelper gpxImportHelper;
+ private String groupNameToShow;
@Override
public void onCreate(Bundle icicle) {
@@ -74,16 +77,25 @@ public class FavoritesActivity extends TabActivity {
// setupHomeButton();
ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);
- Intent intent = getIntent();
- if (intent != null) {
- if (intent.hasExtra(OPEN_FAVOURITES_TAB) && intent.getBooleanExtra(OPEN_FAVOURITES_TAB, false)) {
- mViewPager.setCurrentItem(0, false);
- } else if (intent.hasExtra(OPEN_MY_PLACES_TAB) && intent.getBooleanExtra(OPEN_MY_PLACES_TAB, false)) {
- mViewPager.setCurrentItem(1, false);
+ if (icicle == null) {
+ Intent intent = getIntent();
+ if (intent != null) {
+ if (intent.hasExtra(OPEN_FAVOURITES_TAB) && intent.getBooleanExtra(OPEN_FAVOURITES_TAB, false)) {
+ if (intent.hasExtra(GROUP_NAME_TO_SHOW)) {
+ groupNameToShow = intent.getStringExtra(GROUP_NAME_TO_SHOW);
+ }
+ mViewPager.setCurrentItem(0, false);
+ } else if (intent.hasExtra(OPEN_MY_PLACES_TAB) && intent.getBooleanExtra(OPEN_MY_PLACES_TAB, false)) {
+ mViewPager.setCurrentItem(1, false);
+ }
}
}
}
+ public String getGroupNameToShow() {
+ return groupNameToShow;
+ }
+
public void addTrack() {
Intent intent = getImportGpxIntent();
startActivityForResult(intent, OPEN_GPX_DOCUMENT_REQUEST);
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java
index 595fe592aa..742ba1c410 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java
@@ -30,8 +30,8 @@ public class EditPOIMenuBuilder extends MenuBuilder {
if (osmPoint instanceof OsmNotesPoint) {
OsmNotesPoint notes = (OsmNotesPoint) osmPoint;
- buildRow(view, R.drawable.ic_action_note_dark, notes.getText(), 0, false, null, false, 0, false, null);
- buildRow(view, R.drawable.ic_group, notes.getAuthor(), 0, false, null, false, 0, false, null);
+ buildRow(view, R.drawable.ic_action_note_dark, notes.getText(), 0, false, null, false, 0, false, null, false);
+ buildRow(view, R.drawable.ic_group, notes.getAuthor(), 0, false, null, false, 0, false, null, false);
} else if (osmPoint instanceof OpenstreetmapPoint) {
OpenstreetmapPoint point = (OpenstreetmapPoint) osmPoint;
@@ -56,7 +56,7 @@ public class EditPOIMenuBuilder extends MenuBuilder {
if (resId == 0) {
resId = R.drawable.ic_action_folder_stroke;
}
- buildRow(view, resId, poiTranslation, 0, false, null, false, 0, false, null);
+ buildRow(view, resId, poiTranslation, 0, false, null, false, 0, false, null, false);
break;
}
}
@@ -67,12 +67,12 @@ public class EditPOIMenuBuilder extends MenuBuilder {
continue;
}
String text = e.getKey() + "=" + e.getValue();
- buildRow(view, R.drawable.ic_action_info_dark, text, 0, false, null, false, 0, false, null);
+ buildRow(view, R.drawable.ic_action_info_dark, text, 0, false, null, false, 0, false, null, false);
}
}
buildRow(view, R.drawable.ic_action_get_my_location, PointDescription.getLocationName(app,
osmPoint.getLatitude(), osmPoint.getLongitude(), true)
- .replaceAll("\n", " "), 0, false, null, false, 0, false, null);
+ .replaceAll("\n", " "), 0, false, null, false, 0, false, null, false);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java
index 9a16376aaa..f18a927400 100644
--- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java
@@ -1,6 +1,7 @@
package net.osmand.plus.parkingpoint;
import android.graphics.drawable.Drawable;
+import android.text.TextUtils;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandPlugin;
@@ -8,12 +9,13 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController;
-import net.osmand.util.Algorithms;
public class ParkingPositionMenuController extends MenuController {
private ParkingPositionPlugin plugin;
- private String parkingDescription = "";
+ private String parkingStartDescription = "";
+ private String parkingLeftDescription = "";
+ private String parkingTitle = "";
public ParkingPositionMenuController(MapActivity mapActivity, PointDescription pointDescription) {
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
@@ -34,13 +36,9 @@ public class ParkingPositionMenuController extends MenuController {
}
private void buildParkingDescription(MapActivity mapActivity) {
- StringBuilder sb = new StringBuilder();
- sb.append(plugin.getParkingStartDesc(mapActivity));
- String leftDesc = plugin.getParkingLeftDesc(mapActivity);
- if (!Algorithms.isEmpty(leftDesc)) {
- sb.append("\n").append(leftDesc);
- }
- parkingDescription = sb.toString();
+ parkingStartDescription = plugin.getParkingStartDesc(mapActivity);
+ parkingLeftDescription = plugin.getParkingLeftDesc(mapActivity);
+ parkingTitle = plugin.getParkingTitle(mapActivity);
}
@Override
@@ -62,7 +60,27 @@ public class ParkingPositionMenuController extends MenuController {
@Override
public boolean needTypeStr() {
- return !Algorithms.isEmpty(parkingDescription);
+ return true;
+ }
+
+ @Override
+ public String getAdditionalTypeStr() {
+ return parkingLeftDescription;
+ }
+
+ @Override
+ public boolean displayAdditionalTypeStrInHours() {
+ return true;
+ }
+
+ @Override
+ public int getTimeStrColor() {
+ return plugin.getParkingType() ? R.color.ctx_menu_amenity_closed_text_color : isLight() ? R.color.icon_color : R.color.dash_search_icon_dark;
+ }
+
+ @Override
+ public String getNameStr() {
+ return parkingTitle;
}
@Override
@@ -77,7 +95,7 @@ public class ParkingPositionMenuController extends MenuController {
@Override
public String getTypeStr() {
- return parkingDescription;
+ return parkingStartDescription;
}
@Override
diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java
index 65017e4121..93f6e3ac0b 100644
--- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java
@@ -2,7 +2,6 @@ package net.osmand.plus.parkingpoint;
import android.app.Activity;
-import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AlertDialog;
@@ -11,7 +10,6 @@ import android.text.format.Time;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
-import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.TimePicker;
@@ -582,9 +580,32 @@ public class ParkingPositionPlugin extends OsmandPlugin {
return timeStringBuilder.toString();
}
+ public String getParkingTitle(Activity ctx) {
+ StringBuilder title = new StringBuilder();
+ if (getParkingType()) {
+ title.append(ctx.getString(R.string.pick_up_till)).append(" ");
+ long endTime = getParkingTime();
+ title.append(getFormattedTime(endTime, ctx));
+ } else {
+ title.append(ctx.getString(R.string.osmand_parking_position_name));
+ }
+ return title.toString();
+ }
+
public String getParkingStartDesc(Activity ctx) {
- return ctx.getString(R.string.osmand_parking_position_description_add_time)
- + " " + getFormattedTime(getStartParkingTime(), ctx);
+ StringBuilder parkingStartDesc = new StringBuilder();
+ String startTime = getFormattedTime(getStartParkingTime(), ctx);
+ if (getParkingType()) {
+ parkingStartDesc.append(ctx.getString(R.string.osmand_parking_position_name));
+ parkingStartDesc.append(", ");
+ parkingStartDesc.append(ctx.getString(R.string.parked_at));
+ parkingStartDesc.append(" ").append(startTime);
+ } else {
+ parkingStartDesc.append(ctx.getString(R.string.osmand_parking_position_description_add_time));
+ parkingStartDesc.append(" ");
+ parkingStartDesc.append(startTime);
+ }
+ return parkingStartDesc.toString();
}
public String getParkingLeftDesc(Activity ctx) {
@@ -599,6 +620,8 @@ public class ParkingPositionPlugin extends OsmandPlugin {
} else {
descr.append(ctx.getString(R.string.osmand_parking_time_left));
}
+ } else {
+ descr.append(ctx.getString(R.string.without_time_limit));
}
return descr.toString();
}
diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java
index 31e672bc6c..f3d7b33ee7 100644
--- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java
+++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java
@@ -16,6 +16,7 @@ import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
+import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorCompat;
import android.support.v4.view.ViewPropertyAnimatorListener;
@@ -293,7 +294,7 @@ public class MapControlsLayer extends OsmandMapLayer {
public void updateRouteButtons(View main, boolean routeInfo) {
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
ImageView cancelRouteButton = (ImageView) main.findViewById(R.id.map_cancel_route_button);
- cancelRouteButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.map_action_cancel, !nightMode));
+ cancelRouteButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.map_action_cancel, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light));
AndroidUtils.setBackground(mapActivity, cancelRouteButton, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
cancelRouteButton.setOnClickListener(new View.OnClickListener() {
@Override
@@ -303,7 +304,7 @@ public class MapControlsLayer extends OsmandMapLayer {
});
ImageView waypointsButton = (ImageView) main.findViewById(R.id.map_waypoints_route_button);
- waypointsButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.map_action_waypoint, !nightMode));
+ waypointsButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.map_action_flag_dark, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light));
AndroidUtils.setBackground(mapActivity, waypointsButton, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
waypointsButton.setOnClickListener(new View.OnClickListener() {
@Override
@@ -314,7 +315,7 @@ public class MapControlsLayer extends OsmandMapLayer {
ImageView options = (ImageView) main.findViewById(R.id.map_options_route_button);
options.setImageDrawable(!routeInfo ? app.getIconsCache().getIcon(R.drawable.map_action_settings,
- R.color.osmand_orange) : app.getIconsCache().getIcon(R.drawable.map_action_settings, !nightMode));
+ R.color.osmand_orange) : app.getIconsCache().getIcon(R.drawable.map_action_settings, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light));
AndroidUtils.setBackground(mapActivity, options, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
options.setOnClickListener(new View.OnClickListener() {
@Override
@@ -324,10 +325,10 @@ public class MapControlsLayer extends OsmandMapLayer {
});
TextView routeGoButton = (TextView) main.findViewById(R.id.map_go_route_button);
- routeGoButton.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache().getIcon(R.drawable.map_start_navigation, R.color.color_myloc_distance), null, null, null);
+ routeGoButton.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache().getIcon(R.drawable.map_start_navigation, R.color.color_white), null, null, null);
routeGoButton.setText(mapActivity.getString(R.string.shared_string_go));
- AndroidUtils.setTextSecondaryColor(mapActivity, routeGoButton, nightMode);
- AndroidUtils.setBackground(mapActivity, routeGoButton, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
+ routeGoButton.setTextColor(ContextCompat.getColor(mapActivity, R.color.color_white));
+ AndroidUtils.setBackground(mapActivity, routeGoButton, nightMode, R.drawable.route_info_go_btn_bg_light, R.drawable.route_info_go_btn_bg_dark);
routeGoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -474,7 +475,7 @@ public class MapControlsLayer extends OsmandMapLayer {
hasTargets = false;
}
- public void navigateFab() {
+ public void navigateButton() {
if (!OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
ActivityCompat.requestPermissions(mapActivity,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
@@ -1303,7 +1304,7 @@ public class MapControlsLayer extends OsmandMapLayer {
} else if (requestCode == REQUEST_LOCATION_FOR_NAVIGATION_FAB_PERMISSION
&& grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- navigateFab();
+ navigateButton();
} else if (requestCode == REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION
&& grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {