Add options menu fragment; fix layouts

This commit is contained in:
Alex 2017-08-11 13:57:37 +03:00
parent a78dcee686
commit 584143f6a2
6 changed files with 250 additions and 10 deletions

View file

@ -0,0 +1,205 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
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">
<TextView
android:layout_width="match_parent"
android:layout_height="52dp"
android:gravity="center_vertical"
android:paddingEnd="16dp"
android:paddingStart="16dp"
android:text="@string/shared_string_options"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="?attr/selectableItemBackground"
android:minHeight="48dp"
android:paddingEnd="16dp"
android:paddingStart="16dp">
<ImageView
android:id="@+id/snap_to_road_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="24dp"
android:layout_marginRight="24dp"
tools:src="@drawable/ic_action_snap_to_road"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/snap_to_road_icon"
android:layout_toRightOf="@id/snap_to_road_icon"
android:maxLines="1"
android:text="@string/snap_to_road"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</RelativeLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="64dp"
android:layout_marginStart="64dp"
android:layout_marginTop="7dp"
android:background="?attr/dashboard_divider"/>
<RelativeLayout
android:id="@+id/save_as_new_segment_row"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="?attr/selectableItemBackground"
android:minHeight="48dp"
android:paddingEnd="16dp"
android:paddingStart="16dp"
android:visibility="gone">
<ImageView
android:id="@+id/save_as_new_segment_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="24dp"
android:layout_marginRight="24dp"
tools:src="@drawable/ic_action_polygom_dark"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/save_as_new_segment_icon"
android:layout_toRightOf="@id/save_as_new_segment_icon"
android:maxLines="1"
android:text="@string/save_as_new_segment"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/save_as_new_track_row"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="?attr/selectableItemBackground"
android:minHeight="48dp"
android:paddingEnd="16dp"
android:paddingStart="16dp">
<ImageView
android:id="@+id/save_as_new_track_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="24dp"
android:layout_marginRight="24dp"
tools:src="@drawable/ic_action_polygom_dark"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/save_as_new_track_icon"
android:layout_toRightOf="@id/save_as_new_track_icon"
android:maxLines="1"
android:text="@string/shared_string_save_as_gpx"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/add_to_the_track_row"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="?attr/selectableItemBackground"
android:minHeight="48dp"
android:paddingEnd="16dp"
android:paddingStart="16dp">
<ImageView
android:id="@+id/add_to_the_track_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="24dp"
android:layout_marginRight="24dp"
tools:src="@drawable/ic_action_split_interval"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/add_to_the_track_icon"
android:layout_toRightOf="@id/add_to_the_track_icon"
android:maxLines="1"
android:text="@string/add_segment_to_the_track"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</RelativeLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="64dp"
android:layout_marginStart="64dp"
android:layout_marginTop="7dp"
android:background="?attr/dashboard_divider"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="?attr/selectableItemBackground"
android:minHeight="48dp"
android:paddingEnd="16dp"
android:paddingStart="16dp">
<ImageView
android:id="@+id/clear_all_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="24dp"
android:layout_marginRight="24dp"
tools:src="@drawable/ic_action_reset_to_default_dark"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/clear_all_icon"
android:layout_toRightOf="@id/clear_all_icon"
android:maxLines="1"
android:text="@string/shared_string_clear_all"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp"
android:background="?attr/dashboard_divider"/>
<FrameLayout
android:id="@+id/cancel_row"
android:layout_width="match_parent"
android:layout_height="@dimen/snap_to_road_bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground">
<TextView
android:id="@+id/cancel_row_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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

@ -3,6 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<ScrollView
@ -39,7 +40,6 @@
</ScrollView>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>

View file

@ -14,8 +14,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="24dp"
android:layout_marginRight="24dp"
tools:src="@drawable/ic_action_car_dark"/>
<TextView

View file

@ -9,6 +9,7 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="shared_string_options">Options</string>
<string name="measurement_tool_snap_to_road_descr">OsmAnd will add additional points, depending on the navigation type.</string>
<string name="choose_navigation_type">Choose navigation type</string>
<string name="none_point_error">Please add at least one point.</string>
@ -792,7 +793,7 @@
<string name="shared_string_clear">Clear</string>
<string name="shared_string_clear_all">Clear all</string>
<string name="shared_string_save">Save</string>
<string name="shared_string_save_as_gpx">Save as Track</string>
<string name="shared_string_save_as_gpx">Save as new Track</string>
<string name="shared_string_rename">Rename</string>
<string name="shared_string_delete">Delete</string>
<string name="shared_string_delete_all">Delete all</string>
@ -2680,5 +2681,5 @@
<string name="import_track_desc">File %1$s does not contain waypoints, import it as a track?</string>
<string name="save_as_new_segment">Save as new segment</string>
<string name="move_point">Move Point</string>
<string name="add_segment_to_the_track">Add segment to the track</string>
<string name="add_segment_to_the_track">Add to a track</string>
</resources>

View file

@ -0,0 +1,39 @@
package net.osmand.plus.measurementtool;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import net.osmand.plus.R;
import net.osmand.plus.base.BottomSheetDialogFragment;
public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment {
public final static String TAG = "OptionsBottomSheetDialogFragment";
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_options_bottom_sheet_dialog, null);
((ImageView) mainView.findViewById(R.id.snap_to_road_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_snap_to_road));
((ImageView) mainView.findViewById(R.id.save_as_new_track_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_polygom_dark));
((ImageView) mainView.findViewById(R.id.add_to_the_track_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_split_interval));
((ImageView) mainView.findViewById(R.id.clear_all_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_reset_to_default_dark));
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
return mainView;
}
}

View file

@ -34,16 +34,11 @@ public class SnapToRoadBottomSheetDialogFragment extends BottomSheetDialogFragme
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);
final View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_snap_to_road_bottom_sheet_dialog, container);
view.setBackgroundColor(backgroundColor);
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