From ee09074abf8b5df60d7c6b4a8f1fa2406b37d2de Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 10 Aug 2017 17:48:36 +0300 Subject: [PATCH] Show application modes in bottom sheet --- ...gment_snap_to_road_bottom_sheet_dialog.xml | 37 ++++++++++------ .../res/layout/list_item_icon_and_title.xml | 1 + .../SnapToRoadBottomSheetDialogFragment.java | 44 ++++++++++++------- 3 files changed, 51 insertions(+), 31 deletions(-) diff --git a/OsmAnd/res/layout/fragment_snap_to_road_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_snap_to_road_bottom_sheet_dialog.xml index 9fd046e63f..e397dd568d 100644 --- a/OsmAnd/res/layout/fragment_snap_to_road_bottom_sheet_dialog.xml +++ b/OsmAnd/res/layout/fragment_snap_to_road_bottom_sheet_dialog.xml @@ -33,26 +33,35 @@ android:textSize="@dimen/default_desc_text_size"/> - + android:layout_height="wrap_content" + android:orientation="vertical"/> - + android:layout_height="1dp" + android:layout_marginTop="8dp" + android:background="?attr/dashboard_divider"/> - + + - + android:layout_gravity="center" + android:text="@string/shared_string_cancel" + android:textAllCaps="true" + android:textColor="@color/dashboard_general_button_text_light" + android:textSize="14sp" + android:textStyle="bold"/> + \ No newline at end of file diff --git a/OsmAnd/res/layout/list_item_icon_and_title.xml b/OsmAnd/res/layout/list_item_icon_and_title.xml index c5d881834a..24308873c8 100644 --- a/OsmAnd/res/layout/list_item_icon_and_title.xml +++ b/OsmAnd/res/layout/list_item_icon_and_title.xml @@ -5,6 +5,7 @@ android:layout_width="match_parent" android:layout_height="48dp" android:background="?attr/selectableItemBackground" + android:minHeight="48dp" android:paddingEnd="16dp" android:paddingStart="16dp"> diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SnapToRoadBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/SnapToRoadBottomSheetDialogFragment.java index 4546a8582b..1c2dbc3d25 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/SnapToRoadBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/SnapToRoadBottomSheetDialogFragment.java @@ -3,17 +3,22 @@ package net.osmand.plus.measurementtool; 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.View; import android.view.ViewGroup; -import android.widget.FrameLayout; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.TextView; -import android.widget.Toast; +import net.osmand.plus.ApplicationMode; +import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.base.BottomSheetDialogFragment; +import java.util.ArrayList; +import java.util.List; + public class SnapToRoadBottomSheetDialogFragment extends BottomSheetDialogFragment { public static final String TAG = "SnapToRoadBottomSheetDialogFragment"; @@ -21,32 +26,37 @@ public class SnapToRoadBottomSheetDialogFragment extends BottomSheetDialogFragme @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + final OsmandSettings settings = getMyApplication().getSettings(); final boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls(); + final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; final int backgroundColor = ContextCompat.getColor(getActivity(), nightMode ? R.color.ctx_menu_info_view_bg_dark : R.color.ctx_menu_info_view_bg_light); - View view = inflater.inflate(R.layout.fragment_snap_to_road_bottom_sheet_dialog, container, false); + View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_snap_to_road_bottom_sheet_dialog, container); view.setBackgroundColor(backgroundColor); - - FrameLayout navigationTypesContainer = (FrameLayout) view.findViewById(R.id.navigation_types_container); - - View carNavigation = inflater.inflate(R.layout.list_item_icon_and_title, navigationTypesContainer, true); - ((ImageView) carNavigation.findViewById(R.id.icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_car_dark)); - ((TextView) carNavigation.findViewById(R.id.title)).setText(getString(R.string.rendering_value_car_name)); - carNavigation.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Toast.makeText(getActivity(), "Car", Toast.LENGTH_SHORT).show(); - } - }); - - view.findViewById(R.id.cancel_button).setOnClickListener(new View.OnClickListener() { + if (nightMode) { + ((TextView) view.findViewById(R.id.cancel_row_text)) + .setTextColor(ContextCompat.getColor(getActivity(), R.color.dashboard_general_button_text_dark)); + } else { + view.findViewById(R.id.divider).setBackgroundResource(R.drawable.divider); + } + view.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dismiss(); } }); + LinearLayout navContainer = (LinearLayout) view.findViewById(R.id.navigation_types_container); + final List modes = new ArrayList<>(ApplicationMode.values(settings)); + modes.remove(ApplicationMode.DEFAULT); + for (ApplicationMode mode : modes) { + View row = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.list_item_icon_and_title, null); + ((ImageView) row.findViewById(R.id.icon)).setImageDrawable(getContentIcon(mode.getSmallIconDark())); + ((TextView) row.findViewById(R.id.title)).setText(mode.toHumanString(getContext())); + navContainer.addView(row); + } + return view; } }