Show application modes in bottom sheet

This commit is contained in:
Alexander Sytnyk 2017-08-10 17:48:36 +03:00
parent 8af25f51ce
commit ee09074abf
3 changed files with 51 additions and 31 deletions

View file

@ -33,26 +33,35 @@
android:textSize="@dimen/default_desc_text_size"/> android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout> </LinearLayout>
<FrameLayout <LinearLayout
android:id="@+id/navigation_types_container" android:id="@+id/navigation_types_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"
android:orientation="vertical"/>
<RelativeLayout <View
android:id="@+id/divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="52dp"> android:layout_height="1dp"
android:layout_marginTop="8dp"
android:background="?attr/dashboard_divider"/>
<android.support.v7.widget.AppCompatButton <FrameLayout
android:id="@+id/cancel_button" android:id="@+id/cancel_row"
style="@style/Widget.AppCompat.Button.Borderless.Colored" android:layout_width="match_parent"
android:layout_height="48dp"
android:background="?attr/selectableItemBackground">
<TextView
android:id="@+id/cancel_row_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:layout_gravity="center"
android:layout_alignParentRight="true" android:text="@string/shared_string_cancel"
android:layout_centerVertical="true" android:textAllCaps="true"
android:layout_marginEnd="8dp" android:textColor="@color/dashboard_general_button_text_light"
android:layout_marginRight="8dp" android:textSize="14sp"
android:text="@string/shared_string_cancel"/> android:textStyle="bold"/>
</RelativeLayout> </FrameLayout>
</LinearLayout> </LinearLayout>

View file

@ -5,6 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="48dp" android:layout_height="48dp"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:minHeight="48dp"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:paddingStart="16dp"> android:paddingStart="16dp">

View file

@ -3,17 +3,22 @@ package net.osmand.plus.measurementtool;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView; 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.R;
import net.osmand.plus.base.BottomSheetDialogFragment; import net.osmand.plus.base.BottomSheetDialogFragment;
import java.util.ArrayList;
import java.util.List;
public class SnapToRoadBottomSheetDialogFragment extends BottomSheetDialogFragment { public class SnapToRoadBottomSheetDialogFragment extends BottomSheetDialogFragment {
public static final String TAG = "SnapToRoadBottomSheetDialogFragment"; public static final String TAG = "SnapToRoadBottomSheetDialogFragment";
@ -21,32 +26,37 @@ public class SnapToRoadBottomSheetDialogFragment extends BottomSheetDialogFragme
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final OsmandSettings settings = getMyApplication().getSettings();
final boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls(); final boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final int backgroundColor = ContextCompat.getColor(getActivity(), final int backgroundColor = ContextCompat.getColor(getActivity(),
nightMode ? R.color.ctx_menu_info_view_bg_dark : R.color.ctx_menu_info_view_bg_light); 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); view.setBackgroundColor(backgroundColor);
if (nightMode) {
FrameLayout navigationTypesContainer = (FrameLayout) view.findViewById(R.id.navigation_types_container); ((TextView) view.findViewById(R.id.cancel_row_text))
.setTextColor(ContextCompat.getColor(getActivity(), R.color.dashboard_general_button_text_dark));
View carNavigation = inflater.inflate(R.layout.list_item_icon_and_title, navigationTypesContainer, true); } else {
((ImageView) carNavigation.findViewById(R.id.icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_car_dark)); view.findViewById(R.id.divider).setBackgroundResource(R.drawable.divider);
((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_row).setOnClickListener(new View.OnClickListener() {
view.findViewById(R.id.cancel_button).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
dismiss(); dismiss();
} }
}); });
LinearLayout navContainer = (LinearLayout) view.findViewById(R.id.navigation_types_container);
final List<ApplicationMode> 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; return view;
} }
} }