From e6eb1b0ecd44d2ec2df6989094fde0c455be78b9 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Fri, 11 Dec 2015 16:29:36 +0300 Subject: [PATCH] Route preparation menu in progress --- OsmAnd/res/layout-land/map_hud_top.xml | 2 +- OsmAnd/res/layout-land/plan_route_info.xml | 102 +++++++- .../res/layout/map_route_prepare_bottom.xml | 9 +- OsmAnd/res/layout/plan_route_info.xml | 102 +++++++- OsmAnd/res/values-large/sizes.xml | 3 +- OsmAnd/res/values/sizes.xml | 1 + OsmAnd/res/values/strings.xml | 2 + OsmAnd/src/net/osmand/AndroidUtils.java | 13 + .../net/osmand/plus/ContextMenuAdapter.java | 2 +- OsmAnd/src/net/osmand/plus/IconsCache.java | 4 + .../osmand/plus/activities/MapActivity.java | 7 +- .../plus/activities/SettingsBaseActivity.java | 2 +- .../activities/actions/AppModeDialog.java | 25 +- .../SettingsDevelopmentActivity.java | 2 +- .../other/MapRouteInfoMenu.java | 230 ++++++++++++++---- .../other/MapRouteInfoMenuFragment.java | 87 +++++++ .../other/MapRoutePreferencesControl.java | 2 +- .../net/osmand/plus/views/FavoritesLayer.java | 3 + .../osmand/plus/views/MapControlsLayer.java | 128 +++------- 19 files changed, 539 insertions(+), 187 deletions(-) diff --git a/OsmAnd/res/layout-land/map_hud_top.xml b/OsmAnd/res/layout-land/map_hud_top.xml index 8d0b0423e0..0d78ef80fa 100644 --- a/OsmAnd/res/layout-land/map_hud_top.xml +++ b/OsmAnd/res/layout-land/map_hud_top.xml @@ -8,7 +8,7 @@ diff --git a/OsmAnd/res/layout-land/plan_route_info.xml b/OsmAnd/res/layout-land/plan_route_info.xml index fdd26eefd5..76a04908b9 100644 --- a/OsmAnd/res/layout-land/plan_route_info.xml +++ b/OsmAnd/res/layout-land/plan_route_info.xml @@ -11,7 +11,7 @@ android:layout_width="@dimen/map_route_planning_land_width" android:layout_height="match_parent" android:layout_gravity="bottom" - android:background="?attr/left_menu_view_bg" + android:background="@drawable/bg_left_menu_dark" android:clickable="true" android:orientation="vertical"> @@ -26,10 +26,11 @@ android:layout_height="wrap_content"> @@ -261,13 +267,84 @@ + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/res/layout/map_route_prepare_bottom.xml b/OsmAnd/res/layout/map_route_prepare_bottom.xml index c028922324..eb8a2b009c 100644 --- a/OsmAnd/res/layout/map_route_prepare_bottom.xml +++ b/OsmAnd/res/layout/map_route_prepare_bottom.xml @@ -15,9 +15,10 @@ android:src="@drawable/ic_action_test_light" /> + android:background="@color/dashboard_divider_dark"/> + android:background="@color/dashboard_divider_dark"/> + android:background="@color/dashboard_divider_dark"/> @@ -26,10 +26,11 @@ android:layout_height="wrap_content"> @@ -261,13 +267,84 @@ + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/res/values-large/sizes.xml b/OsmAnd/res/values-large/sizes.xml index e87db739d8..37553b7427 100644 --- a/OsmAnd/res/values-large/sizes.xml +++ b/OsmAnd/res/values-large/sizes.xml @@ -10,7 +10,8 @@ 450dp 160dp 510dp - + 496dp + 60dp 78dp 66dp diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index 68eb36dd58..f1dc5e7b83 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -86,6 +86,7 @@ 1dp 1dp 320dp + 306dp 330dp 100dp diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index a09ab9ef7c..168454c65e 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,8 @@ 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 --> + Distance: + Travelling time: Every Hour Once a day diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java index cbae5e3012..63050e10c8 100644 --- a/OsmAnd/src/net/osmand/AndroidUtils.java +++ b/OsmAnd/src/net/osmand/AndroidUtils.java @@ -3,8 +3,10 @@ package net.osmand; import java.util.Date; +import android.annotation.SuppressLint; import android.content.Context; import android.content.res.Configuration; +import android.os.Build; import android.text.format.DateFormat; import android.view.View; import android.view.ViewParent; @@ -64,4 +66,15 @@ public class AndroidUtils { return null; } + + @SuppressLint("NewApi") + @SuppressWarnings("deprecation") + public static void setBackground(Context ctx, View view, boolean night, int lightResId, int darkResId) { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) { + view.setBackground(ctx.getResources().getDrawable(night ? darkResId : lightResId, + ctx.getTheme())); + } else { + view.setBackgroundDrawable(ctx.getResources().getDrawable(night ? darkResId : lightResId)); + } + } } diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java index a55cde4123..99c6187cca 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java @@ -330,7 +330,7 @@ public class ContextMenuAdapter { Integer lid = getLayoutId(position); if (lid == R.layout.mode_toggles) { final Set selected = new LinkedHashSet(); - return AppModeDialog.prepareAppModeDrawerView(activity, visibleModes, selected, allModes, new View.OnClickListener() { + return AppModeDialog.prepareAppModeDrawerView(activity, visibleModes, selected, allModes, false, new View.OnClickListener() { @Override public void onClick(View view) { if (selected.size() > 0) { diff --git a/OsmAnd/src/net/osmand/plus/IconsCache.java b/OsmAnd/src/net/osmand/plus/IconsCache.java index 2b8a9fdbaa..393c411891 100644 --- a/OsmAnd/src/net/osmand/plus/IconsCache.java +++ b/OsmAnd/src/net/osmand/plus/IconsCache.java @@ -82,6 +82,10 @@ public class IconsCache { return getDrawable(id, app.getSettings().isLightContent() ? R.color.icon_color : 0); } + public Drawable getContentIcon(@DrawableRes int id, boolean isLightContent) { + return getDrawable(id, isLightContent ? R.color.icon_color : 0); + } + public Drawable getIcon(@DrawableRes int id) { return getDrawable(id, 0); } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 64bb4b95b2..84b452fbcf 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -555,7 +555,12 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents, if (mapLabelToShow != null && !mapLabelToShow.contextMenuDisabled()) { mapContextMenu.setMapCenter(latLonToShow); mapContextMenu.setMapPosition(mapView.getMapPosition()); - mapContextMenu.show(latLonToShow, mapLabelToShow, toShow); + if (mapLayers.getMapControlsLayer().getMapRouteInfoMenu().isVisible()) { + mapContextMenu.showMinimized(latLonToShow, mapLabelToShow, toShow); + mapLayers.getMapControlsLayer().getMapRouteInfoMenu().updateMenu(); + } else { + mapContextMenu.show(latLonToShow, mapLabelToShow, toShow); + } } if (!latLonToShow.equals(cur)) { mapView.getAnimatedDraggingThread().startMoving(latLonToShow.getLatitude(), diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java index 02c83a6ddd..95d2ce3bdd 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java @@ -400,7 +400,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity protected void profileDialog() { AlertDialog.Builder b = new AlertDialog.Builder(this); final Set selected = new LinkedHashSet(); - View v = AppModeDialog.prepareAppModeView(this, selected, false, null, true, + View v = AppModeDialog.prepareAppModeView(this, selected, false, null, true, false, new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java b/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java index ec14b9bbf3..e4ecad3b03 100644 --- a/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java +++ b/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; +import net.osmand.AndroidUtils; import net.osmand.plus.ApplicationMode; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.OsmandApplication; @@ -20,7 +21,7 @@ import android.widget.LinearLayout.LayoutParams; public class AppModeDialog { public static View prepareAppModeView(Activity a, final Set selected, boolean showDefault, - ViewGroup parent, final boolean singleSelection, final View.OnClickListener onClickListener) { + ViewGroup parent, final boolean singleSelection, boolean useMapTheme, final View.OnClickListener onClickListener) { OsmandSettings settings = ((OsmandApplication) a.getApplication()).getSettings(); final List values = new ArrayList(ApplicationMode.values(settings)); if(!showDefault) { @@ -29,21 +30,21 @@ public class AppModeDialog { if (showDefault || settings.getApplicationMode() != ApplicationMode.DEFAULT) { selected.add(settings.getApplicationMode()); } - return prepareAppModeView(a, values, selected, parent, singleSelection, false, onClickListener); + return prepareAppModeView(a, values, selected, parent, singleSelection, false, useMapTheme, onClickListener); } //special method for drawer menu //needed because if there's more than 4 items - the don't fit in drawer public static View prepareAppModeDrawerView(Activity a, List visible, final Set selected, ContextMenuAdapter.BooleanResult allModes, - final View.OnClickListener onClickListener) { + boolean useMapTheme, final View.OnClickListener onClickListener) { OsmandSettings settings = ((OsmandApplication) a.getApplication()).getSettings(); final List values = new ArrayList(ApplicationMode.values(settings)); selected.add(settings.getApplicationMode()); - return prepareAppModeView(a, values, selected, null, true, true, onClickListener); + return prepareAppModeView(a, values, selected, null, true, true, useMapTheme, onClickListener); } public static View prepareAppModeView(Activity a, final List values , final Set selected, - ViewGroup parent, final boolean singleSelection, boolean drawer, final View.OnClickListener onClickListener) { + ViewGroup parent, final boolean singleSelection, boolean drawer, boolean useMapTheme, final View.OnClickListener onClickListener) { View ll = a.getLayoutInflater().inflate(R.layout.mode_toggles, parent); final View[] buttons = new View[values.size()]; int k = 0; @@ -52,7 +53,7 @@ public class AppModeDialog { } for (int i = 0; i < buttons.length; i++) { updateButtonState((OsmandApplication) a.getApplication(), values, selected, onClickListener, buttons, i, - singleSelection); + singleSelection, useMapTheme); } return ll; } @@ -60,7 +61,7 @@ public class AppModeDialog { private static void updateButtonState(final OsmandApplication ctx, final List visible, final Set selected, final View.OnClickListener onClickListener, final View[] buttons, - int i, final boolean singleChoice) { + int i, final boolean singleChoice, final boolean useMapTheme) { if (buttons[i] != null) { View tb = buttons[i]; final ApplicationMode mode = visible.get(i); @@ -70,7 +71,13 @@ public class AppModeDialog { iv.setImageDrawable(ctx.getIconsCache().getIcon(mode.getSmallIconDark(), R.color.osmand_orange)); tb.findViewById(R.id.selection).setVisibility(View.VISIBLE); } else { - iv.setImageDrawable(ctx.getIconsCache().getContentIcon(mode.getSmallIconDark())); + if (useMapTheme) { + boolean nightMode = ctx.getDaynightHelper().isNightMode(); + iv.setImageDrawable(ctx.getIconsCache().getContentIcon(mode.getSmallIconDark(), !nightMode)); + AndroidUtils.setBackground(ctx, iv, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark); + } else { + iv.setImageDrawable(ctx.getIconsCache().getContentIcon(mode.getSmallIconDark())); + } tb.findViewById(R.id.selection).setVisibility(View.INVISIBLE); } iv.setOnClickListener(new View.OnClickListener() { @@ -94,7 +101,7 @@ public class AppModeDialog { onClickListener.onClick(null); } for(int i = 0; i < visible.size(); i++) { - updateButtonState(ctx, visible, selected, onClickListener, buttons, i, singleChoice); + updateButtonState(ctx, visible, selected, onClickListener, buttons, i, singleChoice, useMapTheme); } } }); diff --git a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java index f7487c2e9c..51d346b749 100644 --- a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java +++ b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java @@ -211,7 +211,7 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity { modes.remove(ApplicationMode.DEFAULT); final Set selected = new LinkedHashSet(ApplicationMode.values(settings)); selected.remove(ApplicationMode.DEFAULT); - View v = AppModeDialog.prepareAppModeView(this, modes, selected, null, false, false, + View v = AppModeDialog.prepareAppModeView(this, modes, selected, null, false, false, false, new View.OnClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java index 866d8ea90d..356152ccff 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java @@ -1,12 +1,16 @@ package net.osmand.plus.mapcontextmenu.other; import android.app.Dialog; +import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnDismissListener; import android.content.Intent; +import android.content.res.Resources; import android.graphics.PointF; import android.graphics.drawable.Drawable; import android.support.v4.app.Fragment; +import android.support.v4.content.ContextCompat; +import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; @@ -35,6 +39,7 @@ import net.osmand.plus.activities.ShowRouteInfoActivity; import net.osmand.plus.activities.actions.AppModeDialog; import net.osmand.plus.activities.search.SearchAddressActivity; import net.osmand.plus.dialogs.FavoriteDialogs; +import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.routing.RouteDirectionInfo; import net.osmand.plus.routing.RoutingHelper; @@ -48,6 +53,8 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import static android.util.TypedValue.COMPLEX_UNIT_DIP; + public class MapRouteInfoMenu implements IRouteInformationListener { public static int directionInfo = -1; public static boolean controlVisible = false; @@ -61,6 +68,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener { private MapActivity mapActivity; private MapControlsLayer mapControlsLayer; public static final String TARGET_SELECT = "TARGET_SELECT"; + private boolean nightMode; + private boolean switched; public MapRouteInfoMenu(MapActivity mapActivity, MapControlsLayer mapControlsLayer) { this.mapActivity = mapActivity; @@ -116,6 +125,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener { } public void updateInfo(final View main) { + nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightMode(); updateViaView(main); updateFromSpinner(main); updateToSpinner(main); @@ -132,6 +142,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener { private void updateRouteCalcProgress(final View main) { TargetPointsHelper targets = getTargets(); if (targets.hasTooLongDistanceToNavigate()) { + main.findViewById(R.id.dividerToDropDown).setVisibility(View.VISIBLE); main.findViewById(R.id.RouteInfoControls).setVisibility(View.VISIBLE); TextView textView = (TextView) main.findViewById(R.id.InfoTextView); ImageView iconView = (ImageView) main.findViewById(R.id.InfoIcon); @@ -139,8 +150,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener { main.findViewById(R.id.Next).setVisibility(View.GONE); textView.setText(R.string.route_is_too_long); textView.setVisibility(View.VISIBLE); - iconView.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_warning)); + iconView.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_warning, isLight())); } else { + main.findViewById(R.id.dividerToDropDown).setVisibility(View.GONE); main.findViewById(R.id.RouteInfoControls).setVisibility(View.GONE); } } @@ -153,7 +165,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener { ViewGroup vg = (ViewGroup) parentView.findViewById(R.id.app_modes); vg.removeAllViews(); AppModeDialog.prepareAppModeView(mapActivity, selected, false, - vg, true, new View.OnClickListener() { + vg, true, true, new View.OnClickListener() { @Override public void onClick(View v) { if (selected.size() > 0) { @@ -167,15 +179,25 @@ public class MapRouteInfoMenu implements IRouteInformationListener { private void updateViaView(final View parentView) { String via = generateViaDescription(); + View viaLayout = parentView.findViewById(R.id.ViaLayout); if (via.length() == 0) { - parentView.findViewById(R.id.ViaLayout).setVisibility(View.GONE); + viaLayout.setVisibility(View.GONE); parentView.findViewById(R.id.viaLayoutDivider).setVisibility(View.GONE); } else { - parentView.findViewById(R.id.ViaLayout).setVisibility(View.VISIBLE); + viaLayout.setVisibility(View.VISIBLE); parentView.findViewById(R.id.viaLayoutDivider).setVisibility(View.VISIBLE); ((TextView) parentView.findViewById(R.id.ViaView)).setText(via); } + viaLayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (getTargets().checkPointToNavigateShort()) { + mapActivity.getMapActions().openIntermediatePointsDialog(); + } + } + }); + ImageView viaIcon = (ImageView) parentView.findViewById(R.id.viaIcon); if (isLight()) { viaIcon.setImageDrawable(getIconOrig(R.drawable.widget_intermediate_day)); @@ -186,6 +208,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener { private void updateToSpinner(final View parentView) { final Spinner toSpinner = setupToSpinner(parentView); + toSpinner.setClickable(false); toSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { @@ -206,6 +229,13 @@ public class MapRouteInfoMenu implements IRouteInformationListener { } }); + parentView.findViewById(R.id.ToLayout).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + toSpinner.performClick(); + } + }); + ImageView toIcon = (ImageView) parentView.findViewById(R.id.toIcon); if (isLight()) { toIcon.setImageDrawable(getIconOrig(R.drawable.widget_target_day)); @@ -214,19 +244,14 @@ public class MapRouteInfoMenu implements IRouteInformationListener { } ImageView toDropDownIcon = (ImageView) parentView.findViewById(R.id.toDropDownIcon); - toDropDownIcon.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_arrow_drop_down)); - toDropDownIcon.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - toSpinner.performClick(); - } - }); + toDropDownIcon.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_arrow_drop_down, isLight())); } @SuppressWarnings("deprecation") private void updateFromSpinner(final View parentView) { final TargetPointsHelper targets = getTargets(); final Spinner fromSpinner = setupFromSpinner(parentView); + fromSpinner.setClickable(false); fromSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override @@ -252,18 +277,19 @@ public class MapRouteInfoMenu implements IRouteInformationListener { } }); - ImageView fromIcon = (ImageView) parentView.findViewById(R.id.fromIcon); - ApplicationMode appMode = mapActivity.getMyApplication().getSettings().getApplicationMode(); - fromIcon.setImageDrawable(mapActivity.getResources().getDrawable(appMode.getResourceLocationDay())); - - ImageView fromDropDownIcon = (ImageView) parentView.findViewById(R.id.fromDropDownIcon); - fromDropDownIcon.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_arrow_drop_down)); - fromDropDownIcon.setOnClickListener(new View.OnClickListener() { + parentView.findViewById(R.id.FromLayout).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { fromSpinner.performClick(); } }); + + ImageView fromIcon = (ImageView) parentView.findViewById(R.id.fromIcon); + ApplicationMode appMode = mapActivity.getMyApplication().getSettings().getApplicationMode(); + fromIcon.setImageDrawable(mapActivity.getResources().getDrawable(appMode.getResourceLocationDay())); + + ImageView fromDropDownIcon = (ImageView) parentView.findViewById(R.id.fromDropDownIcon); + fromDropDownIcon.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_arrow_drop_down, isLight())); } protected void selectOnScreen(boolean target) { @@ -304,7 +330,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener { } private boolean isLight() { - return mapActivity.getMyApplication().getSettings().isLightContent(); + return !nightMode; } private Drawable getIconOrig(int iconId) { @@ -357,10 +383,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener { } private void updateRouteButtons(final View mainView) { + mainView.findViewById(R.id.dividerToDropDown).setVisibility(View.VISIBLE); mainView.findViewById(R.id.RouteInfoControls).setVisibility(View.VISIBLE); final OsmandApplication ctx = mapActivity.getMyApplication(); ImageView prev = (ImageView) mainView.findViewById(R.id.Prev); - prev.setImageDrawable(ctx.getIconsCache().getContentIcon(R.drawable.ic_prev)); + prev.setImageDrawable(ctx.getIconsCache().getContentIcon(R.drawable.ic_prev, isLight())); if (directionInfo >= 0) { prev.setVisibility(View.VISIBLE); prev.setOnClickListener(new View.OnClickListener() { @@ -389,7 +416,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener { } ImageView next = (ImageView) mainView.findViewById(R.id.Next); next.setVisibility(View.VISIBLE); - next.setImageDrawable(ctx.getIconsCache().getContentIcon(R.drawable.ic_next)); + next.setImageDrawable(ctx.getIconsCache().getContentIcon(R.drawable.ic_next, isLight())); next.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -416,19 +443,45 @@ public class MapRouteInfoMenu implements IRouteInformationListener { }); TextView textView = (TextView) mainView.findViewById(R.id.InfoTextView); - ImageView iconView = (ImageView) mainView.findViewById(R.id.InfoIcon); + ImageView infoIcon = (ImageView) mainView.findViewById(R.id.InfoIcon); + ImageView durationIcon = (ImageView) mainView.findViewById(R.id.DurationIcon); + View infoDistanceView = mainView.findViewById(R.id.InfoDistance); + View infoDurationView = mainView.findViewById(R.id.InfoDuration); if (directionInfo >= 0) { - iconView.setVisibility(View.GONE); + infoIcon.setVisibility(View.GONE); + durationIcon.setVisibility(View.GONE); + infoDistanceView.setVisibility(View.GONE); + infoDurationView.setVisibility(View.GONE); + textView.setVisibility(View.VISIBLE); } else { - iconView.setImageDrawable(ctx.getIconsCache().getContentIcon(R.drawable.ic_action_info_dark)); - iconView.setVisibility(View.VISIBLE); + infoIcon.setImageDrawable(ctx.getIconsCache().getContentIcon(R.drawable.ic_action_polygom_dark, isLight())); + infoIcon.setVisibility(View.VISIBLE); + durationIcon.setImageDrawable(ctx.getIconsCache().getContentIcon(R.drawable.ic_action_time, isLight())); + durationIcon.setVisibility(View.VISIBLE); + infoDistanceView.setVisibility(View.VISIBLE); + infoDurationView.setVisibility(View.VISIBLE); + textView.setVisibility(View.GONE); } if (directionInfo >= 0 && routingHelper.getRouteDirections() != null && directionInfo < routingHelper.getRouteDirections().size()) { RouteDirectionInfo ri = routingHelper.getRouteDirections().get(directionInfo); textView.setText((directionInfo + 1) + ". " + ri.getDescriptionRoutePart() + " " + OsmAndFormatter.getFormattedDistance(ri.distance, ctx)); } else { - textView.setText(ctx.getRoutingHelper().getGeneralRouteInformation().replace(",", ",\n")); + TextView distanceText = (TextView) mainView.findViewById(R.id.DistanceText); + TextView durationText = (TextView) mainView.findViewById(R.id.DurationText); + distanceText.setText(OsmAndFormatter.getFormattedDistance(ctx.getRoutingHelper().getLeftDistance(), ctx)); + int leftTime = ctx.getRoutingHelper().getLeftTime(); + int hours = leftTime / (60 * 60); + int minutes = (leftTime / 60) % 60; + if (hours > 0) { + durationText.setText(hours + " " + + ctx.getString(R.string.osmand_parking_hour) + + (minutes > 0 ? " " + minutes + " " + + ctx.getString(R.string.osmand_parking_minute) : "")); + } else { + durationText.setText(minutes + " " + + ctx.getString(R.string.osmand_parking_minute)); + } } } @@ -472,24 +525,25 @@ public class MapRouteInfoMenu implements IRouteInformationListener { } private Spinner setupFromSpinner(View view) { - ArrayList fromActions = new ArrayList<>(); - fromActions.add(mapActivity.getString(R.string.route_descr_current_location)); - fromActions.add(mapActivity.getString(R.string.shared_string_favorite) + mapActivity.getString(R.string.shared_string_ellipsis)); - fromActions.add(mapActivity.getString(R.string.shared_string_select_on_map)); - fromActions.add(mapActivity.getString(R.string.shared_string_address) + mapActivity.getString(R.string.shared_string_ellipsis)); + ArrayList fromActions = new ArrayList<>(); + fromActions.add(new RouteSpinnerRow(R.drawable.ic_action_get_my_location, + mapActivity.getString(R.string.route_descr_current_location))); + fromActions.add(new RouteSpinnerRow(R.drawable.ic_action_fav_dark, + mapActivity.getString(R.string.shared_string_favorite) + mapActivity.getString(R.string.shared_string_ellipsis))); + fromActions.add(new RouteSpinnerRow(R.drawable.ic_action_marker_dark, + mapActivity.getString(R.string.shared_string_select_on_map))); + fromActions.add(new RouteSpinnerRow(R.drawable.ic_action_home_dark, + mapActivity.getString(R.string.shared_string_address) + mapActivity.getString(R.string.shared_string_ellipsis))); TargetPoint start = getTargets().getPointToStart(); if (start != null) { String oname = start.getOnlyName().length() > 0 ? start.getOnlyName() : (mapActivity.getString(R.string.route_descr_map_location) + " " + getRoutePointDescription(start.getLatitude(), start.getLongitude())); - fromActions.add(oname); + fromActions.add(new RouteSpinnerRow(R.drawable.ic_action_get_my_location, oname)); } final Spinner fromSpinner = ((Spinner) view.findViewById(R.id.FromSpinner)); - ArrayAdapter fromAdapter = new ArrayAdapter<>(view.getContext(), - android.R.layout.simple_spinner_item, - fromActions - ); - fromAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + RouteSpinnerArrayAdapter fromAdapter = new RouteSpinnerArrayAdapter(view.getContext()); + fromAdapter.addAll(fromActions); fromSpinner.setAdapter(fromAdapter); if (start != null) { fromSpinner.setSelection(fromActions.size() - 1); @@ -505,24 +559,25 @@ public class MapRouteInfoMenu implements IRouteInformationListener { private Spinner setupToSpinner(View view) { final Spinner toSpinner = ((Spinner) view.findViewById(R.id.ToSpinner)); final TargetPointsHelper targets = getTargets(); - ArrayList toActions = new ArrayList<>(); + ArrayList toActions = new ArrayList<>(); if (targets.getPointToNavigate() != null) { - toActions.add(mapActivity.getString(R.string.route_descr_destination) + " " - + getRoutePointDescription(targets.getPointToNavigate().point, - targets.getPointToNavigate().getOnlyName())); + toActions.add(new RouteSpinnerRow(R.drawable.ic_action_get_my_location, + getRoutePointDescription(targets.getPointToNavigate().point, + targets.getPointToNavigate().getOnlyName()))); } else { toSpinner.setPromptId(R.string.route_descr_select_destination); - toActions.add(mapActivity.getString(R.string.route_descr_select_destination)); + toActions.add(new RouteSpinnerRow(R.drawable.ic_action_get_my_location, + mapActivity.getString(R.string.route_descr_select_destination))); } - toActions.add(mapActivity.getString(R.string.shared_string_favorite) + mapActivity.getString(R.string.shared_string_ellipsis)); - toActions.add(mapActivity.getString(R.string.shared_string_select_on_map)); - toActions.add(mapActivity.getString(R.string.shared_string_address) + mapActivity.getString(R.string.shared_string_ellipsis)); + toActions.add(new RouteSpinnerRow(R.drawable.ic_action_fav_dark, + mapActivity.getString(R.string.shared_string_favorite) + mapActivity.getString(R.string.shared_string_ellipsis))); + toActions.add(new RouteSpinnerRow(R.drawable.ic_action_marker_dark, + mapActivity.getString(R.string.shared_string_select_on_map))); + toActions.add(new RouteSpinnerRow(R.drawable.ic_action_home_dark, + mapActivity.getString(R.string.shared_string_address) + mapActivity.getString(R.string.shared_string_ellipsis))); - ArrayAdapter toAdapter = new ArrayAdapter<>(view.getContext(), - android.R.layout.simple_spinner_item, - toActions - ); - toAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + RouteSpinnerArrayAdapter toAdapter = new RouteSpinnerArrayAdapter(view.getContext()); + toAdapter.addAll(toActions); toSpinner.setAdapter(toAdapter); return toSpinner; } @@ -537,9 +592,34 @@ public class MapRouteInfoMenu implements IRouteInformationListener { // do not hide fragment (needed for use case entering Planning mode without destination) } + public void onDismiss() { + mapActivity.getMapView().setMapPositionX(0); + mapActivity.getMapView().refreshMap(); + AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin), false); + AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_right_widgets_panel), true); + AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_left_widgets_panel), true); + if (switched) { + mapControlsLayer.switchToRouteFollowingLayout(); + } + } public void show() { + switched = mapControlsLayer.switchToRoutePlanningLayout(); + boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity); + if (!portrait) { + mapActivity.getMapView().setMapPositionX(1); + mapActivity.getMapView().refreshMap(); + } + MapRouteInfoMenuFragment.showInstance(mapActivity); + + if (!AndroidUiHelper.isXLargeDevice(mapActivity)) { + AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_right_widgets_panel), false); + AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_left_widgets_panel), false); + } + if (!portrait) { + AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin), true); + } } public void hide() { @@ -552,4 +632,54 @@ public class MapRouteInfoMenu implements IRouteInformationListener { public void setShowMenu() { showMenu = true; } + + private class RouteSpinnerRow { + int iconId; + String text; + + public RouteSpinnerRow(int iconId, String text) { + this.iconId = iconId; + this.text = text; + } + } + + private class RouteSpinnerArrayAdapter extends ArrayAdapter { + + public RouteSpinnerArrayAdapter(Context context) { + super(context, android.R.layout.simple_spinner_item); + setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + TextView label = (TextView) super.getView(position, convertView, parent); + RouteSpinnerRow row = getItem(position); + label.setText(row.text); + label.setTextColor(!isLight() ? + ContextCompat.getColorStateList(mapActivity, android.R.color.primary_text_dark) : ContextCompat.getColorStateList(mapActivity, android.R.color.primary_text_light)); + return label; + } + + @Override + public View getDropDownView(int position, View convertView, ViewGroup parent) { + TextView label = (TextView) super.getDropDownView(position, convertView, parent); + + RouteSpinnerRow row = getItem(position); + label.setText(row.text); + Drawable icon = mapActivity.getMyApplication().getIconsCache().getContentIcon(row.iconId); + label.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); + label.setCompoundDrawablePadding(dpToPx(12f)); + + return label; + } + + private int dpToPx(float dp) { + Resources r = mapActivity.getResources(); + return (int) TypedValue.applyDimension( + COMPLEX_UNIT_DIP, + dp, + r.getDisplayMetrics() + ); + } + } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java index 207c851810..2e23ab5844 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java @@ -4,10 +4,13 @@ import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; +import android.support.v4.content.ContextCompat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.TextView; +import net.osmand.AndroidUtils; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.AndroidUiHelper; @@ -54,8 +57,17 @@ public class MapRouteInfoMenuFragment extends Fragment { } } + @Override + public void onDestroyView() { + super.onDestroyView(); + if (menu != null) { + menu.onDismiss(); + } + } + public void updateInfo() { menu.updateInfo(mainView); + applyDayNightMode(); } public void show(MapActivity mapActivity) { @@ -81,6 +93,81 @@ public class MapRouteInfoMenuFragment extends Fragment { } } + public void applyDayNightMode() { + MapActivity ctx = getMapActivity(); + boolean portrait = AndroidUiHelper.isOrientationPortrait(ctx); + boolean nightMode = ctx.getMyApplication().getDaynightHelper().isNightMode(); + if (portrait) { + AndroidUtils.setBackground(ctx, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark); + } else { + AndroidUtils.setBackground(ctx, mainView, nightMode, R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark); + } + AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerModesLayout), nightMode, + R.color.dashboard_divider_light, R.color.dashboard_divider_dark); + AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerFromDropDown), nightMode, + R.color.dashboard_divider_light, R.color.dashboard_divider_dark); + AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.viaLayoutDivider), nightMode, + R.color.dashboard_divider_light, R.color.dashboard_divider_dark); + AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerToDropDown), nightMode, + R.color.dashboard_divider_light, R.color.dashboard_divider_dark); + AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerButtons), nightMode, + R.color.dashboard_divider_light, R.color.dashboard_divider_dark); + + AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerBtn1), nightMode, + R.color.dashboard_divider_light, R.color.dashboard_divider_dark); + AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerBtn2), nightMode, + R.color.dashboard_divider_light, R.color.dashboard_divider_dark); + AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerBtn3), nightMode, + R.color.dashboard_divider_light, R.color.dashboard_divider_dark); + + ((TextView) mainView.findViewById(R.id.ViaView)).setTextColor(nightMode ? + ContextCompat.getColorStateList(ctx, android.R.color.primary_text_dark) + : ContextCompat.getColorStateList(ctx, android.R.color.primary_text_light)); + ((TextView) mainView.findViewById(R.id.ViaSubView)).setTextColor(nightMode ? + ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_dark) + : ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_light)); + + ((TextView) mainView.findViewById(R.id.toTitle)).setTextColor(nightMode ? + ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_dark) + : ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_light)); + + ((TextView) mainView.findViewById(R.id.fromTitle)).setTextColor(nightMode ? + ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_dark) + : ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_light)); + + ((TextView) mainView.findViewById(R.id.InfoTextView)).setTextColor(nightMode ? + ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_dark) + : ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_light)); + + AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.FromLayout), nightMode, + R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark); + AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.ViaLayout), nightMode, + R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark); + AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.ToLayout), nightMode, + R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark); + AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.Info), nightMode, + R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark); + + AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.Next), nightMode, + R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark); + AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.Prev), nightMode, + R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark); + + ((TextView) mainView.findViewById(R.id.DistanceText)).setTextColor(nightMode ? + ContextCompat.getColorStateList(ctx, android.R.color.primary_text_dark) + : ContextCompat.getColorStateList(ctx, android.R.color.primary_text_light)); + ((TextView) mainView.findViewById(R.id.DistanceTitle)).setTextColor(nightMode ? + ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_dark) + : ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_light)); + ((TextView) mainView.findViewById(R.id.DurationText)).setTextColor(nightMode ? + ContextCompat.getColorStateList(ctx, android.R.color.primary_text_dark) + : ContextCompat.getColorStateList(ctx, android.R.color.primary_text_light)); + ((TextView) mainView.findViewById(R.id.DurationTitle)).setTextColor(nightMode ? + ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_dark) + : ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_light)); + + } + public static boolean showInstance(final MapActivity mapActivity) { try { boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRoutePreferencesControl.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRoutePreferencesControl.java index cf3fd13fbb..12090f5e44 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRoutePreferencesControl.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRoutePreferencesControl.java @@ -461,7 +461,7 @@ public class MapRoutePreferencesControl { final Set selected = new HashSet(); selected.add(settings.APPLICATION_MODE.get()); AppModeDialog.prepareAppModeView(mapActivity, selected, false, - (ViewGroup) settingsDlg.findViewById(R.id.app_modes), true, new View.OnClickListener() { + (ViewGroup) settingsDlg.findViewById(R.id.app_modes), true, false, new View.OnClickListener() { @Override public void onClick(View v) { if (selected.size() > 0) { diff --git a/OsmAnd/src/net/osmand/plus/views/FavoritesLayer.java b/OsmAnd/src/net/osmand/plus/views/FavoritesLayer.java index 52df922fbe..9ccef9ada3 100644 --- a/OsmAnd/src/net/osmand/plus/views/FavoritesLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/FavoritesLayer.java @@ -102,6 +102,9 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer. final QuadRect latLonBounds = tileBox.getLatLonBounds(); List fullObjects = new ArrayList<>(); for (LocationPoint o : getPoints()) { + if (!o.isVisible()) { + continue; + } float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude()); float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude()); diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index 6497bef979..fc6d3f6610 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -11,9 +11,9 @@ import android.graphics.ColorFilter; import android.graphics.PointF; import android.graphics.drawable.Drawable; import android.os.Build; -import android.os.Handler; import android.support.annotation.NonNull; import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; import android.support.v7.app.AlertDialog; import android.view.MotionEvent; import android.view.View; @@ -26,6 +26,7 @@ import android.widget.TextView; import net.londatiga.android.ActionItem; import net.londatiga.android.QuickAction; +import net.osmand.AndroidUtils; import net.osmand.core.android.MapRendererContext; import net.osmand.data.LatLon; import net.osmand.data.RotatedTileBox; @@ -40,7 +41,6 @@ import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.search.SearchAddressFragment; import net.osmand.plus.dashboard.DashboardOnMap.DashboardType; -import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu; import net.osmand.plus.mapcontextmenu.other.MapRoutePreferencesControl; import net.osmand.plus.routing.RoutingHelper; @@ -81,9 +81,6 @@ public class MapControlsLayer extends OsmandMapLayer { private MapHudButton menuControl; private MapHudButton compassHud; private float cachedRotate = 0; - private static long startCounter; - private Runnable delayStart; - private Handler showUIHandler; private ImageView appModeIcon; private TextView zoomText; private OsmandMapTileView mapView; @@ -114,7 +111,6 @@ public class MapControlsLayer extends OsmandMapLayer { @Override public void initLayer(final OsmandMapTileView view) { - showUIHandler = new Handler(); initTopControls(); initTransparencyBar(); initZooms(); @@ -200,7 +196,6 @@ public class MapControlsLayer extends OsmandMapLayer { configureMap.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - notifyClicked(); mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP); } }); @@ -213,7 +208,6 @@ public class MapControlsLayer extends OsmandMapLayer { compass.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - notifyClicked(); mapActivity.getMapViewTrackingUtilities().switchRotateMapMode(); } }); @@ -226,8 +220,10 @@ public class MapControlsLayer extends OsmandMapLayer { } public void updateRouteButtons(View main, boolean routeInfo) { + boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightMode(); ImageView cancelRouteButton = (ImageView) main.findViewById(R.id.map_cancel_route_button); - cancelRouteButton.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.map_action_cancel)); + cancelRouteButton.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.map_action_cancel, !nightMode)); + AndroidUtils.setBackground(mapActivity, cancelRouteButton, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark); cancelRouteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -236,7 +232,8 @@ public class MapControlsLayer extends OsmandMapLayer { }); ImageView waypointsButton = (ImageView) main.findViewById(R.id.map_waypoints_route_button); - waypointsButton.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.map_action_waypoints)); + waypointsButton.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.map_action_waypoints, !nightMode)); + AndroidUtils.setBackground(mapActivity, waypointsButton, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark); waypointsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -246,7 +243,8 @@ public class MapControlsLayer extends OsmandMapLayer { ImageView options = (ImageView) main.findViewById(R.id.map_options_route_button); options.setImageDrawable(!routeInfo ? app.getIconsCache().getIcon(R.drawable.map_action_settings, - R.color.osmand_orange) : app.getIconsCache().getContentIcon(R.drawable.map_action_settings)); + R.color.osmand_orange) : app.getIconsCache().getContentIcon(R.drawable.map_action_settings, !nightMode)); + AndroidUtils.setBackground(mapActivity, options, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark); options.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -256,8 +254,10 @@ public class MapControlsLayer extends OsmandMapLayer { TextView routeGoButton = (TextView) main.findViewById(R.id.map_go_route_button); routeGoButton.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache().getIcon(R.drawable.map_start_navigation, R.color.color_myloc_distance), null, null, null); - routeGoButton.setText(/*AndroidUiHelper.isOrientationPortrait(mapActivity) ?*/ - mapActivity.getString(R.string.shared_string_go) /*: ""*/); + routeGoButton.setText(mapActivity.getString(R.string.shared_string_go)); + routeGoButton.setTextColor(nightMode ? + ContextCompat.getColorStateList(mapActivity, android.R.color.secondary_text_dark) : ContextCompat.getColorStateList(mapActivity, android.R.color.secondary_text_light)); + AndroidUtils.setBackground(mapActivity, routeGoButton, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark); routeGoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -277,7 +277,6 @@ public class MapControlsLayer extends OsmandMapLayer { } protected void clickRouteParams() { - notifyClicked(); if (optionsRouteControlDialog.isDialogVisible()) { optionsRouteControlDialog.hideDialog(); mapRouteInfoMenu.showHideMenu(); @@ -289,13 +288,11 @@ public class MapControlsLayer extends OsmandMapLayer { protected void clickRouteWaypoints() { if (getTargets().checkPointToNavigateShort()) { - notifyClicked(); mapActivity.getMapActions().openIntermediatePointsDialog(); } } protected void clickRouteCancel() { - notifyClicked(); mapRouteInfoMenu.hide(); optionsRouteControlDialog.hideDialog(); if (mapActivity.getRoutingHelper().isFollowingMode()) { @@ -306,16 +303,9 @@ public class MapControlsLayer extends OsmandMapLayer { } protected void clickRouteGo() { - notifyClicked(); mapRouteInfoMenu.hide(); optionsRouteControlDialog.hideDialog(); -// RoutingHelper routingHelper = mapActivity.getMyApplication().getRoutingHelper(); -// if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) { - // never possible -// mapActivity.getMapActions().enterRoutePlanningMode(null, null, false); -// } else { startNavigation(); -// } } public void showRouteInfoControlDialog() { @@ -356,10 +346,6 @@ public class MapControlsLayer extends OsmandMapLayer { backToMenuButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - // double lat = activity.getMapView().getLatitude(); - // double lon = activity.getMapView().getLongitude(); - // MainMenuActivity.backToMainMenuDialog(activity, new LatLon(lat, lon)); - notifyClicked(); if (dash) { mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD); } else { @@ -397,7 +383,6 @@ public class MapControlsLayer extends OsmandMapLayer { } private void onNavigationClick() { - notifyClicked(); RoutingHelper routingHelper = mapActivity.getRoutingHelper(); if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) { mapActivity.getMapActions().enterRoutePlanningMode(null, null); @@ -433,7 +418,6 @@ public class MapControlsLayer extends OsmandMapLayer { zoomInButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - notifyClicked(); if (view.isZooming()) { mapActivity.changeZoom(2, System.currentTimeMillis()); } else { @@ -451,7 +435,6 @@ public class MapControlsLayer extends OsmandMapLayer { zoomOutButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - notifyClicked(); mapActivity.changeZoom(-1, System.currentTimeMillis()); } }); @@ -459,7 +442,6 @@ public class MapControlsLayer extends OsmandMapLayer { } public void startNavigation() { - stopCounter(); OsmandApplication app = mapActivity.getMyApplication(); RoutingHelper routingHelper = app.getRoutingHelper(); if (routingHelper.isFollowingMode()) { @@ -480,44 +462,6 @@ public class MapControlsLayer extends OsmandMapLayer { } } - - private void stopCounter() { - startCounter = 0; - - } - - @Deprecated - public void startCounter() { - //OsmandSettings settings = mapActivity.getMyApplication().getSettings(); - int del = 0; // settings.DELAY_TO_START_NAVIGATION.get(); - if (del <= 0) { - return; - } - if (startCounter <= 0) { - startCounter = System.currentTimeMillis() + del * 1000; - delayStart = new Runnable() { - @Override - public void run() { - if (startCounter > 0) { - if (System.currentTimeMillis() > startCounter) { - startCounter = 0; - startNavigation(); - } else { - mapActivity.refreshMap(); - showUIHandler.postDelayed(delayStart, 1000); - } - } - } - }; - delayStart.run(); - } - - } - - protected void notifyClicked() { - stopCounter(); - } - @Override public void destroyLayer() { controls.clear(); @@ -528,7 +472,7 @@ public class MapControlsLayer extends OsmandMapLayer { updateControls(tileBox, nightMode); } - + @SuppressWarnings("deprecation") private void updateControls(@NonNull RotatedTileBox tileBox, DrawSettings nightMode) { boolean isNight = nightMode != null && nightMode.isNightMode(); int shadw = isNight ? Color.TRANSPARENT : Color.WHITE; @@ -538,7 +482,6 @@ public class MapControlsLayer extends OsmandMapLayer { // TODOnightMode // updatextColor(textColor, shadw, rulerControl, zoomControls, mapMenuControls); } - boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity); // default buttons boolean routePlanningMode = false; RoutingHelper rh = mapActivity.getRoutingHelper(); @@ -552,12 +495,18 @@ public class MapControlsLayer extends OsmandMapLayer { boolean showRouteCalculationControls = routePlanningMode || ((System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS) && routeFollowingMode); updateMyLocation(rh, dialogOpened); -// routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions ); -// routePlanningBtn.updateVisibility(showButtons && !routePlanningMode); - routePlanningBtn.setIconResId(R.drawable.map_directions); - routePlanningBtn.updateVisibility(!dialogOpened); + boolean showButtons = (showRouteCalculationControls || !routeFollowingMode); + routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions); + if (routePlanningMode || routeFollowingMode) { + routePlanningBtn.setIconResId(R.drawable.map_start_navigation); + routePlanningBtn.setIconColorId(R.color.color_myloc_distance); + } else { + routePlanningBtn.setIconResId(R.drawable.map_directions); + routePlanningBtn.resetIconColors(); + } + routePlanningBtn.updateVisibility(showButtons); + menuControl.updateVisibility(showButtons); - menuControl.updateVisibility(!dialogOpened); mapZoomIn.updateVisibility(!dialogOpened); mapZoomOut.updateVisibility(!dialogOpened); compassHud.updateVisibility(!dialogOpened); @@ -586,15 +535,6 @@ public class MapControlsLayer extends OsmandMapLayer { } mapRouteInfoMenu.setVisible(showRouteCalculationControls); - if (showRouteCalculationControls) { - if (!mapActivity.getRoutingHelper().isFollowingMode() - && !mapActivity.getRoutingHelper().isPauseNavigation()) { - startCounter(); - } - } else { - stopCounter(); - } - updateCompass(isNight); for (MapHudButton mc : controls) { @@ -638,16 +578,11 @@ public class MapControlsLayer extends OsmandMapLayer { public boolean onSingleTap(PointF point, RotatedTileBox tileBox) { - if (mapRouteInfoMenu.onSingleTap(point, tileBox)) { - return true; - } - stopCounter(); - return false; + return mapRouteInfoMenu.onSingleTap(point, tileBox); } @Override public boolean onTouchEvent(MotionEvent event, RotatedTileBox tileBox) { - stopCounter(); touchEvent = System.currentTimeMillis(); RoutingHelper rh = mapActivity.getRoutingHelper(); if (rh.isFollowingMode()) { @@ -771,6 +706,11 @@ public class MapControlsLayer extends OsmandMapLayer { return true; } + public void resetIconColors() { + resClrLight = R.color.icon_color; + resClrDark = 0; + } + public MapHudButton setIconColorId(int clr) { if (resClrLight == clr && resClrDark == clr) { return this; @@ -802,6 +742,7 @@ public class MapControlsLayer extends OsmandMapLayer { } @SuppressLint("NewApi") + @SuppressWarnings("deprecation") public void update(OsmandApplication ctx, boolean night) { if (nightMode == night && !f) { return; @@ -883,7 +824,7 @@ public class MapControlsLayer extends OsmandMapLayer { } public static View.OnLongClickListener getOnClickMagnifierListener(final OsmandMapTileView view) { - final View.OnLongClickListener listener = new View.OnLongClickListener() { + return new View.OnLongClickListener() { @Override public boolean onLongClick(View notUseCouldBeNull) { @@ -891,7 +832,7 @@ public class MapControlsLayer extends OsmandMapLayer { final AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext()); int p = (int) (mapDensity.get() * 100); final TIntArrayList tlist = new TIntArrayList(new int[]{20, 25, 33, 50, 75, 100, 150, 200, 300, 400}); - final List values = new ArrayList(); + final List values = new ArrayList<>(); int i = -1; for (int k = 0; k <= tlist.size(); k++) { final boolean end = k == tlist.size(); @@ -931,7 +872,6 @@ public class MapControlsLayer extends OsmandMapLayer { return true; } }; - return listener; } public void onActivityResult(int requestCode, int resultCode, Intent data) {