Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-11-25 06:50:38 +01:00
commit a2eafddcb0
28 changed files with 228 additions and 80 deletions

View file

@ -116,8 +116,8 @@ public class NativeLibrary {
return getRouteDataObjects(rs.region.routeReg, rs.nativeHandler, x31, y31); return getRouteDataObjects(rs.region.routeReg, rs.nativeHandler, x31, y31);
} }
public boolean initMapFile(String filePath) { public boolean initMapFile(String filePath, boolean useLive) {
return initBinaryMapFile(filePath); return initBinaryMapFile(filePath, useLive);
} }
public boolean initCacheMapFile(String filePath) { public boolean initCacheMapFile(String filePath) {
@ -160,7 +160,7 @@ public class NativeLibrary {
protected static native void deleteSearchResult(long searchResultHandle); 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); protected static native boolean initCacheMapFiles(String filePath);

View file

@ -171,6 +171,14 @@ public class GeoPointParserUtil {
assertGeoPoint(actual, new GeoParsedPoint(qstr)); assertGeoPoint(actual, new GeoParsedPoint(qstr));
assertUrlEquals(url, actual.getGeoUriString()); 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 // geo:0,0?q=760 West Genesee Street Syracuse NY 13204
qstr = "760 West Genesee Street Syracuse NY 13204"; qstr = "760 West Genesee Street Syracuse NY 13204";
url = "geo:0,0?q=" + qstr; url = "geo:0,0?q=" + qstr;
@ -1247,11 +1255,12 @@ public class GeoPointParserUtil {
final Pattern positionPattern = Pattern.compile( final Pattern positionPattern = Pattern.compile(
"([+-]?\\d+(?:\\.\\d+)?),\\s?([+-]?\\d+(?:\\.\\d+)?)"); "([+-]?\\d+(?:\\.\\d+)?),\\s?([+-]?\\d+(?:\\.\\d+)?)");
final Matcher positionMatcher = positionPattern.matcher(positionPart); final Matcher positionMatcher = positionPattern.matcher(positionPart);
if (!positionMatcher.find()) { double lat = 0.0;
return null; 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; int zoom = GeoParsedPoint.NO_ZOOM;
String searchRequest = null; String searchRequest = null;

View file

@ -46,11 +46,14 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true"> android:fitsSystemWindows="true">
<include layout="@layout/map_hud_top"/> <include layout="@layout/map_hud_top"
android:id="@+id/MapHudButtonsOverlayTop"/>
<include layout="@layout/map_hud_bottom"/> <include layout="@layout/map_hud_bottom"
android:id="@+id/MapHudButtonsOverlayBottom"/>
<include layout="@layout/map_hud_quick_actions"/> <include layout="@layout/map_hud_quick_actions"
android:id="@+id/MapHudButtonsOverlayQuickActions"/>
</FrameLayout> </FrameLayout>
<FrameLayout <FrameLayout

View file

@ -3662,4 +3662,7 @@
<string name="poi_enforcement_check">Требование: контроль</string> <string name="poi_enforcement_check">Требование: контроль</string>
<string name="poi_payment_account_cards_no">Карточки не принимаются</string> <string name="poi_payment_account_cards_no">Карточки не принимаются</string>
<string name="poi_payment_prepaid_ticket_yes">Предоплаченные билеты</string> <string name="poi_payment_prepaid_ticket_yes">Предоплаченные билеты</string>
<string name="poi_depot">Депо</string>
</resources> </resources>

View file

@ -938,7 +938,7 @@
<string name="osb_comment_dialog_author">Автор</string> <string name="osb_comment_dialog_author">Автор</string>
<string name="poi_edit_title">Редактирование POI</string> <string name="poi_edit_title">Редактирование POI</string>
<string name="poi_create_title">Добавление POI</string> <string name="poi_create_title">Добавление POI</string>
<string name="poi_error_poi_not_found">Узел не найден или удобство (amenity) состоит из нескольких узлов, что не поддерживается.</string> <string name="poi_error_poi_not_found">Узел не найден или объект состоит из нескольких узлов, что не поддерживается.</string>
<string name="poi_remove_confirm_template">Вы действительно хотите удалить {0}?</string> <string name="poi_remove_confirm_template">Вы действительно хотите удалить {0}?</string>
<string name="poi_remove_title">Удаление POI</string> <string name="poi_remove_title">Удаление POI</string>
<string name="poi_remove_success">POI успешно удалена</string> <string name="poi_remove_success">POI успешно удалена</string>

View file

@ -3634,4 +3634,6 @@
<string name="poi_charging_station_filter">Charging station</string> <string name="poi_charging_station_filter">Charging station</string>
<string name="poi_depot">Depot</string>
</resources> </resources>

View file

@ -284,9 +284,11 @@ public class AndroidUtils {
decorView.setSystemUiVisibility(uiOptions); decorView.setSystemUiVisibility(uiOptions);
} }
public static int[] getViewLocation(View view) { public static int[] getCenterViewCoordinates(View view) {
int[] coordinates = new int[2]; int[] coordinates = new int[2];
view.getLocationOnScreen(coordinates); view.getLocationOnScreen(coordinates);
coordinates[0] += view.getWidth() / 2;
coordinates[1] += view.getHeight() / 2;
return coordinates; return coordinates;
} }

View file

@ -57,6 +57,8 @@ public class GPXUtilities {
private final static NumberFormat latLonFormat = new DecimalFormat("0.00#####", new DecimalFormatSymbols( private final static NumberFormat latLonFormat = new DecimalFormat("0.00#####", new DecimalFormatSymbols(
new Locale("EN", "US"))); new Locale("EN", "US")));
private final static NumberFormat decimalFormat = new DecimalFormat("#.###", new DecimalFormatSymbols(
new Locale("EN", "US")));
public static class GPXExtensions { public static class GPXExtensions {
Map<String, String> extensions = null; Map<String, String> extensions = null;
@ -1299,7 +1301,7 @@ public class GPXUtilities {
serializer.attribute(null, "lon", latLonFormat.format(p.lon)); //$NON-NLS-1$ //$NON-NLS-2$ serializer.attribute(null, "lon", latLonFormat.format(p.lon)); //$NON-NLS-1$ //$NON-NLS-2$
if (!Double.isNaN(p.ele)) { if (!Double.isNaN(p.ele)) {
writeNotNullText(serializer, "ele", (float) p.ele + ""); writeNotNullText(serializer, "ele", decimalFormat.format(p.ele));
} }
if (p.time != 0) { if (p.time != 0) {
writeNotNullText(serializer, "time", format.format(new Date(p.time))); writeNotNullText(serializer, "time", format.format(new Date(p.time)));
@ -1316,10 +1318,10 @@ public class GPXUtilities {
writeNotNullText(serializer, "cmt", p.comment); writeNotNullText(serializer, "cmt", p.comment);
} }
if (!Double.isNaN(p.hdop)) { if (!Double.isNaN(p.hdop)) {
writeNotNullText(serializer, "hdop", p.hdop + ""); writeNotNullText(serializer, "hdop", decimalFormat.format(p.hdop));
} }
if (p.speed > 0) { if (p.speed > 0) {
p.getExtensionsToWrite().put("speed", p.speed + ""); p.getExtensionsToWrite().put("speed", decimalFormat.format(p.speed));
} }
writeExtensions(serializer, p); writeExtensions(serializer, p);
} }

View file

@ -167,12 +167,16 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view); 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); 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); Button importButton = (Button) emptyView.findViewById(R.id.import_button);
importButton.setOnClickListener(new View.OnClickListener() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
@Override importButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) { @Override
importFavourites(); public void onClick(View view) {
} importFavourites();
}); }
});
} else {
importButton.setVisibility(View.GONE);
}
listView.setEmptyView(emptyView); listView.setEmptyView(emptyView);
listView.setAdapter(favouritesAdapter); listView.setAdapter(favouritesAdapter);
setListView(listView); setListView(listView);
@ -321,8 +325,10 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
if (!MenuItemCompat.isActionViewExpanded(mi)) { if (!MenuItemCompat.isActionViewExpanded(mi)) {
createMenuItem(menu, IMPORT_FAVOURITES_ID, R.string.shared_string_add_to_favorites, R.drawable.ic_action_plus, if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
R.drawable.ic_action_plus, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); 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, 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); R.drawable.ic_action_gshare_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
if (getSettings().USE_MAP_MARKERS.get()) { if (getSettings().USE_MAP_MARKERS.get()) {

View file

@ -1000,7 +1000,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
} }
public void readLocationToShow() { public void readLocationToShow() {
mapLayers.getMapControlsLayer().showMapControls(); mapLayers.getMapControlsLayer().showMapControlsIfHidden();
LatLon cur = new LatLon(mapView.getLatitude(), mapView.getLongitude()); LatLon cur = new LatLon(mapView.getLatitude(), mapView.getLongitude());
LatLon latLonToShow = settings.getAndClearMapLocationToShow(); LatLon latLonToShow = settings.getAndClearMapLocationToShow();

View file

@ -947,7 +947,7 @@ public class MapActivityActions implements DialogProvider {
ContextMenuItem item = contextMenuAdapter.getItem(position); ContextMenuItem item = contextMenuAdapter.getItem(position);
ContextMenuAdapter.ItemClickListener click = item.getItemClickListener(); ContextMenuAdapter.ItemClickListener click = item.getItemClickListener();
if (click != null && click.onContextMenuClick(simpleListAdapter, item.getTitleId(), if (click != null && click.onContextMenuClick(simpleListAdapter, item.getTitleId(),
position, false, AndroidUtils.getViewLocation(view))) { position, false, AndroidUtils.getCenterViewCoordinates(view))) {
mapActivity.closeDrawer(); mapActivity.closeDrawer();
} }
} }

View file

@ -1581,12 +1581,6 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
private void updateRecordControl(final MapActivity mapActivity, final File f) { private void updateRecordControl(final MapActivity mapActivity, final File f) {
recordControl.setText(app.getString(R.string.shared_string_control_stop), ""); recordControl.setText(app.getString(R.string.shared_string_control_stop), "");
recordControl.setIcons(R.drawable.widget_icon_av_active, R.drawable.widget_icon_av_active); 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() { recordControl.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -1599,10 +1593,6 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
if (!recordingDone) { if (!recordingDone) {
if (!restart || !stopMediaRecording(true)) { if (!restart || !stopMediaRecording(true)) {
recordingDone = true; recordingDone = true;
if (!recordControl.isVisible()) {
recordControl.setExplicitlyVisible(false);
mapActivity.getMapLayers().getMapInfoLayer().recreateControls();
}
stopMediaRecording(false); stopMediaRecording(false);
if (recordControl != null) { if (recordControl != null) {
setRecordListener(recordControl, mapActivity); setRecordListener(recordControl, mapActivity);

View file

@ -196,7 +196,7 @@ public class NotesFragment extends OsmAndListFragment {
NotesSortByMode sortByMode = getMyApplication().getSettings().NOTES_SORT_BY_MODE.get(); NotesSortByMode sortByMode = getMyApplication().getSettings().NOTES_SORT_BY_MODE.get();
if (sortByMode.isByDate()) { if (sortByMode.isByDate()) {
res.add(NotesAdapter.TYPE_DATE_HEADER); res.add(NotesAdapter.TYPE_DATE_HEADER);
res.addAll(sortItemsByDateDescending(recs)); res.addAll(sortRecsByDateDescending(recs));
} else if (sortByMode.isByType()) { } else if (sortByMode.isByType()) {
List<Recording> audios = new LinkedList<>(); List<Recording> audios = new LinkedList<>();
List<Recording> photos = new LinkedList<>(); List<Recording> photos = new LinkedList<>();
@ -221,7 +221,7 @@ public class NotesFragment extends OsmAndListFragment {
private void addToResIfNotEmpty(List<Object> res, List<Recording> recs, int header) { private void addToResIfNotEmpty(List<Object> res, List<Recording> recs, int header) {
if (!recs.isEmpty()) { if (!recs.isEmpty()) {
res.add(header); res.add(header);
res.addAll(recs); res.addAll(sortRecsByDateDescending(recs));
} }
} }
@ -317,7 +317,7 @@ public class NotesFragment extends OsmAndListFragment {
listAdapter.notifyDataSetChanged(); listAdapter.notifyDataSetChanged();
} }
private List<Recording> sortItemsByDateDescending(List<Recording> recs) { private List<Recording> sortRecsByDateDescending(List<Recording> recs) {
Collections.sort(recs, new Comparator<Recording>() { Collections.sort(recs, new Comparator<Recording>() {
@Override @Override
public int compare(Recording first, Recording second) { public int compare(Recording first, Recording second) {

View file

@ -86,7 +86,7 @@ public class DashWaypointsFragment extends DashLocationFragment {
@Override @Override
public void onClick(View v) { 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); LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items);

View file

@ -513,7 +513,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
@Override @Override
public void onClick(View v) { public void onClick(View v) {
setDashboardVisibility(true, flatNow ? DashboardType.WAYPOINTS : DashboardType.WAYPOINTS_FLAT, 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() { markersSelectionButton.onClickListener = new View.OnClickListener() {
@Override @Override
public void onClick(View v) { 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.getMapView().refreshMap();
} }
mapActivity.getMapLayers().getMapControlsLayer().showMapControls(); mapActivity.getMapLayers().getMapControlsLayer().showMapControlsIfHidden();
hideActionButton(); hideActionButton();
for (WeakReference<DashBaseFragment> df : fragList) { for (WeakReference<DashBaseFragment> df : fragList) {
if (df.get() != null) { 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) { private void open(boolean animation, int[] animationCoordinates) {
if (animation) { if (animation) {
this.animationCoordinates = animationCoordinates; 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.animateContent).setVisibility(View.VISIBLE);
dashboardView.findViewById(R.id.toolbar).setVisibility(View.VISIBLE); dashboardView.findViewById(R.id.toolbar).setVisibility(View.VISIBLE);
} }
this.animationCoordinates = animationCoordinates;
} }
private void animateDashboard(final boolean show) { private void animateDashboard(final boolean show) {
@ -1259,6 +1258,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
@Override @Override
public void onAnimationStart(Animator animation) { public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation); super.onAnimationStart(animation);
listView.setVerticalScrollBarEnabled(false);
if (show) { if (show) {
content.setVisibility(View.VISIBLE); content.setVisibility(View.VISIBLE);
toolbar.setVisibility(View.VISIBLE); toolbar.setVisibility(View.VISIBLE);
@ -1268,10 +1268,14 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation); super.onAnimationEnd(animation);
listView.setVerticalScrollBarEnabled(true);
if (!show) { if (!show) {
dashboardView.setVisibility(View.GONE); dashboardView.setVisibility(View.GONE);
content.setVisibility(View.GONE); content.setVisibility(View.GONE);
toolbar.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)); setTranslationY(listBackgroundView, Math.max(0, -scrollY + mFlexibleSpaceImageHeight));
} }
} }
if (portrait) { if (portrait && toolbar.getVisibility() == View.VISIBLE) {
setTranslationY(toolbar, Math.min(0, -scrollY + mFlexibleSpaceImageHeight - mFlexibleBlurSpaceHeight)); setTranslationY(toolbar, Math.min(0, -scrollY + mFlexibleSpaceImageHeight - mFlexibleBlurSpaceHeight));
} }
updateColorOfToolbar(scrollY); updateColorOfToolbar(scrollY);

View file

@ -913,7 +913,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
((View) parent).addOnLayoutChangeListener(containerLayoutListener); ((View) parent).addOnLayoutChangeListener(containerLayoutListener);
} }
menu.updateControlsVisibility(true); menu.updateControlsVisibility(true);
getMapActivity().getMapLayers().getMapControlsLayer().showMapControls(); getMapActivity().getMapLayers().getMapControlsLayer().showMapControlsIfHidden();
} }
@Override @Override

View file

@ -60,7 +60,7 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
if (menu == null) { if (menu == null) {
dismiss(); dismiss();
} }
getMapActivity().getMapLayers().getMapControlsLayer().showMapControls(); getMapActivity().getMapLayers().getMapControlsLayer().showMapControlsIfHidden();
} }
@Override @Override

View file

@ -151,7 +151,7 @@ public class MapillaryPlugin extends OsmandPlugin {
@Override @Override
public boolean onRowItemClick(ArrayAdapter<ContextMenuItem> adapter, View view, int itemId, int position) { public boolean onRowItemClick(ArrayAdapter<ContextMenuItem> adapter, View view, int itemId, int position) {
if (itemId == R.string.mapillary) { 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 false;
} }
return true; return true;

View file

@ -362,7 +362,7 @@ public class PlanRouteFragment extends BaseOsmAndFragment implements OsmAndLocat
super.onResume(); super.onResume();
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
mapActivity.getMyApplication().getLocationProvider().addLocationListener(this); mapActivity.getMyApplication().getLocationProvider().addLocationListener(this);
mapActivity.getMapLayers().getMapControlsLayer().showMapControls(); mapActivity.getMapLayers().getMapControlsLayer().showMapControlsIfHidden();
} }
@Override @Override

View file

@ -460,7 +460,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
getMapActivity().getMapLayers().getMapControlsLayer().showMapControls(); getMapActivity().getMapLayers().getMapControlsLayer().showMapControlsIfHidden();
} }
@Override @Override

View file

@ -332,12 +332,16 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view); 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); 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); Button importButton = (Button) emptyView.findViewById(R.id.import_button);
importButton.setOnClickListener(new View.OnClickListener() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
@Override importButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) { @Override
addTrack(); public void onClick(View view) {
} addTrack();
}); }
});
} else {
importButton.setVisibility(View.GONE);
}
if (this.adapter != null) { if (this.adapter != null) {
listView.setAdapter(this.adapter); listView.setAdapter(this.adapter);
} }

View file

@ -3,7 +3,7 @@ package net.osmand.plus.osmedit;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.system.Os; import android.support.v4.content.ContextCompat;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.style.StyleSpan; import android.text.style.StyleSpan;
@ -157,6 +157,7 @@ public class OsmEditsAdapter extends ArrayAdapter<Object> {
} }
private void bindHeaderViewHolder(final HeaderViewHolder holder) { private void bindHeaderViewHolder(final HeaderViewHolder holder) {
setupBackground(holder.backgroundView);
holder.topDivider.setVisibility(portrait ? View.VISIBLE : View.GONE); holder.topDivider.setVisibility(portrait ? View.VISIBLE : View.GONE);
holder.title.setText(R.string.your_edits); holder.title.setText(R.string.your_edits);
holder.checkBox.setChecked(isAllSelected()); holder.checkBox.setChecked(isAllSelected());
@ -176,6 +177,7 @@ public class OsmEditsAdapter extends ArrayAdapter<Object> {
} }
private void bindOsmEditViewHolder(final OsmEditViewHolder holder, final OsmPoint osmEdit, int position) { private void bindOsmEditViewHolder(final OsmEditViewHolder holder, final OsmPoint osmEdit, int position) {
setupBackground(holder.mainView);
holder.titleTextView.setText(getTitle(osmEdit)); holder.titleTextView.setText(getTitle(osmEdit));
holder.descriptionTextView.setText(getDescription(osmEdit)); holder.descriptionTextView.setText(getDescription(osmEdit));
Drawable icon = getIcon(osmEdit); Drawable icon = getIcon(osmEdit);
@ -227,6 +229,12 @@ public class OsmEditsAdapter extends ArrayAdapter<Object> {
holder.bottomDivider.setVisibility(showDivider ? View.VISIBLE : View.GONE); 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() { private int getItemsCount() {
return items.size(); return items.size();
} }
@ -339,12 +347,14 @@ public class OsmEditsAdapter extends ArrayAdapter<Object> {
private class HeaderViewHolder { private class HeaderViewHolder {
View mainView; View mainView;
View topDivider; View topDivider;
View backgroundView;
CheckBox checkBox; CheckBox checkBox;
TextView title; TextView title;
HeaderViewHolder(View view) { HeaderViewHolder(View view) {
mainView = view; mainView = view;
topDivider = view.findViewById(R.id.top_divider); topDivider = view.findViewById(R.id.top_divider);
backgroundView = view.findViewById(R.id.background_view);
checkBox = (CheckBox) view.findViewById(R.id.check_box); checkBox = (CheckBox) view.findViewById(R.id.check_box);
title = (TextView) view.findViewById(R.id.title_text_view); title = (TextView) view.findViewById(R.id.title_text_view);
} }

View file

@ -242,7 +242,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.OnRowItemClick() { ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.OnRowItemClick() {
@Override @Override
public boolean onRowItemClick(ArrayAdapter<ContextMenuItem> adapter, View view, int itemId, int position) { public boolean onRowItemClick(ArrayAdapter<ContextMenuItem> adapter, View view, int itemId, int position) {
int[] viewCoordinates = AndroidUtils.getViewLocation(view); int[] viewCoordinates = AndroidUtils.getCenterViewCoordinates(view);
if (itemId == R.string.layer_overlay) { if (itemId == R.string.layer_overlay) {
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.OVERLAY_MAP, viewCoordinates); mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.OVERLAY_MAP, viewCoordinates);
return false; return false;

View file

@ -294,6 +294,7 @@ public class MapRenderRepositories {
if(library == null) { if(library == null) {
return; return;
} }
boolean useLive = context.getSettings().USE_OSM_LIVE_FOR_ROUTING.get();
for (String mapName : files.keySet()) { for (String mapName : files.keySet()) {
BinaryMapIndexReader fr = files.get(mapName); BinaryMapIndexReader fr = files.get(mapName);
if (fr != null && (fr.containsMapData(leftX, topY, rightX, bottomY, zoom) || if (fr != null && (fr.containsMapData(leftX, topY, rightX, bottomY, zoom) ||
@ -301,7 +302,7 @@ public class MapRenderRepositories {
if (!nativeFiles.contains(mapName)) { if (!nativeFiles.contains(mapName)) {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
nativeFiles.add(mapName); nativeFiles.add(mapName);
if (!library.initMapFile(fr.getFile().getAbsolutePath())) { if (!library.initMapFile(fr.getFile().getAbsolutePath(), useLive)) {
continue; continue;
} }
log.debug("Native resource " + mapName + " initialized " + (System.currentTimeMillis() - time) + " ms"); //$NON-NLS-1$ //$NON-NLS-2$ log.debug("Native resource " + mapName + " initialized " + (System.currentTimeMillis() - time) + " ms"); //$NON-NLS-1$ //$NON-NLS-2$

View file

@ -19,9 +19,7 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SettingsActivity; import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.dashboard.DashboardOnMap; import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.views.GPXLayer;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.RouteLayer;
import net.osmand.render.RenderingRuleProperty; import net.osmand.render.RenderingRuleProperty;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -130,7 +128,7 @@ public class SRTMPlugin extends OsmandPlugin {
@Override @Override
public boolean onRowItemClick(ArrayAdapter<ContextMenuItem> adapter, View view, int itemId, int position) { public boolean onRowItemClick(ArrayAdapter<ContextMenuItem> adapter, View view, int itemId, int position) {
int[] viewCoordinates = AndroidUtils.getViewLocation(view); int[] viewCoordinates = AndroidUtils.getCenterViewCoordinates(view);
if (itemId == R.string.srtm_plugin_name) { if (itemId == R.string.srtm_plugin_name) {
mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.CONTOUR_LINES, viewCoordinates); mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.CONTOUR_LINES, viewCoordinates);
return false; return false;

View file

@ -1,6 +1,10 @@
package net.osmand.plus.views; package net.osmand.plus.views;
import android.Manifest; 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.annotation.SuppressLint;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@ -249,7 +253,7 @@ public class MapControlsLayer extends OsmandMapLayer {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
MapActivity.clearPrevActivityIntent(); 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) { public void onClick(View v) {
MapActivity.clearPrevActivityIntent(); MapActivity.clearPrevActivityIntent();
if (dash) { if (dash) {
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD, AndroidUtils.getViewLocation(v)); mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD, AndroidUtils.getCenterViewCoordinates(v));
} else { } else {
mapActivity.openDrawer(); mapActivity.openDrawer();
} }
@ -656,13 +660,64 @@ public class MapControlsLayer extends OsmandMapLayer {
zoomOutButton.setOnLongClickListener(listener); zoomOutButton.setOnLongClickListener(listener);
} }
public void showMapControls() { public void showMapControlsIfHidden() {
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE); 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); AndroidUtils.showNavBar(mapActivity);
} }
public void hideMapControls() { 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) { public void setMapControlsVisibility(boolean visible) {

View file

@ -1,14 +1,20 @@
package net.osmand.plus.views; 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.content.Context;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.PointF; import android.graphics.PointF;
import android.os.Build;
import android.os.Vibrator; import android.os.Vibrator;
import android.support.annotation.DimenRes; import android.support.annotation.DimenRes;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v4.util.Pair; import android.support.v4.util.Pair;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewAnimationUtils;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
@ -16,6 +22,7 @@ import android.widget.ImageView;
import com.getkeepsafe.taptargetview.TapTarget; import com.getkeepsafe.taptargetview.TapTarget;
import com.getkeepsafe.taptargetview.TapTargetView; import com.getkeepsafe.taptargetview.TapTargetView;
import net.osmand.AndroidUtils;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
import net.osmand.plus.OsmAndLocationProvider; 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.QuickActionRegistry;
import net.osmand.plus.quickaction.QuickActionsWidget; import net.osmand.plus.quickaction.QuickActionsWidget;
import java.util.ArrayList;
import java.util.List;
import static net.osmand.plus.views.ContextMenuLayer.VIBRATE_SHORT; 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 { public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRegistry.QuickActionUpdatesListener, QuickAction.QuickActionSelectionListener {
private final ContextMenuLayer contextMenuLayer; private final ContextMenuLayer contextMenuLayer;
private final MeasurementToolLayer measurementToolLayer; private final MeasurementToolLayer measurementToolLayer;
private final MapMarkersLayer mapMarkersLayer; private final MapMarkersLayer mapMarkersLayer;
private ImageView contextMarker; private ImageView contextMarker;
private final MapActivity mapActivity; private final MapActivity mapActivity;
private final OsmandApplication app; private final OsmandApplication app;
private final OsmandSettings settings; private final OsmandSettings settings;
private final QuickActionRegistry quickActionRegistry; private final QuickActionRegistry quickActionRegistry;
private ImageButton quickActionButton; private ImageButton quickActionButton;
private QuickActionsWidget quickActionsWidget; private QuickActionsWidget quickActionsWidget;
private OsmandMapTileView view; private OsmandMapTileView view;
private boolean wasCollapseButtonVisible; private boolean wasCollapseButtonVisible;
private int previousMapPosition; private int previousMapPosition;
private boolean inMovingMarkerMode; private boolean inMovingMarkerMode;
private boolean isLayerOn; private boolean isLayerOn;
private boolean nightMode; private boolean nightMode;
public MapQuickActionLayer(MapActivity activity, ContextMenuLayer contextMenuLayer) { public MapQuickActionLayer(MapActivity activity, ContextMenuLayer contextMenuLayer) {
this.mapActivity = activity; this.mapActivity = activity;
@ -194,7 +204,11 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
return false; return false;
updateQuickActionButton(showWidget); 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(); mapActivity.updateStatusBarColor();
if (!showWidget) { if (!showWidget) {
@ -211,6 +225,51 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
return true; return true;
} }
private void animateWidget(final boolean show) {
AnimatorSet set = new AnimatorSet();
List<Animator> 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) { private void updateQuickActionButton(boolean widgetVisible) {
quickActionButton.setImageDrawable(app.getIconsCache().getIcon( quickActionButton.setImageDrawable(app.getIconsCache().getIcon(
!widgetVisible ? R.drawable.map_quick_action : R.drawable.map_action_cancel, !nightMode)); !widgetVisible ? R.drawable.map_quick_action : R.drawable.map_action_cancel, !nightMode));

View file

@ -882,7 +882,7 @@ public class MapInfoWidgetsFactory {
all.setOnClickListener(new OnClickListener() { all.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View view) { 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() { remove.setOnClickListener(new OnClickListener() {