Redesign "add waypoint" menu; remove some legacy code
This commit is contained in:
parent
cd757e3516
commit
4f776f3268
6 changed files with 457 additions and 40 deletions
263
OsmAnd/res/layout/fragment_add_waypoint_bottom_sheet_dialog.xml
Normal file
263
OsmAnd/res/layout/fragment_add_waypoint_bottom_sheet_dialog.xml
Normal file
|
@ -0,0 +1,263 @@
|
||||||
|
<?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:orientation="vertical"
|
||||||
|
tools:background="?attr/bg_color">
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:id="@+id/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: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/new_destination_point_dialog"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/replace_dest_row"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
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/current_dest_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
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_point_destination"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text="@string/replace_destination_point"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/current_dest_text_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:textColor="@color/searchbar_text_hint_light"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
tools:text="Current: Some street 46"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/current_dest_divider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_marginBottom="@dimen/bottom_sheet_content_padding_small"
|
||||||
|
android:layout_marginLeft="@dimen/bottom_sheet_divider_margin_start"
|
||||||
|
android:layout_marginStart="@dimen/bottom_sheet_divider_margin_start"
|
||||||
|
android:layout_marginTop="@dimen/bottom_sheet_content_padding_small"
|
||||||
|
android:background="?attr/dashboard_divider"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/subsequent_dest_row"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
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/subsequent_dest_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||||
|
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||||
|
tools:foreground="@drawable/ic_action_route_subsequent_destination"
|
||||||
|
tools:src="@drawable/ic_action_route_subsequent_destination_point"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text="@string/keep_and_add_destination_point"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:text="@string/subsequent_dest_description"
|
||||||
|
android:textColor="@color/searchbar_text_hint_light"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/first_intermediate_dest_row"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
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/first_interm_dest_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||||
|
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||||
|
tools:foreground="@drawable/ic_action_route_first_intermediate"
|
||||||
|
tools:src="@drawable/ic_action_route_first_intermediate_point"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text="@string/add_as_first_destination_point"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:text="@string/first_intermediate_dest_description"
|
||||||
|
android:textColor="@color/searchbar_text_hint_light"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/last_intermediate_dest_row"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
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/last_interm_dest_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||||
|
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||||
|
tools:foreground="@drawable/ic_action_route_last_intermediate"
|
||||||
|
tools:src="@drawable/ic_action_route_last_intermediate_point"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text="@string/add_as_last_destination_point"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:text="@string/last_intermediate_dest_description"
|
||||||
|
android:textColor="@color/searchbar_text_hint_light"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/cancel_divider"
|
||||||
|
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).
|
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="shared_string_current">Current</string>
|
||||||
|
<string name="last_intermediate_dest_description">Adds the last stop along the route</string>
|
||||||
|
<string name="first_intermediate_dest_description">Adds the first stop on the route</string>
|
||||||
|
<string name="subsequent_dest_description">Move destination up, and create destination</string>
|
||||||
<string name="show_closed_notes">Show closed notes</string>
|
<string name="show_closed_notes">Show closed notes</string>
|
||||||
<string name="switch_osm_notes_visibility_desc">Show/Hide OSM Notes on the map.</string>
|
<string name="switch_osm_notes_visibility_desc">Show/Hide OSM Notes on the map.</string>
|
||||||
<string name="gpx_file_desc">GPX - suitable for export to JOSM or other OSM editors.</string>
|
<string name="gpx_file_desc">GPX - suitable for export to JOSM or other OSM editors.</string>
|
||||||
|
|
|
@ -90,7 +90,6 @@ public abstract class SearchByNameAbstractActivity<T> extends OsmandListActivity
|
||||||
private static final Log log = PlatformUtil.getLog(SearchByNameAbstractActivity.class);
|
private static final Log log = PlatformUtil.getLog(SearchByNameAbstractActivity.class);
|
||||||
|
|
||||||
private static final int NAVIGATE_TO = 3;
|
private static final int NAVIGATE_TO = 3;
|
||||||
private static final int ADD_WAYPOINT = 4;
|
|
||||||
private static final int SHOW_ON_MAP = 5;
|
private static final int SHOW_ON_MAP = 5;
|
||||||
private static final int ADD_TO_FAVORITE = 6;
|
private static final int ADD_TO_FAVORITE = 6;
|
||||||
|
|
||||||
|
@ -571,9 +570,6 @@ public abstract class SearchByNameAbstractActivity<T> extends OsmandListActivity
|
||||||
} else if (mode == NAVIGATE_TO) {
|
} else if (mode == NAVIGATE_TO) {
|
||||||
DirectionsDialogs.directionsToDialogAndLaunchMap(getActivity(), searchPoint.getLatitude(),
|
DirectionsDialogs.directionsToDialogAndLaunchMap(getActivity(), searchPoint.getLatitude(),
|
||||||
searchPoint.getLongitude(), ai.getHistoryName());
|
searchPoint.getLongitude(), ai.getHistoryName());
|
||||||
} else if (mode == ADD_WAYPOINT) {
|
|
||||||
DirectionsDialogs.addWaypointDialogAndLaunchMap(getActivity(), searchPoint.getLatitude(),
|
|
||||||
searchPoint.getLongitude(), ai.getHistoryName());
|
|
||||||
} else if (mode == SHOW_ON_MAP) {
|
} else if (mode == SHOW_ON_MAP) {
|
||||||
showOnMap(searchPoint, ai);
|
showOnMap(searchPoint, ai);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,14 +80,12 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AndroidUiHelper.isOrientationPortrait(activity)) {
|
if (AndroidUiHelper.isOrientationPortrait(activity)) {
|
||||||
AndroidUtils.setBackground(activity, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
mainView.setBackgroundResource(getPortraitBgResId());
|
||||||
} else {
|
} else {
|
||||||
if (screenHeight - statusBarHeight - mainView.getHeight() >= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) {
|
if (screenHeight - statusBarHeight - mainView.getHeight() >= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) {
|
||||||
AndroidUtils.setBackground(activity, mainView, nightMode,
|
mainView.setBackgroundResource(getLandscapeTopsidesBgResId());
|
||||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
|
||||||
} else {
|
} else {
|
||||||
AndroidUtils.setBackground(activity, mainView, nightMode,
|
mainView.setBackgroundResource(getLandscapeSidesBgResId());
|
||||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +99,21 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DrawableRes
|
||||||
|
protected int getPortraitBgResId() {
|
||||||
|
return nightMode ? R.drawable.bg_bottom_menu_dark : R.drawable.bg_bottom_menu_light;
|
||||||
|
}
|
||||||
|
|
||||||
|
@DrawableRes
|
||||||
|
protected int getLandscapeTopsidesBgResId() {
|
||||||
|
return nightMode ? R.drawable.bg_bottom_sheet_topsides_landscape_dark : R.drawable.bg_bottom_sheet_topsides_landscape_light;
|
||||||
|
}
|
||||||
|
|
||||||
|
@DrawableRes
|
||||||
|
protected int getLandscapeSidesBgResId() {
|
||||||
|
return nightMode ? R.drawable.bg_bottom_sheet_sides_landscape_dark : R.drawable.bg_bottom_sheet_sides_landscape_light;
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean isNightMode() {
|
protected boolean isNightMode() {
|
||||||
if (usedOnMap) {
|
if (usedOnMap) {
|
||||||
return getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
return getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||||
|
|
|
@ -0,0 +1,160 @@
|
||||||
|
package net.osmand.plus.dialogs;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.graphics.drawable.LayerDrawable;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.DrawableRes;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.view.ContextThemeWrapper;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.data.PointDescription;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.TargetPointsHelper;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
|
|
||||||
|
public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
|
public static final String TAG = "AddWaypointBottomSheetDialogFragment";
|
||||||
|
public static final String LAT_KEY = "latitude";
|
||||||
|
public static final String LON_KEY = "longitude";
|
||||||
|
public static final String POINT_DESCRIPTION_KEY = "point_description";
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
Bundle args = getArguments();
|
||||||
|
final LatLon latLon = new LatLon(args.getDouble(LAT_KEY), args.getDouble(LON_KEY));
|
||||||
|
final PointDescription name = PointDescription.deserializeFromString(args.getString(POINT_DESCRIPTION_KEY), latLon);
|
||||||
|
final TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper();
|
||||||
|
|
||||||
|
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
|
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes),
|
||||||
|
R.layout.fragment_add_waypoint_bottom_sheet_dialog, container);
|
||||||
|
|
||||||
|
((TextView) mainView.findViewById(R.id.current_dest_text_view))
|
||||||
|
.setText(getCurrentDestinationName(targetPointsHelper.getPointToNavigate()));
|
||||||
|
|
||||||
|
((ImageView) mainView.findViewById(R.id.current_dest_icon))
|
||||||
|
.setImageDrawable(getBackgroundIcon(R.drawable.ic_action_point_destination));
|
||||||
|
((ImageView) mainView.findViewById(R.id.subsequent_dest_icon)).setImageDrawable(getSubsequentDestIcon());
|
||||||
|
((ImageView) mainView.findViewById(R.id.first_interm_dest_icon)).setImageDrawable(getFirstIntermDestIcon());
|
||||||
|
((ImageView) mainView.findViewById(R.id.last_interm_dest_icon)).setImageDrawable(getLastIntermDistIcon());
|
||||||
|
|
||||||
|
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
int id = v.getId();
|
||||||
|
if (id == R.id.replace_dest_row) {
|
||||||
|
targetPointsHelper.navigateToPoint(latLon, true, -1, name);
|
||||||
|
} else if (id == R.id.subsequent_dest_row) {
|
||||||
|
targetPointsHelper.navigateToPoint(latLon, true,
|
||||||
|
targetPointsHelper.getIntermediatePoints().size() + 1, name);
|
||||||
|
} else if (id == R.id.first_intermediate_dest_row) {
|
||||||
|
targetPointsHelper.navigateToPoint(latLon, true, 0, name);
|
||||||
|
} else if (id == R.id.last_intermediate_dest_row) {
|
||||||
|
targetPointsHelper.navigateToPoint(latLon, true, targetPointsHelper.getIntermediatePoints().size(), name);
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
mainView.findViewById(R.id.replace_dest_row).setOnClickListener(onClickListener);
|
||||||
|
mainView.findViewById(R.id.subsequent_dest_row).setOnClickListener(onClickListener);
|
||||||
|
mainView.findViewById(R.id.first_intermediate_dest_row).setOnClickListener(onClickListener);
|
||||||
|
mainView.findViewById(R.id.last_intermediate_dest_row).setOnClickListener(onClickListener);
|
||||||
|
mainView.findViewById(R.id.cancel_row).setOnClickListener(onClickListener);
|
||||||
|
|
||||||
|
if (nightMode) {
|
||||||
|
int dividerColor = ContextCompat.getColor(getContext(), R.color.route_info_bottom_view_bg_dark);
|
||||||
|
mainView.findViewById(R.id.current_dest_divider).setBackgroundColor(dividerColor);
|
||||||
|
mainView.findViewById(R.id.cancel_divider).setBackgroundColor(dividerColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
setupHeightAndBackground(mainView, R.id.scroll_view);
|
||||||
|
|
||||||
|
return mainView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialog) {
|
||||||
|
super.onDismiss(dialog);
|
||||||
|
closeContextMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Drawable getActiveIcon(@DrawableRes int id) {
|
||||||
|
return getIcon(id, nightMode ? R.color.ctx_menu_direction_color_dark : R.color.map_widget_blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getPortraitBgResId() {
|
||||||
|
return nightMode ? R.drawable.bg_additional_menu_dark : R.drawable.bg_bottom_menu_light;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getLandscapeTopsidesBgResId() {
|
||||||
|
return nightMode ? R.drawable.bg_additional_menu_topsides_dark : R.drawable.bg_bottom_sheet_topsides_landscape_light;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getLandscapeSidesBgResId() {
|
||||||
|
return nightMode ? R.drawable.bg_additional_menu_sides_dark : R.drawable.bg_bottom_sheet_sides_landscape_light;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Drawable getBackgroundIcon(@DrawableRes int resId) {
|
||||||
|
return getIcon(resId, R.color.searchbar_text_hint_light);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LayerDrawable getLayerDrawable(@DrawableRes int bgIdRes, @DrawableRes int icIdRes) {
|
||||||
|
return new LayerDrawable(new Drawable[]{getBackgroundIcon(bgIdRes), getActiveIcon(icIdRes)});
|
||||||
|
}
|
||||||
|
|
||||||
|
private LayerDrawable getSubsequentDestIcon() {
|
||||||
|
return getLayerDrawable(R.drawable.ic_action_route_subsequent_destination,
|
||||||
|
R.drawable.ic_action_route_subsequent_destination_point);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LayerDrawable getFirstIntermDestIcon() {
|
||||||
|
return getLayerDrawable(R.drawable.ic_action_route_first_intermediate,
|
||||||
|
R.drawable.ic_action_route_first_intermediate_point);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LayerDrawable getLastIntermDistIcon() {
|
||||||
|
return getLayerDrawable(R.drawable.ic_action_route_last_intermediate,
|
||||||
|
R.drawable.ic_action_route_last_intermediate_point);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getCurrentDestinationName(@Nullable TargetPointsHelper.TargetPoint finish) {
|
||||||
|
Context ctx = getContext();
|
||||||
|
StringBuilder builder = new StringBuilder(ctx.getString(R.string.shared_string_current));
|
||||||
|
builder.append(": ");
|
||||||
|
if (finish != null) {
|
||||||
|
if (finish.getOnlyName().length() > 0) {
|
||||||
|
builder.append(finish.getOnlyName());
|
||||||
|
} else {
|
||||||
|
builder.append(ctx.getString(R.string.route_descr_map_location));
|
||||||
|
builder.append(" ");
|
||||||
|
builder.append(ctx.getString(R.string.route_descr_lat_lon, finish.getLatitude(), finish.getLongitude()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void closeContextMenu() {
|
||||||
|
Activity activity = getActivity();
|
||||||
|
if (activity instanceof MapActivity) {
|
||||||
|
((MapActivity) activity).getContextMenu().close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,9 @@ package net.osmand.plus.dialogs;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.PopupMenu;
|
import android.support.v7.widget.PopupMenu;
|
||||||
|
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
@ -46,37 +48,16 @@ public class DirectionsDialogs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addWaypointDialogAndLaunchMap(final Activity act, final double lat, final double lon, final PointDescription name) {
|
public static void addWaypointDialogAndLaunchMap(final AppCompatActivity act, final double lat, final double lon, final PointDescription name) {
|
||||||
final OsmandApplication ctx = (OsmandApplication) act.getApplication();
|
final TargetPointsHelper targetPointsHelper = ((OsmandApplication) act.getApplication()).getTargetPointsHelper();
|
||||||
final TargetPointsHelper targetPointsHelper = ctx.getTargetPointsHelper();
|
|
||||||
if (targetPointsHelper.getPointToNavigate() != null) {
|
if (targetPointsHelper.getPointToNavigate() != null) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(act);
|
Bundle args = new Bundle();
|
||||||
builder.setTitle(R.string.new_destination_point_dialog);
|
args.putDouble(AddWaypointBottomSheetDialogFragment.LAT_KEY, lat);
|
||||||
builder.setItems(
|
args.putDouble(AddWaypointBottomSheetDialogFragment.LON_KEY, lon);
|
||||||
new String[] { act.getString(R.string.replace_destination_point),
|
args.putString(AddWaypointBottomSheetDialogFragment.POINT_DESCRIPTION_KEY, PointDescription.serializeToString(name));
|
||||||
act.getString(R.string.keep_and_add_destination_point),
|
AddWaypointBottomSheetDialogFragment fragment = new AddWaypointBottomSheetDialogFragment();
|
||||||
act.getString(R.string.add_as_first_destination_point), act.getString(R.string.add_as_last_destination_point) },
|
fragment.setArguments(args);
|
||||||
new DialogInterface.OnClickListener() {
|
fragment.show(act.getSupportFragmentManager(), AddWaypointBottomSheetDialogFragment.TAG);
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
if (which == 0) {
|
|
||||||
targetPointsHelper.navigateToPoint(new LatLon(lat, lon), true, -1, name);
|
|
||||||
closeContextMenu(act);
|
|
||||||
} else if (which == 1) {
|
|
||||||
targetPointsHelper.navigateToPoint(new LatLon(lat, lon), true,
|
|
||||||
targetPointsHelper.getIntermediatePoints().size() + 1, name);
|
|
||||||
closeContextMenu(act);
|
|
||||||
} else if (which == 2) {
|
|
||||||
targetPointsHelper.navigateToPoint(new LatLon(lat, lon), true, 0, name);
|
|
||||||
closeContextMenu(act);
|
|
||||||
} else {
|
|
||||||
targetPointsHelper.navigateToPoint(new LatLon(lat, lon), true, targetPointsHelper.getIntermediatePoints().size(), name);
|
|
||||||
closeContextMenu(act);
|
|
||||||
}
|
|
||||||
MapActivity.launchMapActivityMoveToTop(act);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.show();
|
|
||||||
} else {
|
} else {
|
||||||
targetPointsHelper.navigateToPoint(new LatLon(lat, lon), true, -1, name);
|
targetPointsHelper.navigateToPoint(new LatLon(lat, lon), true, -1, name);
|
||||||
closeContextMenu(act);
|
closeContextMenu(act);
|
||||||
|
|
Loading…
Reference in a new issue