Add AddPointBottomSheetDialog instead of spinner
This commit is contained in:
parent
bdf3ad58ef
commit
488478270c
12 changed files with 510 additions and 87 deletions
113
OsmAnd/res/layout/bottom_sheet_double_item.xml
Normal file
113
OsmAnd/res/layout/bottom_sheet_double_item.xml
Normal file
|
@ -0,0 +1,113 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/bottom_sheet_selected_item_title_height">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/first_item"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:layout_marginTop="4dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/first_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_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
tools:src="@drawable/ic_action_search_dark" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/first_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_content_margin_small"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_content_margin_small"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
tools:text="@string/shared_string_search" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/first_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_content_margin_small"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_content_margin_small"
|
||||
android:layout_marginStart="@dimen/content_padding" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/second_item"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:layout_marginTop="4dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/second_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_marginLeft="@dimen/bottom_sheet_content_margin_small"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_content_margin_small"
|
||||
tools:src="@drawable/ic_action_info_dark" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/second_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
tools:text="@string/shared_string_address" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/second_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_content_margin_small"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_content_margin_small" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -19,7 +19,7 @@
|
|||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_info_dark"/>
|
||||
|
||||
<TextView
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
android:paddingRight="@dimen/route_info_buttons_padding_top_bottom"
|
||||
android:paddingTop="@dimen/content_padding">
|
||||
|
||||
<net.osmand.plus.routepreparationmenu.FlowLayout
|
||||
<net.osmand.plus.widgets.FlowLayout
|
||||
android:id="@+id/routes_badges"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
- For wording and consistency, please note https://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
|
||||
Thx - Hardy
|
||||
-->
|
||||
<string name="swap_start_and_destination">Swap start and destination</string>
|
||||
<string name="add_destination_point">Add destination</string>
|
||||
<string name="add_intermediate_point">Add intermediate</string>
|
||||
<string name="add_start_point">Add Start point</string>
|
||||
<string name="intermediate_waypoint">Intermediate point: %1$s</string>
|
||||
<string name="waypoints">Waypoints: %1$s</string>
|
||||
<string name="transfers">transfers: %1$s</string>
|
||||
|
|
|
@ -1874,6 +1874,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
showQuickSearch(mode, showCategories, "", null);
|
||||
}
|
||||
|
||||
public void showQuickSearch(ShowQuickSearchMode mode, QuickSearchTab showSearchTab) {
|
||||
showQuickSearch(mode, showSearchTab, "", null);
|
||||
}
|
||||
|
||||
public void showQuickSearch(@NonNull ShowQuickSearchMode mode, boolean showCategories,
|
||||
@NonNull String searchQuery, @Nullable LatLon searchLocation) {
|
||||
if (mode == ShowQuickSearchMode.CURRENT) {
|
||||
|
@ -1916,6 +1920,48 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
}
|
||||
}
|
||||
|
||||
public void showQuickSearch(@NonNull ShowQuickSearchMode mode, QuickSearchTab showSearchTab,
|
||||
@NonNull String searchQuery, @Nullable LatLon searchLocation) {
|
||||
if (mode == ShowQuickSearchMode.CURRENT) {
|
||||
mapContextMenu.close();
|
||||
} else {
|
||||
hideContextMenu();
|
||||
}
|
||||
QuickSearchDialogFragment fragment = getQuickSearchDialogFragment();
|
||||
if (mode == ShowQuickSearchMode.START_POINT_SELECTION || mode == ShowQuickSearchMode.DESTINATION_SELECTION
|
||||
|| mode == ShowQuickSearchMode.DESTINATION_SELECTION_AND_START || mode == ShowQuickSearchMode.INTERMEDIATE_SELECTION) {
|
||||
if (fragment != null) {
|
||||
fragment.dismiss();
|
||||
}
|
||||
if (mode == ShowQuickSearchMode.INTERMEDIATE_SELECTION) {
|
||||
QuickSearchDialogFragment.showInstance(this, searchQuery, null,
|
||||
QuickSearchType.INTERMEDIATE, showSearchTab, searchLocation);
|
||||
} else if (mode == ShowQuickSearchMode.START_POINT_SELECTION) {
|
||||
QuickSearchDialogFragment.showInstance(this, searchQuery, null,
|
||||
QuickSearchType.START_POINT, showSearchTab, searchLocation);
|
||||
} else if (mode == ShowQuickSearchMode.DESTINATION_SELECTION) {
|
||||
QuickSearchDialogFragment.showInstance(this, searchQuery, null,
|
||||
QuickSearchType.DESTINATION, showSearchTab, searchLocation);
|
||||
} else {
|
||||
QuickSearchDialogFragment.showInstance(this, searchQuery, null,
|
||||
QuickSearchType.DESTINATION_AND_START, showSearchTab, searchLocation);
|
||||
}
|
||||
} else if (fragment != null) {
|
||||
if (mode == ShowQuickSearchMode.NEW
|
||||
|| (mode == ShowQuickSearchMode.NEW_IF_EXPIRED && fragment.isExpired())) {
|
||||
fragment.dismiss();
|
||||
QuickSearchDialogFragment.showInstance(this, searchQuery, null,
|
||||
QuickSearchType.REGULAR, showSearchTab, searchLocation);
|
||||
} else {
|
||||
fragment.show();
|
||||
}
|
||||
refreshMap();
|
||||
} else {
|
||||
QuickSearchDialogFragment.showInstance(this, searchQuery, null,
|
||||
QuickSearchType.REGULAR, showSearchTab, searchLocation);
|
||||
}
|
||||
}
|
||||
|
||||
private void hideContextMenu() {
|
||||
if (mapContextMenu.isVisible()) {
|
||||
mapContextMenu.hide();
|
||||
|
|
|
@ -498,7 +498,7 @@ public class WaypointDialogHelper {
|
|||
}
|
||||
|
||||
// switch start & finish
|
||||
private static void switchStartAndFinish(TargetPointsHelper targetPointsHelper, TargetPoint finish,
|
||||
public static void switchStartAndFinish(TargetPointsHelper targetPointsHelper, TargetPoint finish,
|
||||
Activity ctx, TargetPoint start, OsmandApplication app,
|
||||
WaypointDialogHelper helper) {
|
||||
targetPointsHelper.setStartPoint(new LatLon(finish.getLatitude(),
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu.other;
|
|||
import android.app.Activity;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.ContextThemeWrapper;
|
||||
|
@ -156,6 +157,10 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
|
|||
setupMapRouteInfoMenuSpinners(routeMenu);
|
||||
updateMapRouteInfoMenuFromIcon(routeMenu);
|
||||
}
|
||||
Fragment fragment = getTargetFragment();
|
||||
if (fragment != null) {
|
||||
fragment.onActivityResult(getTargetRequestCode(), 0, null);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,309 @@
|
|||
package net.osmand.plus.routepreparationmenu;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.text.SpannableString;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import net.osmand.plus.helpers.MapMarkerDialogHelper;
|
||||
import net.osmand.plus.helpers.WaypointDialogHelper;
|
||||
import net.osmand.plus.mapcontextmenu.other.FavouritesBottomSheetMenuFragment;
|
||||
import net.osmand.plus.search.QuickSearchDialogFragment;
|
||||
import net.osmand.plus.widgets.style.CustomTypefaceSpan;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
||||
|
||||
public static final String TAG = "AddPointBottomSheetDialog";
|
||||
public static final String TARGET_KEY = "target";
|
||||
public static final String INTERMEDIATE_KEY = "intermediate";
|
||||
|
||||
public static final int ADD_FAVOURITE_TO_ROUTE_REQUEST_CODE = 1;
|
||||
|
||||
private boolean target;
|
||||
private boolean intermediate;
|
||||
|
||||
@Override
|
||||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
Bundle args = getArguments();
|
||||
if (args != null && args.containsKey(TARGET_KEY) && args.containsKey(INTERMEDIATE_KEY)) {
|
||||
target = args.getBoolean(TARGET_KEY);
|
||||
intermediate = args.getBoolean(INTERMEDIATE_KEY);
|
||||
}
|
||||
String title;
|
||||
if (intermediate) {
|
||||
title = getString(R.string.add_intermediate_point);
|
||||
} else if (target) {
|
||||
title = getString(R.string.add_destination_point);
|
||||
} else {
|
||||
title = getString(R.string.add_start_point);
|
||||
}
|
||||
items.add(new TitleItem(title));
|
||||
|
||||
createSearchItem();
|
||||
if (intermediate) {
|
||||
createSelectOnTheMapItem();
|
||||
createFavouritesItem();
|
||||
createMarkersItem();
|
||||
} else if (target) {
|
||||
createMyLocItem();
|
||||
createSelectOnTheMapItem();
|
||||
createFavouritesItem();
|
||||
createMarkersItem();
|
||||
items.add(new DividerHalfItem(getContext()));
|
||||
createSwitchStartAndEndItem();
|
||||
} else {
|
||||
createMyLocItem();
|
||||
createSelectOnTheMapItem();
|
||||
createFavouritesItem();
|
||||
createMarkersItem();
|
||||
items.add(new DividerHalfItem(getContext()));
|
||||
createSwitchStartAndEndItem();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == ADD_FAVOURITE_TO_ROUTE_REQUEST_CODE) {
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDismissButtonTextId() {
|
||||
return R.string.shared_string_close;
|
||||
}
|
||||
|
||||
private void createSearchItem() {
|
||||
View searchView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.bottom_sheet_double_item, null);
|
||||
TextView firstTitle = (TextView) searchView.findViewById(R.id.first_title);
|
||||
TextView secondTitle = (TextView) searchView.findViewById(R.id.second_title);
|
||||
ImageView firstIcon = (ImageView) searchView.findViewById(R.id.first_icon);
|
||||
ImageView secondIcon = (ImageView) searchView.findViewById(R.id.second_icon);
|
||||
|
||||
firstTitle.setText(R.string.shared_string_search);
|
||||
secondTitle.setText(R.string.shared_string_address);
|
||||
firstIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_search_dark));
|
||||
secondIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_street_name));
|
||||
|
||||
AndroidUtils.setBackground(getContext(), searchView.findViewById(R.id.first_divider),
|
||||
nightMode, R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
|
||||
AndroidUtils.setBackground(getContext(), searchView.findViewById(R.id.second_divider),
|
||||
nightMode, R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
|
||||
|
||||
searchView.findViewById(R.id.first_item).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MapActivity mapActivity = (MapActivity) getActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.showQuickSearch(getSearchMode(), QuickSearchDialogFragment.QuickSearchTab.HISTORY);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
searchView.findViewById(R.id.second_item).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MapActivity mapActivity = (MapActivity) getActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.showQuickSearch(getSearchMode(), false);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
items.add(new BaseBottomSheetItem.Builder().setCustomView(searchView).create());
|
||||
}
|
||||
|
||||
private MapActivity.ShowQuickSearchMode getSearchMode() {
|
||||
if (intermediate) {
|
||||
return MapActivity.ShowQuickSearchMode.INTERMEDIATE_SELECTION;
|
||||
} else if (target) {
|
||||
return MapActivity.ShowQuickSearchMode.DESTINATION_SELECTION;
|
||||
} else {
|
||||
return MapActivity.ShowQuickSearchMode.START_POINT_SELECTION;
|
||||
}
|
||||
}
|
||||
|
||||
private void createMyLocItem() {
|
||||
BaseBottomSheetItem myLocationItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getIcon(R.drawable.ic_action_location_color, 0))
|
||||
.setTitle(getString(R.string.shared_string_my_location))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple_56dp)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null) {
|
||||
TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
|
||||
Location myLocation = app.getLocationProvider().getLastKnownLocation();
|
||||
if (myLocation != null) {
|
||||
LatLon ll = new LatLon(myLocation.getLatitude(), myLocation.getLongitude());
|
||||
if (intermediate) {
|
||||
app.showShortToastMessage(R.string.add_intermediate_point);
|
||||
targetPointsHelper.navigateToPoint(ll, true, targetPointsHelper.getIntermediatePoints().size());
|
||||
} else if (target) {
|
||||
app.showShortToastMessage(R.string.add_destination_point);
|
||||
targetPointsHelper.navigateToPoint(ll, true, -1);
|
||||
} else {
|
||||
if (targetPointsHelper.getPointToStart() != null) {
|
||||
targetPointsHelper.clearStartPoint(true);
|
||||
app.getSettings().backupPointToStart();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
}).create();
|
||||
items.add(myLocationItem);
|
||||
}
|
||||
|
||||
private void createSelectOnTheMapItem() {
|
||||
BaseBottomSheetItem selectOnTheMapItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_show_on_map))
|
||||
.setTitle(getString(R.string.shared_string_select_on_map))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple_56dp)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MapActivity mapActivity = (MapActivity) getActivity();
|
||||
if (mapActivity != null) {
|
||||
MapRouteInfoMenu menu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
|
||||
menu.selectOnScreen(target, intermediate);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
items.add(selectOnTheMapItem);
|
||||
}
|
||||
|
||||
private void createFavouritesItem() {
|
||||
BaseBottomSheetItem favouritesItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_fav_dark))
|
||||
.setTitle(getString(R.string.shared_string_favorites))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple_56dp)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MapActivity mapActivity = (MapActivity) getActivity();
|
||||
if (mapActivity != null) {
|
||||
FragmentManager fragmentManager = mapActivity.getSupportFragmentManager();
|
||||
FavouritesBottomSheetMenuFragment fragment = new FavouritesBottomSheetMenuFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean(FavouritesBottomSheetMenuFragment.TARGET, target);
|
||||
args.putBoolean(FavouritesBottomSheetMenuFragment.INTERMEDIATE, intermediate);
|
||||
fragment.setTargetFragment(AddPointBottomSheetDialog.this, ADD_FAVOURITE_TO_ROUTE_REQUEST_CODE);
|
||||
fragment.setArguments(args);
|
||||
fragment.show(fragmentManager, FavouritesBottomSheetMenuFragment.TAG);
|
||||
}
|
||||
}
|
||||
})
|
||||
.create();
|
||||
items.add(favouritesItem);
|
||||
}
|
||||
|
||||
private void createMarkersItem() {
|
||||
final OsmandApplication app = getMyApplication();
|
||||
if (app == null) {
|
||||
return;
|
||||
}
|
||||
final View markersView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.bottom_sheet_double_item, null);
|
||||
|
||||
MapMarkersHelper markersHelper = app.getMapMarkersHelper();
|
||||
List<MapMarkersHelper.MapMarker> markers = markersHelper.getMapMarkers();
|
||||
MapMarkersHelper.MapMarker marker = null;
|
||||
if (markers.size() > 0) {
|
||||
marker = markers.get(0);
|
||||
}
|
||||
TextView firstTitle = (TextView) markersView.findViewById(R.id.first_title);
|
||||
TextView secondTitle = (TextView) markersView.findViewById(R.id.second_title);
|
||||
ImageView firstIcon = (ImageView) markersView.findViewById(R.id.first_icon);
|
||||
ImageView secondIcon = (ImageView) markersView.findViewById(R.id.second_icon);
|
||||
|
||||
firstTitle.setText(R.string.shared_string_markers);
|
||||
firstIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_flag_dark));
|
||||
|
||||
if (marker != null) {
|
||||
secondTitle.setText(marker.getName(getContext()));
|
||||
secondIcon.setImageDrawable(MapMarkerDialogHelper.getMapMarkerIcon(app, marker.colorIndex));
|
||||
|
||||
}
|
||||
markersView.findViewById(R.id.first_item).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MapActivity mapActivity = (MapActivity) getActivity();
|
||||
if (mapActivity != null) {
|
||||
MapRouteInfoMenu menu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
|
||||
menu.selectMapMarker(-1, target, intermediate);
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
markersView.findViewById(R.id.second_item).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MapActivity mapActivity = (MapActivity) getActivity();
|
||||
if (mapActivity != null) {
|
||||
MapRouteInfoMenu menu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
|
||||
menu.selectMapMarker(0, target, intermediate);
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
items.add(new BaseBottomSheetItem.Builder().setCustomView(markersView).create());
|
||||
}
|
||||
|
||||
private void createSwitchStartAndEndItem() {
|
||||
final View switchStartAndEndView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.bottom_sheet_item_simple_56dp, null);
|
||||
TextView title = (TextView) switchStartAndEndView.findViewById(R.id.title);
|
||||
ImageView iconIv = (ImageView) switchStartAndEndView.findViewById(R.id.icon);
|
||||
iconIv.setImageDrawable(getContentIcon(R.drawable.ic_action_change_navigation_points));
|
||||
|
||||
String titleS = getString(R.string.swap_start_and_destination);
|
||||
SpannableString titleSpan = new SpannableString(titleS);
|
||||
int firstIndex = titleS.indexOf(" ");
|
||||
if (firstIndex != -1) {
|
||||
Typeface typeface = FontCache.getRobotoMedium(getContext());
|
||||
titleSpan.setSpan(new CustomTypefaceSpan(typeface), firstIndex, titleS.indexOf(" ", firstIndex + 1), 0);
|
||||
titleSpan.setSpan(new CustomTypefaceSpan(typeface), titleS.lastIndexOf(" "), titleS.length(), 0);
|
||||
}
|
||||
title.setText(titleSpan);
|
||||
|
||||
switchStartAndEndView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MapActivity mapActivity = (MapActivity) getActivity();
|
||||
if (mapActivity != null) {
|
||||
TargetPointsHelper targetsHelper = mapActivity.getMyApplication().getTargetPointsHelper();
|
||||
WaypointDialogHelper.switchStartAndFinish(targetsHelper, targetsHelper.getPointToNavigate(),
|
||||
mapActivity, targetsHelper.getPointToStart(), mapActivity.getMyApplication(),
|
||||
mapActivity.getDashboard().getWaypointDialogHelper());
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
items.add(new BaseBottomSheetItem.Builder().setCustomView(switchStartAndEndView).create());
|
||||
}
|
||||
}
|
|
@ -14,8 +14,6 @@ import android.support.v4.app.Fragment;
|
|||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.ListPopupWindow;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -870,7 +868,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
RouteOptionsBottomSheet.showInstance(mapActivity.getSupportFragmentManager());
|
||||
}
|
||||
|
||||
protected void clickRouteWaypoints() {
|
||||
private void clickRouteWaypoints() {
|
||||
if (getTargets().checkPointToNavigateShort()) {
|
||||
mapActivity.getMapActions().openIntermediatePointsDialog();
|
||||
}
|
||||
|
@ -894,6 +892,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
viaButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// clickRouteWaypoints();
|
||||
if (getTargets().checkPointToNavigateShort()) {
|
||||
WaypointsFragment.showInstance(mapActivity);
|
||||
}
|
||||
|
@ -905,9 +904,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
viaIcon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (getTargets().checkPointToNavigateShort()) {
|
||||
mapActivity.getMapActions().openIntermediatePointsDialog();
|
||||
}
|
||||
clickRouteWaypoints();
|
||||
}
|
||||
});
|
||||
LinearLayout viaButtonContainer = (LinearLayout) parentView.findViewById(R.id.via_button_container);
|
||||
|
@ -976,7 +973,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
toLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
toSpinner.performClick();
|
||||
openAddPointDialog(true, false);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1002,38 +999,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
toButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mapActivity != null) {
|
||||
final ListPopupWindow popup = new ListPopupWindow(mapActivity);
|
||||
popup.setAnchorView(toLayout);
|
||||
popup.setDropDownGravity(Gravity.END | Gravity.TOP);
|
||||
popup.setModal(true);
|
||||
popup.setAdapter(getIntermediatesPopupAdapter(mapActivity));
|
||||
popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
boolean hideDashboard = false;
|
||||
if (id == MapRouteInfoMenu.SPINNER_FAV_ID) {
|
||||
selectFavorite(null, false, true);
|
||||
} else if (id == MapRouteInfoMenu.SPINNER_MAP_ID) {
|
||||
hideDashboard = true;
|
||||
selectOnScreen(false, true);
|
||||
} else if (id == MapRouteInfoMenu.SPINNER_ADDRESS_ID) {
|
||||
mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.INTERMEDIATE_SELECTION, false);
|
||||
} else if (id == MapRouteInfoMenu.SPINNER_MAP_MARKER_MORE_ID) {
|
||||
selectMapMarker(-1, false, true);
|
||||
} else if (id == MapRouteInfoMenu.SPINNER_MAP_MARKER_1_ID) {
|
||||
selectMapMarker(0, false, true);
|
||||
} else if (id == MapRouteInfoMenu.SPINNER_MAP_MARKER_2_ID) {
|
||||
selectMapMarker(1, false, true);
|
||||
}
|
||||
popup.dismiss();
|
||||
if (hideDashboard) {
|
||||
mapActivity.getDashboard().hideDashboard();
|
||||
}
|
||||
}
|
||||
});
|
||||
popup.show();
|
||||
}
|
||||
openAddPointDialog(false, true);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1100,7 +1066,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
fromLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
fromSpinner.performClick();
|
||||
openAddPointDialog(false, false);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1206,14 +1172,22 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
getTargets().setStartPoint(point, true, m.getPointDescription(mapActivity));
|
||||
}
|
||||
updateFromIcon();
|
||||
|
||||
} else {
|
||||
|
||||
MapMarkerSelectionFragment selectionFragment = MapMarkerSelectionFragment.newInstance(target, intermediate);
|
||||
selectionFragment.show(mapActivity.getSupportFragmentManager(), MapMarkerSelectionFragment.TAG);
|
||||
}
|
||||
}
|
||||
|
||||
private void openAddPointDialog(final boolean target, final boolean intermediate) {
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean(AddPointBottomSheetDialog.TARGET_KEY, target);
|
||||
args.putBoolean(AddPointBottomSheetDialog.INTERMEDIATE_KEY, intermediate);
|
||||
AddPointBottomSheetDialog fragment = new AddPointBottomSheetDialog();
|
||||
fragment.setArguments(args);
|
||||
fragment.setUsedOnMap(false);
|
||||
fragment.show(mapActivity.getSupportFragmentManager(), AddPointBottomSheetDialog.TAG);
|
||||
}
|
||||
|
||||
private boolean isLight() {
|
||||
return !nightMode;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import android.support.annotation.Nullable;
|
|||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.ListPopupWindow;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -271,7 +270,13 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
|||
addButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onWaypointItemClick(view.findViewById(R.id.waypoints_control_buttons));
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean(AddPointBottomSheetDialog.TARGET_KEY, false);
|
||||
args.putBoolean(AddPointBottomSheetDialog.INTERMEDIATE_KEY, true);
|
||||
AddPointBottomSheetDialog fragment = new AddPointBottomSheetDialog();
|
||||
fragment.setArguments(args);
|
||||
fragment.setUsedOnMap(false);
|
||||
fragment.show(mapActivity.getSupportFragmentManager(), AddPointBottomSheetDialog.TAG);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -597,47 +602,14 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
|||
title.setText(app.getString(R.string.waypoints, (pointsSize != 0 ? pointsSize : 1)));
|
||||
}
|
||||
|
||||
private void onWaypointItemClick(View addWaypointItem) {
|
||||
if (mapActivity != null) {
|
||||
final MapRouteInfoMenu routeMenu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
|
||||
final ListPopupWindow popup = new ListPopupWindow(mapActivity);
|
||||
popup.setAnchorView(addWaypointItem);
|
||||
popup.setDropDownGravity(Gravity.END | Gravity.TOP);
|
||||
popup.setModal(true);
|
||||
popup.setAdapter(routeMenu.getIntermediatesPopupAdapter(mapActivity));
|
||||
popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
boolean hideDashboard = false;
|
||||
if (id == MapRouteInfoMenu.SPINNER_FAV_ID) {
|
||||
routeMenu.selectFavorite(null, false, true);
|
||||
} else if (id == MapRouteInfoMenu.SPINNER_MAP_ID) {
|
||||
hideDashboard = true;
|
||||
routeMenu.selectOnScreen(false, true);
|
||||
dismiss();
|
||||
} else if (id == MapRouteInfoMenu.SPINNER_ADDRESS_ID) {
|
||||
mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.INTERMEDIATE_SELECTION, false);
|
||||
} else if (id == MapRouteInfoMenu.SPINNER_MAP_MARKER_MORE_ID) {
|
||||
routeMenu.selectMapMarker(-1, false, true);
|
||||
} else if (id == MapRouteInfoMenu.SPINNER_MAP_MARKER_1_ID) {
|
||||
routeMenu.selectMapMarker(0, false, true);
|
||||
} else if (id == MapRouteInfoMenu.SPINNER_MAP_MARKER_2_ID) {
|
||||
routeMenu.selectMapMarker(1, false, true);
|
||||
}
|
||||
popup.dismiss();
|
||||
if (hideDashboard) {
|
||||
mapActivity.getDashboard().hideDashboard();
|
||||
}
|
||||
}
|
||||
});
|
||||
popup.show();
|
||||
}
|
||||
}
|
||||
|
||||
private void applyPointsChanges() {
|
||||
app.runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app == null || !isVisible()) {
|
||||
return;
|
||||
}
|
||||
List<TargetPointsHelper.TargetPoint> allTargets = new ArrayList<>();
|
||||
TargetPointsHelper.TargetPoint start = null;
|
||||
List<Object> items = listAdapter.getActiveObjects();
|
||||
|
@ -905,7 +877,7 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
|||
WaypointsFragment fragment = new WaypointsFragment();
|
||||
mapActivity.getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.routeMenuContainer, fragment, TAG)
|
||||
.add(R.id.routeMenuContainer, fragment, TAG)
|
||||
.addToBackStack(TAG)
|
||||
.commitAllowingStateLoss();
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import net.osmand.plus.routepreparationmenu.FlowLayout;
|
||||
import net.osmand.plus.widgets.FlowLayout;
|
||||
import net.osmand.plus.transport.TransportStopRoute;
|
||||
import net.osmand.plus.transport.TransportStopType;
|
||||
import net.osmand.plus.widgets.style.CustomTypefaceSpan;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package net.osmand.plus.routepreparationmenu;
|
||||
package net.osmand.plus.widgets;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
Loading…
Reference in a new issue