Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-11-07 21:58:23 +01:00
commit 15951c96d4
9 changed files with 48 additions and 22 deletions

View file

@ -47,6 +47,7 @@ public class OsmandRegions {
public static final String FIELD_METRIC = "region_metric";
public static final String FIELD_ROAD_SIGNS = "region_road_signs";
public static final String FIELD_LEFT_HAND_DRIVING = "region_left_hand_navigation";
public static final String FIELD_WIKI_LINK = "region_wiki_link";
private BinaryMapIndexReader reader;
private String locale = "en";
@ -74,7 +75,8 @@ public class OsmandRegions {
Integer metricType = null;
Integer leftHandDrivingType = null;
Integer roadSignsType = null;
Integer wikiLinkType = null;
public String get(Integer tp, BinaryMapDataObject object) {
if(tp == null) {
return null;
@ -393,6 +395,7 @@ public class OsmandRegions {
rd.params.regionLeftHandDriving = mapIndexFields.get(mapIndexFields.leftHandDrivingType, object);
rd.params.regionMetric = mapIndexFields.get(mapIndexFields.metricType, object);
rd.params.regionRoadSigns = mapIndexFields.get(mapIndexFields.roadSignsType, object);
rd.params.wikiLink = mapIndexFields.get(mapIndexFields.wikiLinkType, object);
rd.regionSearchText = getSearchIndex(object);
rd.regionMapDownload = isDownloadOfType(object, MAP_TYPE);
return rd;
@ -509,6 +512,7 @@ public class OsmandRegions {
mapIndexFields.metricType = object.getMapIndex().getRule(FIELD_METRIC, null);
mapIndexFields.leftHandDrivingType = object.getMapIndex().getRule(FIELD_LEFT_HAND_DRIVING, null);
mapIndexFields.roadSignsType = object.getMapIndex().getRule(FIELD_ROAD_SIGNS, null);
mapIndexFields.wikiLinkType = object.getMapIndex().getRule(FIELD_WIKI_LINK, null);
mapIndexFields.nameType = object.getMapIndex().getRule(FIELD_NAME, null);
}
}

View file

@ -41,6 +41,7 @@ public class WorldRegion {
protected String regionLang;
protected String regionMetric;
protected String regionRoadSigns;
protected String wikiLink;
public String getRegionLeftHandDriving() {
return regionLeftHandDriving;
@ -57,6 +58,10 @@ public class WorldRegion {
public String getRegionRoadSigns() {
return regionRoadSigns;
}
public String getWikiLink() {
return wikiLink;
}
}

View file

@ -38,10 +38,12 @@ public class MenuBuilder {
public class PlainMenuItem {
private int iconId;
private String text;
private boolean needLinks;
public PlainMenuItem(int iconId, String text) {
public PlainMenuItem(int iconId, String text, boolean needLinks) {
this.iconId = iconId;
this.text = text;
this.needLinks = needLinks;
}
public int getIconId() {
@ -51,6 +53,10 @@ public class MenuBuilder {
public String getText() {
return text;
}
public boolean isNeedLinks() {
return needLinks;
}
}
public MenuBuilder(OsmandApplication app) {
@ -68,7 +74,7 @@ public class MenuBuilder {
protected void buildPlainMenuItems(View view) {
for (PlainMenuItem item : plainMenuItems) {
buildRow(view, item.getIconId(), item.getText(), 0);
buildRow(view, item.getIconId(), item.getText(), 0, item.isNeedLinks());
}
}
@ -84,11 +90,11 @@ public class MenuBuilder {
firstRow = false;
}
protected void buildRow(View view, int iconId, String text, int textColor) {
buildRow(view, getRowIcon(iconId), text, textColor);
protected void buildRow(View view, int iconId, String text, int textColor, boolean needLinks) {
buildRow(view, getRowIcon(iconId), text, textColor, needLinks);
}
protected void buildRow(final View view, Drawable icon, String text, int textColor) {
protected void buildRow(final View view, Drawable icon, String text, int textColor, boolean needLinks) {
LinearLayout ll = new LinearLayout(view.getContext());
ll.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
@ -122,8 +128,10 @@ public class MenuBuilder {
textView.setTextSize(16);
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
textView.setAutoLinkMask(Linkify.ALL);
textView.setLinksClickable(true);
if (needLinks) {
textView.setAutoLinkMask(Linkify.ALL);
textView.setLinksClickable(true);
}
textView.setText(text);
if (textColor > 0) {
textView.setTextColor(view.getResources().getColor(textColor));
@ -191,8 +199,8 @@ public class MenuBuilder {
rowBuilt();
}
public void addPlainMenuItem(int iconId, String text) {
plainMenuItems.add(new PlainMenuItem(iconId, text));
public void addPlainMenuItem(int iconId, String text, boolean needLinks) {
plainMenuItems.add(new PlainMenuItem(iconId, text, needLinks));
}
public Drawable getRowIcon(int iconId) {

View file

@ -105,8 +105,8 @@ public abstract class MenuController extends BaseMenuController {
return menuController;
}
public void addPlainMenuItem(int iconId, String text) {
builder.addPlainMenuItem(iconId, text);
public void addPlainMenuItem(int iconId, String text, boolean needLinks) {
builder.addPlainMenuItem(iconId, text, needLinks);
}
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
@ -116,7 +116,7 @@ public abstract class MenuController extends BaseMenuController {
protected void addMyLocationToPlainItems(PointDescription pointDescription, LatLon latLon) {
if (pointDescription != null) {
addPlainMenuItem(R.drawable.map_my_location, PointDescription.getLocationName(getMapActivity(),
latLon.getLatitude(), latLon.getLongitude(), true).replaceAll("\n", ""));
latLon.getLatitude(), latLon.getLongitude(), true).replaceAll("\n", ""), false);
}
}

View file

@ -44,7 +44,7 @@ public class AudioVideoNoteMenuBuilder extends MenuBuilder {
DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(view.getContext());
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);
buildRow(view, R.drawable.ic_action_data, dateFormat.format(date) + "" + timeFormat.format(date), 0, false);
buildPlainMenuItems(view);

View file

@ -27,7 +27,7 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
super.build(view);
if (!Algorithms.isEmpty(fav.getDescription())) {
buildRow(view, R.drawable.ic_action_note_dark, fav.getDescription(), 0);
buildRow(view, R.drawable.ic_action_note_dark, fav.getDescription(), 0, true);
}
buildPlainMenuItems(view);

View file

@ -27,7 +27,7 @@ public class WptPtMenuBuilder extends MenuBuilder {
super.build(view);
if (!Algorithms.isEmpty(wpt.desc)) {
buildRow(view, R.drawable.ic_action_note_dark, wpt.desc, 0);
buildRow(view, R.drawable.ic_action_note_dark, wpt.desc, 0, true);
}
buildPlainMenuItems(view);

View file

@ -71,7 +71,7 @@ public class AmenityMenuController extends MenuController {
@Override
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
if (!Algorithms.isEmpty(typeStr)) {
addPlainMenuItem(R.drawable.ic_action_info_dark, typeStr);
addPlainMenuItem(R.drawable.ic_action_info_dark, typeStr, false);
}
addMyLocationToPlainItems(pointDescription, amenity.getLocation());
}

View file

@ -23,6 +23,7 @@ import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.util.Algorithms;
import java.io.File;
import java.text.DateFormat;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@ -94,7 +95,7 @@ public class MapDataMenuController extends MenuController {
@Override
protected int getSupportedMenuStatesPortrait() {
return MenuState.HEADER_ONLY;
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN;
}
@Override
@ -133,6 +134,16 @@ public class MapDataMenuController extends MenuController {
@Override
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
if (indexItem != null) {
addPlainMenuItem(R.drawable.ic_action_info_dark, indexItem.getSizeDescription(getMapActivity()), false);
}
if (region != null && !Algorithms.isEmpty(region.getParams().getWikiLink())) {
addPlainMenuItem(R.drawable.ic_action_wikipedia, region.getParams().getWikiLink(), true);
}
if (indexItem != null) {
DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(getMapActivity());
addPlainMenuItem(R.drawable.ic_action_data, indexItem.getRemoteDate(dateFormat), false);
}
}
@Override
@ -163,11 +174,9 @@ public class MapDataMenuController extends MenuController {
topRightTitleButtonController.visible = otherIndexItems.size() > 0;
if (indexItem != null) {
if (indexItem.isOutdated()) {
leftTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_update)
+ " (" + indexItem.getSizeDescription(getMapActivity()) + ")";
leftTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_update);
} else {
leftTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_download)
+ " (" + indexItem.getSizeDescription(getMapActivity()) + ")";
leftTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_download);
}
}
rightTitleButtonController.visible = indexItem != null && indexItem.isDownloaded();