Merge remote-tracking branch 'origin/master'
|
@ -685,21 +685,25 @@ public class RouteDataObject {
|
|||
return direction;
|
||||
}
|
||||
|
||||
public boolean isStopDirectionOpposite(boolean direction) {
|
||||
for(int i=0; i<types.length; i++) {
|
||||
public int isStopApplicable(boolean direction) {
|
||||
int sz = types.length;
|
||||
for (int i = 0; i < sz; i++) {
|
||||
RouteTypeRule r = region.quickGetEncodingRule(types[i]);
|
||||
if (r.getTag().equals("highway") && r.getValue().equals("stop")) {
|
||||
for (int j=0; j<types.length; j++) {
|
||||
if (direction = true && r.getTag().equals("direction") && r.getValue().equals("backward")) {
|
||||
return true;
|
||||
}
|
||||
if (direction = false && r.getTag().equals("direction") && r.getValue().equals("forward")) {
|
||||
return true;
|
||||
if (r.getTag().equals("direction")) {
|
||||
String dv = r.getValue();
|
||||
if ((dv.equals("forward") && direction == true) || (dv.equals("backward") && direction == false)) {
|
||||
return 1;
|
||||
} else if ((dv.equals("forward") && direction == false) || (dv.equals("backward") && direction == true)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
// stop=all usually tagged on conflicting node itself, so not needed here
|
||||
//if (r.getTag().equals("stop") && r.getValue().equals("all")) {
|
||||
// return 1;
|
||||
//}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
// Open: Could add some analysis if a STOP without directional tagging is shortly _behind_ an intersection
|
||||
return 0; //no directional info detected
|
||||
}
|
||||
|
||||
public double distance(int startPoint, int endPoint) {
|
||||
|
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.2 KiB |
142
OsmAnd/res/layout/fragment_import_gpx_bottom_sheet_dialog.xml
Normal 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>
|
|
@ -9,6 +9,10 @@
|
|||
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
|
||||
-->
|
||||
<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="enter_new_name">Enter new name</string>
|
||||
<string name="shared_string_back">Back</string>
|
||||
|
|
|
@ -87,6 +87,7 @@ import net.osmand.plus.helpers.AndroidUiHelper;
|
|||
import net.osmand.plus.helpers.DiscountHelper;
|
||||
import net.osmand.plus.helpers.ExternalApiHelper;
|
||||
import net.osmand.plus.helpers.GpxImportHelper;
|
||||
import net.osmand.plus.helpers.GpxImportHelper.ImportGpxBottomSheetDialogFragment;
|
||||
import net.osmand.plus.helpers.WakeLockHelper;
|
||||
import net.osmand.plus.inapp.InAppHelper;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
|
@ -319,17 +320,25 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
Fragment planRouteFragment = fm.findFragmentByTag(PlanRouteFragment.TAG);
|
||||
if (planRouteFragment != null) {
|
||||
fm.beginTransaction()
|
||||
.remove(planRouteFragment)
|
||||
.commitNowAllowingStateLoss();
|
||||
if (removeFragment(PlanRouteFragment.TAG)) {
|
||||
app.getMapMarkersHelper().getPlanRouteContext().setFragmentVisible(true);
|
||||
}
|
||||
removeFragment(ImportGpxBottomSheetDialogFragment.TAG);
|
||||
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() {
|
||||
if (app.isApplicationInitializing()) {
|
||||
findViewById(R.id.init_progress).setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -1,18 +1,37 @@
|
|||
package net.osmand.plus.helpers;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.provider.OpenableColumns;
|
||||
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.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 net.osmand.AndroidUtils;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
|
@ -21,6 +40,7 @@ import net.osmand.plus.GPXUtilities.GPXFile;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
||||
|
@ -47,7 +67,7 @@ public class GpxImportHelper {
|
|||
public static final String KML_SUFFIX = ".kml";
|
||||
public static final String KMZ_SUFFIX = ".kmz";
|
||||
public static final String GPX_SUFFIX = ".gpx";
|
||||
private final Activity activity;
|
||||
private final AppCompatActivity activity;
|
||||
private final OsmandApplication app;
|
||||
private final OsmandMapTileView mapView;
|
||||
private OnGpxImportCompleteListener gpxImportCompleteListener;
|
||||
|
@ -56,7 +76,7 @@ public class GpxImportHelper {
|
|||
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.app = app;
|
||||
this.mapView = mapView;
|
||||
|
@ -524,26 +544,13 @@ public class GpxImportHelper {
|
|||
if (forceImportFavourites) {
|
||||
importFavoritesImpl(gpxFile, fileName, true);
|
||||
} else {
|
||||
final DialogInterface.OnClickListener importFavouritesListener = new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_POSITIVE:
|
||||
importFavoritesImpl(gpxFile, fileName, false);
|
||||
break;
|
||||
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();
|
||||
ImportGpxBottomSheetDialogFragment fragment = new ImportGpxBottomSheetDialogFragment();
|
||||
fragment.setGpxImportHelper(this);
|
||||
fragment.setGpxFile(gpxFile);
|
||||
fragment.setFileName(fileName);
|
||||
fragment.setSave(save);
|
||||
fragment.setUseImportDir(useImportDir);
|
||||
fragment.show(activity.getSupportFragmentManager(), ImportGpxBottomSheetDialogFragment.TAG);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -597,4 +604,142 @@ public class GpxImportHelper {
|
|||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -272,23 +272,14 @@ public class WaypointHelper {
|
|||
RouteTypeRule typeRule = reg.quickGetEncodingRule(pointTypes[r]);
|
||||
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) {
|
||||
//TODO: better than bearingVsRouteDirection would be routeVsWayDirection analysis
|
||||
if (ro.isStopDirectionOpposite(ro.bearingVsRouteDirection(loc))) {
|
||||
if (ro.isStopApplicable(ro.bearingVsRouteDirection(loc)) == -1) {
|
||||
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();
|
||||
//}
|
||||
}
|
||||
|
||||
if (info != null) {
|
||||
if (info.getType() != AlarmInfoType.SPEED_CAMERA || showCameras) {
|
||||
|
|
|
@ -95,8 +95,8 @@ public class NominatimPoiFilter extends PoiUIFilter {
|
|||
urlq = NOMINATIM_API + "?format=xml&addressdetails=0&accept-language="+ Locale.getDefault().getLanguage()
|
||||
+ "&q=" + URLEncoder.encode(getFilterByName());
|
||||
} else {
|
||||
urlq = NOMINATIM_API + URLEncoder.encode(getFilterByName()) + "?format=xml&addressdetails=1&limit=" + LIMIT
|
||||
+ "&bounded=1&" + viewbox;
|
||||
urlq = NOMINATIM_API + "?format=xml&addressdetails=1&limit=" + LIMIT
|
||||
+ "&bounded=1&" + viewbox + "&q=" + URLEncoder.encode(getFilterByName());
|
||||
}
|
||||
log.info(urlq);
|
||||
URLConnection connection = NetworkUtils.getHttpURLConnection(urlq); //$NON-NLS-1$
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.router.RouteSegmentResult;
|
||||
import net.osmand.router.TurnType;
|
||||
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
import android.content.Context;
|
||||
|
@ -189,7 +190,8 @@ public class RouteCalculationResult {
|
|||
loc.setLatitude(MapUtils.get31LatitudeY(y31));
|
||||
loc.setLongitude(MapUtils.get31LongitudeX(x31));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -533,12 +533,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
updateClearButtonAndHint();
|
||||
updateClearButtonVisibility(true);
|
||||
boolean textEmpty = newQueryText.length() == 0;
|
||||
updateTabbarVisibility(textEmpty);
|
||||
updateTabbarVisibility(textEmpty && !isOnlineSearch());
|
||||
if (textEmpty) {
|
||||
if (addressSearch) {
|
||||
startAddressSearch();
|
||||
} else if (isOnlineSearch()) {
|
||||
restoreSearch();
|
||||
}
|
||||
if (poiFilterApplied) {
|
||||
poiFilterApplied = false;
|
||||
|
@ -552,7 +550,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
if (!searchQuery.equalsIgnoreCase(newQueryText)) {
|
||||
searchQuery = newQueryText;
|
||||
if (Algorithms.isEmpty(searchQuery)) {
|
||||
cancelSearch();
|
||||
setResultCollection(null);
|
||||
searchUICore.resetPhrase();
|
||||
mainSearchFragment.getAdapter().clear();
|
||||
} else {
|
||||
runSearch();
|
||||
}
|
||||
|
@ -712,6 +713,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
return searchEditText.getText().toString();
|
||||
}
|
||||
|
||||
public boolean isTextEmpty() {
|
||||
return Algorithms.isEmpty(getText());
|
||||
}
|
||||
|
||||
public AccessibilityAssistant getAccessibilityAssistant() {
|
||||
return accessibilityAssistant;
|
||||
}
|
||||
|
@ -999,7 +1004,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
} else {
|
||||
tabToolbarView.setVisibility(View.GONE);
|
||||
buttonToolbarView.setVisibility(
|
||||
(isOnlineSearch() && getText().length() > 0)
|
||||
(isOnlineSearch() && !isTextEmpty())
|
||||
|| !searchUICore.getSearchSettings().isCustomSearch() ? View.VISIBLE : View.GONE);
|
||||
tabsView.setVisibility(View.GONE);
|
||||
searchView.setVisibility(View.VISIBLE);
|
||||
|
@ -1426,6 +1431,13 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
searchUICore.updateSettings(settings);
|
||||
}
|
||||
|
||||
private void cancelSearch() {
|
||||
cancelPrev = true;
|
||||
if (!paused) {
|
||||
hideProgressBar();
|
||||
}
|
||||
}
|
||||
|
||||
private void runSearch() {
|
||||
runSearch(searchQuery);
|
||||
}
|
||||
|
@ -1511,7 +1523,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
app.runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(paused) {
|
||||
if (paused) {
|
||||
return;
|
||||
}
|
||||
searching = false;
|
||||
|
@ -1722,7 +1734,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
}
|
||||
|
||||
private void addMoreButton() {
|
||||
if (!paused && !cancelPrev && mainSearchFragment != null) {
|
||||
if (!paused && !cancelPrev && mainSearchFragment != null && !isTextEmpty()) {
|
||||
QuickSearchMoreListItem moreListItem =
|
||||
new QuickSearchMoreListItem(app, null, new SearchMoreItemOnClickListener() {
|
||||
@Override
|
||||
|
@ -1744,6 +1756,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
});
|
||||
moreListItem.setInterruptedSearch(interruptedSearch);
|
||||
moreListItem.setEmptySearch(isResultEmpty());
|
||||
moreListItem.setOnlineSearch(isOnlineSearch());
|
||||
mainSearchFragment.addListItem(moreListItem);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -338,7 +338,8 @@ public class QuickSearchHelper implements ResourceListener {
|
|||
double lon = phrase.getSettings().getOriginalLocation().getLongitude();
|
||||
String text = phrase.getUnknownSearchPhrase();
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -242,9 +242,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
|||
((QuickSearchMoreListItem) listItem).increaseRadiusOnClick();
|
||||
}
|
||||
});
|
||||
if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null
|
||||
&& !app.getSearchUICore().getCore().getSearchSettings().isCustomSearch()
|
||||
&& !app.getSearchUICore().getCore().getSearchSettings().hasCustomSearchType(ObjectType.ONLINE_SEARCH)) {
|
||||
if (!searchMoreListItem.isOnlineSearch()) {
|
||||
view.findViewById(R.id.online_search_row).setVisibility(View.VISIBLE);
|
||||
view.findViewById(R.id.online_search_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -10,6 +10,7 @@ public class QuickSearchMoreListItem extends QuickSearchListItem {
|
|||
private String name;
|
||||
private SearchMoreItemOnClickListener onClickListener;
|
||||
private boolean emptySearch;
|
||||
private boolean onlineSearch;
|
||||
private boolean interruptedSearch;
|
||||
private String findMore;
|
||||
private String restartSearch;
|
||||
|
@ -59,6 +60,14 @@ public class QuickSearchMoreListItem extends QuickSearchListItem {
|
|||
this.emptySearch = emptySearch;
|
||||
}
|
||||
|
||||
public boolean isOnlineSearch() {
|
||||
return onlineSearch;
|
||||
}
|
||||
|
||||
public void setOnlineSearch(boolean onlineSearch) {
|
||||
this.onlineSearch = onlineSearch;
|
||||
}
|
||||
|
||||
public void increaseRadiusOnClick() {
|
||||
if (onClickListener != null) {
|
||||
onClickListener.increaseRadiusOnClick();
|
||||
|
|