Replace old fragment with new
This commit is contained in:
parent
b47059b758
commit
29d50cb2b3
4 changed files with 6 additions and 595 deletions
|
@ -1,356 +0,0 @@
|
|||
<?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:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/marker_show_direction_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/show_direction_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_title_height"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding"
|
||||
android:text="@string/show_direction"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_descr_height"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding"
|
||||
android:text="@string/marker_show_distance_descr"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/images_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/bottom_sheet_content_margin"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_content_margin_small"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_content_margin_small"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_content_margin"
|
||||
android:layout_weight="1">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/top_bar_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
tools:src="@drawable/img_help_trip_route_points_night"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/top_bar_image_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@id/top_bar_image"
|
||||
android:layout_alignStart="@id/top_bar_image"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_image_text_margin_start"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_image_text_margin_start"
|
||||
android:layout_marginTop="@dimen/bottom_sheet_content_margin_small"
|
||||
android:text="@string/shared_string_topbar"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_split_segments_sub"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_content_margin"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_content_margin_small"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_content_margin"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_content_margin_small"
|
||||
android:layout_weight="1">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/widget_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
tools:src="@drawable/img_help_trip_track_night"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/widget_image_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@id/widget_image"
|
||||
android:layout_alignStart="@id/widget_image"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_image_text_margin_start"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_image_text_margin_start"
|
||||
android:layout_marginTop="@dimen/bottom_sheet_content_margin_small"
|
||||
android:text="@string/shared_string_widgets"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_split_segments_sub"/>
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/show_arrows_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@string/show_arrows_on_the_map"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/show_arrows_switch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/show_guide_line_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@string/show_guide_line"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/show_guide_line_switch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="@dimen/bottom_sheet_content_padding_small"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/top_bar_row_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height">
|
||||
|
||||
<LinearLayout
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:id="@+id/top_bar_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/top_bar_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:background="@drawable/ic_action_device_top"
|
||||
tools:src="@drawable/ic_action_device_topbar"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
osmand:typeface="@string/font_roboto_regular"
|
||||
android:id="@+id/top_bar_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_topbar"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"/>
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/top_bar_radio_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:focusable="false"/>
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/widget_row_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height">
|
||||
|
||||
<LinearLayout
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:id="@+id/widget_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/widget_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:background="@drawable/ic_action_device_top"
|
||||
tools:src="@drawable/ic_action_device_widget"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
osmand:typeface="@string/font_roboto_regular"
|
||||
android:id="@+id/widget_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_widgets"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"/>
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/widget_radio_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:focusable="false"/>
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/none_row_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height">
|
||||
|
||||
<LinearLayout
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:id="@+id/none_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/none_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:background="@drawable/ic_action_device_top"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
osmand:typeface="@string/font_roboto_regular"
|
||||
android:id="@+id/none_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_none"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"/>
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/none_radio_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:focusable="false"/>
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/cancel_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/shared_string_close"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
android:textStyle="bold"/>
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -177,7 +177,8 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
|
|||
}
|
||||
}
|
||||
}
|
||||
((ImageView) mainView.findViewById(R.id.action_bar_image)).setImageDrawable(new LayerDrawable(imgList.toArray(new Drawable[imgList.size()])));
|
||||
((ImageView) mainView.findViewById(R.id.action_bar_image))
|
||||
.setImageDrawable(new LayerDrawable(imgList.toArray(new Drawable[imgList.size()])));
|
||||
}
|
||||
|
||||
private Drawable getTopBar2Img() {
|
||||
|
|
|
@ -1,233 +0,0 @@
|
|||
package net.osmand.plus.mapmarkers;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
|
||||
public class ShowDirectionBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||
|
||||
public final static String TAG = "ShowDirectionBottomSheetDialogFragment";
|
||||
|
||||
private ShowDirectionFragmentListener listener;
|
||||
private View mainView;
|
||||
|
||||
public void setListener(ShowDirectionFragmentListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
final OsmandSettings settings = getMyApplication().getSettings();
|
||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
|
||||
mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_show_direction_bottom_sheet_dialog, container);
|
||||
|
||||
OsmandSettings.MapMarkersMode mode = settings.MAP_MARKERS_MODE.get();
|
||||
highlightSelectedItem(mode, true);
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
mainView.findViewById(R.id.images_row).setVisibility(View.GONE);
|
||||
} else {
|
||||
ImageView topBarImage = (ImageView) mainView.findViewById(R.id.top_bar_image);
|
||||
ImageView widgetImage = (ImageView) mainView.findViewById(R.id.widget_image);
|
||||
if (nightMode) {
|
||||
topBarImage.setImageResource(R.drawable.img_help_markers_topbar_night);
|
||||
widgetImage.setImageResource(R.drawable.img_help_markers_widgets_night);
|
||||
} else {
|
||||
topBarImage.setImageResource(R.drawable.img_help_markers_topbar_day);
|
||||
widgetImage.setImageResource(R.drawable.img_help_markers_widgets_day);
|
||||
}
|
||||
|
||||
mainView.findViewById(R.id.top_bar_image_text).setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
topBarImage.setOnClickListener(showDirectionOnClickListener);
|
||||
|
||||
mainView.findViewById(R.id.widget_image_text).setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
widgetImage.setOnClickListener(showDirectionOnClickListener);
|
||||
}
|
||||
|
||||
if (nightMode) {
|
||||
((TextView) mainView.findViewById(R.id.show_direction_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
|
||||
}
|
||||
|
||||
final CompoundButton showArrowsToggle = (CompoundButton) mainView.findViewById(R.id.show_arrows_switch);
|
||||
showArrowsToggle.setChecked(settings.SHOW_ARROWS_TO_FIRST_MARKERS.get());
|
||||
mainView.findViewById(R.id.show_arrows_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
boolean newState = !settings.SHOW_ARROWS_TO_FIRST_MARKERS.get();
|
||||
settings.SHOW_ARROWS_TO_FIRST_MARKERS.set(newState);
|
||||
showArrowsToggle.setChecked(newState);
|
||||
if (getMapActivity() != null) {
|
||||
getMapActivity().refreshMap();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
final CompoundButton showLinesToggle = (CompoundButton) mainView.findViewById(R.id.show_guide_line_switch);
|
||||
showLinesToggle.setChecked(settings.SHOW_LINES_TO_FIRST_MARKERS.get());
|
||||
mainView.findViewById(R.id.show_guide_line_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
boolean newState = !settings.SHOW_LINES_TO_FIRST_MARKERS.get();
|
||||
settings.SHOW_LINES_TO_FIRST_MARKERS.set(newState);
|
||||
showLinesToggle.setChecked(newState);
|
||||
if (getMapActivity() != null) {
|
||||
getMapActivity().refreshMap();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ImageView topBarIcon = (ImageView) mainView.findViewById(R.id.top_bar_icon);
|
||||
topBarIcon.setBackgroundDrawable(getContentIcon(R.drawable.ic_action_device_top));
|
||||
topBarIcon.setImageDrawable(getIcon(R.drawable.ic_action_device_topbar, R.color.dashboard_blue));
|
||||
|
||||
ImageView widgetIcon = (ImageView) mainView.findViewById(R.id.widget_icon);
|
||||
widgetIcon.setBackgroundDrawable(getContentIcon(R.drawable.ic_action_device_top));
|
||||
widgetIcon.setImageDrawable(getIcon(R.drawable.ic_action_device_widget, R.color.dashboard_blue));
|
||||
|
||||
ImageView noneIcon = (ImageView) mainView.findViewById(R.id.none_icon);
|
||||
noneIcon.setBackgroundDrawable(getContentIcon(R.drawable.ic_action_device_top));
|
||||
|
||||
mainView.findViewById(R.id.top_bar_row).setOnClickListener(showDirectionOnClickListener);
|
||||
mainView.findViewById(R.id.widget_row).setOnClickListener(showDirectionOnClickListener);
|
||||
mainView.findViewById(R.id.none_row).setOnClickListener(showDirectionOnClickListener);
|
||||
|
||||
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
setupHeightAndBackground(mainView, R.id.marker_show_direction_scroll_view);
|
||||
|
||||
return mainView;
|
||||
}
|
||||
|
||||
private MapActivity getMapActivity() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
return (MapActivity) activity;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void highlightSelectedItem(OsmandSettings.MapMarkersMode mode, boolean check) {
|
||||
int iconBgColor = check ? R.color.dashboard_blue : R.color.on_map_icon_color;
|
||||
int iconColor = check ? R.color.color_dialog_buttons_dark : R.color.dashboard_blue;
|
||||
int textColor = ContextCompat.getColor(getContext(), check ? (nightMode ? R.color.color_dialog_buttons_dark : R.color.dashboard_blue) : nightMode ? R.color.color_white : R.color.color_black);
|
||||
Typeface typeface = FontCache.getFont(getContext(), check ? "fonts/Roboto-Medium.ttf" : "fonts/Roboto-Regular.ttf");
|
||||
switch (mode) {
|
||||
case TOOLBAR:
|
||||
((RadioButton) mainView.findViewById(R.id.top_bar_radio_button)).setChecked(check);
|
||||
ImageView topBarIcon = (ImageView) mainView.findViewById(R.id.top_bar_icon);
|
||||
if (check) {
|
||||
mainView.findViewById(R.id.top_bar_row_frame).setBackgroundColor(ContextCompat.getColor(getContext(), R.color.show_direction_menu_selected_item_bg));
|
||||
} else {
|
||||
mainView.findViewById(R.id.top_bar_row_frame).setBackgroundResource(0);
|
||||
}
|
||||
TextView topBarText = (TextView) mainView.findViewById(R.id.top_bar_text);
|
||||
topBarText.setTextColor(textColor);
|
||||
topBarText.setTypeface(typeface);
|
||||
topBarIcon.setBackgroundDrawable(getIcon(R.drawable.ic_action_device_top, iconBgColor));
|
||||
topBarIcon.setImageDrawable(getIcon(R.drawable.ic_action_device_topbar, iconColor));
|
||||
break;
|
||||
case WIDGETS:
|
||||
((RadioButton) mainView.findViewById(R.id.widget_radio_button)).setChecked(check);
|
||||
ImageView widgetIcon = (ImageView) mainView.findViewById(R.id.widget_icon);
|
||||
if (check) {
|
||||
mainView.findViewById(R.id.widget_row_frame).setBackgroundColor(ContextCompat.getColor(getContext(), R.color.show_direction_menu_selected_item_bg));
|
||||
} else {
|
||||
mainView.findViewById(R.id.widget_row_frame).setBackgroundResource(0);
|
||||
}
|
||||
TextView widgetText = (TextView) mainView.findViewById(R.id.widget_text);
|
||||
widgetText.setTextColor(textColor);
|
||||
widgetText.setTypeface(typeface);
|
||||
widgetIcon.setBackgroundDrawable(getIcon(R.drawable.ic_action_device_top, iconBgColor));
|
||||
widgetIcon.setImageDrawable(getIcon(R.drawable.ic_action_device_widget, iconColor));
|
||||
break;
|
||||
case NONE:
|
||||
((RadioButton) mainView.findViewById(R.id.none_radio_button)).setChecked(check);
|
||||
ImageView noneIcon = (ImageView) mainView.findViewById(R.id.none_icon);
|
||||
if (check) {
|
||||
mainView.findViewById(R.id.none_row_frame).setBackgroundColor(ContextCompat.getColor(getContext(), R.color.show_direction_menu_selected_item_bg));
|
||||
} else {
|
||||
mainView.findViewById(R.id.none_row_frame).setBackgroundResource(0);
|
||||
}
|
||||
TextView noneText = (TextView) mainView.findViewById(R.id.none_text);
|
||||
noneText.setTextColor(textColor);
|
||||
noneText.setTypeface(typeface);
|
||||
noneIcon.setBackgroundDrawable(getIcon(R.drawable.ic_action_device_top, iconBgColor));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private View.OnClickListener showDirectionOnClickListener = new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
OsmandSettings.MapMarkersMode previousMode = getMyApplication().getSettings().MAP_MARKERS_MODE.get();
|
||||
highlightSelectedItem(previousMode, false);
|
||||
boolean showDirectionEnabled = false;
|
||||
switch (view.getId()) {
|
||||
case R.id.top_bar_image:
|
||||
case R.id.top_bar_row:
|
||||
getMyApplication().getSettings().MAP_MARKERS_MODE.set(OsmandSettings.MapMarkersMode.TOOLBAR);
|
||||
highlightSelectedItem(OsmandSettings.MapMarkersMode.TOOLBAR, true);
|
||||
showDirectionEnabled = true;
|
||||
break;
|
||||
case R.id.widget_image:
|
||||
case R.id.widget_row:
|
||||
getMyApplication().getSettings().MAP_MARKERS_MODE.set(OsmandSettings.MapMarkersMode.WIDGETS);
|
||||
highlightSelectedItem(OsmandSettings.MapMarkersMode.WIDGETS, true);
|
||||
showDirectionEnabled = true;
|
||||
break;
|
||||
case R.id.none_row:
|
||||
getMyApplication().getSettings().MAP_MARKERS_MODE.set(OsmandSettings.MapMarkersMode.NONE);
|
||||
highlightSelectedItem(OsmandSettings.MapMarkersMode.NONE, true);
|
||||
showDirectionEnabled = false;
|
||||
break;
|
||||
}
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
if (listener != null) {
|
||||
listener.onMapMarkersModeChanged(showDirectionEnabled);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
};
|
||||
|
||||
public interface ShowDirectionFragmentListener {
|
||||
void onMapMarkersModeChanged(boolean showDirectionEnabled);
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ import net.osmand.plus.OsmandSettings.OsmandPreference;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||
import net.osmand.plus.mapmarkers.ShowDirectionBottomSheetDialogFragment;
|
||||
import net.osmand.plus.mapmarkers.DirectionIndicationDialogFragment;
|
||||
import net.osmand.plus.quickaction.QuickActionListFragment;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.MapQuickActionLayer;
|
||||
|
@ -327,9 +327,8 @@ public class MapWidgetRegistry {
|
|||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId, final int position, boolean isChecked) {
|
||||
ShowDirectionBottomSheetDialogFragment fragment = new ShowDirectionBottomSheetDialogFragment();
|
||||
fragment.setUsedOnMap(true);
|
||||
fragment.setListener(new ShowDirectionBottomSheetDialogFragment.ShowDirectionFragmentListener() {
|
||||
DirectionIndicationDialogFragment fragment = new DirectionIndicationDialogFragment();
|
||||
fragment.setListener(new DirectionIndicationDialogFragment.DirectionIndicationFragmentListener() {
|
||||
@Override
|
||||
public void onMapMarkersModeChanged(boolean showDirectionEnabled) {
|
||||
updateMapMarkersMode(map);
|
||||
|
@ -337,7 +336,7 @@ public class MapWidgetRegistry {
|
|||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
fragment.show(map.getSupportFragmentManager(), ShowDirectionBottomSheetDialogFragment.TAG);
|
||||
fragment.show(map.getSupportFragmentManager(), DirectionIndicationDialogFragment.TAG);
|
||||
return false;
|
||||
}
|
||||
}).setLayout(R.layout.list_item_text_button).createItem());
|
||||
|
|
Loading…
Reference in a new issue