Merge pull request #6666 from osmandapp/RoutePreparationUiImprovements

Route preparation ui improvements
This commit is contained in:
Alexey 2019-03-12 20:02:56 +03:00 committed by GitHub
commit 4830917c7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 71 additions and 50 deletions

View file

@ -587,7 +587,7 @@
<include <include
layout="@layout/route_info_menu_control_buttons" layout="@layout/route_info_menu_control_buttons"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="48dp"
android:layout_gravity="bottom" /> android:layout_gravity="bottom" />
</LinearLayout> </LinearLayout>

View file

@ -30,6 +30,11 @@
</FrameLayout> </FrameLayout>
<View
android:id="@+id/controls_divider"
android:layout_width="1dp"
android:layout_height="match_parent" />
<FrameLayout <FrameLayout
android:id="@+id/start_button" android:id="@+id/start_button"
android:layout_width="0dp" android:layout_width="0dp"
@ -47,14 +52,6 @@
tools:progress="60" tools:progress="60"
tools:progressDrawable="?attr/size_progress_bar" /> tools:progressDrawable="?attr/size_progress_bar" />
<net.osmand.plus.widgets.ImageViewExProgress
android:id="@+id/start_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/route_info_icon_padding_left"
android:scaleType="fitStart"
tools:src="@drawable/ic_action_start_navigation" />
<net.osmand.plus.widgets.TextViewExProgress <net.osmand.plus.widgets.TextViewExProgress
android:id="@+id/start_button_descr" android:id="@+id/start_button_descr"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -62,13 +59,15 @@
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:ellipsize="end" android:ellipsize="end"
android:gravity="center" android:gravity="center"
android:layout_gravity="center"
android:letterSpacing="@dimen/text_button_letter_spacing" android:letterSpacing="@dimen/text_button_letter_spacing"
android:maxLines="1" android:maxLines="1"
android:paddingLeft="16dp" android:paddingLeft="@dimen/route_info_icon_padding_left"
android:paddingRight="16dp" android:paddingRight="@dimen/route_info_icon_padding_left"
android:text="@string/shared_string_control_start" android:text="@string/shared_string_control_start"
android:textSize="@dimen/text_button_text_size" android:textSize="@dimen/text_button_text_size"
osmand:typeface="@string/font_roboto_medium" osmand:typeface="@string/font_roboto_medium"
tools:drawableLeft="@drawable/ic_action_start_navigation"
tools:ignore="UnusedAttribute" /> tools:ignore="UnusedAttribute" />
</FrameLayout> </FrameLayout>

View file

@ -12,6 +12,9 @@
--> -->
<string name="transfers_size">%1$d transfers</string> <string name="transfers_size">%1$d transfers</string>
<string name="add_start_and_end_points">Add start and end points</string>
<string name="route_add_start_point">Add start point</string>
<string name="route_descr_select_start_point">Select start point</string>
<string name="rendering_attr_surface_unpaved_name">Unpaved</string> <string name="rendering_attr_surface_unpaved_name">Unpaved</string>
<string name="rendering_attr_surface_sand_name">Sand</string> <string name="rendering_attr_surface_sand_name">Sand</string>
<string name="rendering_attr_surface_grass_name">Grass</string> <string name="rendering_attr_surface_grass_name">Grass</string>

View file

@ -669,7 +669,8 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
spannable.append(OsmAndFormatter.getFormattedDistance((float) segment.getTravelDist(), app)); spannable.append(OsmAndFormatter.getFormattedDistance((float) segment.getTravelDist(), app));
spannable.setSpan(new CustomTypefaceSpan(typeface), startIndex, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); spannable.setSpan(new CustomTypefaceSpan(typeface), startIndex, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
SpannableString textType = new SpannableString(getString(R.string.by_transport_type, transportStopRoute.type.name().toLowerCase())); String type = getString(transportStopRoute.getTypeStrRes()).toLowerCase();
SpannableString textType = new SpannableString(getString(R.string.by_transport_type, type));
buildCollapsableRow(stopsContainer, spannable, textType, true, collapsableView, null); buildCollapsableRow(stopsContainer, spannable, textType, true, collapsableView, null);
final TransportStop endStop = stops.get(stops.size() - 1); final TransportStop endStop = stops.get(stops.size() - 1);

View file

@ -42,6 +42,7 @@ import net.osmand.plus.GeocodingLookupService;
import net.osmand.plus.GeocodingLookupService.AddressLookupRequest; import net.osmand.plus.GeocodingLookupService.AddressLookupRequest;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.CommonPreference; import net.osmand.plus.OsmandSettings.CommonPreference;
@ -782,18 +783,24 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
View startButton = mainView.findViewById(R.id.start_button); View startButton = mainView.findViewById(R.id.start_button);
TextView startButtonText = (TextView) mainView.findViewById(R.id.start_button_descr); TextView startButtonText = (TextView) mainView.findViewById(R.id.start_button_descr);
boolean publicTransportMode = routingHelper.getAppMode() == ApplicationMode.PUBLIC_TRANSPORT;
int iconId = publicTransportMode ? R.drawable.ic_map : R.drawable.ic_action_start_navigation;
if (isRouteCalculated()) { if (isRouteCalculated()) {
AndroidUtils.setBackground(app, startButton, nightMode, R.color.active_buttons_and_links_light, R.color.active_buttons_and_links_dark); 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; int color = nightMode ? R.color.main_font_dark : R.color.card_and_list_background_light;
startButtonText.setTextColor(ContextCompat.getColor(app, color)); startButtonText.setTextColor(ContextCompat.getColor(app, color));
((ImageView) mainView.findViewById(R.id.start_icon)).setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_start_navigation, color)); Drawable icon = app.getUIUtilities().getIcon(iconId, color);
startButtonText.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
} else { } else {
AndroidUtils.setBackground(app, startButton, nightMode, R.color.activity_background_light, R.color.route_info_cancel_button_color_dark); 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; int color = R.color.description_font_and_bottom_sheet_icons;
startButtonText.setTextColor(ContextCompat.getColor(app, color)); startButtonText.setTextColor(ContextCompat.getColor(app, color));
((ImageView) mainView.findViewById(R.id.start_icon)).setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_start_navigation, color)); Drawable icon = app.getUIUtilities().getIcon(iconId, color);
startButtonText.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
} }
if (routingHelper.isFollowingMode() || routingHelper.isPauseNavigation()) { if (publicTransportMode) {
startButtonText.setText(R.string.shared_string_show_on_map);
} else if (routingHelper.isFollowingMode() || routingHelper.isPauseNavigation()) {
startButtonText.setText(R.string.shared_string_continue); startButtonText.setText(R.string.shared_string_continue);
} else { } else {
startButtonText.setText(R.string.shared_string_control_start); startButtonText.setText(R.string.shared_string_control_start);
@ -1418,21 +1425,22 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper(); TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
TargetPoint startPoint = targetPointsHelper.getPointToStart(); TargetPoint startPoint = targetPointsHelper.getPointToStart();
TargetPoint endPoint = targetPointsHelper.getPointToNavigate(); TargetPoint endPoint = targetPointsHelper.getPointToNavigate();
if (endPoint == null) { Location loc = app.getLocationProvider().getLastKnownLocation();
if (loc == null && startPoint == null && endPoint == null) {
app.showShortToastMessage(R.string.add_start_and_end_points);
} else if (endPoint == null) {
app.showShortToastMessage(R.string.mark_final_location_first); app.showShortToastMessage(R.string.mark_final_location_first);
} else { } else {
if (startPoint == null) { if (startPoint == null && loc != null) {
Location loc = app.getLocationProvider().getLastKnownLocation(); startPoint = TargetPoint.createStartPoint(new LatLon(loc.getLatitude(), loc.getLongitude()),
if (loc != null) { new PointDescription(PointDescription.POINT_TYPE_MY_LOCATION, mapActivity.getString(R.string.shared_string_my_location)));
startPoint = TargetPoint.createStartPoint(new LatLon(loc.getLatitude(), loc.getLongitude()),
new PointDescription(PointDescription.POINT_TYPE_MY_LOCATION,
mapActivity.getString(R.string.shared_string_my_location)));
}
} }
if (startPoint != null) { if (startPoint != null) {
targetPointsHelper.navigateToPoint(startPoint.point, false, -1, startPoint.getPointDescription(mapActivity)); targetPointsHelper.navigateToPoint(startPoint.point, false, -1, startPoint.getPointDescription(mapActivity));
targetPointsHelper.setStartPoint(endPoint.point, false, endPoint.getPointDescription(mapActivity)); targetPointsHelper.setStartPoint(endPoint.point, false, endPoint.getPointDescription(mapActivity));
targetPointsHelper.updateRouteAndRefresh(true); targetPointsHelper.updateRouteAndRefresh(true);
} else {
app.showShortToastMessage(R.string.route_add_start_point);
} }
} }
} }
@ -1757,7 +1765,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
if (start != null) { if (start != null) {
fromText.setText(name); fromText.setText(name);
} else { } else {
fromText.setText(R.string.shared_string_my_location); if (OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
fromText.setText(R.string.shared_string_my_location);
} else {
fromText.setText(R.string.route_descr_select_start_point);
}
} }
} }
} }

View file

@ -23,7 +23,6 @@ import android.view.ViewParent;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.view.animation.DecelerateInterpolator; import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.OverScroller; import android.widget.OverScroller;
import android.widget.ProgressBar; import android.widget.ProgressBar;
@ -33,6 +32,8 @@ import net.osmand.AndroidUtils;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.data.QuadRect; import net.osmand.data.QuadRect;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
import net.osmand.osm.edit.Node;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.LockableScrollView; import net.osmand.plus.LockableScrollView;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -839,11 +840,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
textViewExProgress.color1 = ContextCompat.getColor(mapActivity, color); textViewExProgress.color1 = ContextCompat.getColor(mapActivity, color);
textViewExProgress.color2 = ContextCompat.getColor(mapActivity, R.color.description_font_and_bottom_sheet_icons); textViewExProgress.color2 = ContextCompat.getColor(mapActivity, R.color.description_font_and_bottom_sheet_icons);
textViewExProgress.invalidate(); textViewExProgress.invalidate();
ImageViewExProgress imageViewExProgress = (ImageViewExProgress) view.findViewById(R.id.start_icon);
imageViewExProgress.percent = progress / 100f;
imageViewExProgress.color1 = ContextCompat.getColor(mapActivity, color);
imageViewExProgress.color2 = ContextCompat.getColor(mapActivity, R.color.description_font_and_bottom_sheet_icons);
imageViewExProgress.invalidate();
} }
public void hideRouteCalculationProgressBar() { public void hideRouteCalculationProgressBar() {
@ -872,14 +868,16 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
textViewExProgress.color1 = ContextCompat.getColor(mapActivity, nightMode ? R.color.main_font_dark : R.color.card_and_list_background_light); textViewExProgress.color1 = ContextCompat.getColor(mapActivity, nightMode ? R.color.main_font_dark : R.color.card_and_list_background_light);
textViewExProgress.color2 = ContextCompat.getColor(mapActivity, R.color.description_font_and_bottom_sheet_icons); textViewExProgress.color2 = ContextCompat.getColor(mapActivity, R.color.description_font_and_bottom_sheet_icons);
ImageViewExProgress imageViewExProgress = (ImageViewExProgress) view.findViewById(R.id.start_icon); boolean publicTransportMode = app.getRoutingHelper().getAppMode() == ApplicationMode.PUBLIC_TRANSPORT;
imageViewExProgress.color1 = ContextCompat.getColor(mapActivity, nightMode ? R.color.main_font_dark : R.color.card_and_list_background_light);
imageViewExProgress.color2 = ContextCompat.getColor(mapActivity, R.color.description_font_and_bottom_sheet_icons);
((ImageView) view.findViewById(R.id.start_icon)).setImageResource(R.drawable.ic_action_start_navigation);
if (menu.isRouteCalculated()) { if (menu.isRouteCalculated()) {
AndroidUtils.setBackground(app, view.findViewById(R.id.start_button), nightMode, R.color.active_buttons_and_links_light, R.color.active_buttons_and_links_dark); if (publicTransportMode) {
AndroidUtils.setBackground(app, view.findViewById(R.id.start_button), nightMode, R.color.card_and_list_background_light, R.color.card_and_list_background_dark);
textViewExProgress.color1 = ContextCompat.getColor(mapActivity, nightMode ? R.color.active_buttons_and_links_dark : R.color.route_info_cancel_button_color_light);
} else {
AndroidUtils.setBackground(app, view.findViewById(R.id.start_button), nightMode, R.color.active_buttons_and_links_light, R.color.active_buttons_and_links_dark);
textViewExProgress.color1 = ContextCompat.getColor(mapActivity, nightMode ? R.color.main_font_dark : R.color.card_and_list_background_light);
}
textViewExProgress.percent = 1; textViewExProgress.percent = 1;
imageViewExProgress.percent = 1;
} }
} }
} }
@ -934,6 +932,8 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
R.color.divider_light, R.color.divider_dark); R.color.divider_light, R.color.divider_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerButtons), nightMode, AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerButtons), nightMode,
R.color.divider_light, R.color.divider_dark); R.color.divider_light, R.color.divider_dark);
AndroidUtils.setBackground(ctx, view.findViewById(R.id.controls_divider), nightMode,
R.color.divider_light, R.color.divider_dark);
AndroidUtils.setBackground(ctx, view.findViewById(R.id.app_modes_options_container), nightMode, AndroidUtils.setBackground(ctx, view.findViewById(R.id.app_modes_options_container), nightMode,
R.drawable.route_info_trans_gradient_light, R.drawable.route_info_trans_gradient_dark); R.drawable.route_info_trans_gradient_light, R.drawable.route_info_trans_gradient_dark);
AndroidUtils.setBackground(ctx, view.findViewById(R.id.app_modes_fold_container), nightMode, AndroidUtils.setBackground(ctx, view.findViewById(R.id.app_modes_fold_container), nightMode,

View file

@ -543,11 +543,6 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
textViewExProgress.color1 = ContextCompat.getColor(mapActivity, color); textViewExProgress.color1 = ContextCompat.getColor(mapActivity, color);
textViewExProgress.color2 = ContextCompat.getColor(mapActivity, R.color.description_font_and_bottom_sheet_icons); textViewExProgress.color2 = ContextCompat.getColor(mapActivity, R.color.description_font_and_bottom_sheet_icons);
textViewExProgress.invalidate(); textViewExProgress.invalidate();
ImageViewExProgress imageViewExProgress = (ImageViewExProgress) view.findViewById(R.id.start_icon);
imageViewExProgress.percent = progress / 100f;
imageViewExProgress.color1 = ContextCompat.getColor(mapActivity, color);
imageViewExProgress.color2 = ContextCompat.getColor(mapActivity, R.color.description_font_and_bottom_sheet_icons);
imageViewExProgress.invalidate();
} }
public void setupRouteCalculationButtonProgressBar(@NonNull ProgressBar pb) { public void setupRouteCalculationButtonProgressBar(@NonNull ProgressBar pb) {

View file

@ -390,15 +390,7 @@ public class MapControlsLayer extends OsmandMapLayer {
public void doRoute(boolean hasTargets) { public void doRoute(boolean hasTargets) {
this.hasTargets = hasTargets; this.hasTargets = hasTargets;
if (OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) { onNavigationClick();
onNavigationClick();
} else if (!ActivityCompat.shouldShowRequestPermissionRationale(mapActivity, Manifest.permission.ACCESS_FINE_LOCATION)) {
app.showToastMessage(R.string.ask_for_location_permission);
} else {
ActivityCompat.requestPermissions(mapActivity,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
REQUEST_LOCATION_FOR_NAVIGATION_PERMISSION);
}
} }
public void doNavigate() { public void doNavigate() {

View file

@ -2,7 +2,9 @@ package net.osmand.plus.widgets;
import android.content.Context; import android.content.Context;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.PorterDuff;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet; import android.util.AttributeSet;
public class TextViewExProgress extends TextViewEx { public class TextViewExProgress extends TextViewEx {
@ -30,6 +32,15 @@ public class TextViewExProgress extends TextViewEx {
public void draw(Canvas canvas) { public void draw(Canvas canvas) {
canvas.save(); canvas.save();
setTextColor(color1); setTextColor(color1);
Drawable[] icons = getCompoundDrawables();
for (int i = 0; i < icons.length; i++) {
Drawable drawable = icons[i];
if (drawable != null) {
drawable.setColorFilter(color1, PorterDuff.Mode.SRC_ATOP);
icons[i] = drawable;
}
}
setCompoundDrawables(icons[0], icons[1], icons[2], icons[3]);
int width = getWidth(); int width = getWidth();
int widthP = (int) (width * percent); int widthP = (int) (width * percent);
int height = getHeight(); int height = getHeight();
@ -39,6 +50,14 @@ public class TextViewExProgress extends TextViewEx {
canvas.save(); canvas.save();
setTextColor(color2); setTextColor(color2);
for (int i = 0; i < icons.length; i++) {
Drawable drawable = icons[i];
if (drawable != null) {
drawable.setColorFilter(color2, PorterDuff.Mode.SRC_ATOP);
icons[i] = drawable;
}
}
setCompoundDrawables(icons[0], icons[1], icons[2], icons[3]);
int width2 = getWidth(); int width2 = getWidth();
int widthP2 = (int) (width2 * percent); int widthP2 = (int) (width2 * percent);
int height2 = getHeight(); int height2 = getHeight();