Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-02-21 02:39:07 +01:00
commit 205eeb9178
12 changed files with 219 additions and 107 deletions

View file

@ -34,14 +34,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/card_bottom_divider"/>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"/>
<include layout="@layout/card_bottom_divider"/>
</FrameLayout>
</LinearLayout>

View file

@ -1,37 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/view_transparent_selection"
android:id="@+id/package_delivered_layout"
android:minHeight="50dp"
android:descendantFocusability="blocksDescendants">
<LinearLayout
android:id="@+id/package_delivered_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/view_transparent_selection"
android:descendantFocusability="blocksDescendants"
android:minHeight="50dp"
android:orientation="horizontal">
<CheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_gravity="center_vertical"
android:visibility="gone"/>
<ImageView
android:id="@+id/waypoint_icon"
android:src="@drawable/ic_action_fav_dark"
android:layout_height="25dp"
android:layout_width="56dp"
android:layout_gravity="center_vertical" />
android:layout_height="25dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_action_fav_dark"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:gravity="center"
android:layout_gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/waypoint_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="2"
android:ellipsize="end"
android:layout_gravity="center_vertical"
android:textSize="@dimen/default_list_text_size" />
android:ellipsize="end"
android:maxLines="2"
android:textSize="@dimen/default_list_text_size"/>
<LinearLayout
android:layout_width="match_parent"
@ -53,8 +62,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:textColor="@color/color_myloc_distance"
android:maxLines="1"
android:textColor="@color/color_myloc_distance"
android:textSize="@dimen/default_sub_text_size"/>
<TextView
@ -62,22 +71,22 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:textColor="@color/secondary_text_dark"
android:layout_marginLeft="6dp"
android:drawablePadding="2dp"
android:maxLines="1"
android:textColor="@color/secondary_text_dark"
android:textSize="@dimen/default_sub_text_size"/>
<TextView
android:id="@+id/waypoint_desc_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:layout_gravity="bottom"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/secondary_text_dark"
android:textSize="@dimen/default_sub_text_size" />
android:textSize="@dimen/default_sub_text_size"/>
</LinearLayout>
@ -86,28 +95,28 @@
<ImageButton
android:id="@+id/all_points"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="48dp"
android:layout_height="48dp"
android:contentDescription="@string/shared_string_more"
android:layout_gravity="center_vertical"
android:layout_marginRight="2dp"
android:visibility="gone"
android:contentDescription="@string/shared_string_more"
android:focusable="false"
android:scaleType="center"
style="@style/Widget.AppCompat.ActionButton"
android:src="@drawable/map_overflow_menu_white" />
android:src="@drawable/map_overflow_menu_white"
android:visibility="gone"/>
<ImageButton
android:id="@+id/info_close"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="48dp"
android:layout_height="48dp"
android:contentDescription="@string/shared_string_close"
android:layout_gravity="center_vertical"
android:layout_marginRight="2dp"
style="@style/Widget.AppCompat.ActionButton"
android:contentDescription="@string/shared_string_close"
android:focusable="false"
android:scaleType="center"
android:src="@drawable/ic_action_remove_dark" />
android:src="@drawable/ic_action_remove_dark"/>
<ImageView
android:id="@+id/info_move"
@ -115,8 +124,8 @@
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="2dp"
android:focusable="false"
android:clickable="false"
android:focusable="false"
android:scaleType="center"
android:src="@drawable/ic_flat_list_dark"
android:visibility="gone"/>

View file

@ -36,14 +36,16 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/card_bottom_divider"/>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="?attr/dashboard_divider"
android:dividerHeight="1dp"
android:drawSelectorOnTop="true"/>
<include layout="@layout/card_bottom_divider"/>
</FrameLayout>
</LinearLayout>

View file

@ -6,6 +6,7 @@ import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.text.TextUtils;
import android.text.format.DateFormat;
@ -14,6 +15,7 @@ import android.util.TypedValue;
import android.view.View;
import android.view.ViewParent;
import android.view.inputmethod.InputMethodManager;
import android.widget.ListView;
import android.widget.TextView;
import net.osmand.plus.R;
@ -100,6 +102,10 @@ public class AndroidUtils {
setBackgroundColor(ctx, view, night, R.color.bg_color_light, R.color.bg_color_dark);
}
public static void setListBackground(Context ctx, View view, boolean night) {
setBackgroundColor(ctx, view, night, R.color.ctx_menu_info_view_bg_light, R.color.ctx_menu_info_view_bg_dark);
}
public static void setTextPrimaryColor(Context ctx, TextView textView, boolean night) {
textView.setTextColor(night ?
ctx.getResources().getColor(R.color.primary_text_dark)

View file

@ -35,13 +35,16 @@ public class MapMarkersHelper {
public int pos;
public int index;
public boolean history;
public boolean selected;
public int dist;
public MapMarker(LatLon point, PointDescription name, int colorIndex, int pos, int index) {
public MapMarker(LatLon point, PointDescription name, int colorIndex, int pos,
boolean selected, int index) {
this.point = point;
this.pointDescription = name;
this.colorIndex = colorIndex;
this.pos = pos;
this.selected = selected;
this.index = index;
}
@ -58,10 +61,6 @@ public class MapMarkersHelper {
return pointDescription == null ? "" : pointDescription.getName();
}
public boolean isSearchingAddress(Context ctx) {
return pointDescription != null && pointDescription.isSearchingAddress(ctx);
}
public double getLatitude() {
return point.getLatitude();
}
@ -95,6 +94,7 @@ public class MapMarkersHelper {
List<String> desc = settings.getMapMarkersPointDescriptions(ips.size());
List<Integer> colors = settings.getMapMarkersColors(ips.size());
List<Integer> positions = settings.getMapMarkersPositions(ips.size());
List<Boolean> selections = settings.getMapMarkersSelections(ips.size());
int colorIndex = 0;
int pos = 0;
for (int i = 0; i < ips.size(); i++) {
@ -108,7 +108,7 @@ public class MapMarkersHelper {
}
MapMarker mapMarker = new MapMarker(ips.get(i),
PointDescription.deserializeFromString(desc.get(i), ips.get(i)), colorIndex,
pos, i);
pos, selections.get(i), i);
mapMarkers.add(mapMarker);
lookupAddress(mapMarker, false);
}
@ -117,10 +117,9 @@ public class MapMarkersHelper {
ips = settings.getMapMarkersHistoryPoints();
desc = settings.getMapMarkersHistoryPointDescriptions(ips.size());
colors = settings.getMapMarkersHistoryColors(ips.size());
for (int i = 0; i < ips.size(); i++) {
MapMarker mapMarker = new MapMarker(ips.get(i),
PointDescription.deserializeFromString(desc.get(i), ips.get(i)), colors.get(i), 0, i);
PointDescription.deserializeFromString(desc.get(i), ips.get(i)), 0, 0, false, i);
mapMarker.history = true;
mapMarkersHistory.add(mapMarker);
lookupAddress(mapMarker, true);
@ -162,7 +161,7 @@ public class MapMarkersHelper {
mapMarker.pointDescription, mapMarker.colorIndex);
} else {
settings.updateMapMarker(mapMarker.point.getLatitude(), mapMarker.point.getLongitude(),
mapMarker.pointDescription, mapMarker.colorIndex, mapMarker.pos);
mapMarker.pointDescription, mapMarker.colorIndex, mapMarker.pos, mapMarker.selected);
}
updateMarker(mapMarker);
}
@ -253,6 +252,7 @@ public class MapMarkersHelper {
List<PointDescription> pointDescriptions = new ArrayList<>();
int[] colorIndexes = new int[points.size()];
int[] positions = new int[points.size()];
boolean[] selections = new boolean[points.size()];
int[] indexes = new int[points.size()];
for (int i = 0; i < points.size(); i++) {
LatLon point = points.get(i);
@ -280,14 +280,19 @@ public class MapMarkersHelper {
longitudes[i] = point.getLongitude();
pointDescriptions.add(pointDescription);
colorIndexes[i] = colorIndex;
positions[i] = 0 - i;
positions[i] = -1 - i;
selections[i] = false;
indexes[i] = 0;
}
/*
if (sortedMapMarkers.size() > 0) {
MapMarker firstMarker = sortedMapMarkers.get(0);
settings.updateMapMarker(firstMarker.getLatitude(), firstMarker.getLongitude(), firstMarker.pointDescription, firstMarker.colorIndex, -points.size());
settings.updateMapMarker(firstMarker.getLatitude(), firstMarker.getLongitude(),
firstMarker.pointDescription, firstMarker.colorIndex, -points.size(), firstMarker.selected);
}
settings.insertMapMarkers(latitudes, longitudes, pointDescriptions, colorIndexes, positions, indexes);
*/
settings.insertMapMarkers(latitudes, longitudes, pointDescriptions, colorIndexes, positions,
selections, indexes);
readFromSettings();
normalizePositions();
}
@ -323,13 +328,15 @@ public class MapMarkersHelper {
List<String> names = new ArrayList<>(markers.size());
List<Integer> colors = new ArrayList<>(markers.size());
List<Integer> positions = new ArrayList<>(markers.size());
List<Boolean> selections = new ArrayList<>(markers.size());
for (MapMarker marker : markers) {
ls.add(marker.point);
names.add(PointDescription.serializeToString(marker.pointDescription));
colors.add(marker.colorIndex);
positions.add(marker.pos);
selections.add(marker.selected);
}
settings.saveMapMarkers(ls, names, colors, positions);
settings.saveMapMarkers(ls, names, colors, positions, selections);
}
if (markersHistory != null) {

View file

@ -1520,8 +1520,8 @@ public class OsmandSettings {
public final static String MAP_MARKERS_COLOR = "map_markers_color"; //$NON-NLS-1$
public final static String MAP_MARKERS_DESCRIPTION = "map_markers_description"; //$NON-NLS-1$
public final static String MAP_MARKERS_POSITION = "map_markers_position"; //$NON-NLS-1$
public final static String MAP_MARKERS_SELECTION = "map_markers_selection"; //$NON-NLS-1$
public final static String MAP_MARKERS_HISTORY_POINT = "map_markers_history_point"; //$NON-NLS-1$
public final static String MAP_MARKERS_HISTORY_COLOR = "map_markers_history_color"; //$NON-NLS-1$
public final static String MAP_MARKERS_HISTORY_DESCRIPTION = "map_markers_history_description"; //$NON-NLS-1$
public final static int MAP_MARKERS_HISTORY_LIMIT = 30;
private MapMarkersStorage mapMarkersStorage = new MapMarkersStorage();
@ -1576,6 +1576,7 @@ public class OsmandSettings {
.remove(MAP_MARKERS_DESCRIPTION)
.remove(MAP_MARKERS_COLOR)
.remove(MAP_MARKERS_POSITION)
.remove(MAP_MARKERS_SELECTION)
.commit();
}
@ -1583,7 +1584,6 @@ public class OsmandSettings {
return settingsAPI.edit(globalPreferences)
.remove(MAP_MARKERS_HISTORY_POINT)
.remove(MAP_MARKERS_HISTORY_DESCRIPTION)
.remove(MAP_MARKERS_HISTORY_COLOR)
.commit();
}
@ -1599,22 +1599,11 @@ public class OsmandSettings {
}
}
private class MapMarkersHistoryStorage extends MapMarkersStorage {
private class MapMarkersHistoryStorage extends MapPointsStorage {
public MapMarkersHistoryStorage() {
pointsKey = MAP_MARKERS_HISTORY_POINT;
descriptionsKey = MAP_MARKERS_HISTORY_DESCRIPTION;
colorsKey = MAP_MARKERS_HISTORY_COLOR;
}
@Override
public boolean savePoints(List<LatLon> ps, List<String> ds, List<Integer> cs, List<Integer> ns) {
if (ps.size() > MAP_MARKERS_HISTORY_LIMIT) {
ps.remove(ps.size() - 1);
ds.remove(ds.size() - 1);
cs.remove(cs.size() - 1);
}
return super.savePoints(ps, ds, cs, ns);
}
}
@ -1622,12 +1611,14 @@ public class OsmandSettings {
protected String colorsKey;
protected String posKey;
protected String selectionKey;
public MapMarkersStorage() {
pointsKey = MAP_MARKERS_POINT;
descriptionsKey = MAP_MARKERS_DESCRIPTION;
colorsKey = MAP_MARKERS_COLOR;
posKey = MAP_MARKERS_POSITION;
selectionKey = MAP_MARKERS_SELECTION;
}
public List<Integer> getColors(int sz) {
@ -1640,79 +1631,130 @@ public class OsmandSettings {
list.add(Integer.parseInt(colorStr));
}
}
while (list.size() > sz) {
list.remove(list.size() - 1);
}
int i = 0;
while (list.size() < sz) {
list.add(i % MapMarkersHelper.MAP_MARKERS_COLORS_COUNT);
i++;
}
return list;
}
public List<Integer> getPositions(int sz) {
List<Integer> list = new ArrayList<>();
int pos = 0;
String ip = settingsAPI.getString(globalPreferences, posKey, "");
if (ip.trim().length() > 0) {
StringTokenizer tok = new StringTokenizer(ip, ",");
while (tok.hasMoreTokens()) {
String indexStr = tok.nextToken();
list.add(Integer.parseInt(indexStr));
int p = Integer.parseInt(indexStr);
list.add(p);
if (p > pos) {
pos = p;
}
}
}
while (list.size() > sz) {
list.remove(list.size() - 1);
}
while (list.size() < sz) {
list.add(++pos);
}
return list;
}
public List<Boolean> getSelections(int sz) {
List<Boolean> list = new ArrayList<>();
String ip = settingsAPI.getString(globalPreferences, selectionKey, "");
if (ip.trim().length() > 0) {
StringTokenizer tok = new StringTokenizer(ip, ",");
while (tok.hasMoreTokens()) {
String indexStr = tok.nextToken();
list.add(Boolean.parseBoolean(indexStr));
}
}
while (list.size() > sz) {
list.remove(list.size() - 1);
}
while (list.size() < sz) {
list.add(false);
}
return list;
}
public boolean insertPoint(double latitude, double longitude,
PointDescription historyDescription, int colorIndex, int pos, int index) {
PointDescription historyDescription, int colorIndex, int pos,
boolean selected, int index) {
List<LatLon> ps = getPoints();
List<String> ds = getPointDescriptions(ps.size());
List<Integer> cs = getColors(ps.size());
List<Integer> ns = getPositions(ps.size());
List<Boolean> bs = getSelections(ps.size());
ps.add(index, new LatLon(latitude, longitude));
ds.add(index, PointDescription.serializeToString(historyDescription));
cs.add(index, colorIndex);
ns.add(index, pos);
bs.add(index, selected);
if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) {
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription);
}
return savePoints(ps, ds, cs, ns);
return savePoints(ps, ds, cs, ns, bs);
}
public boolean insertPoints(double[] latitudes, double[] longitudes,
List<PointDescription> historyDescriptions, int[] colorIndexes,
int[] positions, int[] indexes) {
int[] positions, boolean[] selections, int[] indexes) {
List<LatLon> ps = getPoints();
List<String> ds = getPointDescriptions(ps.size());
List<Integer> cs = getColors(ps.size());
List<Integer> ns = getPositions(ps.size());
List<Boolean> bs = getSelections(ps.size());
for (int i = 0; i < latitudes.length; i++) {
double latitude = latitudes[i];
double longitude = longitudes[i];
PointDescription historyDescription = historyDescriptions.get(i);
int colorIndex = colorIndexes[i];
int pos = positions[i];
boolean selected = selections[i];
int index = indexes[i];
ps.add(index, new LatLon(latitude, longitude));
ds.add(index, PointDescription.serializeToString(historyDescription));
cs.add(index, colorIndex);
ns.add(index, pos);
bs.add(index, selected);
if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) {
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription);
}
}
return savePoints(ps, ds, cs, ns);
return savePoints(ps, ds, cs, ns, bs);
}
public boolean updatePoint(double latitude, double longitude,
PointDescription historyDescription, int colorIndex, int pos) {
PointDescription historyDescription, int colorIndex,
int pos, boolean selected) {
List<LatLon> ps = getPoints();
List<String> ds = getPointDescriptions(ps.size());
List<Integer> cs = getColors(ps.size());
List<Integer> ns = getPositions(ps.size());
List<Boolean> bs = getSelections(ps.size());
int index = ps.indexOf(new LatLon(latitude, longitude));
ds.set(index, PointDescription.serializeToString(historyDescription));
cs.set(index, colorIndex);
if (cs.size() > index) {
cs.set(index, colorIndex);
}
if (ns.size() > index) {
ns.set(index, pos);
}
if (bs.size() > index) {
bs.set(index, selected);
}
if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) {
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription);
}
return savePoints(ps, ds, cs, ns);
return savePoints(ps, ds, cs, ns, bs);
}
@Override
@ -1721,6 +1763,7 @@ public class OsmandSettings {
List<String> ds = getPointDescriptions(ps.size());
List<Integer> cs = getColors(ps.size());
List<Integer> ns = getPositions(ps.size());
List<Boolean> bs = getSelections(ps.size());
ps.remove(index);
ds.remove(index);
if (cs.size() > index) {
@ -1729,10 +1772,14 @@ public class OsmandSettings {
if (ns.size() > index) {
ns.remove(index);
}
return savePoints(ps, ds, cs, ns);
if (bs.size() > index) {
bs.remove(index);
}
return savePoints(ps, ds, cs, ns, bs);
}
public boolean savePoints(List<LatLon> ps, List<String> ds, List<Integer> cs, List<Integer> ns) {
public boolean savePoints(List<LatLon> ps, List<String> ds, List<Integer> cs,
List<Integer> ns, List<Boolean> bs) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < ps.size(); i++) {
if (i > 0) {
@ -1767,11 +1814,21 @@ public class OsmandSettings {
nb.append(Integer.toString(ns.get(i)));
}
}
StringBuilder bb = new StringBuilder();
if (bs != null) {
for (int i = 0; i < bs.size(); i++) {
if (i > 0) {
bb.append(",");
}
bb.append(Boolean.toString(bs.get(i)));
}
}
return settingsAPI.edit(globalPreferences)
.putString(pointsKey, sb.toString())
.putString(descriptionsKey, tb.toString())
.putString(colorsKey, cb.toString())
.putString(posKey, nb.toString())
.putString(selectionKey, bb.toString())
.commit();
}
@ -1925,33 +1982,42 @@ public class OsmandSettings {
return mapMarkersStorage.getPositions(sz);
}
public List<Boolean> getMapMarkersSelections(int sz) {
return mapMarkersStorage.getSelections(sz);
}
public List<LatLon> getMapMarkersPoints() {
return mapMarkersStorage.getPoints();
}
public boolean insertMapMarker(double latitude, double longitude,
PointDescription historyDescription, int colorIndex, int pos, int index) {
return mapMarkersStorage.insertPoint(latitude, longitude, historyDescription, colorIndex, index, pos);
PointDescription historyDescription, int colorIndex, int pos,
boolean selected, int index) {
return mapMarkersStorage.insertPoint(latitude, longitude, historyDescription, colorIndex,
index, selected, pos);
}
public boolean insertMapMarkers(double[] latitudes, double[] longitudes,
List<PointDescription> historyDescriptions, int[] colorIndexes,
int[] positions, int[] indexes) {
int[] positions, boolean[] selections, int[] indexes) {
return mapMarkersStorage.insertPoints(latitudes, longitudes, historyDescriptions, colorIndexes,
positions, indexes);
positions, selections, indexes);
}
public boolean updateMapMarker(double latitude, double longitude,
PointDescription historyDescription, int colorIndex, int pos) {
return mapMarkersStorage.updatePoint(latitude, longitude, historyDescription, colorIndex, pos);
PointDescription historyDescription, int colorIndex,
int pos, boolean selected) {
return mapMarkersStorage.updatePoint(latitude, longitude, historyDescription, colorIndex,
pos, selected);
}
public boolean deleteMapMarker(int index) {
return mapMarkersStorage.deletePoint(index);
}
public boolean saveMapMarkers(List<LatLon> ps, List<String> ds, List<Integer> cs, List<Integer> ns) {
return mapMarkersStorage.savePoints(ps, ds, cs, ns);
public boolean saveMapMarkers(List<LatLon> ps, List<String> ds, List<Integer> cs, List<Integer> ns,
List<Boolean> bs) {
return mapMarkersStorage.savePoints(ps, ds, cs, ns, bs);
}
@ -1959,22 +2025,18 @@ public class OsmandSettings {
return mapMarkersHistoryStorage.getPointDescriptions(sz);
}
public List<Integer> getMapMarkersHistoryColors(int sz) {
return mapMarkersHistoryStorage.getColors(sz);
}
public List<LatLon> getMapMarkersHistoryPoints() {
return mapMarkersHistoryStorage.getPoints();
}
public boolean insertMapMarkerHistory(double latitude, double longitude,
PointDescription historyDescription, int colorIndex, int index) {
return mapMarkersHistoryStorage.insertPoint(latitude, longitude, historyDescription, colorIndex, index, 0);
return mapMarkersHistoryStorage.insertPoint(latitude, longitude, historyDescription, index);
}
public boolean updateMapMarkerHistory(double latitude, double longitude,
PointDescription historyDescription, int colorIndex) {
return mapMarkersHistoryStorage.updatePoint(latitude, longitude, historyDescription, colorIndex, 0);
return mapMarkersHistoryStorage.updatePoint(latitude, longitude, historyDescription);
}
public boolean deleteMapMarkerHistory(int index) {
@ -1982,7 +2044,7 @@ public class OsmandSettings {
}
public boolean saveMapMarkersHistory(List<LatLon> ps, List<String> ds, List<Integer> cs) {
return mapMarkersHistoryStorage.savePoints(ps, ds, cs, null);
return mapMarkersHistoryStorage.savePoints(ps, ds);
}

View file

@ -1037,8 +1037,17 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
}
((MapActivity) activity).readLocationToShow();
} else {
prevActivityIntent = new Intent(((Activity) activity).getIntent());
prevActivityIntent.putExtra(INTENT_KEY_PARENT_MAP_ACTIVITY, true);
if (activity instanceof Activity) {
Intent intent = ((Activity) activity).getIntent();
if (intent != null) {
prevActivityIntent = new Intent(intent);
prevActivityIntent.putExtra(INTENT_KEY_PARENT_MAP_ACTIVITY, true);
} else {
prevActivityIntent = null;
}
} else {
prevActivityIntent = null;
}
Intent newIntent = new Intent(activity, ((OsmandApplication) activity.getApplicationContext())
.getAppCustomization().getMapActivity());

View file

@ -776,6 +776,11 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
listView.setDivider(null);
}
}
/*
listView.setOverscrollFooter(new ColorDrawable(
nightMode ? mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_dark)
: mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_light)));
*/
}
private int dpToPx(float dp) {

View file

@ -14,6 +14,7 @@ import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
@ -63,6 +64,7 @@ public class MapMarkerDialogHelper {
private MapMarkersDialogHelperCallbacks helperCallbacks;
private boolean sorted;
private boolean nightMode;
private boolean selectionMode;
private boolean useCenter;
private LatLon loc;
@ -73,6 +75,7 @@ public class MapMarkerDialogHelper {
public interface MapMarkersDialogHelperCallbacks {
void reloadAdapter();
void deleteMapMarker(int position);
}
@ -86,6 +89,14 @@ public class MapMarkerDialogHelper {
this.helperCallbacks = helperCallbacks;
}
public boolean isSelectionMode() {
return selectionMode;
}
public void setSelectionMode(boolean selectionMode) {
this.selectionMode = selectionMode;
}
public boolean isNightMode() {
return nightMode;
}
@ -154,8 +165,10 @@ public class MapMarkerDialogHelper {
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
} else if (topDividerView) {
v = mapActivity.getLayoutInflater().inflate(R.layout.card_top_divider, null);
AndroidUtils.setListBackground(mapActivity, v, nightMode);
} else if (bottomDividerView) {
v = mapActivity.getLayoutInflater().inflate(R.layout.card_bottom_divider, null);
AndroidUtils.setListBackground(mapActivity, v, nightMode);
} else if (obj instanceof MapMarker) {
MapMarker marker = (MapMarker) obj;
v = updateMapMarkerItemView(this, v, marker);
@ -329,7 +342,8 @@ public class MapMarkerDialogHelper {
if (v == null || v.findViewById(R.id.info_close) == null) {
v = mapActivity.getLayoutInflater().inflate(R.layout.map_marker_item, null);
}
updateMapMarkerInfoView(mapActivity, v, loc, heading, useCenter, nightMode, screenOrientation, marker);
updateMapMarkerInfoView(mapActivity, v, loc, heading, useCenter, nightMode, screenOrientation,
selectionMode, marker);
final View more = v.findViewById(R.id.all_points);
final View move = v.findViewById(R.id.info_move);
final View remove = v.findViewById(R.id.info_close);
@ -370,8 +384,9 @@ public class MapMarkerDialogHelper {
}
public static void updateMapMarkerInfoView(Context ctx, View localView, LatLon loc,
Float heading, boolean useCenter, boolean nightMode,
int screenOrientation, final MapMarker marker) {
Float heading, boolean useCenter, boolean nightMode,
int screenOrientation, boolean selectionMode,
final MapMarker marker) {
TextView text = (TextView) localView.findViewById(R.id.waypoint_text);
TextView textShadow = (TextView) localView.findViewById(R.id.waypoint_text_shadow);
TextView textDist = (TextView) localView.findViewById(R.id.waypoint_dist);
@ -379,10 +394,13 @@ public class MapMarkerDialogHelper {
ImageView waypointIcon = (ImageView) localView.findViewById(R.id.waypoint_icon);
TextView waypointDeviation = (TextView) localView.findViewById(R.id.waypoint_deviation);
TextView descText = (TextView) localView.findViewById(R.id.waypoint_desc_text);
CheckBox checkBox = (CheckBox) localView.findViewById(R.id.checkbox);
if (text == null || textDist == null || arrow == null || waypointIcon == null
|| waypointDeviation == null || descText == null) {
return;
}
float[] mes = new float[2];
if (loc != null && marker.point != null) {
Location.distanceBetween(marker.getLatitude(), marker.getLongitude(), loc.getLatitude(), loc.getLongitude(), mes);
@ -445,6 +463,13 @@ public class MapMarkerDialogHelper {
text.setText(descr);
descText.setVisibility(View.GONE);
if (selectionMode) {
checkBox.setVisibility(View.VISIBLE);
} else {
checkBox.setVisibility(View.GONE);
}
/*
String pointDescription = "";
if (descText != null) {
@ -659,7 +684,8 @@ public class MapMarkerDialogHelper {
Object obj = listView.getItemAtPosition(i);
View v = listView.getChildAt(i - listView.getFirstVisiblePosition());
if (obj == marker) {
updateMapMarkerInfoView(mapActivity, v, loc, heading, useCenter, nightMode, screenOrientation, marker);
updateMapMarkerInfoView(mapActivity, v, loc, heading, useCenter, nightMode,
screenOrientation, selectionMode, marker);
}
}
} catch (Exception e) {

View file

@ -353,8 +353,10 @@ public class WaypointDialogHelper {
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
} else if (topDividerView) {
v = ctx.getLayoutInflater().inflate(R.layout.card_top_divider, null);
AndroidUtils.setListBackground(mapActivity, v, nightMode);
} else if (bottomDividerView) {
v = ctx.getLayoutInflater().inflate(R.layout.card_bottom_divider, null);
AndroidUtils.setListBackground(mapActivity, v, nightMode);
} else if (obj instanceof LocationPointWrapper) {
LocationPointWrapper point = (LocationPointWrapper) obj;
v = updateWaypointItemView(edit, deletedPoints, app, ctx, helper, v, point, this,

View file

@ -3,8 +3,6 @@ package net.osmand.plus.mapmarkers;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.Shape;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
@ -27,7 +25,6 @@ import net.osmand.plus.base.BaseOsmAndDialogFragment;
import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.plus.helpers.MapMarkerDialogHelper;
import net.osmand.plus.views.controls.ListDividerShape;
import java.util.List;
@ -84,18 +81,6 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment {
});
ListView listView = (ListView) view.findViewById(android.R.id.list);
int color;
if (nightMode) {
color = mapActivity.getResources().getColor(R.color.dashboard_divider_dark);
} else {
color = mapActivity.getResources().getColor(R.color.dashboard_divider_light);
}
Shape dividerShape = new ListDividerShape(color, 0);
final ShapeDrawable divider = new ShapeDrawable(dividerShape);
int divHeight = AndroidUtils.dpToPx(getContext(), 1f);
divider.setIntrinsicHeight(divHeight);
listView.setDivider(divider);
final ArrayAdapter<MapMarker> adapter = new MapMarkersListAdapter();
List<MapMarker> markers = getMyApplication().getMapMarkersHelper().getActiveMapMarkers();
if (markers.size() > 0) {
@ -135,7 +120,7 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment {
convertView = getMapActivity().getLayoutInflater().inflate(R.layout.map_marker_item, null);
}
MapMarkerDialogHelper.updateMapMarkerInfoView(getContext(), convertView, loc, heading,
useCenter, nightMode, screenOrientation, marker);
useCenter, nightMode, screenOrientation, false, marker);
final View remove = convertView.findViewById(R.id.info_close);
remove.setVisibility(View.GONE);
AndroidUtils.setListItemBackground(getMapActivity(), convertView, nightMode);

View file

@ -32,7 +32,6 @@ import android.support.annotation.NonNull;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;