diff --git a/OsmAnd-java/src/net/osmand/NativeLibrary.java b/OsmAnd-java/src/net/osmand/NativeLibrary.java index b33b8ea195..7fbac147b0 100644 --- a/OsmAnd-java/src/net/osmand/NativeLibrary.java +++ b/OsmAnd-java/src/net/osmand/NativeLibrary.java @@ -116,8 +116,8 @@ public class NativeLibrary { return getRouteDataObjects(rs.region.routeReg, rs.nativeHandler, x31, y31); } - public boolean initMapFile(String filePath) { - return initBinaryMapFile(filePath); + public boolean initMapFile(String filePath, boolean useLive) { + return initBinaryMapFile(filePath, useLive); } public boolean initCacheMapFile(String filePath) { @@ -160,7 +160,7 @@ public class NativeLibrary { protected static native void deleteSearchResult(long searchResultHandle); - protected static native boolean initBinaryMapFile(String filePath); + protected static native boolean initBinaryMapFile(String filePath, boolean useLive); protected static native boolean initCacheMapFiles(String filePath); diff --git a/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java b/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java index 3f0cc32f9d..f246bfeb47 100644 --- a/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java +++ b/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java @@ -171,6 +171,14 @@ public class GeoPointParserUtil { assertGeoPoint(actual, new GeoParsedPoint(qstr)); assertUrlEquals(url, actual.getGeoUriString()); + // geo:?q=Paris + qstr = "Paris"; + url = "geo:?q=" + URLEncoder.encode(qstr); + System.out.println("url: " + url); + actual = GeoPointParserUtil.parse(url); + assertGeoPoint(actual, new GeoParsedPoint(qstr)); + assertUrlEquals("geo:0,0?q=" + URLEncoder.encode(qstr), actual.getGeoUriString()); + // geo:0,0?q=760 West Genesee Street Syracuse NY 13204 qstr = "760 West Genesee Street Syracuse NY 13204"; url = "geo:0,0?q=" + qstr; @@ -1247,11 +1255,12 @@ public class GeoPointParserUtil { final Pattern positionPattern = Pattern.compile( "([+-]?\\d+(?:\\.\\d+)?),\\s?([+-]?\\d+(?:\\.\\d+)?)"); final Matcher positionMatcher = positionPattern.matcher(positionPart); - if (!positionMatcher.find()) { - return null; + double lat = 0.0; + double lon = 0.0; + if (positionMatcher.find()) { + lat = Double.valueOf(positionMatcher.group(1)); + lon = Double.valueOf(positionMatcher.group(2)); } - double lat = Double.valueOf(positionMatcher.group(1)); - double lon = Double.valueOf(positionMatcher.group(2)); int zoom = GeoParsedPoint.NO_ZOOM; String searchRequest = null; diff --git a/OsmAnd/res/layout/main.xml b/OsmAnd/res/layout/main.xml index 71011b2b97..926cf7414e 100644 --- a/OsmAnd/res/layout/main.xml +++ b/OsmAnd/res/layout/main.xml @@ -46,11 +46,14 @@ android:layout_height="match_parent" android:fitsSystemWindows="true"> - + - + - + Требование: контроль Карточки не принимаются Предоплаченные билеты + + Депо + diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index 8e1d2c26fa..872dd20ea6 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -938,7 +938,7 @@ Автор Редактирование POI Добавление POI - Узел не найден или удобство (amenity) состоит из нескольких узлов, что не поддерживается. + Узел не найден или объект состоит из нескольких узлов, что не поддерживается. Вы действительно хотите удалить {0}? Удаление POI POI успешно удалена diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml index c9a47078d2..8c6a71c4a8 100644 --- a/OsmAnd/res/values/phrases.xml +++ b/OsmAnd/res/values/phrases.xml @@ -3634,4 +3634,6 @@ Charging station + Depot + diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java index a46f98e7c1..c0535bcf66 100644 --- a/OsmAnd/src/net/osmand/AndroidUtils.java +++ b/OsmAnd/src/net/osmand/AndroidUtils.java @@ -284,9 +284,11 @@ public class AndroidUtils { decorView.setSystemUiVisibility(uiOptions); } - public static int[] getViewLocation(View view) { + public static int[] getCenterViewCoordinates(View view) { int[] coordinates = new int[2]; view.getLocationOnScreen(coordinates); + coordinates[0] += view.getWidth() / 2; + coordinates[1] += view.getHeight() / 2; return coordinates; } diff --git a/OsmAnd/src/net/osmand/plus/GPXUtilities.java b/OsmAnd/src/net/osmand/plus/GPXUtilities.java index 21e12e8a88..307de185fc 100644 --- a/OsmAnd/src/net/osmand/plus/GPXUtilities.java +++ b/OsmAnd/src/net/osmand/plus/GPXUtilities.java @@ -57,6 +57,8 @@ public class GPXUtilities { private final static NumberFormat latLonFormat = new DecimalFormat("0.00#####", new DecimalFormatSymbols( new Locale("EN", "US"))); + private final static NumberFormat decimalFormat = new DecimalFormat("#.###", new DecimalFormatSymbols( + new Locale("EN", "US"))); public static class GPXExtensions { Map extensions = null; @@ -1299,7 +1301,7 @@ public class GPXUtilities { serializer.attribute(null, "lon", latLonFormat.format(p.lon)); //$NON-NLS-1$ //$NON-NLS-2$ if (!Double.isNaN(p.ele)) { - writeNotNullText(serializer, "ele", (float) p.ele + ""); + writeNotNullText(serializer, "ele", decimalFormat.format(p.ele)); } if (p.time != 0) { writeNotNullText(serializer, "time", format.format(new Date(p.time))); @@ -1316,10 +1318,10 @@ public class GPXUtilities { writeNotNullText(serializer, "cmt", p.comment); } if (!Double.isNaN(p.hdop)) { - writeNotNullText(serializer, "hdop", p.hdop + ""); + writeNotNullText(serializer, "hdop", decimalFormat.format(p.hdop)); } if (p.speed > 0) { - p.getExtensionsToWrite().put("speed", p.speed + ""); + p.getExtensionsToWrite().put("speed", decimalFormat.format(p.speed)); } writeExtensions(serializer, p); } diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java index e1cdd641c7..a57e1c5508 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java @@ -167,12 +167,16 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view); emptyImageView.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_empty_state_favorites_day : R.drawable.ic_empty_state_favorites_night); Button importButton = (Button) emptyView.findViewById(R.id.import_button); - importButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - importFavourites(); - } - }); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + importButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + importFavourites(); + } + }); + } else { + importButton.setVisibility(View.GONE); + } listView.setEmptyView(emptyView); listView.setAdapter(favouritesAdapter); setListView(listView); @@ -321,8 +325,10 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { if (!MenuItemCompat.isActionViewExpanded(mi)) { - createMenuItem(menu, IMPORT_FAVOURITES_ID, R.string.shared_string_add_to_favorites, R.drawable.ic_action_plus, - R.drawable.ic_action_plus, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + createMenuItem(menu, IMPORT_FAVOURITES_ID, R.string.shared_string_add_to_favorites, R.drawable.ic_action_plus, + R.drawable.ic_action_plus, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + } createMenuItem(menu, SHARE_ID, R.string.shared_string_share, R.drawable.ic_action_gshare_dark, R.drawable.ic_action_gshare_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); if (getSettings().USE_MAP_MARKERS.get()) { diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index c63d47518e..6ec8ed06fb 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -1000,7 +1000,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven } public void readLocationToShow() { - mapLayers.getMapControlsLayer().showMapControls(); + mapLayers.getMapControlsLayer().showMapControlsIfHidden(); LatLon cur = new LatLon(mapView.getLatitude(), mapView.getLongitude()); LatLon latLonToShow = settings.getAndClearMapLocationToShow(); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index ab55d0f5e5..aed969a25e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -947,7 +947,7 @@ public class MapActivityActions implements DialogProvider { ContextMenuItem item = contextMenuAdapter.getItem(position); ContextMenuAdapter.ItemClickListener click = item.getItemClickListener(); if (click != null && click.onContextMenuClick(simpleListAdapter, item.getTitleId(), - position, false, AndroidUtils.getViewLocation(view))) { + position, false, AndroidUtils.getCenterViewCoordinates(view))) { mapActivity.closeDrawer(); } } diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index 76e31beaf6..379fb7339f 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -1581,12 +1581,6 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { private void updateRecordControl(final MapActivity mapActivity, final File f) { recordControl.setText(app.getString(R.string.shared_string_control_stop), ""); recordControl.setIcons(R.drawable.widget_icon_av_active, R.drawable.widget_icon_av_active); - final MapInfoLayer mil = mapActivity.getMapLayers().getMapInfoLayer(); - if (!recordControl.isVisible()) { - recordControl.setExplicitlyVisible(true); - mil.recreateControls(); - mapActivity.getMapView().refreshMap(true); - } recordControl.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -1599,10 +1593,6 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { if (!recordingDone) { if (!restart || !stopMediaRecording(true)) { recordingDone = true; - if (!recordControl.isVisible()) { - recordControl.setExplicitlyVisible(false); - mapActivity.getMapLayers().getMapInfoLayer().recreateControls(); - } stopMediaRecording(false); if (recordControl != null) { setRecordListener(recordControl, mapActivity); diff --git a/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java b/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java index 978b6c8a4b..d7d5fd151a 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java @@ -196,7 +196,7 @@ public class NotesFragment extends OsmAndListFragment { NotesSortByMode sortByMode = getMyApplication().getSettings().NOTES_SORT_BY_MODE.get(); if (sortByMode.isByDate()) { res.add(NotesAdapter.TYPE_DATE_HEADER); - res.addAll(sortItemsByDateDescending(recs)); + res.addAll(sortRecsByDateDescending(recs)); } else if (sortByMode.isByType()) { List audios = new LinkedList<>(); List photos = new LinkedList<>(); @@ -221,7 +221,7 @@ public class NotesFragment extends OsmAndListFragment { private void addToResIfNotEmpty(List res, List recs, int header) { if (!recs.isEmpty()) { res.add(header); - res.addAll(recs); + res.addAll(sortRecsByDateDescending(recs)); } } @@ -317,7 +317,7 @@ public class NotesFragment extends OsmAndListFragment { listAdapter.notifyDataSetChanged(); } - private List sortItemsByDateDescending(List recs) { + private List sortRecsByDateDescending(List recs) { Collections.sort(recs, new Comparator() { @Override public int compare(Recording first, Recording second) { diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java index 9ffa04673a..c516ba3f73 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java @@ -86,7 +86,7 @@ public class DashWaypointsFragment extends DashLocationFragment { @Override public void onClick(View v) { - dashboard.setDashboardVisibility(true, DashboardType.WAYPOINTS, AndroidUtils.getViewLocation(v)); + dashboard.setDashboardVisibility(true, DashboardType.WAYPOINTS, AndroidUtils.getCenterViewCoordinates(v)); } }); LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items); diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 2c622e05b4..dc3039bfb7 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -513,7 +513,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis @Override public void onClick(View v) { setDashboardVisibility(true, flatNow ? DashboardType.WAYPOINTS : DashboardType.WAYPOINTS_FLAT, - previousVisibleType, false, AndroidUtils.getViewLocation(v)); + previousVisibleType, false, AndroidUtils.getCenterViewCoordinates(v)); } }); } @@ -664,7 +664,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis markersSelectionButton.onClickListener = new View.OnClickListener() { @Override public void onClick(View v) { - setDashboardVisibility(true, DashboardType.MAP_MARKERS_SELECTION, AndroidUtils.getViewLocation(v)); + setDashboardVisibility(true, DashboardType.MAP_MARKERS_SELECTION, AndroidUtils.getCenterViewCoordinates(v)); } }; @@ -893,7 +893,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis mapActivity.getMapView().refreshMap(); } - mapActivity.getMapLayers().getMapControlsLayer().showMapControls(); + mapActivity.getMapLayers().getMapControlsLayer().showMapControlsIfHidden(); hideActionButton(); for (WeakReference df : fragList) { if (df.get() != null) { @@ -1212,7 +1212,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis } - // To animate view slide out from right to left + // To bounce animate view private void open(boolean animation, int[] animationCoordinates) { if (animation) { this.animationCoordinates = animationCoordinates; @@ -1221,7 +1221,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis dashboardView.findViewById(R.id.animateContent).setVisibility(View.VISIBLE); dashboardView.findViewById(R.id.toolbar).setVisibility(View.VISIBLE); } - this.animationCoordinates = animationCoordinates; } private void animateDashboard(final boolean show) { @@ -1259,6 +1258,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); + listView.setVerticalScrollBarEnabled(false); if (show) { content.setVisibility(View.VISIBLE); toolbar.setVisibility(View.VISIBLE); @@ -1268,10 +1268,14 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); + listView.setVerticalScrollBarEnabled(true); if (!show) { dashboardView.setVisibility(View.GONE); content.setVisibility(View.GONE); toolbar.setVisibility(View.GONE); + content.setTranslationX(0); + content.setTranslationY(0); + toolbar.setTranslationY(0); } } }); @@ -1421,7 +1425,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis setTranslationY(listBackgroundView, Math.max(0, -scrollY + mFlexibleSpaceImageHeight)); } } - if (portrait) { + if (portrait && toolbar.getVisibility() == View.VISIBLE) { setTranslationY(toolbar, Math.min(0, -scrollY + mFlexibleSpaceImageHeight - mFlexibleBlurSpaceHeight)); } updateColorOfToolbar(scrollY); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index cde5b3f35b..2ecedf2e9a 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -913,7 +913,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo ((View) parent).addOnLayoutChangeListener(containerLayoutListener); } menu.updateControlsVisibility(true); - getMapActivity().getMapLayers().getMapControlsLayer().showMapControls(); + getMapActivity().getMapLayers().getMapControlsLayer().showMapControlsIfHidden(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java index 1c9f3a26de..ca359b1fcc 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java @@ -60,7 +60,7 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment { if (menu == null) { dismiss(); } - getMapActivity().getMapLayers().getMapControlsLayer().showMapControls(); + getMapActivity().getMapLayers().getMapControlsLayer().showMapControlsIfHidden(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java index 04424812f3..5c2a06187e 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java @@ -151,7 +151,7 @@ public class MapillaryPlugin extends OsmandPlugin { @Override public boolean onRowItemClick(ArrayAdapter adapter, View view, int itemId, int position) { if (itemId == R.string.mapillary) { - mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.MAPILLARY, AndroidUtils.getViewLocation(view)); + mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.MAPILLARY, AndroidUtils.getCenterViewCoordinates(view)); return false; } return true; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java index b5b7c67470..098748fa6c 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java @@ -362,7 +362,7 @@ public class PlanRouteFragment extends BaseOsmAndFragment implements OsmAndLocat super.onResume(); MapActivity mapActivity = getMapActivity(); mapActivity.getMyApplication().getLocationProvider().addLocationListener(this); - mapActivity.getMapLayers().getMapControlsLayer().showMapControls(); + mapActivity.getMapLayers().getMapControlsLayer().showMapControlsIfHidden(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index 47eb908c7c..0245c0ce75 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -460,7 +460,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment { @Override public void onResume() { super.onResume(); - getMapActivity().getMapLayers().getMapControlsLayer().showMapControls(); + getMapActivity().getMapLayers().getMapControlsLayer().showMapControlsIfHidden(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index d50a6983ca..0579238c10 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -332,12 +332,16 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view); emptyImageView.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_empty_state_trip_day : R.drawable.ic_empty_state_trip_night); Button importButton = (Button) emptyView.findViewById(R.id.import_button); - importButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - addTrack(); - } - }); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + importButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + addTrack(); + } + }); + } else { + importButton.setVisibility(View.GONE); + } if (this.adapter != null) { listView.setAdapter(this.adapter); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java index e6ddc88858..1a88db662c 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java @@ -3,7 +3,7 @@ package net.osmand.plus.osmedit; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.support.annotation.NonNull; -import android.system.Os; +import android.support.v4.content.ContextCompat; import android.text.SpannableString; import android.text.TextUtils; import android.text.style.StyleSpan; @@ -157,6 +157,7 @@ public class OsmEditsAdapter extends ArrayAdapter { } private void bindHeaderViewHolder(final HeaderViewHolder holder) { + setupBackground(holder.backgroundView); holder.topDivider.setVisibility(portrait ? View.VISIBLE : View.GONE); holder.title.setText(R.string.your_edits); holder.checkBox.setChecked(isAllSelected()); @@ -176,6 +177,7 @@ public class OsmEditsAdapter extends ArrayAdapter { } private void bindOsmEditViewHolder(final OsmEditViewHolder holder, final OsmPoint osmEdit, int position) { + setupBackground(holder.mainView); holder.titleTextView.setText(getTitle(osmEdit)); holder.descriptionTextView.setText(getDescription(osmEdit)); Drawable icon = getIcon(osmEdit); @@ -227,6 +229,12 @@ public class OsmEditsAdapter extends ArrayAdapter { holder.bottomDivider.setVisibility(showDivider ? View.VISIBLE : View.GONE); } + private void setupBackground(View view) { + if (!portrait) { + view.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.color_transparent)); + } + } + private int getItemsCount() { return items.size(); } @@ -339,12 +347,14 @@ public class OsmEditsAdapter extends ArrayAdapter { private class HeaderViewHolder { View mainView; View topDivider; + View backgroundView; CheckBox checkBox; TextView title; HeaderViewHolder(View view) { mainView = view; topDivider = view.findViewById(R.id.top_divider); + backgroundView = view.findViewById(R.id.background_view); checkBox = (CheckBox) view.findViewById(R.id.check_box); title = (TextView) view.findViewById(R.id.title_text_view); } diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java index cd868a8e67..513f0f2a91 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java @@ -242,7 +242,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.OnRowItemClick() { @Override public boolean onRowItemClick(ArrayAdapter adapter, View view, int itemId, int position) { - int[] viewCoordinates = AndroidUtils.getViewLocation(view); + int[] viewCoordinates = AndroidUtils.getCenterViewCoordinates(view); if (itemId == R.string.layer_overlay) { mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.OVERLAY_MAP, viewCoordinates); return false; diff --git a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java index 3c58062b1f..0f84ece17e 100644 --- a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java +++ b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java @@ -294,6 +294,7 @@ public class MapRenderRepositories { if(library == null) { return; } + boolean useLive = context.getSettings().USE_OSM_LIVE_FOR_ROUTING.get(); for (String mapName : files.keySet()) { BinaryMapIndexReader fr = files.get(mapName); if (fr != null && (fr.containsMapData(leftX, topY, rightX, bottomY, zoom) || @@ -301,7 +302,7 @@ public class MapRenderRepositories { if (!nativeFiles.contains(mapName)) { long time = System.currentTimeMillis(); nativeFiles.add(mapName); - if (!library.initMapFile(fr.getFile().getAbsolutePath())) { + if (!library.initMapFile(fr.getFile().getAbsolutePath(), useLive)) { continue; } log.debug("Native resource " + mapName + " initialized " + (System.currentTimeMillis() - time) + " ms"); //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java index 832be4c298..499661585a 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java @@ -19,9 +19,7 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.SettingsActivity; import net.osmand.plus.dashboard.DashboardOnMap; -import net.osmand.plus.views.GPXLayer; import net.osmand.plus.views.OsmandMapTileView; -import net.osmand.plus.views.RouteLayer; import net.osmand.render.RenderingRuleProperty; import net.osmand.util.Algorithms; @@ -130,7 +128,7 @@ public class SRTMPlugin extends OsmandPlugin { @Override public boolean onRowItemClick(ArrayAdapter adapter, View view, int itemId, int position) { - int[] viewCoordinates = AndroidUtils.getViewLocation(view); + int[] viewCoordinates = AndroidUtils.getCenterViewCoordinates(view); if (itemId == R.string.srtm_plugin_name) { mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.CONTOUR_LINES, viewCoordinates); return false; diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index 7eb6ad64e1..068d6962a8 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -1,6 +1,10 @@ package net.osmand.plus.views; import android.Manifest; +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.AnimatorSet; +import android.animation.ObjectAnimator; import android.annotation.SuppressLint; import android.content.DialogInterface; import android.content.pm.PackageManager; @@ -249,7 +253,7 @@ public class MapControlsLayer extends OsmandMapLayer { @Override public void onClick(View v) { MapActivity.clearPrevActivityIntent(); - mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP, AndroidUtils.getViewLocation(v)); + mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP, AndroidUtils.getCenterViewCoordinates(v)); } }); @@ -410,7 +414,7 @@ public class MapControlsLayer extends OsmandMapLayer { public void onClick(View v) { MapActivity.clearPrevActivityIntent(); if (dash) { - mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD, AndroidUtils.getViewLocation(v)); + mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD, AndroidUtils.getCenterViewCoordinates(v)); } else { mapActivity.openDrawer(); } @@ -656,13 +660,64 @@ public class MapControlsLayer extends OsmandMapLayer { zoomOutButton.setOnLongClickListener(listener); } - public void showMapControls() { - mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE); + public void showMapControlsIfHidden() { + if (!isMapControlsVisible()) { + showMapControls(); + } + } + + private void showMapControls() { + if (settings.DO_NOT_USE_ANIMATIONS.get()) { + mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE); + } else { + animateMapControls(true); + } AndroidUtils.showNavBar(mapActivity); } public void hideMapControls() { - mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE); + if (settings.DO_NOT_USE_ANIMATIONS.get()) { + mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE); + } else { + animateMapControls(false); + } + } + + private void animateMapControls(final boolean show) { + final View mapHudButtonsOverlay = mapActivity.findViewById(R.id.MapHudButtonsOverlay); + View mapHudButtonsTop = mapActivity.findViewById(R.id.MapHudButtonsOverlayTop); + View mapHudButtonsBottom = mapActivity.findViewById(R.id.MapHudButtonsOverlayBottom); + View mapHudButtonsQuickActions = mapActivity.findViewById(R.id.MapHudButtonsOverlayQuickActions); + AnimatorSet set = new AnimatorSet(); + float transTopInitial = show ? -mapHudButtonsTop.getHeight() : 0; + float transTopFinal = show ? 0 : -mapHudButtonsTop.getHeight(); + float transBottomInitial = show ? mapHudButtonsBottom.getHeight() : 0; + float transBottomFinal = show ? 0 : mapHudButtonsBottom.getHeight(); + float alphaInitial = show ? 0f : 1f; + float alphaFinal = show ? 1f : 0f; + set.setDuration(300).playTogether( + ObjectAnimator.ofFloat(mapHudButtonsTop, View.TRANSLATION_Y, transTopInitial, transTopFinal), + ObjectAnimator.ofFloat(mapHudButtonsBottom, View.TRANSLATION_Y, transBottomInitial, transBottomFinal), + ObjectAnimator.ofFloat(mapHudButtonsQuickActions, View.ALPHA, alphaInitial, alphaFinal) + ); + set.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(Animator animation) { + super.onAnimationStart(animation); + if (show) { + mapHudButtonsOverlay.setVisibility(View.VISIBLE); + } + } + + @Override + public void onAnimationEnd(Animator animation) { + super.onAnimationEnd(animation); + if (!show) { + mapHudButtonsOverlay.setVisibility(View.INVISIBLE); + } + } + }); + set.start(); } public void setMapControlsVisibility(boolean visible) { diff --git a/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java b/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java index 56cf2beff9..bb96f035ec 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java @@ -1,14 +1,20 @@ package net.osmand.plus.views; +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.AnimatorSet; +import android.animation.ObjectAnimator; import android.content.Context; import android.graphics.Canvas; import android.graphics.PointF; +import android.os.Build; import android.os.Vibrator; import android.support.annotation.DimenRes; import android.support.v4.content.ContextCompat; import android.support.v4.util.Pair; import android.view.MotionEvent; import android.view.View; +import android.view.ViewAnimationUtils; import android.widget.FrameLayout; import android.widget.ImageButton; import android.widget.ImageView; @@ -16,6 +22,7 @@ import android.widget.ImageView; import com.getkeepsafe.taptargetview.TapTarget; import com.getkeepsafe.taptargetview.TapTargetView; +import net.osmand.AndroidUtils; import net.osmand.data.LatLon; import net.osmand.data.RotatedTileBox; import net.osmand.plus.OsmAndLocationProvider; @@ -31,6 +38,9 @@ import net.osmand.plus.quickaction.QuickActionFactory; import net.osmand.plus.quickaction.QuickActionRegistry; import net.osmand.plus.quickaction.QuickActionsWidget; +import java.util.ArrayList; +import java.util.List; + import static net.osmand.plus.views.ContextMenuLayer.VIBRATE_SHORT; /** @@ -39,26 +49,26 @@ import static net.osmand.plus.views.ContextMenuLayer.VIBRATE_SHORT; public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRegistry.QuickActionUpdatesListener, QuickAction.QuickActionSelectionListener { - private final ContextMenuLayer contextMenuLayer; - private final MeasurementToolLayer measurementToolLayer; - private final MapMarkersLayer mapMarkersLayer; - private ImageView contextMarker; - private final MapActivity mapActivity; - private final OsmandApplication app; - private final OsmandSettings settings; + private final ContextMenuLayer contextMenuLayer; + private final MeasurementToolLayer measurementToolLayer; + private final MapMarkersLayer mapMarkersLayer; + private ImageView contextMarker; + private final MapActivity mapActivity; + private final OsmandApplication app; + private final OsmandSettings settings; private final QuickActionRegistry quickActionRegistry; - private ImageButton quickActionButton; + private ImageButton quickActionButton; private QuickActionsWidget quickActionsWidget; private OsmandMapTileView view; - private boolean wasCollapseButtonVisible; - private int previousMapPosition; + private boolean wasCollapseButtonVisible; + private int previousMapPosition; private boolean inMovingMarkerMode; private boolean isLayerOn; - private boolean nightMode; + private boolean nightMode; public MapQuickActionLayer(MapActivity activity, ContextMenuLayer contextMenuLayer) { this.mapActivity = activity; @@ -194,7 +204,11 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe return false; updateQuickActionButton(showWidget); - quickActionsWidget.setVisibility(!showWidget ? View.GONE : View.VISIBLE); + if (settings.DO_NOT_USE_ANIMATIONS.get()) { + quickActionsWidget.setVisibility(!showWidget ? View.GONE : View.VISIBLE); + } else { + animateWidget(showWidget); + } mapActivity.updateStatusBarColor(); if (!showWidget) { @@ -211,6 +225,51 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe return true; } + private void animateWidget(final boolean show) { + AnimatorSet set = new AnimatorSet(); + List animators = new ArrayList<>(); + int[] animationCoordinates = AndroidUtils.getCenterViewCoordinates(quickActionButton); + int centerX = quickActionsWidget.getWidth() / 2; + int centerY = quickActionsWidget.getHeight() / 2; + float initialValueX = show ? animationCoordinates[0] - centerX : 0; + float finalValueX = show ? 0 : animationCoordinates[0] - centerX; + float initialValueY = show ? animationCoordinates[1] - centerY : 0; + float finalValueY = show ? 0 : animationCoordinates[1] - centerY; + animators.add(ObjectAnimator.ofFloat(quickActionsWidget, View.TRANSLATION_X, initialValueX, finalValueX)); + animators.add(ObjectAnimator.ofFloat(quickActionsWidget, View.TRANSLATION_Y, initialValueY, finalValueY)); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + float initialRadius = show ? 0 : (float) Math.sqrt(Math.pow(quickActionsWidget.getWidth() / 2, 2) + Math.pow(quickActionsWidget.getHeight() / 2, 2)); + float finalRadius = show ? (float) Math.sqrt(Math.pow(quickActionsWidget.getWidth() / 2, 2) + Math.pow(quickActionsWidget.getHeight() / 2, 2)) : 0; + Animator circleAnimator = ViewAnimationUtils.createCircularReveal(quickActionsWidget, centerX, centerY, initialRadius, finalRadius); + animators.add(circleAnimator); + } + float initialValueScale = show ? 0f : 1f; + float finalValueScale = show ? 1f : 0f; + animators.add(ObjectAnimator.ofFloat(quickActionsWidget, View.SCALE_X, initialValueScale, finalValueScale)); + animators.add(ObjectAnimator.ofFloat(quickActionsWidget, View.SCALE_Y, initialValueScale, finalValueScale)); + set.setDuration(300).playTogether(animators); + set.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(Animator animation) { + super.onAnimationStart(animation); + if (show) { + quickActionsWidget.setVisibility(View.VISIBLE); + } + } + + @Override + public void onAnimationEnd(Animator animation) { + super.onAnimationEnd(animation); + if (!show) { + quickActionsWidget.setVisibility(View.GONE); + quickActionsWidget.setTranslationX(0); + quickActionsWidget.setTranslationY(0); + } + } + }); + set.start(); + } + private void updateQuickActionButton(boolean widgetVisible) { quickActionButton.setImageDrawable(app.getIconsCache().getIcon( !widgetVisible ? R.drawable.map_quick_action : R.drawable.map_action_cancel, !nightMode)); diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index 18bc20a05a..1a9343cbcb 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -882,7 +882,7 @@ public class MapInfoWidgetsFactory { all.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { - map.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS, AndroidUtils.getViewLocation(view)); + map.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS, AndroidUtils.getCenterViewCoordinates(view)); } }); remove.setOnClickListener(new OnClickListener() {