Fix route info card colors

This commit is contained in:
crimean 2019-02-17 11:44:36 +03:00
parent 79475851c9
commit 948991ced8
10 changed files with 138 additions and 119 deletions

View file

@ -15,6 +15,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/card_content"
android:layout_width="match_parent"
android:layout_height="@dimen/route_info_card_row_min_height"
android:background="?attr/bg_color"
@ -32,6 +33,7 @@
android:orientation="horizontal">
<android.support.v7.widget.AppCompatImageView
android:id="@+id/home_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/list_content_padding"
@ -39,7 +41,7 @@
android:layout_marginEnd="@dimen/favorites_icon_right_margin"
android:layout_marginRight="@dimen/favorites_icon_right_margin"
android:src="@drawable/ic_action_home_dark"
android:tint="?attr/menu_bottom_sheet_icon_color" />
tools:tint="?attr/route_info_control_icon_color" />
<LinearLayout
android:layout_width="match_parent"
@ -56,9 +58,9 @@
android:letterSpacing="@dimen/text_button_letter_spacing"
android:maxLines="1"
android:text="@string/home_button"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:ignore="UnusedAttribute" />
tools:ignore="UnusedAttribute"
tools:textColor="?android:attr/textColorPrimary" />
<TextView
android:id="@+id/home_button_descr"
@ -68,19 +70,20 @@
android:letterSpacing="@dimen/text_button_letter_spacing"
android:maxLines="1"
android:text="@string/home_button"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
tools:ignore="UnusedAttribute"
tools:text="Amsterdam" />
tools:text="Amsterdam"
tools:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
</LinearLayout>
<View
android:id="@+id/buttons_divider"
android:layout_width="1dp"
android:layout_height="36dp"
android:background="?attr/divider_color" />
tools:background="?attr/divider_color" />
<LinearLayout
android:id="@+id/work_button"
@ -92,6 +95,7 @@
android:orientation="horizontal">
<android.support.v7.widget.AppCompatImageView
android:id="@+id/work_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/list_content_padding"
@ -99,7 +103,7 @@
android:layout_marginEnd="@dimen/favorites_icon_right_margin"
android:layout_marginRight="@dimen/favorites_icon_right_margin"
android:src="@drawable/ic_action_work"
android:tint="?attr/menu_bottom_sheet_icon_color" />
tools:tint="?attr/route_info_control_icon_color" />
<LinearLayout
android:layout_width="match_parent"
@ -116,9 +120,9 @@
android:letterSpacing="@dimen/text_button_letter_spacing"
android:maxLines="1"
android:text="@string/work_button"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:ignore="UnusedAttribute" />
tools:ignore="UnusedAttribute"
tools:textColor="?android:attr/textColorPrimary" />
<TextView
android:id="@+id/work_button_descr"
@ -128,10 +132,10 @@
android:letterSpacing="@dimen/text_button_letter_spacing"
android:maxLines="1"
android:text="@string/work_button"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
tools:ignore="UnusedAttribute"
tools:text="Business centre" />
tools:text="Business centre"
tools:textColor="?android:attr/textColorSecondary" />
</LinearLayout>

View file

@ -105,6 +105,7 @@
<attr name="text_rounded_bg_active" format="reference" />
<attr name="menu_bottom_sheet_icon_color" format="reference" />
<attr name="route_info_control_icon_color" format="reference" />
</declare-styleable>
<declare-styleable name="PagerSlidingTabStrip">

View file

@ -236,6 +236,7 @@
<item name="text_rounded_bg_regular">@drawable/text_rounded_bg_regular_light</item>
<item name="menu_bottom_sheet_icon_color">@color/on_map_icon_color</item>
<item name="route_info_control_icon_color">@color/route_info_control_icon_color_light</item>
</style>
<style name="OverflowMenuButton" parent="@style/Widget.AppCompat.ActionButton.Overflow">
@ -458,6 +459,7 @@
<item name="text_rounded_bg_regular">@drawable/text_rounded_bg_regular_dark</item>
<item name="menu_bottom_sheet_icon_color">@color/ctx_menu_info_text_dark</item>
<item name="route_info_control_icon_color">@color/route_info_control_icon_color_dark</item>
</style>
<style name="FreeVersionBanner" parent="OsmandDarkTheme">

View file

@ -32,7 +32,14 @@ public abstract class BaseCard {
public abstract int getCardLayoutId();
public abstract void update();
public void update() {
if (view != null) {
updateContent();
applyDayNightMode();
}
}
protected abstract void updateContent();
public View build(Context ctx) {
view = LayoutInflater.from(ctx).inflate(getCardLayoutId(), null);

View file

@ -14,7 +14,7 @@ public class HistoryCard extends BaseCard {
}
@Override
public void update() {
protected void updateContent() {
}

View file

@ -1,9 +1,12 @@
package net.osmand.plus.routepreparationmenu.cards;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v7.widget.AppCompatImageView;
import android.view.View;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
@ -23,37 +26,44 @@ public class HomeWorkCard extends BaseCard {
}
@Override
public void update() {
if (view != null) {
TargetPointsHelper targetPointsHelper = mapActivity.getMyApplication().getTargetPointsHelper();
TargetPoint homePoint = targetPointsHelper.getHomePoint();
TargetPoint workPoint = targetPointsHelper.getWorkPoint();
protected void updateContent() {
TargetPointsHelper targetPointsHelper = mapActivity.getMyApplication().getTargetPointsHelper();
TargetPoint homePoint = targetPointsHelper.getHomePoint();
TargetPoint workPoint = targetPointsHelper.getWorkPoint();
TextView homeDescr = (TextView) view.findViewById(R.id.home_button_descr);
TextView workDescr = (TextView) view.findViewById(R.id.work_button_descr);
homeDescr.setText(homePoint != null ? homePoint.getPointDescription(mapActivity).getName() :
mapActivity.getString(R.string.shared_string_add));
workDescr.setText(workPoint != null ? workPoint.getPointDescription(mapActivity).getName() :
mapActivity.getString(R.string.shared_string_add));
TextView homeDescr = (TextView) view.findViewById(R.id.home_button_descr);
TextView workDescr = (TextView) view.findViewById(R.id.work_button_descr);
homeDescr.setText(homePoint != null ? homePoint.getPointDescription(mapActivity).getName() :
mapActivity.getString(R.string.shared_string_add));
workDescr.setText(workPoint != null ? workPoint.getPointDescription(mapActivity).getName() :
mapActivity.getString(R.string.shared_string_add));
view.findViewById(R.id.home_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openAddPointDialog(mapActivity, true);
}
});
view.findViewById(R.id.work_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openAddPointDialog(mapActivity, false);
}
});
}
view.findViewById(R.id.home_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openAddPointDialog(mapActivity, true);
}
});
view.findViewById(R.id.work_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openAddPointDialog(mapActivity, false);
}
});
}
@Override
protected void applyDayNightMode() {
AndroidUtils.setTextPrimaryColor(app, (TextView) view.findViewById(R.id.home_button_title), nightMode);
AndroidUtils.setTextPrimaryColor(app, (TextView) view.findViewById(R.id.work_button_title), nightMode);
AndroidUtils.setTextSecondaryColor(app, (TextView) view.findViewById(R.id.home_button_descr), nightMode);
AndroidUtils.setTextSecondaryColor(app, (TextView) view.findViewById(R.id.work_button_descr), nightMode);
Drawable homeImg = app.getUIUtilities().getIcon(R.drawable.ic_action_home_dark, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
Drawable workImg = app.getUIUtilities().getIcon(R.drawable.ic_action_work, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
((AppCompatImageView) view.findViewById(R.id.home_img)).setImageDrawable(homeImg);
((AppCompatImageView) view.findViewById(R.id.work_img)).setImageDrawable(workImg);
AndroidUtils.setBackground(app, view.findViewById(R.id.card_content), nightMode, R.color.route_info_bg_light, R.color.route_info_bg_dark);
AndroidUtils.setBackgroundColor(app, view.findViewById(R.id.buttons_divider), nightMode, R.color.divider_color, R.color.dashboard_divider_dark);
}
private void openAddPointDialog(MapActivity mapActivity, boolean home) {

View file

@ -14,7 +14,7 @@ public class PreviousRouteCard extends BaseCard {
}
@Override
public void update() {
protected void updateContent() {
}

View file

@ -52,31 +52,27 @@ public class PublicTransportCard extends BaseCard {
}
@Override
public void update() {
if (view != null) {
view.setBackgroundColor(ContextCompat.getColor(app, nightMode ? R.color.route_info_bg_dark : R.color.route_info_bg_light));
protected void updateContent() {
view.setBackgroundColor(ContextCompat.getColor(app, nightMode ? R.color.route_info_bg_dark : R.color.route_info_bg_light));
List<TransportRouteResultSegment> segments = routeResult.getSegments();
createRouteBadges(segments);
List<TransportRouteResultSegment> segments = routeResult.getSegments();
createRouteBadges(segments);
TextView fromLine = (TextView) view.findViewById(R.id.from_line);
TextView wayLine = (TextView) view.findViewById(R.id.way_line);
TextView fromLine = (TextView) view.findViewById(R.id.from_line);
TextView wayLine = (TextView) view.findViewById(R.id.way_line);
fromLine.setText(getFirstLineDescrSpan());
wayLine.setText(getSecondLineDescrSpan());
fromLine.setText(getFirstLineDescrSpan());
wayLine.setText(getSecondLineDescrSpan());
view.findViewById(R.id.details_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
app.getTransportRoutingHelper().setCurrentRoute(routeId);
getMapActivity().refreshMap();
}
});
view.findViewById(R.id.bottom_shadow).setVisibility(showBottomShadow ? View.VISIBLE : View.GONE);
view.findViewById(R.id.card_divider).setVisibility(showTopShadow ? View.VISIBLE : View.GONE);
applyDayNightMode();
}
view.findViewById(R.id.details_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
app.getTransportRoutingHelper().setCurrentRoute(routeId);
getMapActivity().refreshMap();
}
});
view.findViewById(R.id.bottom_shadow).setVisibility(showBottomShadow ? View.VISIBLE : View.GONE);
view.findViewById(R.id.card_divider).setVisibility(showTopShadow ? View.VISIBLE : View.GONE);
}
public int getRouteId() {
@ -87,6 +83,7 @@ public class PublicTransportCard extends BaseCard {
this.secondButtonVisible = secondButtonVisible;
}
@Override
protected void applyDayNightMode() {
TextView fromLine = (TextView) view.findViewById(R.id.from_line);
TextView wayLine = (TextView) view.findViewById(R.id.way_line);

View file

@ -44,71 +44,69 @@ public class SimpleRouteCard extends BaseCard {
}
@Override
public void update() {
if (view != null) {
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
protected void updateContent() {
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
view.setBackgroundColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.route_info_bg_dark : R.color.route_info_bg_light));
view.setBackgroundColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.route_info_bg_dark : R.color.route_info_bg_light));
view.findViewById(R.id.dividerToDropDown).setVisibility(View.VISIBLE);
view.findViewById(R.id.route_info_details_card).setVisibility(View.VISIBLE);
view.findViewById(R.id.dividerToDropDown).setVisibility(View.VISIBLE);
view.findViewById(R.id.route_info_details_card).setVisibility(View.VISIBLE);
View info = view.findViewById(R.id.info_container);
info.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ShowRouteInfoDialogFragment.showDialog(mapActivity.getSupportFragmentManager());
}
});
ImageView infoIcon = (ImageView) view.findViewById(R.id.InfoIcon);
ImageView durationIcon = (ImageView) view.findViewById(R.id.DurationIcon);
View infoDistanceView = view.findViewById(R.id.InfoDistance);
View infoDurationView = view.findViewById(R.id.InfoDuration);
if (directionInfo >= 0) {
infoIcon.setVisibility(View.GONE);
durationIcon.setVisibility(View.GONE);
infoDistanceView.setVisibility(View.GONE);
infoDurationView.setVisibility(View.GONE);
} else {
infoIcon.setImageDrawable(getColoredIcon(R.drawable.ic_action_route_distance, R.color.route_info_unchecked_mode_icon_color));
infoIcon.setVisibility(View.VISIBLE);
durationIcon.setImageDrawable(getColoredIcon(R.drawable.ic_action_time_span, R.color.route_info_unchecked_mode_icon_color));
durationIcon.setVisibility(View.VISIBLE);
infoDistanceView.setVisibility(View.VISIBLE);
infoDurationView.setVisibility(View.VISIBLE);
View info = view.findViewById(R.id.info_container);
info.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ShowRouteInfoDialogFragment.showDialog(mapActivity.getSupportFragmentManager());
}
if (directionInfo >= 0 && routingHelper.getRouteDirections() != null
&& directionInfo < routingHelper.getRouteDirections().size()) {
RouteDirectionInfo ri = routingHelper.getRouteDirections().get(directionInfo);
} else {
TextView distanceText = (TextView) view.findViewById(R.id.DistanceText);
TextView distanceTitle = (TextView) view.findViewById(R.id.DistanceTitle);
TextView durationText = (TextView) view.findViewById(R.id.DurationText);
TextView durationTitle = (TextView) view.findViewById(R.id.DurationTitle);
});
distanceText.setText(OsmAndFormatter.getFormattedDistance(app.getRoutingHelper().getLeftDistance(), app));
durationText.setText(OsmAndFormatter.getFormattedDuration(app.getRoutingHelper().getLeftTime(), app));
durationTitle.setText(app.getString(R.string.arrive_at_time, OsmAndFormatter.getFormattedTime(app.getRoutingHelper().getLeftTime(), true)));
AndroidUtils.setTextPrimaryColor(app, distanceText, nightMode);
AndroidUtils.setTextSecondaryColor(app, distanceTitle, nightMode);
AndroidUtils.setTextPrimaryColor(app, durationText, nightMode);
AndroidUtils.setTextSecondaryColor(app, durationTitle, nightMode);
}
view.findViewById(R.id.details_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ShowRouteInfoDialogFragment.showDialog(mapActivity.getSupportFragmentManager());
}
});
buildHeader(view);
applyDayNightMode();
ImageView infoIcon = (ImageView) view.findViewById(R.id.InfoIcon);
ImageView durationIcon = (ImageView) view.findViewById(R.id.DurationIcon);
View infoDistanceView = view.findViewById(R.id.InfoDistance);
View infoDurationView = view.findViewById(R.id.InfoDuration);
if (directionInfo >= 0) {
infoIcon.setVisibility(View.GONE);
durationIcon.setVisibility(View.GONE);
infoDistanceView.setVisibility(View.GONE);
infoDurationView.setVisibility(View.GONE);
} else {
infoIcon.setImageDrawable(getColoredIcon(R.drawable.ic_action_route_distance, R.color.route_info_unchecked_mode_icon_color));
infoIcon.setVisibility(View.VISIBLE);
durationIcon.setImageDrawable(getColoredIcon(R.drawable.ic_action_time_span, R.color.route_info_unchecked_mode_icon_color));
durationIcon.setVisibility(View.VISIBLE);
infoDistanceView.setVisibility(View.VISIBLE);
infoDurationView.setVisibility(View.VISIBLE);
}
if (directionInfo >= 0 && routingHelper.getRouteDirections() != null
&& directionInfo < routingHelper.getRouteDirections().size()) {
RouteDirectionInfo ri = routingHelper.getRouteDirections().get(directionInfo);
} else {
TextView distanceText = (TextView) view.findViewById(R.id.DistanceText);
TextView distanceTitle = (TextView) view.findViewById(R.id.DistanceTitle);
TextView durationText = (TextView) view.findViewById(R.id.DurationText);
TextView durationTitle = (TextView) view.findViewById(R.id.DurationTitle);
distanceText.setText(OsmAndFormatter.getFormattedDistance(app.getRoutingHelper().getLeftDistance(), app));
durationText.setText(OsmAndFormatter.getFormattedDuration(app.getRoutingHelper().getLeftTime(), app));
durationTitle.setText(app.getString(R.string.arrive_at_time, OsmAndFormatter.getFormattedTime(app.getRoutingHelper().getLeftTime(), true)));
AndroidUtils.setTextPrimaryColor(app, distanceText, nightMode);
AndroidUtils.setTextSecondaryColor(app, distanceTitle, nightMode);
AndroidUtils.setTextPrimaryColor(app, durationText, nightMode);
AndroidUtils.setTextSecondaryColor(app, durationTitle, nightMode);
}
view.findViewById(R.id.details_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ShowRouteInfoDialogFragment.showDialog(mapActivity.getSupportFragmentManager());
}
});
buildHeader(view);
}
@Override
protected void applyDayNightMode() {
FrameLayout detailsButton = view.findViewById(R.id.details_button);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {

View file

@ -12,9 +12,9 @@ public class TracksCard extends BaseCard {
public int getCardLayoutId() {
return 0;
}
@Override
public void update() {
protected void updateContent() {
}