Fix bottom sheet height and improve route info cards ui
This commit is contained in:
parent
0077c78a78
commit
818fe36d62
9 changed files with 120 additions and 39 deletions
|
@ -3,7 +3,7 @@
|
||||||
<item android:id="@android:id/mask">
|
<item android:id="@android:id/mask">
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<solid android:color="@color/active_buttons_and_links_dark" />
|
<solid android:color="@color/active_buttons_and_links_dark" />
|
||||||
<corners android:radius="18dp" />
|
<corners android:radius="@dimen/route_info_button_bg_line_radius" />
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
</ripple>
|
</ripple>
|
|
@ -3,7 +3,7 @@
|
||||||
<item android:id="@android:id/mask">
|
<item android:id="@android:id/mask">
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<solid android:color="@color/active_buttons_and_links_light" />
|
<solid android:color="@color/active_buttons_and_links_light" />
|
||||||
<corners android:radius="18dp" />
|
<corners android:radius="@dimen/route_info_button_bg_line_radius" />
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
</ripple>
|
</ripple>
|
34
OsmAnd/res/layout/route_details_legend.xml
Normal file
34
OsmAnd/res/layout/route_details_legend.xml
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/route_details_legend"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="@dimen/route_info_legend_item_size"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingRight="@dimen/content_padding">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/legend_icon_color"
|
||||||
|
android:layout_width="@dimen/standard_icon_size"
|
||||||
|
android:layout_height="@dimen/standard_icon_size"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||||
|
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||||
|
tools:src="@drawable/ic_action_circle" />
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/legend_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:textColor="?attr/main_font_color_basic"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_regular"
|
||||||
|
tools:text="Unpaved 13.4 km" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -9,13 +9,12 @@
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:paddingTop="@dimen/content_padding">
|
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/info_type_title"
|
android:id="@+id/info_type_title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
|
@ -23,26 +22,51 @@
|
||||||
android:paddingLeft="@dimen/content_padding"
|
android:paddingLeft="@dimen/content_padding"
|
||||||
android:paddingRight="@dimen/content_padding"
|
android:paddingRight="@dimen/content_padding"
|
||||||
android:textColor="?attr/main_font_color_basic"
|
android:textColor="?attr/main_font_color_basic"
|
||||||
android:textSize="@dimen/text_button_text_size"
|
android:textSize="@dimen/default_list_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
tools:ignore="UnusedAttribute"
|
tools:ignore="UnusedAttribute"
|
||||||
tools:text="@string/route_class_stat_container" />
|
tools:text="@string/route_class_stat_container" />
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<LinearLayout
|
||||||
android:id="@+id/info_type_details"
|
android:id="@+id/info_type_details_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
android:gravity="center"
|
android:layout_marginTop="@dimen/route_info_card_details_margin"
|
||||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
android:layout_marginBottom="@dimen/route_info_card_details_margin"
|
||||||
android:maxLines="1"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:paddingLeft="@dimen/content_padding"
|
android:orientation="horizontal"
|
||||||
android:paddingRight="@dimen/content_padding"
|
android:paddingStart="@dimen/bottom_sheet_content_margin_small"
|
||||||
android:text="@string/rendering_category_details"
|
android:paddingLeft="@dimen/bottom_sheet_content_margin_small"
|
||||||
android:textSize="@dimen/text_button_text_size"
|
android:paddingEnd="@dimen/content_padding"
|
||||||
android:textColor="?attr/active_color_basic"
|
android:paddingRight="@dimen/content_padding">
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
tools:ignore="UnusedAttribute" />
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/info_type_details"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:paddingLeft="@dimen/bottom_sheet_content_margin_small"
|
||||||
|
android:paddingTop="@dimen/bottom_sheet_image_text_margin_start"
|
||||||
|
android:paddingRight="@dimen/bottom_sheet_content_margin_small"
|
||||||
|
android:paddingBottom="@dimen/bottom_sheet_image_text_margin_start"
|
||||||
|
android:text="@string/rendering_category_details"
|
||||||
|
android:textColor="?attr/active_color_basic"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:ignore="UnusedAttribute" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/up_down_icon"
|
||||||
|
android:layout_width="@dimen/standard_icon_size"
|
||||||
|
android:layout_height="@dimen/standard_icon_size"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
tools:src="@drawable/ic_action_arrow_down"
|
||||||
|
tools:tint="@color/description_font_and_bottom_sheet_icons" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
|
@ -191,9 +191,11 @@
|
||||||
<dimen name="route_info_list_text_padding">78dp</dimen>
|
<dimen name="route_info_list_text_padding">78dp</dimen>
|
||||||
<dimen name="route_info_legend_padding">12dp</dimen>
|
<dimen name="route_info_legend_padding">12dp</dimen>
|
||||||
<dimen name="route_info_warning_padding">27dp</dimen>
|
<dimen name="route_info_warning_padding">27dp</dimen>
|
||||||
<dimen name="route_info_chart_height">78dp</dimen>
|
<dimen name="route_info_chart_height">106dp</dimen>
|
||||||
<dimen name="route_info_control_buttons_height">72dp</dimen>
|
<dimen name="route_info_control_buttons_height">72dp</dimen>
|
||||||
<dimen name="route_info_button_bg_line_radius">27dp</dimen>
|
<dimen name="route_info_button_bg_line_radius">27dp</dimen>
|
||||||
|
<dimen name="route_info_card_details_margin">13dp</dimen>
|
||||||
|
<dimen name="route_info_legend_item_size">60dp</dimen>
|
||||||
|
|
||||||
<dimen name="multi_selection_header_height">78dp</dimen>
|
<dimen name="multi_selection_header_height">78dp</dimen>
|
||||||
|
|
||||||
|
|
|
@ -284,10 +284,12 @@
|
||||||
<dimen name="route_info_list_text_padding">54dp</dimen>
|
<dimen name="route_info_list_text_padding">54dp</dimen>
|
||||||
<dimen name="route_info_legend_padding">8dp</dimen>
|
<dimen name="route_info_legend_padding">8dp</dimen>
|
||||||
<dimen name="route_info_warning_padding">18dp</dimen>
|
<dimen name="route_info_warning_padding">18dp</dimen>
|
||||||
<dimen name="route_info_chart_height">52dp</dimen>
|
<dimen name="route_info_chart_height">71dp</dimen>
|
||||||
<dimen name="route_info_toolbar_button_size">40dp</dimen>
|
<dimen name="route_info_toolbar_button_size">40dp</dimen>
|
||||||
<dimen name="route_info_control_buttons_height">48dp</dimen>
|
<dimen name="route_info_control_buttons_height">48dp</dimen>
|
||||||
<dimen name="route_info_button_bg_line_radius">18dp</dimen>
|
<dimen name="route_info_button_bg_line_radius">18dp</dimen>
|
||||||
|
<dimen name="route_info_card_details_margin">9dp</dimen>
|
||||||
|
<dimen name="route_info_legend_item_size">40dp</dimen>
|
||||||
|
|
||||||
<dimen name="multi_selection_header_height">52dp</dimen>
|
<dimen name="multi_selection_header_height">52dp</dimen>
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
}
|
}
|
||||||
final int screenHeight = AndroidUtils.getScreenHeight(activity);
|
final int screenHeight = AndroidUtils.getScreenHeight(activity);
|
||||||
final int statusBarHeight = AndroidUtils.getStatusBarHeight(activity);
|
final int statusBarHeight = AndroidUtils.getStatusBarHeight(activity);
|
||||||
final int contentHeight = getContentHeight(screenHeight - statusBarHeight - AndroidUtils.getNavBarHeight(activity));
|
final int contentHeight = getContentHeight(screenHeight - statusBarHeight);
|
||||||
|
|
||||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -363,6 +363,7 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
|
||||||
private void createRouteCard(LinearLayout cardsContainer, RouteInfoCard routeInfoCard) {
|
private void createRouteCard(LinearLayout cardsContainer, RouteInfoCard routeInfoCard) {
|
||||||
OsmandApplication app = requireMyApplication();
|
OsmandApplication app = requireMyApplication();
|
||||||
menuCards.add(routeInfoCard);
|
menuCards.add(routeInfoCard);
|
||||||
|
routeInfoCard.setListener(this);
|
||||||
cardsContainer.addView(routeInfoCard.build(app));
|
cardsContainer.addView(routeInfoCard.build(app));
|
||||||
buildRowDivider(cardsContainer, false);
|
buildRowDivider(cardsContainer, false);
|
||||||
}
|
}
|
||||||
|
@ -1499,6 +1500,7 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCardLayoutNeeded(@NonNull BaseCard card) {
|
public void onCardLayoutNeeded(@NonNull BaseCard card) {
|
||||||
|
runLayoutListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
package net.osmand.plus.routepreparationmenu.cards;
|
package net.osmand.plus.routepreparationmenu.cards;
|
||||||
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v7.view.ContextThemeWrapper;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.style.StyleSpan;
|
import android.text.style.StyleSpan;
|
||||||
import android.view.Gravity;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.github.mikephil.charting.charts.HorizontalBarChart;
|
import com.github.mikephil.charting.charts.HorizontalBarChart;
|
||||||
import com.github.mikephil.charting.data.BarData;
|
import com.github.mikephil.charting.data.BarData;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -39,6 +40,8 @@ public class RouteInfoCard extends BaseCard {
|
||||||
private Statistics routeStatistics;
|
private Statistics routeStatistics;
|
||||||
private GPXUtilities.GPXTrackAnalysis analysis;
|
private GPXUtilities.GPXTrackAnalysis analysis;
|
||||||
|
|
||||||
|
private boolean showLegend;
|
||||||
|
|
||||||
public RouteInfoCard(MapActivity mapActivity, Statistics routeStatistics, GPXUtilities.GPXTrackAnalysis analysis) {
|
public RouteInfoCard(MapActivity mapActivity, Statistics routeStatistics, GPXUtilities.GPXTrackAnalysis analysis) {
|
||||||
super(mapActivity);
|
super(mapActivity);
|
||||||
this.routeStatistics = routeStatistics;
|
this.routeStatistics = routeStatistics;
|
||||||
|
@ -54,11 +57,28 @@ public class RouteInfoCard extends BaseCard {
|
||||||
protected void updateContent() {
|
protected void updateContent() {
|
||||||
updateHeader();
|
updateHeader();
|
||||||
final HorizontalBarChart chart = (HorizontalBarChart) view.findViewById(R.id.chart);
|
final HorizontalBarChart chart = (HorizontalBarChart) view.findViewById(R.id.chart);
|
||||||
GpxUiHelper.setupHorizontalGPXChart(app, chart, 5, 10, 10, true, nightMode);
|
GpxUiHelper.setupHorizontalGPXChart(app, chart, 5, 9, 24, true, nightMode);
|
||||||
BarData barData = GpxUiHelper.buildStatisticChart(app, chart, routeStatistics, analysis, true, nightMode);
|
BarData barData = GpxUiHelper.buildStatisticChart(app, chart, routeStatistics, analysis, true, nightMode);
|
||||||
chart.setData(barData);
|
chart.setData(barData);
|
||||||
LinearLayout container = view.findViewById(R.id.route_items);
|
final LinearLayout container = (LinearLayout) view.findViewById(R.id.route_items);
|
||||||
attachLegend(container, routeStatistics);
|
container.removeAllViews();
|
||||||
|
if (showLegend) {
|
||||||
|
attachLegend(container, routeStatistics);
|
||||||
|
}
|
||||||
|
final ImageView iconViewCollapse = (ImageView) view.findViewById(R.id.up_down_icon);
|
||||||
|
iconViewCollapse.setImageDrawable(getCollapseIcon(!showLegend));
|
||||||
|
view.findViewById(R.id.info_type_details_button).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
showLegend = !showLegend;
|
||||||
|
updateContent();
|
||||||
|
setLayoutNeeded();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private Drawable getCollapseIcon(boolean collapsed) {
|
||||||
|
return collapsed ? getContentIcon(R.drawable.ic_action_arrow_down) : getActiveIcon(R.drawable.ic_action_arrow_up);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateHeader() {
|
private void updateHeader() {
|
||||||
|
@ -85,24 +105,21 @@ public class RouteInfoCard extends BaseCard {
|
||||||
Map<E, RouteSegmentAttribute<E>> partition = routeStatistics.getPartition();
|
Map<E, RouteSegmentAttribute<E>> partition = routeStatistics.getPartition();
|
||||||
List<E> list = new ArrayList<E>(partition.keySet());
|
List<E> list = new ArrayList<E>(partition.keySet());
|
||||||
sortRouteSegmentAttributes(list);
|
sortRouteSegmentAttributes(list);
|
||||||
|
ContextThemeWrapper ctx = new ContextThemeWrapper(mapActivity, !nightMode ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
|
||||||
|
LayoutInflater inflater = LayoutInflater.from(ctx);
|
||||||
for (E key : list) {
|
for (E key : list) {
|
||||||
RouteSegmentAttribute<E> segment = partition.get(key);
|
RouteSegmentAttribute<E> segment = partition.get(key);
|
||||||
int color = segment.getColor();
|
View view = inflater.inflate(R.layout.route_details_legend, container, false);
|
||||||
Drawable circle = app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_circle, color);
|
Drawable circle = app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_circle, segment.getColor());
|
||||||
|
ImageView legendIcon = (ImageView) view.findViewById(R.id.legend_icon_color);
|
||||||
|
legendIcon.setImageDrawable(circle);
|
||||||
String propertyName = segment.getPropertyName();
|
String propertyName = segment.getPropertyName();
|
||||||
String name = SettingsNavigationActivity.getStringPropertyName(app, propertyName, propertyName.replaceAll("_", " "));
|
String name = SettingsNavigationActivity.getStringPropertyName(app, propertyName, propertyName.replaceAll("_", " "));
|
||||||
Spannable text = getSpanLegend(name, segment);
|
Spannable text = getSpanLegend(name, segment);
|
||||||
|
TextView legend = (TextView) view.findViewById(R.id.legend_text);
|
||||||
TextView legend = new TextView(app);
|
|
||||||
legend.setTextColor(getMainFontColor());
|
|
||||||
legend.setTextSize(15);
|
|
||||||
legend.setGravity(Gravity.CENTER_VERTICAL);
|
|
||||||
legend.setCompoundDrawablePadding(AndroidUtils.dpToPx(app, 16));
|
|
||||||
legend.setPadding(AndroidUtils.dpToPx(app, 16), AndroidUtils.dpToPx(app, 4), AndroidUtils.dpToPx(app, 16), AndroidUtils.dpToPx(app, 4));
|
|
||||||
legend.setCompoundDrawablesWithIntrinsicBounds(circle, null, null, null);
|
|
||||||
legend.setText(text);
|
legend.setText(text);
|
||||||
|
|
||||||
container.addView(legend);
|
container.addView(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue