Change background in route preparation

This commit is contained in:
PavelRatushnyi 2017-12-22 11:45:19 +02:00
parent de015fde3e
commit d8f0a7e8e1
10 changed files with 60 additions and 122 deletions

View file

@ -49,7 +49,7 @@
android:id="@+id/waypoints"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:background="?attr/dashboard_button"
android:background="?attr/selectableItemBackground"
android:scaleType="center"
android:src="@drawable/map_action_waypoints"/>
</LinearLayout>
@ -74,16 +74,19 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<LinearLayout
android:background="?attr/selectableItemBackground"
android:id="@+id/FromLayout"
android:layout_width="fill_parent"
android:layout_height="@dimen/list_item_height"
@ -130,39 +133,19 @@
android:layout_marginRight="@dimen/list_header_text_left_margin"
android:src="@drawable/ic_action_arrow_drop_down"/>
<View
android:id="@+id/from_layout_empty_view"
android:layout_width="@dimen/route_info_directions_margin"
android:layout_height="match_parent"/>
</LinearLayout>
<FrameLayout
<View
android:layout_marginStart="@dimen/route_info_divider_margin"
android:layout_marginLeft="@dimen/route_info_divider_margin"
android:id="@+id/dividerFromDropDown"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_marginStart="@dimen/route_info_divider_margin"
android:layout_marginLeft="@dimen/route_info_divider_margin"
android:layout_marginRight="@dimen/route_info_directions_margin"
android:layout_marginEnd="@dimen/route_info_directions_margin"
android:id="@+id/dividerFromDropDown"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dashboard_divider_dark"
android:focusable="false"/>
<View
android:id="@+id/divider_from_drop_down_empty"
android:layout_gravity="end"
android:layout_width="@dimen/route_info_directions_margin"
android:layout_height="1dp"
android:focusable="false"
android:background="@color/dashboard_divider_dark"/>
</FrameLayout>
android:layout_height="1dp"
android:background="@color/dashboard_divider_dark"
android:focusable="false"/>
<LinearLayout
android:background="?attr/selectableItemBackground"
android:id="@+id/ViaLayout"
android:layout_width="match_parent"
android:layout_height="@dimen/list_item_height"
@ -216,6 +199,7 @@
android:focusable="false"/>
<LinearLayout
android:background="?attr/selectableItemBackground"
android:id="@+id/ToLayout"
android:layout_width="fill_parent"
android:layout_height="@dimen/list_item_height"
@ -262,18 +246,13 @@
android:layout_marginRight="@dimen/list_header_text_left_margin"
android:src="@drawable/ic_action_arrow_drop_down"/>
<View
android:id="@+id/to_layout_empty_view"
android:layout_width="@dimen/route_info_directions_margin"
android:layout_height="match_parent"/>
</LinearLayout>
</LinearLayout>
<ImageView
android:background="?attr/selectableItemBackground"
android:id="@+id/swap_direction_image_view"
android:visibility="gone"
android:paddingRight="@dimen/route_info_icon_padding_right"
android:paddingLeft="@dimen/route_info_icon_padding_right"
android:layout_gravity="end"
@ -281,7 +260,7 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
</FrameLayout>
</LinearLayout>
<View
android:id="@+id/dividerToDropDown"
@ -300,7 +279,7 @@
android:id="@+id/Info"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="?attr/dashboard_button"
android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/list_item_height"
android:orientation="horizontal">
@ -308,7 +287,7 @@
android:id="@+id/Prev"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:background="?attr/dashboard_button"
android:background="?attr/selectableItemBackground"
android:contentDescription="@string/shared_string_previous"
android:scaleType="center"
android:src="@drawable/ic_prev"/>
@ -407,7 +386,7 @@
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:layout_marginLeft="5dp"
android:background="?attr/dashboard_button"
android:background="?attr/selectableItemBackground"
android:contentDescription="@string/shared_string_next"
android:scaleType="center"
android:src="@drawable/ic_next"/>

View file

@ -18,7 +18,7 @@
android:paddingLeft="@dimen/route_info_buttons_padding_left_right"
android:paddingRight="@dimen/route_info_buttons_padding_left_right"
android:layout_gravity="center_vertical"
android:background="?attr/dashboard_button"
android:background="?attr/selectableItemBackground"
android:src="@drawable/ic_action_test_light" />
<View
@ -40,7 +40,7 @@
android:paddingLeft="@dimen/route_info_buttons_padding_left_right"
android:paddingRight="@dimen/route_info_buttons_padding_left_right"
android:layout_gravity="center_vertical"
android:background="?attr/dashboard_button"
android:background="?attr/selectableItemBackground"
android:src="@drawable/ic_action_test_light" />
<View
@ -62,7 +62,7 @@
android:paddingLeft="@dimen/route_info_buttons_padding_left_right"
android:paddingRight="@dimen/route_info_buttons_padding_left_right"
android:layout_gravity="center_vertical"
android:background="?attr/dashboard_button"
android:background="?attr/selectableItemBackground"
android:src="@drawable/ic_action_test_light" />
<TextView

View file

@ -49,7 +49,7 @@
android:id="@+id/waypoints"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:background="?attr/dashboard_button"
android:background="?attr/selectableItemBackground"
android:scaleType="center"
android:src="@drawable/map_action_waypoints"/>
</LinearLayout>
@ -73,16 +73,19 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<LinearLayout
android:background="?attr/selectableItemBackground"
android:id="@+id/FromLayout"
android:layout_width="fill_parent"
android:layout_height="@dimen/list_item_height"
@ -131,39 +134,19 @@
android:layout_marginRight="@dimen/list_header_text_left_margin"
android:src="@drawable/ic_action_arrow_drop_down"/>
<View
android:id="@+id/from_layout_empty_view"
android:layout_width="@dimen/route_info_directions_margin"
android:layout_height="match_parent"/>
</LinearLayout>
<FrameLayout
<View
android:layout_marginStart="@dimen/route_info_divider_margin"
android:layout_marginLeft="@dimen/route_info_divider_margin"
android:id="@+id/dividerFromDropDown"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_marginStart="@dimen/route_info_divider_margin"
android:layout_marginLeft="@dimen/route_info_divider_margin"
android:layout_marginRight="@dimen/route_info_directions_margin"
android:layout_marginEnd="@dimen/route_info_directions_margin"
android:id="@+id/dividerFromDropDown"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dashboard_divider_dark"
android:focusable="false"/>
<View
android:id="@+id/divider_from_drop_down_empty"
android:layout_gravity="end"
android:layout_width="@dimen/route_info_directions_margin"
android:layout_height="1dp"
android:focusable="false"
android:background="@color/dashboard_divider_dark"/>
</FrameLayout>
android:layout_height="1dp"
android:background="@color/dashboard_divider_dark"
android:focusable="false"/>
<LinearLayout
android:background="?attr/selectableItemBackground"
android:id="@+id/ViaLayout"
android:layout_width="match_parent"
android:layout_height="@dimen/list_item_height"
@ -219,6 +202,7 @@
android:focusable="false"/>
<LinearLayout
android:background="?attr/selectableItemBackground"
android:id="@+id/ToLayout"
android:layout_width="fill_parent"
android:layout_height="@dimen/list_item_height"
@ -267,16 +251,12 @@
android:layout_marginRight="@dimen/list_header_text_left_margin"
android:src="@drawable/ic_action_arrow_drop_down"/>
<View
android:id="@+id/to_layout_empty_view"
android:layout_width="@dimen/route_info_directions_margin"
android:layout_height="match_parent"/>
</LinearLayout>
</LinearLayout>
<ImageView
android:background="?attr/selectableItemBackground"
android:id="@+id/swap_direction_image_view"
android:paddingRight="@dimen/route_info_icon_padding_right"
android:paddingLeft="@dimen/route_info_icon_padding_right"
@ -285,7 +265,7 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
</FrameLayout>
</LinearLayout>
<View
android:id="@+id/dividerToDropDown"
@ -304,7 +284,7 @@
android:id="@+id/Info"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="?attr/dashboard_button"
android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/list_item_height"
android:orientation="horizontal">
@ -312,7 +292,7 @@
android:id="@+id/Prev"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:background="?attr/dashboard_button"
android:background="?attr/selectableItemBackground"
android:contentDescription="@string/shared_string_previous"
android:scaleType="center"
android:src="@drawable/ic_prev"/>
@ -411,7 +391,7 @@
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:layout_marginLeft="5dp"
android:background="?attr/dashboard_button"
android:background="?attr/selectableItemBackground"
android:contentDescription="@string/shared_string_next"
android:scaleType="center"
android:src="@drawable/ic_next"/>

View file

@ -177,6 +177,12 @@ public class AndroidUtils {
);
}
public static int resolveAttribute(Context ctx, int attribute) {
TypedValue outValue = new TypedValue();
ctx.getTheme().resolveAttribute(attribute, outValue, true);
return outValue.resourceId;
}
public static int getStatusBarHeight(Context ctx) {
int result = 0;
int resourceId = ctx.getResources().getIdentifier("status_bar_height", "dimen", "android");

View file

@ -88,7 +88,7 @@ public class AppModeDialog {
} else {
if (useMapTheme) {
iv.setImageDrawable(ctx.getIconsCache().getIcon(mode.getSmallIconDark(), R.color.route_info_unchecked_mode_icon_color));
AndroidUtils.setBackground(ctx, iv, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
iv.setBackgroundResource(AndroidUtils.resolveAttribute(ctx, android.R.attr.selectableItemBackground));
} else {
iv.setImageDrawable(ctx.getIconsCache().getThemedIcon(mode.getSmallIconDark()));
}

View file

@ -19,7 +19,6 @@ import android.text.TextUtils;
import android.text.util.Linkify;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
@ -29,6 +28,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.Amenity;
import net.osmand.data.FavouritePoint;
@ -466,7 +466,7 @@ public class MenuBuilder {
ll.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ll.setLayoutParams(llParams);
ll.setBackgroundResource(resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
ll.setBackgroundResource(AndroidUtils.resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
ll.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
@ -613,7 +613,7 @@ public class MenuBuilder {
ll.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ll.setLayoutParams(llParams);
ll.setBackgroundResource(resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
ll.setBackgroundResource(AndroidUtils.resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
// Empty
LinearLayout llIcon = new LinearLayout(view.getContext());
@ -634,7 +634,7 @@ public class MenuBuilder {
buttonView.setPadding(dpToPx(10f), 0, dpToPx(10f), 0);
buttonView.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
//buttonView.setTextSize(view.getResources().getDimension(resolveAttribute(view.getContext(), R.dimen.default_desc_text_size)));
buttonView.setTextColor(view.getResources().getColor(resolveAttribute(view.getContext(), R.attr.contextMenuButtonColor)));
buttonView.setTextColor(view.getResources().getColor(AndroidUtils.resolveAttribute(view.getContext(), R.attr.contextMenuButtonColor)));
buttonView.setText(text);
if (buttonIcon != null) {
@ -702,12 +702,6 @@ public class MenuBuilder {
}
}
public int resolveAttribute(Context ctx, int attribute) {
TypedValue outValue = new TypedValue();
ctx.getTheme().resolveAttribute(attribute, outValue, true);
return outValue.resourceId;
}
public int dpToPx(float dp) {
Resources r = app.getResources();
return (int) TypedValue.applyDimension(
@ -723,7 +717,7 @@ public class MenuBuilder {
LinearLayout.LayoutParams llBaseViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
baseView.setLayoutParams(llBaseViewParams);
baseView.setPadding(dpToPx(16), 0, dpToPx(16), dpToPx(12));
baseView.setBackgroundResource(resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
baseView.setBackgroundResource(AndroidUtils.resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
TextViewEx transportRect = new TextViewEx(view.getContext());
LinearLayout.LayoutParams trParams = new LinearLayout.LayoutParams(dpToPx(32), dpToPx(18));

View file

@ -19,6 +19,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.data.Amenity;
import net.osmand.data.PointDescription;
import net.osmand.osm.AbstractPoiType;
@ -92,7 +93,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
ll.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ll.setLayoutParams(llParams);
ll.setBackgroundResource(resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
ll.setBackgroundResource(AndroidUtils.resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
ll.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {

View file

@ -259,24 +259,16 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
private void updateViaView(final View parentView) {
String via = generateViaDescription();
View viaLayout = parentView.findViewById(R.id.ViaLayout);
View fromLayoutEmptyView = parentView.findViewById(R.id.from_layout_empty_view);
View toLayoutEmptyView = parentView.findViewById(R.id.to_layout_empty_view);
View dividerFromDropDownEmpty = parentView.findViewById(R.id.divider_from_drop_down_empty);
View viaLayoutDivider = parentView.findViewById(R.id.viaLayoutDivider);
ImageView swapDirectionView = (ImageView) parentView.findViewById(R.id.swap_direction_image_view);
if (via.length() == 0) {
viaLayout.setVisibility(View.GONE);
parentView.findViewById(R.id.viaLayoutDivider).setVisibility(View.GONE);
dividerFromDropDownEmpty.setVisibility(View.GONE);
fromLayoutEmptyView.setVisibility(View.VISIBLE);
toLayoutEmptyView.setVisibility(View.VISIBLE);
viaLayoutDivider.setVisibility(View.GONE);
swapDirectionView.setVisibility(View.VISIBLE);
} else {
fromLayoutEmptyView.setVisibility(View.GONE);
toLayoutEmptyView.setVisibility(View.GONE);
swapDirectionView.setVisibility(View.GONE);
dividerFromDropDownEmpty.setVisibility(View.VISIBLE);
viaLayout.setVisibility(View.VISIBLE);
parentView.findViewById(R.id.viaLayoutDivider).setVisibility(View.VISIBLE);
viaLayoutDivider.setVisibility(View.VISIBLE);
((TextView) parentView.findViewById(R.id.ViaView)).setText(via);
}
@ -294,7 +286,6 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
swapDirectionView.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_change_navigation_points,
isLight() ? R.color.route_info_control_icon_color_light : R.color.route_info_control_icon_color_dark));
AndroidUtils.setBackground(mapActivity, swapDirectionView, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
swapDirectionView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

View file

@ -150,8 +150,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
R.color.route_info_divider_light, R.color.route_info_divider_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerFromDropDown), nightMode,
R.color.route_info_divider_light, R.color.route_info_divider_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.divider_from_drop_down_empty), nightMode,
R.color.route_info_divider_light, R.color.route_info_divider_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.viaLayoutDivider), nightMode,
R.color.route_info_divider_light, R.color.route_info_divider_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerToDropDown), nightMode,
@ -170,14 +168,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.fromTitle), nightMode);
AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.InfoTextView), nightMode);
AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.FromLayout), nightMode);
AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.ViaLayout), nightMode);
AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.ToLayout), nightMode);
AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.Info), nightMode);
AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.Next), nightMode);
AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.Prev), nightMode);
AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.DistanceText), nightMode);
AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.DistanceTitle), nightMode);
AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.DurationText), nightMode);

View file

@ -295,7 +295,6 @@ public class MapControlsLayer extends OsmandMapLayer {
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
ImageView cancelRouteButton = (ImageView) main.findViewById(R.id.map_cancel_route_button);
cancelRouteButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.map_action_cancel, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light));
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) {
@ -305,7 +304,6 @@ public class MapControlsLayer extends OsmandMapLayer {
ImageView waypointsButton = (ImageView) main.findViewById(R.id.map_waypoints_route_button);
waypointsButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.map_action_flag_dark, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light));
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) {
@ -316,7 +314,6 @@ 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().getIcon(R.drawable.map_action_settings, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light));
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) {