Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-10-28 10:48:40 +02:00
commit 20c67186bb
24 changed files with 384 additions and 66 deletions

View file

@ -685,21 +685,25 @@ public class RouteDataObject {
return direction; return direction;
} }
public boolean isStopDirectionOpposite(boolean direction) { public int isStopApplicable(boolean direction) {
for(int i=0; i<types.length; i++) { int sz = types.length;
for (int i = 0; i < sz; i++) {
RouteTypeRule r = region.quickGetEncodingRule(types[i]); RouteTypeRule r = region.quickGetEncodingRule(types[i]);
if (r.getTag().equals("highway") && r.getValue().equals("stop")) { if (r.getTag().equals("direction")) {
for (int j=0; j<types.length; j++) { String dv = r.getValue();
if (direction = true && r.getTag().equals("direction") && r.getValue().equals("backward")) { if ((dv.equals("forward") && direction == true) || (dv.equals("backward") && direction == false)) {
return true; return 1;
} } else if ((dv.equals("forward") && direction == false) || (dv.equals("backward") && direction == true)) {
if (direction = false && r.getTag().equals("direction") && r.getValue().equals("forward")) { return -1;
return true;
} }
} }
// stop=all usually tagged on conflicting node itself, so not needed here
//if (r.getTag().equals("stop") && r.getValue().equals("all")) {
// return 1;
//}
} }
} // Open: Could add some analysis if a STOP without directional tagging is shortly _behind_ an intersection
return false; return 0; //no directional info detected
} }
public double distance(int startPoint, int endPoint) { public double distance(int startPoint, int endPoint) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -0,0 +1,142 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?attr/bg_color"
android:orientation="vertical">
<ScrollView
android:id="@+id/import_gpx_scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/import_gpx_title"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_title_height"
android:gravity="center_vertical"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding"
android:text="@string/import_file"
android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"/>
<TextView
android:id="@+id/import_gpx_description"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_descr_height"
android:ellipsize="end"
android:maxLines="2"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding"
android:textSize="@dimen/default_desc_text_size"
tools:text="Berlin_CultourTour.gpx can be imported as Favorites points, or as track file."/>
<LinearLayout
android:id="@+id/import_as_favorites_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding">
<ImageView
android:id="@+id/import_as_favorites_icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_fav_dark"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxLines="1"
android:text="@string/import_as_favorites"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_marginBottom="@dimen/bottom_sheet_divider_margin_bottom"
android:layout_marginLeft="@dimen/bottom_sheet_divider_margin_start"
android:layout_marginStart="@dimen/bottom_sheet_divider_margin_start"
android:layout_marginTop="@dimen/bottom_sheet_divider_margin_top"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:id="@+id/import_as_gpx_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding">
<ImageView
android:id="@+id/import_as_gpx_icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_polygom_dark"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxLines="1"
android:text="@string/import_as_gpx"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<FrameLayout
android:id="@+id/cancel_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/shared_string_cancel"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"/>
</FrameLayout>
</LinearLayout>

View file

@ -9,6 +9,10 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="import_gpx_file_description">can be imported as Favorites points, or as track file.</string>
<string name="import_as_gpx">Import as GPX file</string>
<string name="import_as_favorites">Import as Favorites</string>
<string name="import_file">Import file</string>
<string name="wrong_input">Wrong input</string> <string name="wrong_input">Wrong input</string>
<string name="enter_new_name">Enter new name</string> <string name="enter_new_name">Enter new name</string>
<string name="shared_string_back">Back</string> <string name="shared_string_back">Back</string>

View file

@ -87,6 +87,7 @@ import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.DiscountHelper; import net.osmand.plus.helpers.DiscountHelper;
import net.osmand.plus.helpers.ExternalApiHelper; import net.osmand.plus.helpers.ExternalApiHelper;
import net.osmand.plus.helpers.GpxImportHelper; import net.osmand.plus.helpers.GpxImportHelper;
import net.osmand.plus.helpers.GpxImportHelper.ImportGpxBottomSheetDialogFragment;
import net.osmand.plus.helpers.WakeLockHelper; import net.osmand.plus.helpers.WakeLockHelper;
import net.osmand.plus.inapp.InAppHelper; import net.osmand.plus.inapp.InAppHelper;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
@ -319,17 +320,25 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
@Override @Override
protected void onSaveInstanceState(Bundle outState) { protected void onSaveInstanceState(Bundle outState) {
FragmentManager fm = getSupportFragmentManager(); if (removeFragment(PlanRouteFragment.TAG)) {
Fragment planRouteFragment = fm.findFragmentByTag(PlanRouteFragment.TAG);
if (planRouteFragment != null) {
fm.beginTransaction()
.remove(planRouteFragment)
.commitNowAllowingStateLoss();
app.getMapMarkersHelper().getPlanRouteContext().setFragmentVisible(true); app.getMapMarkersHelper().getPlanRouteContext().setFragmentVisible(true);
} }
removeFragment(ImportGpxBottomSheetDialogFragment.TAG);
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
} }
private boolean removeFragment(String tag) {
FragmentManager fm = getSupportFragmentManager();
Fragment fragment = fm.findFragmentByTag(tag);
if (fragment != null) {
fm.beginTransaction()
.remove(fragment)
.commitNowAllowingStateLoss();
return true;
}
return false;
}
private void checkAppInitialization() { private void checkAppInitialization() {
if (app.isApplicationInitializing()) { if (app.isApplicationInitializing()) {
findViewById(R.id.init_progress).setVisibility(View.VISIBLE); findViewById(R.id.init_progress).setVisibility(View.VISIBLE);

View file

@ -1,18 +1,37 @@
package net.osmand.plus.helpers; package net.osmand.plus.helpers;
import android.app.Activity;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.database.Cursor; import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor;
import android.provider.OpenableColumns; import android.provider.OpenableColumns;
import android.provider.Settings; import android.provider.Settings;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.FavouritesDbHelper;
@ -21,6 +40,7 @@ import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BottomSheetDialogFragment;
import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
@ -47,7 +67,7 @@ public class GpxImportHelper {
public static final String KML_SUFFIX = ".kml"; public static final String KML_SUFFIX = ".kml";
public static final String KMZ_SUFFIX = ".kmz"; public static final String KMZ_SUFFIX = ".kmz";
public static final String GPX_SUFFIX = ".gpx"; public static final String GPX_SUFFIX = ".gpx";
private final Activity activity; private final AppCompatActivity activity;
private final OsmandApplication app; private final OsmandApplication app;
private final OsmandMapTileView mapView; private final OsmandMapTileView mapView;
private OnGpxImportCompleteListener gpxImportCompleteListener; private OnGpxImportCompleteListener gpxImportCompleteListener;
@ -56,7 +76,7 @@ public class GpxImportHelper {
void onComplete(boolean success); void onComplete(boolean success);
} }
public GpxImportHelper(final Activity activity, final OsmandApplication app, final OsmandMapTileView mapView) { public GpxImportHelper(final AppCompatActivity activity, final OsmandApplication app, final OsmandMapTileView mapView) {
this.activity = activity; this.activity = activity;
this.app = app; this.app = app;
this.mapView = mapView; this.mapView = mapView;
@ -524,26 +544,13 @@ public class GpxImportHelper {
if (forceImportFavourites) { if (forceImportFavourites) {
importFavoritesImpl(gpxFile, fileName, true); importFavoritesImpl(gpxFile, fileName, true);
} else { } else {
final DialogInterface.OnClickListener importFavouritesListener = new DialogInterface.OnClickListener() { ImportGpxBottomSheetDialogFragment fragment = new ImportGpxBottomSheetDialogFragment();
@Override fragment.setGpxImportHelper(this);
public void onClick(DialogInterface dialog, int which) { fragment.setGpxFile(gpxFile);
switch (which) { fragment.setFileName(fileName);
case DialogInterface.BUTTON_POSITIVE: fragment.setSave(save);
importFavoritesImpl(gpxFile, fileName, false); fragment.setUseImportDir(useImportDir);
break; fragment.show(activity.getSupportFragmentManager(), ImportGpxBottomSheetDialogFragment.TAG);
case DialogInterface.BUTTON_NEGATIVE:
handleResult(gpxFile, fileName, save, useImportDir, false);
break;
}
}
};
new AlertDialog.Builder(activity)
.setTitle(R.string.shared_string_import2osmand)
.setMessage(R.string.import_file_favourites)
.setPositiveButton(R.string.shared_string_import, importFavouritesListener)
.setNegativeButton(R.string.shared_string_save, importFavouritesListener)
.show();
} }
} }
@ -597,4 +604,142 @@ public class GpxImportHelper {
} }
return false; return false;
} }
public static class ImportGpxBottomSheetDialogFragment extends BottomSheetDialogFragment {
public static final String TAG = "ImportGpxBottomSheetDialogFragment";
private GpxImportHelper gpxImportHelper;
private boolean portrait;
private boolean night;
private GPXFile gpxFile;
private String fileName;
private boolean save;
private boolean useImportDir;
public void setGpxImportHelper(GpxImportHelper gpxImportHelper) {
this.gpxImportHelper = gpxImportHelper;
}
public void setGpxFile(GPXFile gpxFile) {
this.gpxFile = gpxFile;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public void setSave(boolean save) {
this.save = save;
}
public void setUseImportDir(boolean useImportDir) {
this.useImportDir = useImportDir;
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
night = getMyApplication().getDaynightHelper().isNightModeForMapControls();
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_import_gpx_bottom_sheet_dialog, container);
if (portrait) {
AndroidUtils.setBackground(getActivity(), mainView, night, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
}
if (night) {
((TextView) mainView.findViewById(R.id.import_gpx_title)).setTextColor(ContextCompat.getColor(getActivity(), R.color.ctx_menu_info_text_dark));
}
((ImageView) mainView.findViewById(R.id.import_as_favorites_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_fav_dark));
((ImageView) mainView.findViewById(R.id.import_as_gpx_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_polygom_dark));
int nameColor = ContextCompat.getColor(getContext(), night ? R.color.osmand_orange : R.color.dashboard_blue);
int descrColor = ContextCompat.getColor(getContext(), night ? R.color.dashboard_subheader_text_dark : R.color.dashboard_subheader_text_light);
String descr = getString(R.string.import_gpx_file_description);
SpannableStringBuilder text = new SpannableStringBuilder(fileName).append(" ").append(descr);
text.setSpan(new ForegroundColorSpan(nameColor), 0, fileName.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
text.setSpan(new ForegroundColorSpan(descrColor), fileName.length() + 1, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
((TextView) mainView.findViewById(R.id.import_gpx_description)).setText(text);
mainView.findViewById(R.id.import_as_favorites_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
gpxImportHelper.importFavoritesImpl(gpxFile, fileName, false);
dismiss();
}
});
mainView.findViewById(R.id.import_as_gpx_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
gpxImportHelper.handleResult(gpxFile, fileName, save, useImportDir, false);
dismiss();
}
});
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
final int screenHeight = AndroidUtils.getScreenHeight(getActivity());
final int statusBarHeight = AndroidUtils.getStatusBarHeight(getActivity());
final int navBarHeight = AndroidUtils.getNavBarHeight(getActivity());
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
final View scrollView = mainView.findViewById(R.id.import_gpx_scroll_view);
int scrollViewHeight = scrollView.getHeight();
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
if (scrollViewHeight > spaceForScrollView) {
scrollView.getLayoutParams().height = spaceForScrollView;
scrollView.requestLayout();
}
if (!portrait) {
if (screenHeight - statusBarHeight - mainView.getHeight() >= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) {
AndroidUtils.setBackground(getActivity(), mainView, night,
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
} else {
AndroidUtils.setBackground(getActivity(), mainView, night,
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
}
}
ViewTreeObserver obs = mainView.getViewTreeObserver();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
obs.removeOnGlobalLayoutListener(this);
} else {
obs.removeGlobalOnLayoutListener(this);
}
}
});
return mainView;
}
@Override
public void onStart() {
super.onStart();
if (!portrait) {
final Window window = getDialog().getWindow();
WindowManager.LayoutParams params = window.getAttributes();
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
window.setAttributes(params);
}
}
@Override
protected Drawable getContentIcon(@DrawableRes int id) {
return getIcon(id, night ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
}
}
} }

View file

@ -272,23 +272,14 @@ public class WaypointHelper {
RouteTypeRule typeRule = reg.quickGetEncodingRule(pointTypes[r]); RouteTypeRule typeRule = reg.quickGetEncodingRule(pointTypes[r]);
AlarmInfo info = AlarmInfo.createAlarmInfo(typeRule, 0, loc); AlarmInfo info = AlarmInfo.createAlarmInfo(typeRule, 0, loc);
//Check if stop sign is tagged with direction=forward/backward // For STOP first check if it has directional info
// TODO: Check if this is needed here
if (info != null && info.getType() != null && info.getType() == AlarmInfoType.STOP) { if (info != null && info.getType() != null && info.getType() == AlarmInfoType.STOP) {
//TODO: better than bearingVsRouteDirection would be routeVsWayDirection analysis if (ro.isStopApplicable(ro.bearingVsRouteDirection(loc)) == -1) {
if (ro.isStopDirectionOpposite(ro.bearingVsRouteDirection(loc))) {
info = null; info = null;
} }
//TODO: Still missing here is analysis if a stop without direction=* tagging is _behind_ an intersection
}
// Issue #2873 may indicate we need some sort of check here if Alarm is in forward direction
// But cannot reproduce the issue for now
//if (loc.hasBearing()) {
// if (Math.abs(MapUtils.alignAngleDifference(bearingTo("actual alarm location") - loc.getBearing() / 180f * Math.PI)) >= Math.PI / 2f) {
// info = null;
// }
//Toast.makeText(app.getApplicationContext(), Double.toString(ro.directionRoute(0, true)) + ",\n" + Double.toString(loc.getBearing()) + ",\n" + Double.toString(MapUtils.alignAngleDifference(ro.directionRoute(0, true) - loc.getBearing() / 180f * Math.PI))), Toast.LENGTH_LONG).show(); //Toast.makeText(app.getApplicationContext(), Double.toString(ro.directionRoute(0, true)) + ",\n" + Double.toString(loc.getBearing()) + ",\n" + Double.toString(MapUtils.alignAngleDifference(ro.directionRoute(0, true) - loc.getBearing() / 180f * Math.PI))), Toast.LENGTH_LONG).show();
//} }
if (info != null) { if (info != null) {
if (info.getType() != AlarmInfoType.SPEED_CAMERA || showCameras) { if (info.getType() != AlarmInfoType.SPEED_CAMERA || showCameras) {

View file

@ -95,8 +95,8 @@ public class NominatimPoiFilter extends PoiUIFilter {
urlq = NOMINATIM_API + "?format=xml&addressdetails=0&accept-language="+ Locale.getDefault().getLanguage() urlq = NOMINATIM_API + "?format=xml&addressdetails=0&accept-language="+ Locale.getDefault().getLanguage()
+ "&q=" + URLEncoder.encode(getFilterByName()); + "&q=" + URLEncoder.encode(getFilterByName());
} else { } else {
urlq = NOMINATIM_API + URLEncoder.encode(getFilterByName()) + "?format=xml&addressdetails=1&limit=" + LIMIT urlq = NOMINATIM_API + "?format=xml&addressdetails=1&limit=" + LIMIT
+ "&bounded=1&" + viewbox; + "&bounded=1&" + viewbox + "&q=" + URLEncoder.encode(getFilterByName());
} }
log.info(urlq); log.info(urlq);
URLConnection connection = NetworkUtils.getHttpURLConnection(urlq); //$NON-NLS-1$ URLConnection connection = NetworkUtils.getHttpURLConnection(urlq); //$NON-NLS-1$

View file

@ -14,6 +14,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.router.RouteSegmentResult; import net.osmand.router.RouteSegmentResult;
import net.osmand.router.TurnType; import net.osmand.router.TurnType;
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import android.content.Context; import android.content.Context;
@ -189,7 +190,8 @@ public class RouteCalculationResult {
loc.setLatitude(MapUtils.get31LatitudeY(y31)); loc.setLatitude(MapUtils.get31LatitudeY(y31));
loc.setLongitude(MapUtils.get31LongitudeX(x31)); loc.setLongitude(MapUtils.get31LongitudeX(x31));
AlarmInfo info = AlarmInfo.createAlarmInfo(typeRule, locInd, loc); AlarmInfo info = AlarmInfo.createAlarmInfo(typeRule, locInd, loc);
if(info != null) { // For STOP first check if it has directional info
if ((info != null) && !((info.getType() == AlarmInfoType.STOP) && (res.getObject().isStopApplicable(res.isForwardDirection()) == -1))) {
alarms.add(info); alarms.add(info);
} }
} }

View file

@ -533,12 +533,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
updateClearButtonAndHint(); updateClearButtonAndHint();
updateClearButtonVisibility(true); updateClearButtonVisibility(true);
boolean textEmpty = newQueryText.length() == 0; boolean textEmpty = newQueryText.length() == 0;
updateTabbarVisibility(textEmpty); updateTabbarVisibility(textEmpty && !isOnlineSearch());
if (textEmpty) { if (textEmpty) {
if (addressSearch) { if (addressSearch) {
startAddressSearch(); startAddressSearch();
} else if (isOnlineSearch()) {
restoreSearch();
} }
if (poiFilterApplied) { if (poiFilterApplied) {
poiFilterApplied = false; poiFilterApplied = false;
@ -552,7 +550,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
if (!searchQuery.equalsIgnoreCase(newQueryText)) { if (!searchQuery.equalsIgnoreCase(newQueryText)) {
searchQuery = newQueryText; searchQuery = newQueryText;
if (Algorithms.isEmpty(searchQuery)) { if (Algorithms.isEmpty(searchQuery)) {
cancelSearch();
setResultCollection(null);
searchUICore.resetPhrase(); searchUICore.resetPhrase();
mainSearchFragment.getAdapter().clear();
} else { } else {
runSearch(); runSearch();
} }
@ -712,6 +713,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
return searchEditText.getText().toString(); return searchEditText.getText().toString();
} }
public boolean isTextEmpty() {
return Algorithms.isEmpty(getText());
}
public AccessibilityAssistant getAccessibilityAssistant() { public AccessibilityAssistant getAccessibilityAssistant() {
return accessibilityAssistant; return accessibilityAssistant;
} }
@ -999,7 +1004,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
} else { } else {
tabToolbarView.setVisibility(View.GONE); tabToolbarView.setVisibility(View.GONE);
buttonToolbarView.setVisibility( buttonToolbarView.setVisibility(
(isOnlineSearch() && getText().length() > 0) (isOnlineSearch() && !isTextEmpty())
|| !searchUICore.getSearchSettings().isCustomSearch() ? View.VISIBLE : View.GONE); || !searchUICore.getSearchSettings().isCustomSearch() ? View.VISIBLE : View.GONE);
tabsView.setVisibility(View.GONE); tabsView.setVisibility(View.GONE);
searchView.setVisibility(View.VISIBLE); searchView.setVisibility(View.VISIBLE);
@ -1426,6 +1431,13 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
searchUICore.updateSettings(settings); searchUICore.updateSettings(settings);
} }
private void cancelSearch() {
cancelPrev = true;
if (!paused) {
hideProgressBar();
}
}
private void runSearch() { private void runSearch() {
runSearch(searchQuery); runSearch(searchQuery);
} }
@ -1511,7 +1523,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
app.runInUIThread(new Runnable() { app.runInUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if(paused) { if (paused) {
return; return;
} }
searching = false; searching = false;
@ -1722,7 +1734,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
} }
private void addMoreButton() { private void addMoreButton() {
if (!paused && !cancelPrev && mainSearchFragment != null) { if (!paused && !cancelPrev && mainSearchFragment != null && !isTextEmpty()) {
QuickSearchMoreListItem moreListItem = QuickSearchMoreListItem moreListItem =
new QuickSearchMoreListItem(app, null, new SearchMoreItemOnClickListener() { new QuickSearchMoreListItem(app, null, new SearchMoreItemOnClickListener() {
@Override @Override
@ -1744,6 +1756,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
}); });
moreListItem.setInterruptedSearch(interruptedSearch); moreListItem.setInterruptedSearch(interruptedSearch);
moreListItem.setEmptySearch(isResultEmpty()); moreListItem.setEmptySearch(isResultEmpty());
moreListItem.setOnlineSearch(isOnlineSearch());
mainSearchFragment.addListItem(moreListItem); mainSearchFragment.addListItem(moreListItem);
} }
} }

View file

@ -338,7 +338,8 @@ public class QuickSearchHelper implements ResourceListener {
double lon = phrase.getSettings().getOriginalLocation().getLongitude(); double lon = phrase.getSettings().getOriginalLocation().getLongitude();
String text = phrase.getUnknownSearchPhrase(); String text = phrase.getUnknownSearchPhrase();
filter.setFilterByName(text); filter.setFilterByName(text);
publishAmenities(phrase, matcher, filter.initializeNewSearch(lat, lon, -1, null, phrase.getRadiusLevel())); publishAmenities(phrase, matcher, filter.initializeNewSearch(lat, lon,
-1, null, phrase.getRadiusLevel() + 3));
return true; return true;
} }

View file

@ -242,9 +242,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
((QuickSearchMoreListItem) listItem).increaseRadiusOnClick(); ((QuickSearchMoreListItem) listItem).increaseRadiusOnClick();
} }
}); });
if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null if (!searchMoreListItem.isOnlineSearch()) {
&& !app.getSearchUICore().getCore().getSearchSettings().isCustomSearch()
&& !app.getSearchUICore().getCore().getSearchSettings().hasCustomSearchType(ObjectType.ONLINE_SEARCH)) {
view.findViewById(R.id.online_search_row).setVisibility(View.VISIBLE); view.findViewById(R.id.online_search_row).setVisibility(View.VISIBLE);
view.findViewById(R.id.online_search_row).setOnClickListener(new View.OnClickListener() { view.findViewById(R.id.online_search_row).setOnClickListener(new View.OnClickListener() {
@Override @Override

View file

@ -10,6 +10,7 @@ public class QuickSearchMoreListItem extends QuickSearchListItem {
private String name; private String name;
private SearchMoreItemOnClickListener onClickListener; private SearchMoreItemOnClickListener onClickListener;
private boolean emptySearch; private boolean emptySearch;
private boolean onlineSearch;
private boolean interruptedSearch; private boolean interruptedSearch;
private String findMore; private String findMore;
private String restartSearch; private String restartSearch;
@ -59,6 +60,14 @@ public class QuickSearchMoreListItem extends QuickSearchListItem {
this.emptySearch = emptySearch; this.emptySearch = emptySearch;
} }
public boolean isOnlineSearch() {
return onlineSearch;
}
public void setOnlineSearch(boolean onlineSearch) {
this.onlineSearch = onlineSearch;
}
public void increaseRadiusOnClick() { public void increaseRadiusOnClick() {
if (onClickListener != null) { if (onClickListener != null) {
onClickListener.increaseRadiusOnClick(); onClickListener.increaseRadiusOnClick();