Show current card header on main header

This commit is contained in:
nazar-kutz 2021-04-05 20:19:16 +03:00
parent 4aa7874750
commit 9fdfa1270b
7 changed files with 148 additions and 125 deletions

View file

@ -0,0 +1,44 @@
<?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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:gravity="center_vertical"
android:orientation="horizontal">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Title" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/descr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Description" />
</LinearLayout>
</LinearLayout>

View file

@ -19,9 +19,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/bg_color" android:background="?attr/bg_color"
android:minHeight="@dimen/bottom_sheet_title_height" android:minHeight="@dimen/bottom_sheet_title_height"
android:orientation="vertical" android:orientation="vertical">
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<View <View
android:layout_width="@dimen/content_padding" android:layout_width="@dimen/content_padding"
@ -31,23 +29,8 @@
android:layout_marginBottom="@dimen/list_item_button_padding" android:layout_marginBottom="@dimen/list_item_button_padding"
android:background="?attr/bg_dash_line" /> android:background="?attr/bg_dash_line" />
<LinearLayout <include android:id="@+id/header_container"
android:layout_width="match_parent" layout="@layout/bottom_sheet_item_with_two_text" />
android:layout_height="wrap_content">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/header_title"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:gravity="center_vertical"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium" />
</LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -9,43 +9,8 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal"
android:paddingTop="@dimen/content_padding_small">
<net.osmand.plus.widgets.TextViewEx
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="@dimen/content_padding_small"
android:text="@string/shared_string_color"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/color_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="@dimen/content_padding_small"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Orange" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view" android:id="@+id/recycler_view"

View file

@ -13,48 +13,13 @@
android:background="?attr/divider_color_basic" android:background="?attr/divider_color_basic"
android:focusable="false" /> android:focusable="false" />
<include layout="@layout/bottom_sheet_item_with_two_text" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<net.osmand.plus.widgets.TextViewEx
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="@dimen/content_padding_small"
android:text="@string/select_track_width"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/width_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="@dimen/content_padding_small"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="21" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="@dimen/context_menu_padding_margin_tiny">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view" android:id="@+id/recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -27,6 +27,9 @@ import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener; import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
import net.osmand.plus.routing.RouteLineDrawInfo; import net.osmand.plus.routing.RouteLineDrawInfo;
import net.osmand.plus.settings.backend.ListStringPreference; import net.osmand.plus.settings.backend.ListStringPreference;
import net.osmand.plus.settings.fragments.RouteLineAppearanceFragment;
import net.osmand.plus.settings.fragments.RouteLineAppearanceFragment.HeaderInfo;
import net.osmand.plus.settings.fragments.RouteLineAppearanceFragment.HeaderUiAdapter;
import net.osmand.plus.track.AppearanceViewHolder; import net.osmand.plus.track.AppearanceViewHolder;
import net.osmand.plus.track.ColorsCard; import net.osmand.plus.track.ColorsCard;
import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener; import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener;
@ -39,17 +42,17 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
public class RouteLineColorCard extends BaseCard implements CardListener, ColorPickerListener { public class RouteLineColorCard extends BaseCard implements CardListener, ColorPickerListener, HeaderInfo {
private static final int DAY_TITLE_ID = R.string.day; private static final int DAY_TITLE_ID = R.string.day;
private static final int NIGHT_TITLE_ID = R.string.night; private static final int NIGHT_TITLE_ID = R.string.night;
private final Fragment targetFragment; private final Fragment targetFragment;
private HeaderUiAdapter headerUiAdapter;
private ColorsCard colorsCard; private ColorsCard colorsCard;
private ColorTypeAdapter colorAdapter; private ColorTypeAdapter colorAdapter;
private RecyclerView groupRecyclerView; private RecyclerView groupRecyclerView;
private TextView tvColorName;
private TextView tvDescription; private TextView tvDescription;
private View themeToggleContainer; private View themeToggleContainer;
private ViewGroup cardsContainer; private ViewGroup cardsContainer;
@ -76,12 +79,14 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP
@NonNull Fragment targetFragment, @NonNull Fragment targetFragment,
@NonNull RouteLineDrawInfo routeLineDrawInfo, @NonNull RouteLineDrawInfo routeLineDrawInfo,
@NonNull DayNightMode initMapTheme, @NonNull DayNightMode initMapTheme,
@NonNull DayNightMode selectedMapTheme) { @NonNull DayNightMode selectedMapTheme,
@NonNull HeaderUiAdapter headerUiAdapter) {
super(mapActivity); super(mapActivity);
this.targetFragment = targetFragment; this.targetFragment = targetFragment;
this.routeLineDrawInfo = routeLineDrawInfo; this.routeLineDrawInfo = routeLineDrawInfo;
this.initMapTheme = initMapTheme; this.initMapTheme = initMapTheme;
this.selectedMapTheme = selectedMapTheme; this.selectedMapTheme = selectedMapTheme;
this.headerUiAdapter = headerUiAdapter;
} }
@Override @Override
@ -91,7 +96,6 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP
@Override @Override
protected void updateContent() { protected void updateContent() {
tvColorName = view.findViewById(R.id.color_name);
tvDescription = view.findViewById(R.id.description); tvDescription = view.findViewById(R.id.description);
colorAdapter = new ColorTypeAdapter(); colorAdapter = new ColorTypeAdapter();
@ -155,8 +159,8 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP
} }
private void changeMapTheme(DayNightMode mapTheme) { private void changeMapTheme(DayNightMode mapTheme) {
if (targetFragment instanceof OnMapThemeUpdateListener) { if (targetFragment instanceof RouteLineAppearanceFragment) {
((OnMapThemeUpdateListener) targetFragment).onMapThemeUpdated(mapTheme); ((RouteLineAppearanceFragment) targetFragment).onMapThemeUpdated(mapTheme);
} }
if (selectedMode == ColorMode.CUSTOM) { if (selectedMode == ColorMode.CUSTOM) {
Integer color = getRouteLineColor(); Integer color = getRouteLineColor();
@ -215,19 +219,27 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP
} }
private void updateColorItems() { private void updateColorItems() {
if (targetFragment instanceof OnSelectedColorChangeListener) { if (targetFragment instanceof RouteLineAppearanceFragment) {
((OnSelectedColorChangeListener) targetFragment).onSelectedColorChanged(); ((RouteLineAppearanceFragment) targetFragment).onSelectedColorChanged();
} }
updateColorName(); updateColorName();
} }
@Override
public void onNeedHeaderUpdate() {
updateColorName();
}
private void updateColorName() { private void updateColorName() {
String title = app.getString(R.string.shared_string_color);
String colorName = "";
if (selectedMode == ColorMode.DEFAULT) { if (selectedMode == ColorMode.DEFAULT) {
tvColorName.setText(app.getString(R.string.map_widget_renderer)); colorName = app.getString(R.string.map_widget_renderer);
} else if (getRouteLineColor() != null) { } else if (getRouteLineColor() != null) {
int colorNameId = ColorDialogs.getColorName(getRouteLineColor()); int colorNameId = ColorDialogs.getColorName(getRouteLineColor());
tvColorName.setText(app.getString(colorNameId)); colorName = app.getString(colorNameId);
} }
headerUiAdapter.onHeaderUpdate(this, title, colorName);
} }
private void updateDescription() { private void updateDescription() {
@ -348,11 +360,4 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP
} }
} }
public interface OnSelectedColorChangeListener {
void onSelectedColorChanged();
}
public interface OnMapThemeUpdateListener {
void onMapThemeUpdated(@NonNull DayNightMode mapTheme);
}
} }

View file

@ -26,6 +26,8 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.routing.RouteLineDrawInfo; import net.osmand.plus.routing.RouteLineDrawInfo;
import net.osmand.plus.settings.fragments.RouteLineAppearanceFragment.HeaderInfo;
import net.osmand.plus.settings.fragments.RouteLineAppearanceFragment.HeaderUiAdapter;
import net.osmand.plus.track.AppearanceViewHolder; import net.osmand.plus.track.AppearanceViewHolder;
import net.osmand.plus.track.TrackAppearanceFragment.OnNeedScrollListener; import net.osmand.plus.track.TrackAppearanceFragment.OnNeedScrollListener;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -33,20 +35,21 @@ import net.osmand.util.Algorithms;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
public class RouteLineWidthCard extends BaseCard { public class RouteLineWidthCard extends BaseCard implements HeaderInfo {
private final static int CUSTOM_WIDTH_MIN = 1; private final static int CUSTOM_WIDTH_MIN = 1;
private final static int CUSTOM_WIDTH_MAX = 36; private final static int CUSTOM_WIDTH_MAX = 36;
private RouteLineDrawInfo routeLineDrawInfo; private RouteLineDrawInfo routeLineDrawInfo;
private OnNeedScrollListener onNeedScrollListener; private OnNeedScrollListener onNeedScrollListener;
private HeaderUiAdapter headerUiAdapter;
private WidthMode selectedMode; private WidthMode selectedMode;
private WidthAdapter widthAdapter; private WidthAdapter widthAdapter;
private View sliderContainer; private View sliderContainer;
private RecyclerView groupRecyclerView; private RecyclerView groupRecyclerView;
private TextView tvModeType; private TextView tvSelectedType;
private TextView tvDescription; private TextView tvDescription;
private enum WidthMode { private enum WidthMode {
@ -69,10 +72,12 @@ public class RouteLineWidthCard extends BaseCard {
public RouteLineWidthCard(@NonNull MapActivity mapActivity, public RouteLineWidthCard(@NonNull MapActivity mapActivity,
@NonNull RouteLineDrawInfo routeLineDrawInfo, @NonNull RouteLineDrawInfo routeLineDrawInfo,
@NonNull OnNeedScrollListener onNeedScrollListener) { @NonNull OnNeedScrollListener onNeedScrollListener,
@NonNull HeaderUiAdapter headerUiAdapter) {
super(mapActivity); super(mapActivity);
this.routeLineDrawInfo = routeLineDrawInfo; this.routeLineDrawInfo = routeLineDrawInfo;
this.onNeedScrollListener = onNeedScrollListener; this.onNeedScrollListener = onNeedScrollListener;
this.headerUiAdapter = headerUiAdapter;
} }
@Override @Override
@ -87,7 +92,8 @@ public class RouteLineWidthCard extends BaseCard {
groupRecyclerView.setAdapter(widthAdapter); groupRecyclerView.setAdapter(widthAdapter);
groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false)); groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
tvModeType = view.findViewById(R.id.width_type); ((TextView) view.findViewById(R.id.title)).setText(R.string.select_track_width);
tvSelectedType = view.findViewById(R.id.descr);
tvDescription = view.findViewById(R.id.description); tvDescription = view.findViewById(R.id.description);
sliderContainer = view.findViewById(R.id.slider_container); sliderContainer = view.findViewById(R.id.slider_container);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.top_divider), isShowDivider()); AndroidUiHelper.updateVisibility(view.findViewById(R.id.top_divider), isShowDivider());
@ -122,8 +128,16 @@ public class RouteLineWidthCard extends BaseCard {
return routeLineDrawInfo.getWidth(); return routeLineDrawInfo.getWidth();
} }
@Override
public void onNeedHeaderUpdate() {
updateHeader();
}
private void updateHeader() { private void updateHeader() {
tvModeType.setText(app.getString(selectedMode.titleId)); String title = app.getString(R.string.select_track_width);
String description = app.getString(selectedMode.titleId);
tvSelectedType.setText(description);
headerUiAdapter.onHeaderUpdate(this, title, description);
} }
private void updateDescription() { private void updateDescription() {

View file

@ -11,6 +11,7 @@ import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.TextView;
import androidx.activity.OnBackPressedCallback; import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -30,13 +31,13 @@ import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.enums.DayNightMode; import net.osmand.plus.helpers.enums.DayNightMode;
import net.osmand.plus.routing.RouteLineDrawInfo; import net.osmand.plus.routing.RouteLineDrawInfo;
import net.osmand.plus.routing.cards.RouteLineColorCard; import net.osmand.plus.routing.cards.RouteLineColorCard;
import net.osmand.plus.routing.cards.RouteLineColorCard.OnMapThemeUpdateListener;
import net.osmand.plus.routing.cards.RouteLineColorCard.OnSelectedColorChangeListener;
import net.osmand.plus.routing.cards.RouteLineWidthCard; import net.osmand.plus.routing.cards.RouteLineWidthCard;
import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener; import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener;
import net.osmand.plus.track.TrackAppearanceFragment.OnNeedScrollListener; import net.osmand.plus.track.TrackAppearanceFragment.OnNeedScrollListener;
public class RouteLineAppearanceFragment extends ContextMenuScrollFragment implements ColorPickerListener, OnSelectedColorChangeListener, OnMapThemeUpdateListener { import static net.osmand.util.Algorithms.objectEquals;
public class RouteLineAppearanceFragment extends ContextMenuScrollFragment implements ColorPickerListener {
public static final String TAG = RouteLineAppearanceFragment.class.getName(); public static final String TAG = RouteLineAppearanceFragment.class.getName();
@ -48,10 +49,15 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
private int toolbarHeightPx; private int toolbarHeightPx;
private DayNightMode initMapTheme; private DayNightMode initMapTheme;
private DayNightMode selectedMapTheme; private DayNightMode selectedMapTheme;
private HeaderUiAdapter headerUiAdapter;
private HeaderInfo selectedHeader;
private View buttonsShadow; private View buttonsShadow;
private View controlButtons; private View controlButtons;
private View toolbarContainer; private View toolbarContainer;
private View headerContainer;
private TextView headerTitle;
private TextView headerDescr;
private RouteLineColorCard colorCard; private RouteLineColorCard colorCard;
private RouteLineWidthCard widthCard; private RouteLineWidthCard widthCard;
@ -123,6 +129,9 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
View view = super.onCreateView(inflater, container, savedInstanceState); View view = super.onCreateView(inflater, container, savedInstanceState);
if (view != null) { if (view != null) {
toolbarContainer = view.findViewById(R.id.context_menu_toolbar_container); toolbarContainer = view.findViewById(R.id.context_menu_toolbar_container);
headerContainer = view.findViewById(R.id.header_container);
headerTitle = headerContainer.findViewById(R.id.title);
headerDescr = headerContainer.findViewById(R.id.descr);
buttonsShadow = view.findViewById(R.id.buttons_shadow); buttonsShadow = view.findViewById(R.id.buttons_shadow);
controlButtons = view.findViewById(R.id.control_buttons); controlButtons = view.findViewById(R.id.control_buttons);
if (isPortrait()) { if (isPortrait()) {
@ -142,7 +151,7 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
setupCards(); setupCards();
setupToolbar(); setupToolbar();
setupButtons(view); setupButtons(view);
setupScrollShadow(); setupScrollListener();
enterAppearanceMode(); enterAppearanceMode();
openMenuHalfScreen(); openMenuHalfScreen();
calculateLayout(); calculateLayout();
@ -163,13 +172,33 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
ViewGroup cardsContainer = getCardsContainer(); ViewGroup cardsContainer = getCardsContainer();
cardsContainer.removeAllViews(); cardsContainer.removeAllViews();
colorCard = new RouteLineColorCard(mapActivity, this, routeLineDrawInfo, initMapTheme, selectedMapTheme); colorCard = new RouteLineColorCard(mapActivity, this, routeLineDrawInfo, initMapTheme, selectedMapTheme, getHeaderUiAdapter());
cardsContainer.addView(colorCard.build(mapActivity)); cardsContainer.addView(colorCard.build(mapActivity));
widthCard = new RouteLineWidthCard(mapActivity, routeLineDrawInfo, createScrollListener()); widthCard = new RouteLineWidthCard(mapActivity, routeLineDrawInfo, createScrollListener(), getHeaderUiAdapter());
cardsContainer.addView(widthCard.build(mapActivity)); cardsContainer.addView(widthCard.build(mapActivity));
} }
private HeaderUiAdapter getHeaderUiAdapter() {
if (headerUiAdapter == null) {
headerUiAdapter = new HeaderUiAdapter() {
@Override
public void onHeaderUpdate(@NonNull HeaderInfo headerInfo,
@NonNull String title,
@NonNull String description) {
if (selectedHeader == null) {
selectedHeader = headerInfo;
}
if (objectEquals(selectedHeader, headerInfo)) {
headerTitle.setText(title);
headerDescr.setText(description);
}
}
};
}
return headerUiAdapter;
}
private OnNeedScrollListener createScrollListener() { private OnNeedScrollListener createScrollListener() {
return new OnNeedScrollListener() { return new OnNeedScrollListener() {
@ -254,7 +283,7 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
AndroidUiHelper.updateVisibility(view.findViewById(R.id.buttons_divider), true); AndroidUiHelper.updateVisibility(view.findViewById(R.id.buttons_divider), true);
} }
private void setupScrollShadow() { private void setupScrollListener() {
final View scrollView = getBottomScrollView(); final View scrollView = getBottomScrollView();
scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
@Override @Override
@ -265,6 +294,7 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
} else { } else {
hideShadowButton(); hideShadowButton();
} }
updateHeaderState();
} }
}); });
} }
@ -283,6 +313,15 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
.setDuration(200); .setDuration(200);
} }
private void updateHeaderState() {
if (getBottomScrollView().getScrollY() > colorCard.getViewHeight() + headerTitle.getBottom()) {
selectedHeader = widthCard;
} else {
selectedHeader = colorCard;
}
selectedHeader.onNeedHeaderUpdate();
}
private void initVisibleRect() { private void initVisibleRect() {
MapActivity ctx = getMapActivity(); MapActivity ctx = getMapActivity();
int screenHeight = AndroidUtils.getScreenHeight(ctx); int screenHeight = AndroidUtils.getScreenHeight(ctx);
@ -385,7 +424,6 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
colorCard.onColorSelected(prevColor, newColor); colorCard.onColorSelected(prevColor, newColor);
} }
@Override
public void onSelectedColorChanged() { public void onSelectedColorChanged() {
updateColorItems(); updateColorItems();
} }
@ -418,7 +456,6 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
} }
} }
@Override
public void onMapThemeUpdated(@NonNull DayNightMode mapTheme) { public void onMapThemeUpdated(@NonNull DayNightMode mapTheme) {
changeMapTheme(mapTheme); changeMapTheme(mapTheme);
updateColorItems(); updateColorItems();
@ -435,4 +472,14 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
public interface OnApplyRouteLineListener { public interface OnApplyRouteLineListener {
void applyRouteLineAppearance(@NonNull RouteLineDrawInfo routeLineDrawInfo); void applyRouteLineAppearance(@NonNull RouteLineDrawInfo routeLineDrawInfo);
} }
public interface HeaderUiAdapter {
void onHeaderUpdate(@NonNull HeaderInfo headerInfo,
@NonNull String title,
@NonNull String description);
}
public interface HeaderInfo {
void onNeedHeaderUpdate();
}
} }