Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
16ca72d722
6 changed files with 514 additions and 6 deletions
|
@ -0,0 +1,236 @@
|
||||||
|
<?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_options_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="8dp">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/measurement_tool_bottom_title_height"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingEnd="@dimen/measurement_tool_content_padding"
|
||||||
|
android:paddingLeft="@dimen/measurement_tool_content_padding"
|
||||||
|
android:paddingRight="@dimen/measurement_tool_content_padding"
|
||||||
|
android:paddingStart="@dimen/measurement_tool_content_padding"
|
||||||
|
android:text="@string/marker_options"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/sort_by_row"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/measurement_tool_bottom_list_item_height"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:minHeight="@dimen/measurement_tool_bottom_list_item_height"
|
||||||
|
android:paddingEnd="@dimen/measurement_tool_content_padding"
|
||||||
|
android:paddingLeft="@dimen/measurement_tool_content_padding"
|
||||||
|
android:paddingRight="@dimen/measurement_tool_content_padding"
|
||||||
|
android:paddingStart="@dimen/measurement_tool_content_padding">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/sort_by_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginEnd="@dimen/measurement_tool_bottom_icon_margin"
|
||||||
|
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin"
|
||||||
|
tools:src="@drawable/ic_sort_waypoint_dark"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text="@string/sort_by"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/show_direction_row"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/measurement_tool_bottom_list_item_height"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:minHeight="@dimen/measurement_tool_bottom_list_item_height"
|
||||||
|
android:paddingEnd="@dimen/measurement_tool_content_padding"
|
||||||
|
android:paddingLeft="@dimen/measurement_tool_content_padding"
|
||||||
|
android:paddingRight="@dimen/measurement_tool_content_padding"
|
||||||
|
android:paddingStart="@dimen/measurement_tool_content_padding">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/show_direction_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginEnd="@dimen/measurement_tool_bottom_icon_margin"
|
||||||
|
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin"
|
||||||
|
tools:src="@drawable/ic_sort_waypoint_dark"/>
|
||||||
|
|
||||||
|
<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_direction"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/show_direction_text_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical|end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
|
android:textColor="@color/map_widget_blue_pressed"
|
||||||
|
tools:text="Top bar"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_marginBottom="@dimen/measurement_tool_bottom_divider_margin_bottom"
|
||||||
|
android:layout_marginLeft="@dimen/measurement_tool_bottom_divider_margin_start"
|
||||||
|
android:layout_marginStart="@dimen/measurement_tool_bottom_divider_margin_start"
|
||||||
|
android:layout_marginTop="@dimen/measurement_tool_bottom_divider_margin_top"
|
||||||
|
android:background="?attr/dashboard_divider"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/build_route_row"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/measurement_tool_bottom_list_item_height"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:minHeight="@dimen/measurement_tool_bottom_list_item_height"
|
||||||
|
android:paddingEnd="@dimen/measurement_tool_content_padding"
|
||||||
|
android:paddingLeft="@dimen/measurement_tool_content_padding"
|
||||||
|
android:paddingRight="@dimen/measurement_tool_content_padding"
|
||||||
|
android:paddingStart="@dimen/measurement_tool_content_padding">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/build_route_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginEnd="@dimen/measurement_tool_bottom_icon_margin"
|
||||||
|
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin"
|
||||||
|
tools:src="@drawable/map_directions"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text="@string/build_route"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/save_as_new_track_row"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/measurement_tool_bottom_list_item_height"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:minHeight="@dimen/measurement_tool_bottom_list_item_height"
|
||||||
|
android:paddingEnd="@dimen/measurement_tool_content_padding"
|
||||||
|
android:paddingLeft="@dimen/measurement_tool_content_padding"
|
||||||
|
android:paddingRight="@dimen/measurement_tool_content_padding"
|
||||||
|
android:paddingStart="@dimen/measurement_tool_content_padding">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/save_as_new_track_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginEnd="@dimen/measurement_tool_bottom_icon_margin"
|
||||||
|
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin"
|
||||||
|
tools:src="@drawable/ic_action_polygom_dark"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text="@string/shared_string_save_as_gpx"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_marginBottom="@dimen/measurement_tool_bottom_divider_margin_bottom"
|
||||||
|
android:layout_marginLeft="@dimen/measurement_tool_bottom_divider_margin_start"
|
||||||
|
android:layout_marginStart="@dimen/measurement_tool_bottom_divider_margin_start"
|
||||||
|
android:layout_marginTop="@dimen/measurement_tool_bottom_divider_margin_top"
|
||||||
|
android:background="?attr/dashboard_divider"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/move_all_to_history_row"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/measurement_tool_bottom_list_item_height"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:minHeight="@dimen/measurement_tool_bottom_list_item_height"
|
||||||
|
android:paddingEnd="@dimen/measurement_tool_content_padding"
|
||||||
|
android:paddingLeft="@dimen/measurement_tool_content_padding"
|
||||||
|
android:paddingRight="@dimen/measurement_tool_content_padding"
|
||||||
|
android:paddingStart="@dimen/measurement_tool_content_padding">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/move_all_to_history_icon"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginEnd="@dimen/measurement_tool_bottom_icon_margin"
|
||||||
|
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin"
|
||||||
|
tools:src="@drawable/ic_action_history2"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text="@string/move_all_to_history"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</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/measure_distance_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_close"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:textColor="?attr/color_dialog_buttons"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -9,6 +9,11 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
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
|
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="move_all_to_history">Move all to history</string>
|
||||||
|
<string name="build_route">Build route</string>
|
||||||
|
<string name="show_direction">Show direction</string>
|
||||||
|
<string name="sort_by">Sort by</string>
|
||||||
|
<string name="marker_options">Marker options</string>
|
||||||
<string name="do_not_use_animations">Do not use animations</string>
|
<string name="do_not_use_animations">Do not use animations</string>
|
||||||
<string name="do_not_use_animations_descr">Disables animations in the app</string>
|
<string name="do_not_use_animations_descr">Disables animations in the app</string>
|
||||||
<string name="keep_showing_on_map">Keep showing on map</string>
|
<string name="keep_showing_on_map">Keep showing on map</string>
|
||||||
|
|
|
@ -19,6 +19,7 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.mapmarkers.MarkerOptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -39,6 +40,12 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
FragmentManager fragmentManager = getChildFragmentManager();
|
||||||
|
Fragment markerOptionsFragment = fragmentManager.findFragmentByTag(MarkerOptionsBottomSheetDialogFragment.TAG);
|
||||||
|
if (markerOptionsFragment != null) {
|
||||||
|
((MarkerOptionsBottomSheetDialogFragment) markerOptionsFragment).setListener(createMarkerOptionsFragmentListener());
|
||||||
|
}
|
||||||
|
|
||||||
View mainView = inflater.inflate(R.layout.fragment_map_markers_dialog, container);
|
View mainView = inflater.inflate(R.layout.fragment_map_markers_dialog, container);
|
||||||
|
|
||||||
Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.map_markers_toolbar);
|
Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.map_markers_toolbar);
|
||||||
|
@ -49,10 +56,13 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() {
|
final View optionsButton = mainView.findViewById(R.id.options_button);
|
||||||
|
optionsButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
Toast.makeText(getContext(), "Options", Toast.LENGTH_SHORT).show();
|
MarkerOptionsBottomSheetDialogFragment fragment = new MarkerOptionsBottomSheetDialogFragment();
|
||||||
|
fragment.setListener(createMarkerOptionsFragmentListener());
|
||||||
|
fragment.show(getChildFragmentManager(), MarkerOptionsBottomSheetDialogFragment.TAG);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -69,10 +79,12 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
case R.id.action_active:
|
case R.id.action_active:
|
||||||
((MapMarkersActiveFragment) adapter.getItem(0)).startLocationUpdate();
|
((MapMarkersActiveFragment) adapter.getItem(0)).startLocationUpdate();
|
||||||
viewPager.setCurrentItem(0);
|
viewPager.setCurrentItem(0);
|
||||||
|
optionsButton.setVisibility(View.VISIBLE);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_history:
|
case R.id.action_history:
|
||||||
((MapMarkersActiveFragment) adapter.getItem(0)).stopLocationUpdate();
|
((MapMarkersActiveFragment) adapter.getItem(0)).stopLocationUpdate();
|
||||||
viewPager.setCurrentItem(1);
|
viewPager.setCurrentItem(1);
|
||||||
|
optionsButton.setVisibility(View.GONE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -86,6 +98,36 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
return (OsmandApplication) getActivity().getApplication();
|
return (OsmandApplication) getActivity().getApplication();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private MarkerOptionsFragmentListener createMarkerOptionsFragmentListener() {
|
||||||
|
return new MarkerOptionsFragmentListener() {
|
||||||
|
@Override
|
||||||
|
public void sortByOnClick() {
|
||||||
|
Toast.makeText(getContext(), "Sort by", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showDirectionOnClick() {
|
||||||
|
Toast.makeText(getContext(), "Show direction", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildRouteOnClick() {
|
||||||
|
Toast.makeText(getContext(), "Build route", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveAsNewTrackOnClick() {
|
||||||
|
Toast.makeText(getContext(), "Save as new track", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void moveAllToHistoryOnClick() {
|
||||||
|
Toast.makeText(getContext(), "Move all to history", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean showInstance(@NonNull MapActivity mapActivity) {
|
public static boolean showInstance(@NonNull MapActivity mapActivity) {
|
||||||
try {
|
try {
|
||||||
if (mapActivity.isActivityDestroyed()) {
|
if (mapActivity.isActivityDestroyed()) {
|
||||||
|
|
|
@ -3,18 +3,26 @@ package net.osmand.plus.mapmarkers;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
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.TextView;
|
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.mapmarkers.adapters.MapMarkersHistoryAdapter;
|
||||||
|
|
||||||
public class MapMarkersHistoryFragment extends Fragment {
|
public class MapMarkersHistoryFragment extends Fragment {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
TextView textView = new TextView(getContext());
|
final RecyclerView recyclerView = new RecyclerView(getContext());
|
||||||
textView.setText("history fragment");
|
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
return textView;
|
final MapActivity mapActivity = (MapActivity) getActivity();
|
||||||
|
|
||||||
|
recyclerView.setAdapter(new MapMarkersHistoryAdapter(mapActivity.getMyApplication()));
|
||||||
|
|
||||||
|
return recyclerView;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,169 @@
|
||||||
|
package net.osmand.plus.mapmarkers;
|
||||||
|
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewTreeObserver;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.base.BottomSheetDialogFragment;
|
||||||
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
|
|
||||||
|
public class MarkerOptionsBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||||
|
|
||||||
|
public final static String TAG = "MarkerOptionsBottomSheetDialogFragment";
|
||||||
|
|
||||||
|
private MarkerOptionsFragmentListener listener;
|
||||||
|
private boolean portrait;
|
||||||
|
|
||||||
|
public void setListener(MarkerOptionsFragmentListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
||||||
|
|
||||||
|
final View mainView = inflater.inflate(R.layout.fragment_marker_options_bottom_sheet_dialog, container);
|
||||||
|
if (portrait) {
|
||||||
|
AndroidUtils.setBackground(getActivity(), mainView, false, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||||
|
}
|
||||||
|
|
||||||
|
((ImageView) mainView.findViewById(R.id.sort_by_icon))
|
||||||
|
.setImageDrawable(getIcon(R.drawable.ic_sort_waypoint_dark, R.color.on_map_icon_color));
|
||||||
|
((ImageView) mainView.findViewById(R.id.show_direction_icon))
|
||||||
|
.setImageDrawable(getIcon(R.drawable.ic_sort_waypoint_dark, R.color.on_map_icon_color));
|
||||||
|
((ImageView) mainView.findViewById(R.id.build_route_icon))
|
||||||
|
.setImageDrawable(getIcon(R.drawable.map_directions, R.color.on_map_icon_color));
|
||||||
|
((ImageView) mainView.findViewById(R.id.save_as_new_track_icon))
|
||||||
|
.setImageDrawable(getIcon(R.drawable.ic_action_polygom_dark, R.color.on_map_icon_color));
|
||||||
|
((ImageView) mainView.findViewById(R.id.move_all_to_history_icon))
|
||||||
|
.setImageDrawable(getIcon(R.drawable.ic_action_history2, R.color.on_map_icon_color));
|
||||||
|
|
||||||
|
((TextView) mainView.findViewById(R.id.show_direction_text_view)).setText("Top bar");
|
||||||
|
|
||||||
|
mainView.findViewById(R.id.sort_by_row).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (listener != null) {
|
||||||
|
listener.sortByOnClick();
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mainView.findViewById(R.id.show_direction_row).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (listener != null) {
|
||||||
|
listener.showDirectionOnClick();
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mainView.findViewById(R.id.build_route_row).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (listener != null) {
|
||||||
|
listener.buildRouteOnClick();
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mainView.findViewById(R.id.save_as_new_track_row).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (listener != null) {
|
||||||
|
listener.saveAsNewTrackOnClick();
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mainView.findViewById(R.id.move_all_to_history_row).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (listener != null) {
|
||||||
|
listener.moveAllToHistoryOnClick();
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final int screenHeight = AndroidUtils.getScreenHeight(getActivity());
|
||||||
|
final int statusBarHeight = AndroidUtils.getStatusBarHeight(getActivity());
|
||||||
|
final int navBarHeight = AndroidUtils.getNavBarHeight(getActivity());
|
||||||
|
|
||||||
|
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
final View scrollView = mainView.findViewById(R.id.marker_options_scroll_view);
|
||||||
|
int scrollViewHeight = scrollView.getHeight();
|
||||||
|
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
|
||||||
|
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.measure_distance_bottom_sheet_cancel_button_height);
|
||||||
|
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
|
||||||
|
if (scrollViewHeight > spaceForScrollView) {
|
||||||
|
scrollView.getLayoutParams().height = spaceForScrollView;
|
||||||
|
scrollView.requestLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!portrait) {
|
||||||
|
if (screenHeight - statusBarHeight - mainView.getHeight()
|
||||||
|
>= AndroidUtils.dpToPx(getActivity(), 8)) {
|
||||||
|
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||||
|
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
||||||
|
} else {
|
||||||
|
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||||
|
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
|
obs.removeOnGlobalLayoutListener(this);
|
||||||
|
} else {
|
||||||
|
obs.removeGlobalOnLayoutListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return mainView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
if (!portrait) {
|
||||||
|
final Window window = getDialog().getWindow();
|
||||||
|
WindowManager.LayoutParams params = window.getAttributes();
|
||||||
|
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
||||||
|
window.setAttributes(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MarkerOptionsFragmentListener {
|
||||||
|
|
||||||
|
void sortByOnClick();
|
||||||
|
|
||||||
|
void showDirectionOnClick();
|
||||||
|
|
||||||
|
void buildRouteOnClick();
|
||||||
|
|
||||||
|
void saveAsNewTrackOnClick();
|
||||||
|
|
||||||
|
void moveAllToHistoryOnClick();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
package net.osmand.plus.mapmarkers.adapters;
|
||||||
|
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import net.osmand.plus.IconsCache;
|
||||||
|
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MapMarkersHistoryAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder> {
|
||||||
|
|
||||||
|
private OsmandApplication app;
|
||||||
|
private List<MapMarker> markers;
|
||||||
|
|
||||||
|
public MapMarkersHistoryAdapter(OsmandApplication app) {
|
||||||
|
this.app = app;
|
||||||
|
markers = app.getMapMarkersHelper().getMapMarkersHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MapMarkerItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
||||||
|
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false);
|
||||||
|
return new MapMarkerItemViewHolder(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(MapMarkerItemViewHolder holder, int pos) {
|
||||||
|
IconsCache iconsCache = app.getIconsCache();
|
||||||
|
MapMarker marker = markers.get(pos);
|
||||||
|
|
||||||
|
holder.iconReorder.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
int color = MapMarker.getColorId(marker.colorIndex);
|
||||||
|
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, color));
|
||||||
|
|
||||||
|
holder.title.setText(marker.getName(app));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return markers.size();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue