Fix control buttons
This commit is contained in:
parent
430f961ec2
commit
9ad5efc9c7
7 changed files with 52 additions and 32 deletions
|
@ -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>
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -664,7 +664,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);
|
||||||
|
|
|
@ -777,18 +777,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);
|
||||||
|
|
|
@ -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,7 @@ import net.osmand.AndroidUtils;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.osm.edit.Node;
|
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;
|
||||||
|
@ -335,6 +335,7 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
|
||||||
}
|
}
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
|
updateInfo();
|
||||||
mapActivity.getMapLayers().getMapControlsLayer().showMapControlsIfHidden();
|
mapActivity.getMapLayers().getMapControlsLayer().showMapControlsIfHidden();
|
||||||
wasDrawerDisabled = mapActivity.isDrawerDisabled();
|
wasDrawerDisabled = mapActivity.isDrawerDisabled();
|
||||||
if (!wasDrawerDisabled) {
|
if (!wasDrawerDisabled) {
|
||||||
|
@ -841,11 +842,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() {
|
||||||
|
@ -874,14 +870,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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -936,6 +934,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,
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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();
|
||||||
|
|
Loading…
Reference in a new issue