diff --git a/OsmAnd/res/layout-land/plan_route_info.xml b/OsmAnd/res/layout-land/plan_route_info.xml index 3ef7ec87a4..ed694f5509 100644 --- a/OsmAnd/res/layout-land/plan_route_info.xml +++ b/OsmAnd/res/layout-land/plan_route_info.xml @@ -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"/> @@ -74,16 +74,19 @@ android:layout_height="wrap_content" android:orientation="vertical"> - - - - - - - - - - + android:layout_height="1dp" + android:background="@color/dashboard_divider_dark" + android:focusable="false"/> - - - + @@ -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"/> diff --git a/OsmAnd/res/layout/map_route_prepare_bottom.xml b/OsmAnd/res/layout/map_route_prepare_bottom.xml index c0d81bab9c..83008eb151 100644 --- a/OsmAnd/res/layout/map_route_prepare_bottom.xml +++ b/OsmAnd/res/layout/map_route_prepare_bottom.xml @@ -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" /> @@ -73,16 +73,19 @@ android:layout_height="wrap_content" android:orientation="vertical"> - - - - - - - - - - + android:layout_height="1dp" + android:background="@color/dashboard_divider_dark" + android:focusable="false"/> - - - + @@ -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"/> diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java index 04b6e89195..930de97418 100644 --- a/OsmAnd/src/net/osmand/AndroidUtils.java +++ b/OsmAnd/src/net/osmand/AndroidUtils.java @@ -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"); diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java b/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java index 16b39e0e23..d062b09db2 100644 --- a/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java +++ b/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java @@ -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())); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 77a296f88c..c213597ffd 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -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)); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index 8e42c71832..cf0c6129a6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -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) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java index aebd43dbaa..49c164ea01 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java @@ -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) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java index f55010cfad..b4e151b190 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java @@ -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); diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index f3d7b33ee7..580305735c 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -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) {