RP refactoring

This commit is contained in:
crimean 2019-02-12 20:08:33 +03:00
parent 403f4de845
commit 2c15e15250
9 changed files with 195 additions and 791 deletions

View file

@ -78,7 +78,7 @@
</LinearLayout>
<net.osmand.plus.views.controls.DynamicListView
<com.github.ksoichiro.android.observablescrollview.ObservableListView
android:id="@+id/dash_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"

View file

@ -123,13 +123,17 @@
android:text="@string/route_from"
android:textSize="@dimen/default_sub_text_size" />
<Spinner
android:id="@+id/FromSpinner"
<TextView
android:id="@+id/fromText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="-8dp"
android:background="@null"
android:textSize="@dimen/default_list_text_size" />
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:gravity="left"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:text="My position" />
</LinearLayout>
@ -237,11 +241,13 @@
android:id="@+id/ViaView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:gravity="left"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size" />
android:textSize="@dimen/default_list_text_size"
tools:text="Intermediate point"/>
</LinearLayout>
@ -342,13 +348,17 @@
android:text="@string/route_to"
android:textSize="@dimen/default_sub_text_size" />
<Spinner
android:id="@+id/ToSpinner"
<TextView
android:id="@+id/toText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="-8dp"
android:background="@null"
android:textSize="@dimen/default_list_text_size" />
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:gravity="left"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:text="Destination"/>
</LinearLayout>
@ -498,7 +508,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foregroundGravity="top|fill_horizontal"
tools:foreground="@drawable/bg_contextmenu_shadow">
android:foreground="@drawable/bg_contextmenu_shadow">
<net.osmand.plus.LockableScrollView
android:id="@+id/route_menu_bottom_scroll"
@ -540,7 +550,7 @@
android:layout_height="wrap_content"
android:layout_gravity="top"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom" />
android:src="@drawable/bg_contextmenu_shadow" />
</LinearLayout>

View file

@ -61,6 +61,7 @@ import net.osmand.plus.mapmarkers.MapMarkersDialogFragment;
import net.osmand.plus.mapmarkers.MarkersPlanRouteContext;
import net.osmand.plus.measurementtool.MeasurementToolFragment;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.routepreparationmenu.WaypointsFragment;
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.BaseMapLayer;
@ -943,7 +944,7 @@ public class MapActivityActions implements DialogProvider {
}
public void openIntermediatePointsDialog() {
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS);
WaypointsFragment.showInstance(mapActivity);
}
public void openRoutePreferencesDialog() {

View file

@ -3,6 +3,7 @@ package net.osmand.plus.dashboard;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.PopupMenu;
import android.view.LayoutInflater;
@ -15,19 +16,18 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.helpers.WaypointDialogHelper;
import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.routepreparationmenu.WaypointsFragment;
import java.util.ArrayList;
import java.util.Collections;
@ -70,38 +70,45 @@ public class DashWaypointsFragment extends DashLocationFragment {
}
private void setupWaypoints() {
FragmentActivity activity = getActivity();
View mainView = getView();
WaypointHelper wh = getMyApplication().getWaypointHelper();
List<LocationPointWrapper> allPoints = wh.getAllPoints();
if (allPoints.size() == 0) {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.GONE);
return;
} else {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.VISIBLE);
}
((TextView) mainView.findViewById(R.id.fav_text)).setText(getString(R.string.shared_string_waypoints));
((Button) mainView.findViewById(R.id.show_all)).setText(getString(R.string.shared_string_show_all));
((Button) mainView.findViewById(R.id.show_all)).setVisibility(View.VISIBLE);
((Button) mainView.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dashboard.setDashboardVisibility(true, DashboardType.WAYPOINTS, AndroidUtils.getCenterViewCoordinates(v));
if (activity != null && mainView != null) {
WaypointHelper wh = getMyApplication().getWaypointHelper();
List<LocationPointWrapper> allPoints = wh.getAllPoints();
if (allPoints.size() == 0) {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.GONE);
return;
} else {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.VISIBLE);
}
});
LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items);
favorites.removeAllViews();
List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
for(int i = 0; i < 3 && i < allPoints.size(); i++) {
LocationPointWrapper ps = allPoints.get(i);
View dv = getActivity().getLayoutInflater().inflate(R.layout.divider, null);
favorites.addView(dv);
View v = WaypointDialogHelper.updateWaypointItemView(false, null, getMyApplication(),
getActivity(), null, null, ps, null, !getMyApplication().getSettings().isLightContent(), true);
favorites.addView(v);
((TextView) mainView.findViewById(R.id.fav_text)).setText(getString(R.string.shared_string_waypoints));
((Button) mainView.findViewById(R.id.show_all)).setText(getString(R.string.shared_string_show_all));
((Button) mainView.findViewById(R.id.show_all)).setVisibility(View.VISIBLE);
((Button) mainView.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentActivity activity = getActivity();
if (activity instanceof MapActivity) {
dashboard.hideDashboard();
WaypointsFragment.showInstance((MapActivity) activity);
}
}
});
LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items);
favorites.removeAllViews();
List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
for (int i = 0; i < 3 && i < allPoints.size(); i++) {
LocationPointWrapper ps = allPoints.get(i);
View dv = activity.getLayoutInflater().inflate(R.layout.divider, null);
favorites.addView(dv);
View v = WaypointDialogHelper.updateWaypointItemView(false, null, getMyApplication(),
activity, null, null, ps, null, !getMyApplication().getSettings().isLightContent(), true);
favorites.addView(v);
}
this.distances = distances;
}
this.distances = distances;
}
public void setupTargets() {

View file

@ -7,7 +7,6 @@ import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
@ -18,7 +17,6 @@ import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.Toolbar;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MenuItem;
@ -40,6 +38,7 @@ import android.widget.ProgressBar;
import android.widget.ScrollView;
import android.widget.TextView;
import com.github.ksoichiro.android.observablescrollview.ObservableListView;
import com.github.ksoichiro.android.observablescrollview.ObservableScrollView;
import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks;
import com.github.ksoichiro.android.observablescrollview.ScrollState;
@ -48,18 +47,15 @@ import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.ValueHolder;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.dashboard.tools.DashboardSettingsDialogFragment;
@ -71,16 +67,15 @@ import net.osmand.plus.download.DownloadIndexesThread;
import net.osmand.plus.download.IndexItem;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.WaypointDialogHelper;
import net.osmand.plus.helpers.WaypointDialogHelper.WaypointDialogHelperCallbacks;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter;
import net.osmand.plus.mapillary.MapillaryFiltersFragment;
import net.osmand.plus.mapillary.MapillaryPlugin.MapillaryFirstDialogFragment;
import net.osmand.plus.osmedit.OsmNotesMenu;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter;
import net.osmand.plus.routing.IRouteInformationListener;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.srtmplugin.ContourLinesMenu;
import net.osmand.plus.srtmplugin.HillshadeMenu;
import net.osmand.plus.srtmplugin.SRTMPlugin;
@ -88,11 +83,6 @@ import net.osmand.plus.views.DownloadedRegionsLayer;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.controls.DynamicListView;
import net.osmand.plus.views.controls.DynamicListViewCallbacks;
import net.osmand.plus.views.controls.StableArrayAdapter;
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener;
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.DismissCallbacks;
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.Undoable;
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
import java.lang.ref.WeakReference;
@ -103,10 +93,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicListViewCallbacks,
IRouteInformationListener, WaypointDialogHelperCallbacks {
public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInformationListener {
private static final org.apache.commons.logging.Log LOG =
PlatformUtil.getLog(DashboardOnMap.class);
private static final String TAG = "DashboardOnMap";
@ -142,7 +129,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
private ArrayAdapter<?> listAdapter;
private OnItemClickListener listAdapterOnClickListener;
private SwipeDismissListViewTouchListener swipeDismissListener;
private boolean visible = false;
private DashboardType visibleType;
@ -155,7 +141,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
private boolean mapLinkedToLocation;
private float mapRotation;
private boolean inLocationUpdate = false;
private DynamicListView listView;
private ObservableListView listView;
private View listBackgroundView;
private Toolbar toolbar;
private View paddingView;
@ -180,8 +166,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
public enum DashboardType {
WAYPOINTS,
WAYPOINTS_FLAT,
CONFIGURE_SCREEN,
CONFIGURE_MAP,
LIST_MENU,
@ -235,7 +219,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
public void createDashboardView() {
baseColor = ContextCompat.getColor(mapActivity, R.color.osmand_orange) & 0x00ffffff;
waypointDialogHelper = new WaypointDialogHelper(mapActivity);
waypointDialogHelper.addHelperCallbacks(this);
landscape = !AndroidUiHelper.isOrientationPortrait(mapActivity);
dashboardView = (FrameLayout) mapActivity.findViewById(R.id.dashboard);
AndroidUtils.addStatusBarPadding21v(mapActivity, dashboardView);
@ -247,122 +230,11 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
};
toolbar = ((Toolbar) dashboardView.findViewById(R.id.toolbar));
ObservableScrollView scrollView = ((ObservableScrollView) dashboardView.findViewById(R.id.main_scroll));
listView = (DynamicListView) dashboardView.findViewById(R.id.dash_list_view);
listView = (ObservableListView) dashboardView.findViewById(R.id.dash_list_view);
//listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
listView.setDrawSelectorOnTop(true);
listView.setDynamicListViewCallbacks(this);
listView.setScrollViewCallbacks(this);
listEmptyTextView = (TextView) dashboardView.findViewById(R.id.emptyTextView);
// Create a ListView-specific touch listener. ListViews are given special treatment because
// by default they handle touches for their list items... i.e. they're in charge of drawing
// the pressed state (the list selector), handling list item clicks, etc.
swipeDismissListener = new SwipeDismissListViewTouchListener(
mapActivity,
listView,
new DismissCallbacks() {
@Override
public boolean canDismiss(int position) {
if (listAdapter instanceof StableArrayAdapter
&& (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT)) {
List<Object> activeObjects = ((StableArrayAdapter) listAdapter).getActiveObjects();
Object obj = listAdapter.getItem(position);
if (obj instanceof LocationPointWrapper) {
LocationPointWrapper w = (LocationPointWrapper) obj;
if (w.getPoint() instanceof TargetPoint) {
return !((TargetPoint) w.getPoint()).start;
}
}
return activeObjects.contains(obj);
}
return false;
}
@Override
public Undoable onDismiss(final int position) {
final Object item;
final StableArrayAdapter stableAdapter;
final int activeObjPos;
if (listAdapter instanceof StableArrayAdapter) {
stableAdapter = (StableArrayAdapter) listAdapter;
item = stableAdapter.getItem(position);
stableAdapter.setNotifyOnChange(false);
stableAdapter.remove(item);
stableAdapter.getObjects().remove(item);
activeObjPos = stableAdapter.getActiveObjects().indexOf(item);
stableAdapter.getActiveObjects().remove(item);
stableAdapter.refreshData();
stableAdapter.notifyDataSetChanged();
} else {
item = null;
stableAdapter = null;
activeObjPos = 0;
}
return new Undoable() {
@Override
public void undo() {
if (item != null) {
stableAdapter.setNotifyOnChange(false);
stableAdapter.insert(item, position);
stableAdapter.getObjects().add(position, item);
stableAdapter.getActiveObjects().add(activeObjPos, item);
stableAdapter.refreshData();
if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) {
onItemsSwapped(stableAdapter.getActiveObjects());
}
}
}
@Override
public String getTitle() {
List<Object> activeObjects;
if ((visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT)
&& (getMyApplication().getRoutingHelper().isRoutePlanningMode() || getMyApplication().getRoutingHelper().isFollowingMode())
&& item != null
&& ((activeObjects = stableAdapter.getActiveObjects()).isEmpty() || isContainsOnlyStart(activeObjects))) {
return mapActivity.getResources().getString(R.string.cancel_navigation);
} else {
return null;
}
}
};
}
@Override
public void onHidePopup() {
if (listAdapter instanceof StableArrayAdapter) {
StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter;
stableAdapter.refreshData();
if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) {
onItemsSwapped(stableAdapter.getActiveObjects());
}
List<Object> activeObjects = stableAdapter.getActiveObjects();
if (activeObjects.isEmpty() || isContainsOnlyStart(activeObjects)) {
hideDashboard();
if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) {
mapActivity.getMapActions().stopNavigationWithoutConfirm();
getMyApplication().getTargetPointsHelper().removeAllWayPoints(false, true);
mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().hide();
}
}
}
}
private boolean isContainsOnlyStart(List<Object> items) {
if (items.size() == 1) {
Object item = items.get(0);
if (item instanceof LocationPointWrapper) {
LocationPointWrapper w = (LocationPointWrapper) item;
if (w.getPoint() instanceof TargetPoint) {
return ((TargetPoint) w.getPoint()).start;
}
}
}
return false;
}
});
gradientToolbar = ContextCompat.getDrawable(mapActivity, R.drawable.gradient_toolbar).mutate();
if (AndroidUiHelper.isOrientationPortrait(mapActivity)) {
this.portrait = true;
@ -432,10 +304,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
private void updateToolbarActions() {
TextView tv = (TextView) dashboardView.findViewById(R.id.toolbar_text);
tv.setText("");
boolean waypointsVisible = visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT;
if (waypointsVisible) {
tv.setText(R.string.shared_string_waypoints);
} else if (visibleType == DashboardType.CONFIGURE_MAP) {
if (visibleType == DashboardType.CONFIGURE_MAP) {
tv.setText(R.string.configure_map);
} else if (visibleType == DashboardType.CONFIGURE_SCREEN) {
tv.setText(R.string.layer_map_appearance);
@ -478,24 +347,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
});
if (waypointsVisible && getMyApplication().getWaypointHelper().getAllPoints().size() > 0) {
if (getMyApplication().getWaypointHelper().isRouteCalculated()) {
flat.setVisibility(View.VISIBLE);
final boolean flatNow = visibleType == DashboardType.WAYPOINTS_FLAT;
flat.setImageDrawable(iconsCache.getIcon(flatNow ? R.drawable.ic_tree_list_dark
: R.drawable.ic_flat_list_dark));
flat.setContentDescription(mapActivity.getString(flatNow ? R.string.access_tree_list : R.string.drawer));
flat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setDashboardVisibility(true, flatNow ? DashboardType.WAYPOINTS : DashboardType.WAYPOINTS_FLAT,
previousVisibleType, false, AndroidUtils.getCenterViewCoordinates(v));
}
});
}
}
if (visibleType == DashboardType.DASHBOARD || visibleType == DashboardType.LIST_MENU) {
settingsButton.setVisibility(View.VISIBLE);
settingsButton.setOnClickListener(new View.OnClickListener() {
@ -607,12 +458,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
button = actionButtons.get(DashboardActionButtonType.MY_LOCATION);
} else if (type == DashboardType.ROUTE_PREFERENCES) {
button = actionButtons.get(DashboardActionButtonType.NAVIGATE);
} else if (type == DashboardType.WAYPOINTS || type == DashboardType.WAYPOINTS_FLAT) {
if (isInRouteOrPlannigMode()) {
button = actionButtons.get(DashboardActionButtonType.NAVIGATE);
} else {
button = actionButtons.get(DashboardActionButtonType.ROUTE);
}
}
if (button != null) {
@ -720,10 +565,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
DashboardOnMap.staticVisible = visible;
DashboardOnMap.staticVisibleType = type;
mapActivity.enableDrawer();
if (swipeDismissListener != null) {
swipeDismissListener.discardUndo();
}
removeMapillaryFiltersFragment();
if (visible) {
@ -825,14 +666,13 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
// listView.setBackgroundColor(backgroundColor);
listEmptyTextView.setBackgroundColor(backgroundColor);
}
if (visibleType != DashboardType.WAYPOINTS
&& visibleType != DashboardType.CONFIGURE_SCREEN
if (visibleType != DashboardType.CONFIGURE_SCREEN
&& visibleType != DashboardType.CONFIGURE_MAP
&& visibleType != DashboardType.CONTOUR_LINES
&& visibleType != DashboardType.HILLSHADE
&& visibleType != DashboardType.OSM_NOTES) {
listView.setDivider(dividerDrawable);
listView.setDividerHeight(dpToPx(1f));
listView.setDividerHeight(AndroidUtils.dpToPx(mapActivity, 1f));
} else {
listView.setDivider(null);
}
@ -843,60 +683,34 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
}
private int dpToPx(float dp) {
Resources r = mapActivity.getResources();
return (int) TypedValue.applyDimension(COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics());
}
private void updateListAdapter() {
listEmptyTextView.setVisibility(View.GONE);
listView.setEmptyView(null);
ContextMenuAdapter cm = null;
if (DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) {
StableArrayAdapter listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(true, deletedPoints, mapActivity, running,
DashboardType.WAYPOINTS_FLAT == visibleType, nightMode);
OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running,
listAdapter);
setDynamicListItems(listView, listAdapter);
if (visibleType == DashboardType.CONFIGURE_SCREEN) {
cm = mapActivity.getMapLayers().getMapWidgetRegistry().getViewConfigureMenuAdapter(mapActivity);
} else if (visibleType == DashboardType.CONFIGURE_MAP) {
cm = new ConfigureMapMenu().createListAdapter(mapActivity);
} else if (visibleType == DashboardType.LIST_MENU) {
cm = mapActivity.getMapActions().createMainOptionsMenu();
} else if (visibleType == DashboardType.ROUTE_PREFERENCES) {
RoutePreferencesMenu routePreferencesMenu = new RoutePreferencesMenu(mapActivity);
ArrayAdapter<LocalRoutingParameter> listAdapter = routePreferencesMenu.getRoutePreferencesDrawerAdapter(nightMode);
OnItemClickListener listener = routePreferencesMenu.getItemClickListener(listAdapter);
updateListAdapter(listAdapter, listener);
if (listAdapter.getObjects().size() == 0) {
listEmptyTextView.setText(mapActivity.getString(R.string.no_waypoints_found));
if (landscape) {
listView.setEmptyView(listEmptyTextView);
} else {
listEmptyTextView.setVisibility(View.VISIBLE);
}
}
} else {
if (visibleType == DashboardType.CONFIGURE_SCREEN) {
cm = mapActivity.getMapLayers().getMapWidgetRegistry().getViewConfigureMenuAdapter(mapActivity);
} else if (visibleType == DashboardType.CONFIGURE_MAP) {
cm = new ConfigureMapMenu().createListAdapter(mapActivity);
} else if (visibleType == DashboardType.LIST_MENU) {
cm = mapActivity.getMapActions().createMainOptionsMenu();
} else if (visibleType == DashboardType.ROUTE_PREFERENCES) {
RoutePreferencesMenu routePreferencesMenu = new RoutePreferencesMenu(mapActivity);
ArrayAdapter<LocalRoutingParameter> listAdapter = routePreferencesMenu.getRoutePreferencesDrawerAdapter(nightMode);
OnItemClickListener listener = routePreferencesMenu.getItemClickListener(listAdapter);
updateListAdapter(listAdapter, listener);
} else if (visibleType == DashboardType.UNDERLAY_MAP) {
cm = RasterMapMenu.createListAdapter(mapActivity, OsmandRasterMapsPlugin.RasterMapType.UNDERLAY);
} else if (visibleType == DashboardType.OVERLAY_MAP) {
cm = RasterMapMenu.createListAdapter(mapActivity, OsmandRasterMapsPlugin.RasterMapType.OVERLAY);
} else if (visibleType == DashboardType.CONTOUR_LINES) {
cm = ContourLinesMenu.createListAdapter(mapActivity);
} else if (visibleType == DashboardType.HILLSHADE) {
cm = HillshadeMenu.createListAdapter(mapActivity);
} else if (visibleType == DashboardType.OSM_NOTES) {
cm = OsmNotesMenu.createListAdapter(mapActivity);
}
if (cm != null) {
updateListAdapter(cm);
}
} else if (visibleType == DashboardType.UNDERLAY_MAP) {
cm = RasterMapMenu.createListAdapter(mapActivity, OsmandRasterMapsPlugin.RasterMapType.UNDERLAY);
} else if (visibleType == DashboardType.OVERLAY_MAP) {
cm = RasterMapMenu.createListAdapter(mapActivity, OsmandRasterMapsPlugin.RasterMapType.OVERLAY);
} else if (visibleType == DashboardType.CONTOUR_LINES) {
cm = ContourLinesMenu.createListAdapter(mapActivity);
} else if (visibleType == DashboardType.HILLSHADE) {
cm = HillshadeMenu.createListAdapter(mapActivity);
} else if (visibleType == DashboardType.OSM_NOTES) {
cm = OsmNotesMenu.createListAdapter(mapActivity);
}
if (cm != null) {
updateListAdapter(cm);
}
}
@ -956,12 +770,9 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
.detach(mapillaryFragment)
.attach(mapillaryFragment)
.commit();
} else if (visibleType == DashboardType.WAYPOINTS
|| visibleType == DashboardType.CONFIGURE_SCREEN
|| force) {
} else if (visibleType == DashboardType.CONFIGURE_SCREEN || force) {
updateListAdapter();
} else if (visibleType == DashboardType.CONFIGURE_MAP
|| visibleType == DashboardType.ROUTE_PREFERENCES) {
} else if (visibleType == DashboardType.CONFIGURE_MAP || visibleType == DashboardType.ROUTE_PREFERENCES) {
int index = listView.getFirstVisiblePosition();
View v = listView.getChildAt(0);
int top = (v == null) ? 0 : (v.getTop() - listView.getPaddingTop());
@ -972,14 +783,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
}
private void setDynamicListItems(DynamicListView listView, StableArrayAdapter listAdapter) {
listView.setItemsList(listAdapter.getObjects());
if (DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) {
listView.setActiveItemsList(listAdapter.getActiveObjects());
}
}
private OnItemClickListener getOptionsMenuOnClickListener(final ContextMenuAdapter cm,
final ArrayAdapter<ContextMenuItem> listAdapter) {
return new AdapterView.OnItemClickListener() {
@ -1063,8 +866,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}, 4000);
}
public void navigationAction() {
void navigationAction() {
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
mapActivity.getMapActions().enterRoutePlanningMode(null, null);
@ -1077,7 +879,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
hideDashboard(animate);
}
// To bounce animate view
private void open(boolean animation, int[] animationCoordinates) {
if (animation) {
@ -1166,7 +967,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
animationCoordinates = null;
}
private void addOrUpdateDashboardFragments() {
OsmandSettings settings = getMyApplication().getSettings();
TransactionBuilder builder =
@ -1192,7 +992,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
return visible;
}
public void onDetach(DashBaseFragment dashBaseFragment) {
void onDetach(DashBaseFragment dashBaseFragment) {
Iterator<WeakReference<DashBaseFragment>> it = fragList.iterator();
while (it.hasNext()) {
WeakReference<DashBaseFragment> wr = it.next();
@ -1202,7 +1002,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
}
public void updateLocation(final boolean centerChanged, final boolean locationChanged,
final boolean compassChanged) {
if (inLocationUpdate) {
@ -1240,16 +1039,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
dashboardView.requestLayout();
}
public void onMenuPressed() {
if (!isVisible()) {
setDashboardVisibility(true, DashboardType.DASHBOARD);
} else {
hideDashboard();
}
}
public boolean onBackPressed() {
if (isVisible()) {
backPressed();
@ -1258,7 +1047,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
return false;
}
private void backPressed() {
if (previousVisibleType != visibleType && previousVisibleType != null) {
if (visibleType == DashboardType.MAPILLARY) {
@ -1275,11 +1063,12 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
View currentFocus = mapActivity.getCurrentFocus();
if (currentFocus != null) {
InputMethodManager imm = (InputMethodManager) mapActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
if (imm != null) {
imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
}
}
}
@Override
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
// Translate list background
@ -1298,8 +1087,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
private boolean isActionButtonVisible() {
return visibleType == DashboardType.DASHBOARD
|| visibleType == DashboardType.WAYPOINTS
|| visibleType == DashboardType.WAYPOINTS_FLAT
|| visibleType == DashboardType.LIST_MENU
|| visibleType == DashboardType.ROUTE_PREFERENCES
|| visibleType == DashboardType.CONFIGURE_SCREEN;
@ -1322,7 +1109,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
private void updateTopButton(int scrollY) {
if (actionButton != null && portrait && isActionButtonVisible()) {
double scale = mapActivity.getResources().getDisplayMetrics().density;
int originalPosition = mFlexibleSpaceImageHeight - (int) (80 * scale);
@ -1350,7 +1136,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
}
private void updateColorOfToolbar(int scrollY) {
if (portrait) {
float sh = mFlexibleSpaceImageHeight - mFlexibleBlurSpaceHeight;
@ -1425,7 +1210,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
public <T extends DashBaseFragment> T getFragmentByClass(Class<T> class1) {
<T extends DashBaseFragment> T getFragmentByClass(Class<T> class1) {
for (WeakReference<DashBaseFragment> f : fragList) {
DashBaseFragment b = f.get();
if (b != null && !b.isDetached() && class1.isInstance(b)) {
@ -1436,26 +1221,26 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
return null;
}
public void blacklistFragmentByTag(String tag) {
void blacklistFragmentByTag(String tag) {
hideFragmentByTag(tag);
getMyApplication().getSettings().registerBooleanPreference(SHOULD_SHOW + tag, true)
.makeGlobal().set(false);
}
public void hideFragmentByTag(String tag) {
void hideFragmentByTag(String tag) {
FragmentManager manager = mapActivity.getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
Fragment frag = manager.findFragmentByTag(tag);
transaction.hide(frag).commit();
}
public void unblacklistFragmentClass(String tag) {
void unblacklistFragmentClass(String tag) {
unhideFragmentByTag(tag);
getMyApplication().getSettings().registerBooleanPreference(SHOULD_SHOW + tag, true)
.makeGlobal().set(true);
}
public void unhideFragmentByTag(String tag) {
void unhideFragmentByTag(String tag) {
FragmentManager manager = mapActivity.getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
Fragment frag = manager.findFragmentByTag(tag);
@ -1470,8 +1255,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
return dashboardView;
}
public static <T> List<T> handleNumberOfRows(List<T> list, OsmandSettings settings,
String rowNumberTag) {
public static <T> void handleNumberOfRows(List<T> list, OsmandSettings settings,
String rowNumberTag) {
int numberOfRows = settings.registerIntPreference(rowNumberTag, 3)
.makeGlobal().get();
if (list.size() > numberOfRows) {
@ -1479,7 +1264,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
list.remove(numberOfRows);
}
}
return list;
}
public static class DefaultShouldShow extends DashFragmentData.ShouldShowFunction {
@ -1489,66 +1273,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
}
@Override
public void onItemSwapping(int position) {
}
@SuppressWarnings("unchecked")
@Override
public void onItemsSwapped(final List<Object> items) {
getMyApplication().runInUIThread(new Runnable() {
@Override
public void run() {
if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) {
List<TargetPoint> allTargets = new ArrayList<>();
TargetPoint start = null;
if (items != null) {
for (Object obj : items) {
if (obj instanceof LocationPointWrapper) {
LocationPointWrapper p = (LocationPointWrapper) obj;
if (p.getPoint() instanceof TargetPoint) {
TargetPoint t = (TargetPoint) p.getPoint();
if (t.start) {
start = t;
} else {
t.intermediate = true;
}
allTargets.add(t);
}
}
}
if (allTargets.size() > 0) {
allTargets.get(allTargets.size() - 1).intermediate = false;
}
}
TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper();
if (start != null) {
int startInd = allTargets.indexOf(start);
TargetPoint first = allTargets.remove(0);
if (startInd != 0) {
start.start = false;
start.intermediate = startInd != allTargets.size() - 1;
if (targetPointsHelper.getPointToStart() == null) {
start.getOriginalPointDescription().setName(PointDescription
.getLocationNamePlain(getMyApplication(), start.getLatitude(), start.getLongitude()));
}
first.start = true;
first.intermediate = false;
targetPointsHelper.setStartPoint(new LatLon(first.getLatitude(), first.getLongitude()),
false, first.getPointDescription(getMyApplication()));
}
}
targetPointsHelper.reorderAllTargetPoints(allTargets, false);
newRouteIsCalculated(false, new ValueHolder<Boolean>());
targetPointsHelper.updateRouteAndRefresh(true);
}
}
}, 50);
}
@Override
public void newRouteIsCalculated(boolean newRoute, ValueHolder<Boolean> showToast) {
reloadAdapter();
showToast.value = false;
}
@ -1559,50 +1285,4 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
@Override
public void routeWasFinished() {
}
@Override
public void onWindowVisibilityChanged(int visibility) {
if (visibility != View.VISIBLE && swipeDismissListener != null) {
swipeDismissListener.discardUndo();
}
}
@Override
public void reloadAdapter() {
if (listAdapter != null && listAdapter instanceof StableArrayAdapter) {
StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter;
if (DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) {
waypointDialogHelper.reloadListAdapter(stableAdapter);
}
setDynamicListItems(listView, stableAdapter);
}
}
private void deleteSwipeItem(int position) {
if (swipeDismissListener != null) {
swipeDismissListener.delete(position);
}
}
@Override
public void deleteWaypoint(int position) {
deleteSwipeItem(position);
}
@Override
public void exchangeWaypoints(int pos1, int pos2) {
if (swipeDismissListener != null) {
swipeDismissListener.discardUndo();
}
if (pos1 != -1 && pos2 != -1) {
StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter;
Object item1 = stableAdapter.getActiveObjects().get(pos1);
Object item2 = stableAdapter.getActiveObjects().get(pos2);
stableAdapter.getActiveObjects().set(pos1, item2);
stableAdapter.getActiveObjects().set(pos2, item1);
stableAdapter.refreshData();
onItemsSwapped(stableAdapter.getActiveObjects());
}
}
}

View file

@ -47,6 +47,7 @@ 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.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.routepreparationmenu.AddPointBottomSheetDialog;
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.views.controls.DynamicListView.DragIcon;
@ -319,108 +320,6 @@ public class WaypointDialogHelper {
return res;
}
public StableArrayAdapter getWaypointsDrawerAdapter(
final boolean edit, final List<LocationPointWrapper> deletedPoints,
final MapActivity ctx, final int[] running, final boolean flat, final boolean nightMode) {
this.flat = flat;
this.deletedPoints = deletedPoints;
final List<Object> points = getPoints();
List<Object> activePoints = getActivePoints(points);
final WaypointDialogHelper helper = this;
final StableArrayAdapter listAdapter = new StableArrayAdapter(ctx,
R.layout.waypoint_reached, R.id.title, points, activePoints) {
@Override
public void buildDividers() {
dividers = getCustomDividers(ctx, getObjects(), nightMode);
}
@Override
public boolean isEnabled(int position) {
Object obj = getItem(position);
boolean labelView = (obj instanceof Integer);
boolean topDividerView = (obj instanceof Boolean) && ((Boolean) obj);
boolean bottomDividerView = (obj instanceof Boolean) && !((Boolean) obj);
boolean enabled = !labelView && !topDividerView && !bottomDividerView;
if (enabled && obj instanceof RadiusItem) {
int type = ((RadiusItem) obj).type;
enabled = type != WaypointHelper.POI;
}
return enabled;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// User super class to create the View
View v = convertView;
final ArrayAdapter<Object> thisAdapter = this;
Object obj = getItem(position);
boolean labelView = (obj instanceof Integer);
boolean topDividerView = (obj instanceof Boolean) && ((Boolean) obj);
boolean bottomDividerView = (obj instanceof Boolean) && !((Boolean) obj);
if (obj instanceof RadiusItem) {
final int type = ((RadiusItem) obj).type;
v = createItemForRadiusProximity(ctx, type, running, position, thisAdapter, nightMode);
//Drawable d = new ColorDrawable(mapActivity.getResources().getColor(R.color.dashboard_divider_light));
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
} else if (labelView) {
v = createItemForCategory(ctx, (Integer) obj, running, position, thisAdapter, nightMode, helper);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
} else if (topDividerView) {
v = ctx.getLayoutInflater().inflate(R.layout.card_top_divider, null);
AndroidUtils.setListBackground(mapActivity, v, nightMode);
} else if (bottomDividerView) {
v = ctx.getLayoutInflater().inflate(R.layout.card_bottom_divider, null);
AndroidUtils.setListBackground(mapActivity, v, nightMode);
} else if (obj instanceof LocationPointWrapper) {
LocationPointWrapper point = (LocationPointWrapper) obj;
v = updateWaypointItemView(edit, deletedPoints, app, ctx, helper, v, point, this,
nightMode, flat);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
}
return v;
}
};
for (Object p : points) {
if (p instanceof LocationPointWrapper) {
LocationPointWrapper w = (LocationPointWrapper) p;
if (w.type == WaypointHelper.TARGETS) {
final TargetPoint t = (TargetPoint) w.point;
if (t.getOriginalPointDescription() != null
&& t.getOriginalPointDescription().isSearchingAddress(mapActivity)) {
GeocodingLookupService.AddressLookupRequest lookupRequest
= new GeocodingLookupService.AddressLookupRequest(t.point, new GeocodingLookupService.OnAddressLookupResult() {
@Override
public void geocodingDone(String address) {
if (!helperCallbacks.isEmpty()) {
for (WaypointDialogHelperCallbacks callback : helperCallbacks) {
callback.reloadAdapter();
}
} else {
reloadListAdapter(listAdapter);
}
//updateRouteInfoMenu(ctx);
}
}, null);
app.getGeocodingLookupService().lookupAddress(lookupRequest);
}
}
}
}
return listAdapter;
}
public static View updateWaypointItemView(final boolean edit, final List<LocationPointWrapper> deletedPoints,
final OsmandApplication app, final Activity ctx,
final WaypointDialogHelper helper, View v,
@ -1129,42 +1028,20 @@ public class WaypointDialogHelper {
return R.string.shared_string_close;
}
private void openAddPointDialog(MapActivity mapActivity) {
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);
}
private void onWaypointItemClick(BaseBottomSheetItem[] addWaypointItem) {
final MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
final MapRouteInfoMenu routeMenu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
final ListPopupWindow popup = new ListPopupWindow(mapActivity);
popup.setAnchorView(addWaypointItem[0].getView());
popup.setDropDownGravity(Gravity.END | Gravity.TOP);
popup.setVerticalOffset(AndroidUtils.dpToPx(mapActivity, 48f));
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);
} 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();
dismiss();
if (hideDashboard) {
mapActivity.getDashboard().hideDashboard();
}
}
});
popup.show();
openAddPointDialog(mapActivity);
}
}

View file

@ -15,16 +15,13 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.AppCompatImageView;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import net.osmand.AndroidUtils;
@ -358,14 +355,17 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
public void updateInfo(final View main) {
mainView = main;
nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
updateViaView(main);
updateFromSpinner(main);
updateToSpinner(main);
updateApplicationModes(mainView);
updateApplicationModesOptions(main);
updateOptionsButtons(main);
updateStartPointView();
updateWaypointsView();
updateFinishPointView();
updateApplicationModes();
updateApplicationModesOptions();
updateOptionsButtons();
routeCards.clear();
if (isBasicRouteCalculated()) {
GPXUtilities.GPXFile gpx = GPXUtilities.makeGpxFromRoute(routingHelper.getRoute());
if (gpx != null) {
@ -401,11 +401,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
public void updateApplicationModesOptions() {
updateApplicationModesOptions(mainView);
}
private void updateApplicationModesOptions(final View parentView) {
AppCompatImageView foldButtonView = (AppCompatImageView) parentView.findViewById(R.id.fold_button);
AppCompatImageView foldButtonView = (AppCompatImageView) mainView.findViewById(R.id.fold_button);
foldButtonView.setImageResource(currentMenuState == MenuState.HEADER_ONLY ?
R.drawable.ic_action_arrow_up : R.drawable.ic_action_arrow_down);
foldButtonView.setOnClickListener(new View.OnClickListener() {
@ -415,7 +411,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
});
parentView.findViewById(R.id.app_modes_options).setOnClickListener(new View.OnClickListener() {
mainView.findViewById(R.id.app_modes_options).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
availableProfileDialog();
@ -429,7 +425,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
} else {
openMenuHeaderOnly();
}
updateApplicationModesOptions(mainView);
updateApplicationModesOptions();
}
private void availableProfileDialog() {
@ -457,7 +453,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
b.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
updateApplicationModes(mainView);
updateApplicationModes();
}
});
b.setView(v);
@ -482,11 +478,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
}
private void updateApplicationModes(final View parentView) {
private void updateApplicationModes() {
final ApplicationMode am = routingHelper.getAppMode();
final Set<ApplicationMode> selected = new HashSet<>();
selected.add(am);
ViewGroup vg = (ViewGroup) parentView.findViewById(R.id.app_modes);
ViewGroup vg = (ViewGroup) mainView.findViewById(R.id.app_modes);
vg.removeAllViews();
View.OnClickListener listener = new View.OnClickListener() {
@Override
@ -495,7 +491,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
ApplicationMode next = selected.iterator().next();
updateApplicationMode(am, next);
}
updateOptionsButtons(mainView);
updateOptionsButtons();
}
};
final List<ApplicationMode> values = new ArrayList<ApplicationMode>(ApplicationMode.values(mapActivity.getMyApplication()));
@ -541,7 +537,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
}
private void updateOptionsButtons(final View main) {
private void updateOptionsButtons() {
final boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
final OsmandSettings settings = app.getSettings();
final int colorActive = ContextCompat.getColor(app, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
@ -550,17 +546,17 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
final RoutingOptionsHelper.RouteMenuAppModes mode = routingOptionsHelper.modes.get(applicationMode);
int margin = AndroidUtils.dpToPx(app, 3);
View startButton = main.findViewById(R.id.start_button);
View startButton = mainView.findViewById(R.id.start_button);
if (isRouteCalculated()) {
AndroidUtils.setBackground(app, startButton, nightMode, R.color.active_buttons_and_links_light, R.color.active_buttons_and_links_dark);
int color = nightMode ? R.color.main_font_dark : R.color.card_and_list_background_light;
((TextView) main.findViewById(R.id.start_button_descr)).setTextColor(ContextCompat.getColor(app, color));
((ImageView) main.findViewById(R.id.start_icon)).setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_start_navigation, color));
((TextView) mainView.findViewById(R.id.start_button_descr)).setTextColor(ContextCompat.getColor(app, color));
((ImageView) mainView.findViewById(R.id.start_icon)).setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_start_navigation, color));
} else {
AndroidUtils.setBackground(app, startButton, nightMode, R.color.activity_background_light, R.color.route_info_cancel_button_color_dark);
int color = R.color.description_font_and_bottom_sheet_icons;
((TextView) main.findViewById(R.id.start_button_descr)).setTextColor(ContextCompat.getColor(app, color));
((ImageView) main.findViewById(R.id.start_icon)).setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_start_navigation, color));
((TextView) mainView.findViewById(R.id.start_button_descr)).setTextColor(ContextCompat.getColor(app, color));
((ImageView) mainView.findViewById(R.id.start_icon)).setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_start_navigation, color));
}
startButton.setOnClickListener(new View.OnClickListener() {
@Override
@ -569,7 +565,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
});
View cancelButton = main.findViewById(R.id.cancel_button);
View cancelButton = mainView.findViewById(R.id.cancel_button);
AndroidUtils.setBackground(app, cancelButton, nightMode, R.color.card_and_list_background_light, R.color.card_and_list_background_dark);
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
@ -578,9 +574,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
});
LinearLayout optionsButton = (LinearLayout) main.findViewById(R.id.map_options_route_button);
TextView optionsTitle = (TextView) main.findViewById(R.id.map_options_route_button_title);
ImageView optionsIcon = (ImageView) main.findViewById(R.id.map_options_route_button_icon);
LinearLayout optionsButton = (LinearLayout) mainView.findViewById(R.id.map_options_route_button);
TextView optionsTitle = (TextView) mainView.findViewById(R.id.map_options_route_button_title);
ImageView optionsIcon = (ImageView) mainView.findViewById(R.id.map_options_route_button_icon);
Drawable drawable = app.getUIUtilities().getIcon(R.drawable.map_action_settings, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
if (Build.VERSION.SDK_INT >= 21) {
Drawable active = app.getUIUtilities().getIcon(R.drawable.map_action_settings, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
@ -599,7 +595,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
scrollView.setVerticalScrollBarEnabled(false);
scrollView.setHorizontalScrollBarEnabled(false);
LinearLayout optionsContainer = (LinearLayout) main.findViewById(R.id.route_options_container);
LinearLayout optionsContainer = (LinearLayout) mainView.findViewById(R.id.route_options_container);
optionsContainer.removeAllViews();
if (mode == null) {
return;
@ -658,7 +654,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
public void onClick(View v) {
app.getPoiFilters().removeSelectedPoiFilter(poiUIFilter);
mapActivity.getMapView().refreshMap();
updateOptionsButtons(mainView);
updateOptionsButtons();
}
});
item.addView(container, newLp);
@ -672,7 +668,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
@Override
public void onClick(View v) {
app.getWaypointHelper().enableWaypointType(WaypointHelper.ALARMS, false);
updateOptionsButtons(mainView);
updateOptionsButtons();
}
});
AndroidUtils.setBackground(app, container, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
@ -686,7 +682,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
@Override
public void onClick(View v) {
app.getWaypointHelper().enableWaypointType(WaypointHelper.FAVORITES, false);
updateOptionsButtons(mainView);
updateOptionsButtons();
}
});
AndroidUtils.setBackground(app, container, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
@ -723,7 +719,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
if (mode.parameters.size() > 2) {
item.removeView(v);
} else {
updateOptionsButtons(mainView);
updateOptionsButtons();
}
}
});
@ -757,7 +753,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
if (mode.parameters.size() > 2) {
item.removeView(v);
} else {
updateOptionsButtons(mainView);
updateOptionsButtons();
}
}
});
@ -777,7 +773,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
routingOptionsHelper.showLocalRoutingParameterGroupDialog(group, mapActivity, new RoutingOptionsHelper.OnClickListener() {
@Override
public void onClick() {
updateOptionsButtons(mainView);
updateOptionsButtons();
}
});
}
@ -915,46 +911,33 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
RouteOptionsBottomSheet.showInstance(mapActivity.getSupportFragmentManager());
}
private void clickRouteWaypoints() {
if (getTargets().checkPointToNavigateShort()) {
mapActivity.getMapActions().openIntermediatePointsDialog();
}
}
private void updateViaView(final View parentView) {
private void updateWaypointsView() {
String via = generateViaDescription();
View viaLayout = parentView.findViewById(R.id.ViaLayout);
View viaLayoutDivider = parentView.findViewById(R.id.viaLayoutDivider);
View viaLayout = mainView.findViewById(R.id.ViaLayout);
View viaLayoutDivider = mainView.findViewById(R.id.viaLayoutDivider);
if (via.length() == 0) {
viaLayout.setVisibility(View.GONE);
viaLayoutDivider.setVisibility(View.GONE);
} else {
viaLayout.setVisibility(View.VISIBLE);
viaLayoutDivider.setVisibility(View.VISIBLE);
((TextView) parentView.findViewById(R.id.ViaView)).setText(via);
((TextView) parentView.findViewById(R.id.ViaSubView)).setText(app.getString(R.string.intermediate_destinations, getTargets().getIntermediatePoints().size()));
((TextView) mainView.findViewById(R.id.ViaView)).setText(via);
((TextView) mainView.findViewById(R.id.ViaSubView)).setText(app.getString(R.string.intermediate_destinations, getTargets().getIntermediatePoints().size()));
}
FrameLayout viaButton = (FrameLayout) parentView.findViewById(R.id.via_button);
FrameLayout viaButton = (FrameLayout) mainView.findViewById(R.id.via_button);
viaButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// clickRouteWaypoints();
if (getTargets().checkPointToNavigateShort()) {
WaypointsFragment.showInstance(mapActivity);
}
}
});
ImageView viaIcon = (ImageView) parentView.findViewById(R.id.viaIcon);
ImageView viaIcon = (ImageView) mainView.findViewById(R.id.viaIcon);
viaIcon.setImageDrawable(getIconOrig(R.drawable.list_intermediate));
viaIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
clickRouteWaypoints();
}
});
LinearLayout viaButtonContainer = (LinearLayout) parentView.findViewById(R.id.via_button_container);
LinearLayout viaButtonContainer = (LinearLayout) mainView.findViewById(R.id.via_button_container);
AndroidUtils.setBackground(app, viaButton, nightMode, R.drawable.btn_border_trans_rounded_light, R.drawable.btn_border_trans_rounded_dark);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
@ -962,7 +945,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
} else {
AndroidUtils.setBackground(app, viaButtonContainer, nightMode, R.drawable.ripple_rounded_light, R.drawable.ripple_rounded_dark);
}
ImageView viaButtonImageView = (ImageView) parentView.findViewById(R.id.via_button_image_view);
ImageView viaButtonImageView = (ImageView) mainView.findViewById(R.id.via_button_image_view);
Drawable normal = mapActivity.getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_edit_dark, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
if (Build.VERSION.SDK_INT >= 21) {
@ -973,50 +956,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
viaButtonImageView.setImageDrawable(normal);
}
private void updateToSpinner(final View parentView) {
final Spinner toSpinner = setupToSpinner(parentView);
toSpinner.setClickable(false);
final View toLayout = parentView.findViewById(R.id.ToLayout);
toSpinner.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
event.offsetLocation(AndroidUtils.dpToPx(mapActivity, 48f), 0);
toLayout.onTouchEvent(event);
return true;
}
});
toSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, final long id) {
parentView.post(new Runnable() {
@Override
public void run() {
if (id == SPINNER_FAV_ID) {
selectFavorite(parentView, true, false);
} else if (id == SPINNER_MAP_ID) {
selectOnScreen(true, false);
} else if (id == SPINNER_ADDRESS_ID) {
mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.DESTINATION_SELECTION, false);
setupToSpinner(parentView);
} else if (id == SPINNER_MAP_MARKER_MORE_ID) {
selectMapMarker(-1, true, false);
setupToSpinner(parentView);
} else if (id == SPINNER_MAP_MARKER_1_ID) {
selectMapMarker(0, true, false);
} else if (id == SPINNER_MAP_MARKER_2_ID) {
selectMapMarker(1, true, false);
} else if (id == SPINNER_MAP_MARKER_3_ID) {
selectMapMarker(2, true, false);
}
}
});
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
private void updateFinishPointView() {
setupToText(mainView);
final View toLayout = mainView.findViewById(R.id.ToLayout);
toLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -1024,8 +966,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
});
final FrameLayout toButton = (FrameLayout) parentView.findViewById(R.id.to_button);
final LinearLayout toButtonContainer = (LinearLayout) parentView.findViewById(R.id.to_button_container);
final FrameLayout toButton = (FrameLayout) mainView.findViewById(R.id.to_button);
final LinearLayout toButtonContainer = (LinearLayout) mainView.findViewById(R.id.to_button_container);
AndroidUtils.setBackground(app, toButton, nightMode, R.drawable.btn_border_trans_rounded_light, R.drawable.btn_border_trans_rounded_dark);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
@ -1033,7 +975,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
} else {
AndroidUtils.setBackground(app, toButtonContainer, nightMode, R.drawable.ripple_rounded_light, R.drawable.ripple_rounded_dark);
}
ImageView toButtonImageView = (ImageView) parentView.findViewById(R.id.to_button_image_view);
ImageView toButtonImageView = (ImageView) mainView.findViewById(R.id.to_button_image_view);
Drawable normal = mapActivity.getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_plus, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
if (Build.VERSION.SDK_INT >= 21) {
@ -1050,7 +992,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
});
updateToIcon(parentView);
updateToIcon(mainView);
}
private void updateToIcon(View parentView) {
@ -1058,58 +1000,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
toIcon.setImageDrawable(getIconOrig(R.drawable.list_destination));
}
private void updateFromSpinner(final View parentView) {
final TargetPointsHelper targets = getTargets();
final Spinner fromSpinner = setupFromSpinner(parentView);
fromSpinner.setClickable(false);
final View fromLayout = parentView.findViewById(R.id.FromLayout);
fromSpinner.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
event.offsetLocation(AndroidUtils.dpToPx(mapActivity, 48f), 0);
fromLayout.onTouchEvent(event);
return true;
}
});
fromSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, final long id) {
parentView.post(new Runnable() {
@Override
public void run() {
if (id == SPINNER_MY_LOCATION_ID) {
if (targets.getPointToStart() != null) {
targets.clearStartPoint(true);
mapActivity.getMyApplication().getSettings().backupPointToStart();
}
updateFromIcon(parentView);
} else if (id == SPINNER_FAV_ID) {
selectFavorite(parentView, false, false);
} else if (id == SPINNER_MAP_ID) {
selectOnScreen(false, false);
} else if (id == SPINNER_ADDRESS_ID) {
mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.START_POINT_SELECTION, false);
setupFromSpinner(parentView);
} else if (id == SPINNER_MAP_MARKER_MORE_ID) {
selectMapMarker(-1, false, false);
setupFromSpinner(parentView);
} else if (id == SPINNER_MAP_MARKER_1_ID) {
selectMapMarker(0, false, false);
} else if (id == SPINNER_MAP_MARKER_2_ID) {
selectMapMarker(1, false, false);
} else if (id == SPINNER_MAP_MARKER_3_ID) {
selectMapMarker(2, false, false);
}
}
});
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
private void updateStartPointView() {
setupFromText(mainView);
final View fromLayout = mainView.findViewById(R.id.FromLayout);
fromLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -1117,8 +1010,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
});
FrameLayout fromButton = (FrameLayout) parentView.findViewById(R.id.from_button);
final LinearLayout fromButtonContainer = (LinearLayout) parentView.findViewById(R.id.from_button_container);
FrameLayout fromButton = (FrameLayout) mainView.findViewById(R.id.from_button);
final LinearLayout fromButtonContainer = (LinearLayout) mainView.findViewById(R.id.from_button_container);
AndroidUtils.setBackground(app, fromButton, nightMode, R.drawable.btn_border_trans_rounded_light, R.drawable.btn_border_trans_rounded_dark);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
@ -1127,7 +1020,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
AndroidUtils.setBackground(app, fromButtonContainer, nightMode, R.drawable.ripple_rounded_light, R.drawable.ripple_rounded_dark);
}
ImageView swapDirectionView = (ImageView) parentView.findViewById(R.id.from_button_image_view);
ImageView swapDirectionView = (ImageView) mainView.findViewById(R.id.from_button_image_view);
Drawable normal = mapActivity.getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_change_navigation_points, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
if (Build.VERSION.SDK_INT >= 21) {
@ -1160,7 +1053,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
});
updateFromIcon(parentView);
updateFromIcon(mainView);
}
public void updateFromIcon(View parentView) {
@ -1200,9 +1093,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
public void setupSpinners(final boolean target, final boolean intermediate) {
if (!intermediate && mainView != null) {
if (target) {
setupToSpinner(mainView);
setupToText(mainView);
} else {
setupFromSpinner(mainView);
setupFromText(mainView);
}
}
}
@ -1337,24 +1230,12 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
return "";
}
private Spinner setupFromSpinner(View view) {
List<RouteSpinnerRow> fromActions = new ArrayList<>();
fromActions.add(new RouteSpinnerRow(SPINNER_MY_LOCATION_ID, R.drawable.ic_action_get_my_location,
mapActivity.getString(R.string.shared_string_my_location)));
fromActions.add(new RouteSpinnerRow(SPINNER_FAV_ID, R.drawable.ic_action_fav_dark,
mapActivity.getString(R.string.shared_string_favorite) + mapActivity.getString(R.string.shared_string_ellipsis)));
fromActions.add(new RouteSpinnerRow(SPINNER_MAP_ID, R.drawable.ic_action_marker_dark,
mapActivity.getString(R.string.shared_string_select_on_map)));
fromActions.add(new RouteSpinnerRow(SPINNER_ADDRESS_ID, R.drawable.ic_action_home_dark,
mapActivity.getString(R.string.shared_string_address) + mapActivity.getString(R.string.shared_string_ellipsis)));
private void setupFromText(View view) {
TargetPoint start = getTargets().getPointToStart();
int startPos = -1;
String name = null;
if (start != null) {
String oname = start.getOnlyName().length() > 0 ? start.getOnlyName()
: (mapActivity.getString(R.string.route_descr_map_location) + " " + getRoutePointDescription(start.getLatitude(), start.getLongitude()));
startPos = fromActions.size();
fromActions.add(new RouteSpinnerRow(SPINNER_START_ID, R.drawable.ic_action_get_my_location, oname));
name = start.getOnlyName().length() > 0 ? start.getOnlyName() :
(mapActivity.getString(R.string.route_descr_map_location) + " " + getRoutePointDescription(start.getLatitude(), start.getLongitude()));
final LatLon latLon = start.point;
final PointDescription pointDescription = start.getOriginalPointDescription();
@ -1372,35 +1253,21 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
}
addMarkersToSpinner(fromActions);
final Spinner fromSpinner = ((Spinner) view.findViewById(R.id.FromSpinner));
RouteSpinnerArrayAdapter fromAdapter = new RouteSpinnerArrayAdapter(view.getContext());
for (RouteSpinnerRow row : fromActions) {
fromAdapter.add(row);
}
fromSpinner.setAdapter(fromAdapter);
final TextView fromText = ((TextView) view.findViewById(R.id.fromText));
if (start != null) {
fromSpinner.setSelection(startPos);
fromText.setText(name);
} else {
if (mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation() == null) {
fromSpinner.setPromptId(R.string.search_poi_location);
}
//fromSpinner.setSelection(0);
fromText.setText(R.string.shared_string_my_location);
}
return fromSpinner;
}
private Spinner setupToSpinner(View view) {
final Spinner toSpinner = ((Spinner) view.findViewById(R.id.ToSpinner));
private void setupToText(View view) {
final TextView toText = ((TextView) view.findViewById(R.id.toText));
final TargetPointsHelper targets = getTargets();
List<RouteSpinnerRow> toActions = new ArrayList<>();
TargetPoint finish = getTargets().getPointToNavigate();
if (finish != null) {
toActions.add(new RouteSpinnerRow(SPINNER_FINISH_ID, R.drawable.ic_action_get_my_location,
getRoutePointDescription(targets.getPointToNavigate().point,
targets.getPointToNavigate().getOnlyName())));
toText.setText(getRoutePointDescription(targets.getPointToNavigate().point,
targets.getPointToNavigate().getOnlyName()));
final LatLon latLon = finish.point;
final PointDescription pointDescription = finish.getOriginalPointDescription();
@ -1418,25 +1285,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
} else {
toSpinner.setPromptId(R.string.route_descr_select_destination);
toActions.add(new RouteSpinnerRow(SPINNER_HINT_ID, R.drawable.ic_action_get_my_location,
mapActivity.getString(R.string.route_descr_select_destination)));
toText.setText(R.string.route_descr_select_destination);
}
toActions.add(new RouteSpinnerRow(SPINNER_FAV_ID, R.drawable.ic_action_fav_dark,
mapActivity.getString(R.string.shared_string_favorite) + mapActivity.getString(R.string.shared_string_ellipsis)));
toActions.add(new RouteSpinnerRow(SPINNER_MAP_ID, R.drawable.ic_action_marker_dark,
mapActivity.getString(R.string.shared_string_select_on_map)));
toActions.add(new RouteSpinnerRow(SPINNER_ADDRESS_ID, R.drawable.ic_action_home_dark,
mapActivity.getString(R.string.shared_string_address) + mapActivity.getString(R.string.shared_string_ellipsis)));
addMarkersToSpinner(toActions);
RouteSpinnerArrayAdapter toAdapter = new RouteSpinnerArrayAdapter(view.getContext());
for (RouteSpinnerRow row : toActions) {
toAdapter.add(row);
}
toSpinner.setAdapter(toAdapter);
return toSpinner;
}
public RoutePopupListArrayAdapter getIntermediatesPopupAdapter(Context ctx) {

View file

@ -142,13 +142,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
bottomScrollView.setScrollingEnabled(false);
bottomScrollView.setBackgroundColor(getResources().getColor(nightMode ? R.color.activity_background_dark : R.color.activity_background_light));
FrameLayout bottomContainer = (FrameLayout) view.findViewById(R.id.bottom_container);
if (!menu.isRouteCalculated()) {
bottomContainer.setForeground(getContentIcon(R.drawable.bg_contextmenu_shadow));
} else {
bottomContainer.setForeground(null);
}
cardsContainer = (LinearLayout) view.findViewById(R.id.route_menu_cards_container);
buildBottomView();
@ -182,8 +175,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
private boolean slidingUp;
private boolean slidingDown;
private boolean hasMoved;
{
scroller = new OverScroller(getMapActivity());
final ViewConfiguration configuration = ViewConfiguration.get(getMapActivity());
@ -205,7 +196,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
hasMoved = false;
mDownY = event.getRawY();
dy = event.getY();
dyMain = getViewY();
@ -219,7 +209,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
moving = true;
}
if (moving) {
hasMoved = true;
float y = event.getY();
float newY = getViewY() + (y - dy);
if (!portrait && newY > topScreenPosY) {
@ -248,7 +237,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
case MotionEvent.ACTION_UP:
if (moving) {
moving = false;
hasMoved = false;
int currentY = getViewY();
final VelocityTracker velocityTracker = this.velocityTracker;
@ -278,7 +266,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
break;
case MotionEvent.ACTION_CANCEL:
moving = false;
hasMoved = false;
recycleVelocityTracker();
break;
@ -949,13 +936,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
ctx.setupRouteCalculationProgressBar((ProgressBar) mainView.findViewById(R.id.progress_bar));
setupRouteCalculationButtonProgressBar((ProgressBar) view.findViewById(R.id.progress_bar_button));
FrameLayout bottomContainer = (FrameLayout) view.findViewById(R.id.bottom_container);
if (!menu.isRouteCalculated()) {
bottomContainer.setForeground(getContentIcon(R.drawable.bg_contextmenu_shadow));
} else {
bottomContainer.setForeground(null);
}
updateControlButtons();
}

View file

@ -17,7 +17,6 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.Location;
import net.osmand.binary.RouteDataObject;
import net.osmand.data.LatLon;
@ -31,12 +30,12 @@ import net.osmand.plus.OsmandSettings.RulerMode;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.actions.StartGPSStatus;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.WaypointDialogHelper;
import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
import net.osmand.plus.routepreparationmenu.WaypointsFragment;
import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
@ -1004,7 +1003,7 @@ public class MapInfoWidgetsFactory {
all.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
map.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS, AndroidUtils.getCenterViewCoordinates(view));
WaypointsFragment.showInstance(map);
}
});
remove.setOnClickListener(new OnClickListener() {