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"/>
</LinearLayout>
<FrameLayout
<LinearLayout
android:id="@+id/navigation_types_container"
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_height="52dp">
android:layout_height="1dp"
android:layout_marginTop="8dp"
android:background="?attr/dashboard_divider"/>
<android.support.v7.widget.AppCompatButton
android:id="@+id/cancel_button"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
<FrameLayout
android:id="@+id/cancel_row"
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_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:text="@string/shared_string_cancel"/>
</RelativeLayout>
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"/>
</FrameLayout>
</LinearLayout>

View file

@ -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">

View file

@ -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();
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_button).setOnClickListener(new View.OnClickListener() {
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<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;
}
}