Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
2007350bbc
14 changed files with 234 additions and 122 deletions
|
@ -407,14 +407,18 @@ public class BinaryMapIndexReader {
|
|||
}
|
||||
String ls = rg.get(0);
|
||||
if (ls.lastIndexOf('_') != -1) {
|
||||
if (ls.matches(".*([0-9]+_*){3}\\.obf")) {
|
||||
Pattern osmDiffDateEnding = Pattern.compile("_([0-9]+_*){3}\\.obf");
|
||||
if (ls.matches("([a-zA-Z-]+_)+([0-9]+_){2}[0-9]+\\.obf")) {
|
||||
Pattern osmDiffDateEnding = Pattern.compile("_([0-9]+_){2}[0-9]+\\.obf");
|
||||
Matcher m = osmDiffDateEnding.matcher(ls);
|
||||
if (m.find()) {
|
||||
ls = ls.substring(0, m.start());
|
||||
if (ls.lastIndexOf('_') != -1) {
|
||||
return ls.substring(0, ls.lastIndexOf('_')).replace('_', ' ');
|
||||
} else {
|
||||
return ls;
|
||||
}
|
||||
|
||||
}
|
||||
return ls.substring(0, ls.lastIndexOf('_')).replace('_', ' ');
|
||||
|
||||
} else {
|
||||
if (ls.contains(".")) {
|
||||
ls = ls.substring(0, ls.indexOf("."));
|
||||
|
|
|
@ -587,7 +587,8 @@ public class SearchPhrase {
|
|||
Iterator<BinaryMapIndexReader> it = indexes.iterator();
|
||||
while (it.hasNext()) {
|
||||
BinaryMapIndexReader r = it.next();
|
||||
if (r.getFile().getName().matches(".*([0-9]+_*){3}\\.obf")) {
|
||||
String filename = r.getFile().getName();
|
||||
if (filename.matches("([a-zA-Z-]+_)+([0-9]+_){2}[0-9]+\\.obf")) {
|
||||
String currRegionName = r.getRegionName();
|
||||
if (result.containsKey(currRegionName)) {
|
||||
result.get(currRegionName).add(r);
|
||||
|
|
|
@ -2530,11 +2530,11 @@
|
|||
<string name="marker_moved_to_history">Маркер перемещен в историю</string>
|
||||
<string name="marker_moved_to_active">Маркер перемещен в действующие</string>
|
||||
<string name="show_direction">Указатель расстояния</string>
|
||||
<string name="release_2_8">• Полностью переработанные маркеры с рекомендациями и планированием маршрута
|
||||
<string name="release_2_8">• Полностью переработанные маркеры карты, с направляющими линиями и планированием маршрута
|
||||
\n
|
||||
\n• Инструмент измерения расстояния, предлагающий привязку к дороге и сохранение точек в качестве трека
|
||||
\n• Инструмент измерения расстояния, с привязкой к дороге и сохранением точек в качестве трека
|
||||
\n
|
||||
\n• OSM Live: исправления ошибок, обновление данных на сервере каждые 30 минут, обновления вносимые в навигацию
|
||||
\n• OsmAnd Live: исправления ошибок, обновление данных на сервере каждые 30 минут, обновления учитываются в навигации
|
||||
\n
|
||||
\n</string>
|
||||
<string name="show_map">Показать карту</string>
|
||||
|
|
|
@ -1052,7 +1052,7 @@
|
|||
<string name="app_mode_truck">kamyon</string>
|
||||
|
||||
|
||||
<string name="copying_osmand_one_file_descr">Şimdidosya ($1%s ) Yeni Geliş kopyalamak …</string>
|
||||
<string name="copying_osmand_one_file_descr">Şimdidosya (%s) Yeni Geliş kopyalamak …</string>
|
||||
<string name="copying_osmand_files_descr">Yeni hedef (%s) için Osmand veri dosyaları kopyalanıyor …</string>
|
||||
<string name="guidance_preferences_descr">Yolbul tercihleri</string>
|
||||
<string name="routing_preferences_descr">Öncelikli yönlendirme</string>
|
||||
|
@ -2008,7 +2008,7 @@
|
|||
<string name="rec_split_clip_length_desc">Kaydedilen her klibin uzunluğunu artık bu belirtilen zaman aralığı olmayacak</string>
|
||||
<string name="rec_split_storage_size">Depolama boyutu</string>
|
||||
<string name="rec_split_storage_size_desc">Tüm kaydedilen kliplerin tarafından işgal edilebilir alan miktarı</string>
|
||||
<string name="last_map_change">Son harita değişikliği:% s</string>
|
||||
<string name="last_map_change">Son harita değişikliği: %s</string>
|
||||
<string name="hourly">Saatlik</string>
|
||||
<string name="daily">Günlük</string>
|
||||
<string name="weekly">Haftalık</string>
|
||||
|
|
|
@ -769,6 +769,7 @@ public class MapMarkersHelper {
|
|||
mapMarkers.add(0, marker);
|
||||
addMarkerToGroup(marker);
|
||||
reorderActiveMarkersIfNeeded();
|
||||
lookupAddress(marker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -920,7 +920,7 @@ public class OsmandSettings {
|
|||
|
||||
public final OsmandPreference<Boolean> SHOW_MAPILLARY = new BooleanPreference("show_mapillary", false).makeGlobal();
|
||||
public final OsmandPreference<Boolean> MAPILLARY_FIRST_DIALOG_SHOWN = new BooleanPreference("mapillary_first_dialog_shown", false).makeGlobal();
|
||||
public final OsmandPreference<Boolean> MAPILLARY_MENU_COLLAPSED = new BooleanPreference("mapillary_menu_collapsed", false).makeGlobal();
|
||||
public final OsmandPreference<Boolean> ONLINE_PHOTOS_ROW_COLLAPSED = new BooleanPreference("mapillary_menu_collapsed", false).makeGlobal();
|
||||
public final OsmandPreference<Boolean> WEBGL_SUPPORTED = new BooleanPreference("webgl_supported", true).makeGlobal();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
|
|
|
@ -30,7 +30,6 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||
import net.osmand.plus.TargetPointsHelper.TargetPointChangedListener;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController.ContextMenuToolbarController;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController.MenuState;
|
||||
|
@ -44,6 +43,7 @@ import net.osmand.plus.mapcontextmenu.editors.RtePtEditor;
|
|||
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor;
|
||||
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu;
|
||||
import net.osmand.plus.mapcontextmenu.other.ShareMenu;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersDialogFragment;
|
||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.views.ContextMenuLayer;
|
||||
|
@ -717,7 +717,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
if (pointDescription.isMapMarker()) {
|
||||
hide();
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.MAP_MARKERS);
|
||||
MapMarkersDialogFragment.showInstance(mapActivity);
|
||||
} else {
|
||||
mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(),
|
||||
getPointDescriptionForMarker());
|
||||
|
@ -898,7 +898,8 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
|
||||
public PointDescription getPointDescriptionForMarker() {
|
||||
PointDescription pd = getPointDescriptionForTarget();
|
||||
if (Algorithms.isEmpty(pd.getName()) && !nameStr.equals(PointDescription.getAddressNotFoundStr(mapActivity))) {
|
||||
if (Algorithms.isEmpty(pd.getName()) && !Algorithms.isEmpty(nameStr)
|
||||
&& !nameStr.equals(PointDescription.getAddressNotFoundStr(mapActivity))) {
|
||||
return new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, nameStr);
|
||||
} else {
|
||||
return pd;
|
||||
|
|
|
@ -42,7 +42,6 @@ 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.ImageCard.GetImageCardsTask.GetImageCardsListener;
|
||||
import net.osmand.plus.mapcontextmenu.builders.cards.NoImagesCard;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -53,8 +52,10 @@ import java.util.Collections;
|
|||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
|
||||
import static net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask.*;
|
||||
|
||||
public class MenuBuilder {
|
||||
|
||||
|
@ -344,12 +345,12 @@ public class MenuBuilder {
|
|||
onlinePhotoCardsRow = new CardsRowBuilder(this, view, false);
|
||||
onlinePhotoCardsRow.build();
|
||||
CollapsableView collapsableView = new CollapsableView(onlinePhotoCardsRow.getContentView(),
|
||||
app.getSettings().MAPILLARY_MENU_COLLAPSED);
|
||||
app.getSettings().ONLINE_PHOTOS_ROW_COLLAPSED);
|
||||
collapsableView.setOnCollExpListener(new CollapsableView.OnCollExpListener() {
|
||||
@Override
|
||||
public void onCollapseExpand(boolean collapsed) {
|
||||
if (!collapsed && onlinePhotoCards == null) {
|
||||
startLoadingImages(MenuBuilder.this);
|
||||
startLoadingImages();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -359,18 +360,23 @@ public class MenuBuilder {
|
|||
if (needUpdateOnly && onlinePhotoCards != null) {
|
||||
onlinePhotoCardsRow.setCards(onlinePhotoCards);
|
||||
} else if (!collapsableView.isCollapsed()) {
|
||||
startLoadingImages(this);
|
||||
startLoadingImages();
|
||||
}
|
||||
}
|
||||
|
||||
private void startLoadingImages(final MenuBuilder menuBuilder) {
|
||||
private void startLoadingImages() {
|
||||
onlinePhotoCards = new ArrayList<>();
|
||||
onlinePhotoCardsRow.setProgressCard();
|
||||
execute(new GetImageCardsTask(mapActivity, menuBuilder.getLatLon(),
|
||||
execute(new GetImageCardsTask(mapActivity, getLatLon(), getAdditionalCardParams(),
|
||||
new GetImageCardsListener() {
|
||||
@Override
|
||||
public void onPostProcess(List<ImageCard> cardList) {
|
||||
processOnlinePhotosCards(cardList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish(List<ImageCard> cardList) {
|
||||
if (!menuBuilder.isHidden()) {
|
||||
if (!isHidden()) {
|
||||
List<AbstractCard> cards = new ArrayList<>();
|
||||
cards.addAll(cardList);
|
||||
if (cardList.size() == 0) {
|
||||
|
@ -383,6 +389,13 @@ public class MenuBuilder {
|
|||
}));
|
||||
}
|
||||
|
||||
protected Map<String, String> getAdditionalCardParams() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void processOnlinePhotosCards(List<ImageCard> cardList) {
|
||||
}
|
||||
|
||||
protected void buildInternal(View view) {
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ import net.osmand.util.OpeningHoursParser;
|
|||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -289,9 +290,13 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
String key = e.getKey();
|
||||
String vl = e.getValue();
|
||||
|
||||
if (key.equals("image") || key.equals("mapillary")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String textPrefix = "";
|
||||
CollapsableView collapsableView = null;
|
||||
boolean collapsable = false;
|
||||
boolean collapsable = false;
|
||||
boolean isWiki = false;
|
||||
boolean isText = false;
|
||||
boolean isDescription = false;
|
||||
|
@ -465,7 +470,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
|
||||
if (processNearstWiki() && nearestWiki.size() > 0) {
|
||||
AmenityInfoRow wikiInfo = new AmenityInfoRow(
|
||||
"nearest_wiki", R.drawable.ic_action_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size()+")", true,
|
||||
"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);
|
||||
buildAmenityRow(view, wikiInfo);
|
||||
|
@ -475,7 +480,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
|
||||
boolean osmEditingEnabled = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class) != null;
|
||||
if (osmEditingEnabled && amenity.getId() != null
|
||||
&& amenity.getId() > 0 &&
|
||||
&& amenity.getId() > 0 &&
|
||||
(amenity.getId() % 2 == 0 || (amenity.getId() >> 1) < Integer.MAX_VALUE)) {
|
||||
String link;
|
||||
if (amenity.getId() % 2 == 0) {
|
||||
|
@ -506,6 +511,21 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, String> getAdditionalCardParams() {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
Map<String, String> additionalInfo = amenity.getAdditionalInfo();
|
||||
String imageValue = additionalInfo.get("image");
|
||||
String mapillaryValue = additionalInfo.get("mapillary");
|
||||
if (!Algorithms.isEmpty(imageValue)) {
|
||||
params.put("osm_image", imageValue);
|
||||
}
|
||||
if (!Algorithms.isEmpty(mapillaryValue)) {
|
||||
params.put("osm_mapillary_key", mapillaryValue);
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
private static class AmenityInfoRow {
|
||||
private String key;
|
||||
private Drawable icon;
|
||||
|
|
|
@ -7,6 +7,8 @@ import android.content.Intent;
|
|||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.TypedValue;
|
||||
|
@ -14,6 +16,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -51,8 +54,12 @@ public abstract class AbstractCard {
|
|||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
@SuppressWarnings("deprecation")
|
||||
protected static void openUrl(Context ctx, OsmandApplication app,
|
||||
String title, String url, boolean externalLink) {
|
||||
protected static void openUrl(@NonNull Context ctx,
|
||||
@NonNull OsmandApplication app,
|
||||
@Nullable String title,
|
||||
@NonNull String url,
|
||||
boolean externalLink,
|
||||
boolean hasImageUrl) {
|
||||
if (externalLink) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(url));
|
||||
|
@ -83,13 +90,22 @@ public abstract class AbstractCard {
|
|||
});
|
||||
|
||||
final WebView wv = new WebView(ctx);
|
||||
WebSettings settings = wv.getSettings();
|
||||
/*
|
||||
settings.setDefaultTextEncodingName("utf-8");
|
||||
settings.setBuiltInZoomControls(true);
|
||||
settings.setDisplayZoomControls(false);
|
||||
settings.setSupportZoom(true);
|
||||
wv.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
WebSettings settings = wv.getSettings();
|
||||
|
||||
if (hasImageUrl) {
|
||||
settings.setDefaultTextEncodingName("utf-8");
|
||||
settings.setBuiltInZoomControls(true);
|
||||
settings.setDisplayZoomControls(false);
|
||||
settings.setSupportZoom(true);
|
||||
}
|
||||
/*
|
||||
//Scale web view font size with system font size
|
||||
float scale = ctx.getResources().getConfiguration().fontScale;
|
||||
if (android.os.Build.VERSION.SDK_INT >= 14) {
|
||||
|
@ -111,7 +127,11 @@ public abstract class AbstractCard {
|
|||
wv.setBackgroundColor(Color.argb(1, 0, 0, 0));
|
||||
//wv.setScrollContainer(false);
|
||||
wv.getSettings().setJavaScriptEnabled(true);
|
||||
wv.loadUrl(url);
|
||||
if (hasImageUrl) {
|
||||
wv.loadData("<html><body style='margin:0;padding:0'><img style='max-width:100%;max-height:100%;' src='" + url + "'/></body></html>", "text/html", "UTF-8");
|
||||
} else {
|
||||
wv.loadUrl(url);
|
||||
}
|
||||
|
||||
ll.addView(topBar);
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0);
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.graphics.Bitmap;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.AppCompatButton;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
@ -38,29 +39,32 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.text.DateFormat.FULL;
|
||||
|
||||
public abstract class ImageCard extends AbstractCard {
|
||||
|
||||
private String type;
|
||||
public static String TYPE_MAPILLARY_PHOTO = "mapillary-photo";
|
||||
public static String TYPE_MAPILLARY_CONTRIBUTE = "mapillary-contribute";
|
||||
|
||||
protected String type;
|
||||
// Image location
|
||||
private LatLon location;
|
||||
// (optional) Image's camera angle in range [0, 360].
|
||||
private double ca = Double.NaN;
|
||||
// Date When bitmap was captured.
|
||||
private Date timestamp;
|
||||
// Image key.
|
||||
private String key;
|
||||
protected LatLon location;
|
||||
// (optional) Image's camera angle in range [0, 360]
|
||||
protected double ca = Double.NaN;
|
||||
// Date When bitmap was captured
|
||||
protected Date timestamp;
|
||||
// Image key
|
||||
protected String key;
|
||||
// Image title
|
||||
protected String title;
|
||||
// User name
|
||||
private String userName;
|
||||
protected String userName;
|
||||
// Image viewer url
|
||||
private String url;
|
||||
protected String url;
|
||||
// Image bitmap url
|
||||
private String imageUrl;
|
||||
protected String imageUrl;
|
||||
// Image high resolution bitmap url
|
||||
private String imageHiresUrl;
|
||||
protected String imageHiresUrl;
|
||||
// true if external browser should to be opened, open webview otherwise
|
||||
private boolean externalLink;
|
||||
protected boolean externalLink;
|
||||
|
||||
protected int topIconId;
|
||||
protected int buttonIconId;
|
||||
|
@ -76,7 +80,8 @@ public abstract class ImageCard extends AbstractCard {
|
|||
protected OnClickListener onClickListener;
|
||||
protected OnClickListener onButtonClickListener;
|
||||
|
||||
private static final DateFormat DATE_FORMAT = SimpleDateFormat.getDateTimeInstance(FULL, FULL, Locale.US); //"yyyy-MM-dd'T'HH:mm:ss");
|
||||
private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
|
||||
|
||||
private boolean downloading;
|
||||
private boolean downloaded;
|
||||
private Bitmap bitmap;
|
||||
|
@ -85,75 +90,81 @@ public abstract class ImageCard extends AbstractCard {
|
|||
|
||||
public ImageCard(MapActivity mapActivity, JSONObject imageObject) {
|
||||
super(mapActivity);
|
||||
try {
|
||||
if (imageObject.has("type")) {
|
||||
this.type = imageObject.getString("type");
|
||||
}
|
||||
if (imageObject.has("ca") && !imageObject.isNull("ca")) {
|
||||
this.ca = imageObject.getDouble("ca");
|
||||
}
|
||||
if (imageObject.has("lat") && imageObject.has("lon")) {
|
||||
double latitude = imageObject.getDouble("lat");
|
||||
double longitude = imageObject.getDouble("lon");
|
||||
this.location = new LatLon(latitude, longitude);
|
||||
}
|
||||
if (imageObject.has("timestamp")) {
|
||||
try {
|
||||
this.timestamp = DATE_FORMAT.parse(imageObject.getString("timestamp"));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
if (imageObject != null) {
|
||||
try {
|
||||
if (imageObject.has("type")) {
|
||||
this.type = imageObject.getString("type");
|
||||
}
|
||||
}
|
||||
if (imageObject.has("key")) {
|
||||
this.key = imageObject.getString("key");
|
||||
}
|
||||
if (imageObject.has("username")) {
|
||||
this.userName = imageObject.getString("username");
|
||||
}
|
||||
if (imageObject.has("url")) {
|
||||
this.url = imageObject.getString("url");
|
||||
}
|
||||
if (imageObject.has("imageUrl")) {
|
||||
this.imageUrl = imageObject.getString("imageUrl");
|
||||
}
|
||||
if (imageObject.has("imageHiresUrl")) {
|
||||
this.imageHiresUrl = imageObject.getString("imageHiresUrl");
|
||||
}
|
||||
if (imageObject.has("externalLink") && !imageObject.isNull("externalLink")) {
|
||||
this.externalLink = imageObject.getBoolean("externalLink");
|
||||
}
|
||||
if (imageObject.has("topIcon") && !imageObject.isNull("topIcon")) {
|
||||
this.topIconId = getDrawableId(imageObject.getString("topIcon"));
|
||||
}
|
||||
if (imageObject.has("buttonIcon") && !imageObject.isNull("buttonIcon")) {
|
||||
this.buttonIconId = getDrawableId(imageObject.getString("buttonIcon"));
|
||||
}
|
||||
if (imageObject.has("buttonText") && !imageObject.isNull("buttonText")) {
|
||||
this.buttonText = imageObject.getString("buttonText");
|
||||
}
|
||||
if (imageObject.has("buttonIconColor") && !imageObject.isNull("buttonIconColor")) {
|
||||
try {
|
||||
this.buttonIconColor = Algorithms.parseColor(imageObject.getString("buttonIconColor"));
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
if (imageObject.has("ca") && !imageObject.isNull("ca")) {
|
||||
this.ca = imageObject.getDouble("ca");
|
||||
}
|
||||
}
|
||||
if (imageObject.has("buttonColor") && !imageObject.isNull("buttonColor")) {
|
||||
try {
|
||||
this.buttonColor = Algorithms.parseColor(imageObject.getString("buttonColor"));
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
if (imageObject.has("lat") && imageObject.has("lon")
|
||||
&& !imageObject.isNull("lat") && !imageObject.isNull("lon")) {
|
||||
double latitude = imageObject.getDouble("lat");
|
||||
double longitude = imageObject.getDouble("lon");
|
||||
this.location = new LatLon(latitude, longitude);
|
||||
}
|
||||
}
|
||||
if (imageObject.has("buttonTextColor") && !imageObject.isNull("buttonTextColor")) {
|
||||
try {
|
||||
this.buttonTextColor = Algorithms.parseColor(imageObject.getString("buttonTextColor"));
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
if (imageObject.has("timestamp")) {
|
||||
try {
|
||||
this.timestamp = DATE_FORMAT.parse(imageObject.getString("timestamp"));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (imageObject.has("key")) {
|
||||
this.key = imageObject.getString("key");
|
||||
}
|
||||
if (imageObject.has("title") && !imageObject.isNull("title")) {
|
||||
this.title = imageObject.getString("title");
|
||||
}
|
||||
if (imageObject.has("username") && !imageObject.isNull("username")) {
|
||||
this.userName = imageObject.getString("username");
|
||||
}
|
||||
if (imageObject.has("url") && !imageObject.isNull("url")) {
|
||||
this.url = imageObject.getString("url");
|
||||
}
|
||||
if (imageObject.has("imageUrl") && !imageObject.isNull("imageUrl")) {
|
||||
this.imageUrl = imageObject.getString("imageUrl");
|
||||
}
|
||||
if (imageObject.has("imageHiresUrl") && !imageObject.isNull("imageHiresUrl")) {
|
||||
this.imageHiresUrl = imageObject.getString("imageHiresUrl");
|
||||
}
|
||||
if (imageObject.has("externalLink") && !imageObject.isNull("externalLink")) {
|
||||
this.externalLink = imageObject.getBoolean("externalLink");
|
||||
}
|
||||
if (imageObject.has("topIcon") && !imageObject.isNull("topIcon")) {
|
||||
this.topIconId = getDrawableId(imageObject.getString("topIcon"));
|
||||
}
|
||||
if (imageObject.has("buttonIcon") && !imageObject.isNull("buttonIcon")) {
|
||||
this.buttonIconId = getDrawableId(imageObject.getString("buttonIcon"));
|
||||
}
|
||||
if (imageObject.has("buttonText") && !imageObject.isNull("buttonText")) {
|
||||
this.buttonText = imageObject.getString("buttonText");
|
||||
}
|
||||
if (imageObject.has("buttonIconColor") && !imageObject.isNull("buttonIconColor")) {
|
||||
try {
|
||||
this.buttonIconColor = Algorithms.parseColor(imageObject.getString("buttonIconColor"));
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (imageObject.has("buttonColor") && !imageObject.isNull("buttonColor")) {
|
||||
try {
|
||||
this.buttonColor = Algorithms.parseColor(imageObject.getString("buttonColor"));
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (imageObject.has("buttonTextColor") && !imageObject.isNull("buttonTextColor")) {
|
||||
try {
|
||||
this.buttonTextColor = Algorithms.parseColor(imageObject.getString("buttonTextColor"));
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,9 +181,9 @@ public abstract class ImageCard extends AbstractCard {
|
|||
try {
|
||||
if (imageObject.has("type")) {
|
||||
String type = imageObject.getString("type");
|
||||
if ("mapillary-photo".equals(type)) {
|
||||
if (TYPE_MAPILLARY_PHOTO.equals(type)) {
|
||||
imageCard = new MapillaryImageCard(mapActivity, imageObject);
|
||||
} else if ("mapillary-contribute".equals(type)) {
|
||||
} else if (TYPE_MAPILLARY_CONTRIBUTE.equals(type)) {
|
||||
imageCard = new MapillaryContributeCard(mapActivity, imageObject);
|
||||
} else {
|
||||
imageCard = new UrlImageCard(mapActivity, imageObject);
|
||||
|
@ -192,6 +203,10 @@ public abstract class ImageCard extends AbstractCard {
|
|||
return key;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
@ -302,9 +317,11 @@ public abstract class ImageCard extends AbstractCard {
|
|||
if (view != null) {
|
||||
ImageView image = (ImageView) view.findViewById(R.id.image);
|
||||
ImageView iconImageView = (ImageView) view.findViewById(R.id.icon);
|
||||
TextView urlTextView = (TextView) view.findViewById(R.id.url);
|
||||
TextView watermarkTextView = (TextView) view.findViewById(R.id.watermark);
|
||||
ProgressBar progress = (ProgressBar) view.findViewById(R.id.progress);
|
||||
AppCompatButton button = (AppCompatButton) view.findViewById(R.id.button);
|
||||
|
||||
if (icon == null && topIconId != 0) {
|
||||
icon = getMyApplication().getIconsCache().getIcon(topIconId);
|
||||
}
|
||||
|
@ -328,6 +345,12 @@ public abstract class ImageCard extends AbstractCard {
|
|||
} else {
|
||||
progress.setVisibility(View.GONE);
|
||||
image.setImageBitmap(bitmap);
|
||||
if (bitmap == null) {
|
||||
urlTextView.setVisibility(View.VISIBLE);
|
||||
urlTextView.setText(getUrl());
|
||||
} else {
|
||||
urlTextView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
if (onClickListener != null) {
|
||||
view.findViewById(R.id.image_card).setOnClickListener(new OnClickListener() {
|
||||
|
@ -377,17 +400,22 @@ public abstract class ImageCard extends AbstractCard {
|
|||
private MapActivity mapActivity;
|
||||
private OsmandApplication app;
|
||||
private LatLon latLon;
|
||||
private Map<String, String> params;
|
||||
private GetImageCardsListener listener;
|
||||
private List<ImageCard> result;
|
||||
|
||||
public interface GetImageCardsListener {
|
||||
void onPostProcess(List<ImageCard> cardList);
|
||||
|
||||
void onFinish(List<ImageCard> cardList);
|
||||
}
|
||||
|
||||
public GetImageCardsTask(@NonNull MapActivity mapActivity, LatLon latLon, GetImageCardsListener listener) {
|
||||
public GetImageCardsTask(@NonNull MapActivity mapActivity, LatLon latLon,
|
||||
@Nullable Map<String, String> params, GetImageCardsListener listener) {
|
||||
this.mapActivity = mapActivity;
|
||||
this.app = mapActivity.getMyApplication();
|
||||
this.latLon = latLon;
|
||||
this.params = params;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
|
@ -410,6 +438,9 @@ public abstract class ImageCard extends AbstractCard {
|
|||
if (!Algorithms.isEmpty(preferredLang)) {
|
||||
pms.put("lang", preferredLang);
|
||||
}
|
||||
if (this.params != null) {
|
||||
pms.putAll(this.params);
|
||||
}
|
||||
String response = AndroidNetworkUtils.sendRequest(app, "https://osmand.net/api/cm_place.php", pms,
|
||||
"Requesting location images...", false, false);
|
||||
|
||||
|
@ -435,6 +466,9 @@ public abstract class ImageCard extends AbstractCard {
|
|||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (listener != null) {
|
||||
listener.onPostProcess(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -465,6 +499,9 @@ public abstract class ImageCard extends AbstractCard {
|
|||
downloading = false;
|
||||
downloaded = true;
|
||||
ImageCard.this.bitmap = bitmap;
|
||||
if (bitmap != null && Algorithms.isEmpty(getImageHiresUrl())) {
|
||||
ImageCard.this.imageHiresUrl = getUrl();
|
||||
}
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,14 @@ public class UrlImageCard extends ImageCard {
|
|||
|
||||
public UrlImageCard(MapActivity mapActivity, JSONObject imageObject) {
|
||||
super(mapActivity, imageObject);
|
||||
if (!Algorithms.isEmpty(getUrl())) {
|
||||
|
||||
if (!Algorithms.isEmpty(getSuitableUrl())) {
|
||||
OnClickListener onClickListener = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openUrl(getMapActivity(), getMyApplication(), "", getUrl(), isExternalLink());
|
||||
openUrl(getMapActivity(), getMyApplication(), getTitle(), getSuitableUrl(),
|
||||
isExternalLink() || Algorithms.isEmpty(getImageHiresUrl()),
|
||||
!Algorithms.isEmpty(getImageHiresUrl()));
|
||||
}
|
||||
};
|
||||
if (!Algorithms.isEmpty(buttonText)) {
|
||||
|
@ -26,4 +29,14 @@ public class UrlImageCard extends ImageCard {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getSuitableUrl() {
|
||||
final String url;
|
||||
if (Algorithms.isEmpty(getImageHiresUrl())) {
|
||||
url = getUrl();
|
||||
} else {
|
||||
url = getImageHiresUrl();
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -121,10 +122,9 @@ public class ShareMenuFragment extends Fragment implements OnItemClickListener {
|
|||
}
|
||||
|
||||
public void dismissMenu() {
|
||||
menu.getMapActivity().getSupportFragmentManager().popBackStackImmediate(TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
if (menu.getMapActivity().getContextMenu().isVisible()) {
|
||||
menu.getMapActivity().getContextMenu().hide();
|
||||
} else {
|
||||
menu.getMapActivity().getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.util.Random;
|
|||
|
||||
public class MapMarkersDbHelper {
|
||||
|
||||
private static final int DB_VERSION = 10;
|
||||
private static final int DB_VERSION = 11;
|
||||
public static final String DB_NAME = "map_markers_db";
|
||||
|
||||
private static final String MARKERS_TABLE_NAME = "map_markers";
|
||||
|
@ -139,8 +139,10 @@ public class MapMarkersDbHelper {
|
|||
}
|
||||
if (oldVersion < 10) {
|
||||
db.execSQL("ALTER TABLE " + MARKERS_TABLE_NAME + " ADD " + MARKERS_COL_SELECTED + " int");
|
||||
}
|
||||
if (oldVersion < 11) {
|
||||
db.execSQL("UPDATE " + MARKERS_TABLE_NAME +
|
||||
" SET" + MARKERS_COL_SELECTED + " = ? " +
|
||||
" SET " + MARKERS_COL_SELECTED + " = ? " +
|
||||
"WHERE " + MARKERS_COL_SELECTED + " IS NULL", new Object[]{0});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue