From 137ce99023412d541d6ed5fc703b6fb0baca28ae Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 8 Aug 2017 13:22:14 +0300 Subject: [PATCH 1/3] Add fab for add line action --- OsmAnd/res/layout/points_tree.xml | 42 ++++++++++++++++++- OsmAnd/res/layout/track_segments_tree.xml | 42 ++++++++++++++++++- OsmAnd/res/values/strings.xml | 1 + .../osmand/plus/activities/TrackActivity.java | 4 ++ .../plus/myplaces/TrackPointFragment.java | 19 +++++++++ .../plus/myplaces/TrackSegmentFragment.java | 19 +++++++++ 6 files changed, 125 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/layout/points_tree.xml b/OsmAnd/res/layout/points_tree.xml index 296e09695b..6d9af2a4ab 100644 --- a/OsmAnd/res/layout/points_tree.xml +++ b/OsmAnd/res/layout/points_tree.xml @@ -27,7 +27,7 @@ android:layout_alignParentRight="true" android:layout_margin="16dp" android:contentDescription="@string/quick_action_new_action" - android:src="@drawable/ic_action_plus" + tools:src="@drawable/ic_action_plus" app:backgroundTint="@color/dashboard_blue" app:fabSize="normal"/> @@ -109,4 +109,44 @@ + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/track_segments_tree.xml b/OsmAnd/res/layout/track_segments_tree.xml index df56f12a0f..ee8115cfe9 100644 --- a/OsmAnd/res/layout/track_segments_tree.xml +++ b/OsmAnd/res/layout/track_segments_tree.xml @@ -23,7 +23,7 @@ android:layout_alignParentRight="true" android:layout_margin="16dp" android:contentDescription="@string/quick_action_new_action" - android:src="@drawable/ic_action_plus" + tools:src="@drawable/ic_action_plus" app:backgroundTint="@color/dashboard_blue" app:fabSize="normal"/> @@ -104,4 +104,44 @@ android:text="@string/add_route_point"/> + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index a32a2ac34c..6ed9ecce85 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -2665,6 +2665,7 @@ Retry Add Route Point Add Waypoint + Add Line Save GPX Waypoint Save Route Point Waypoint 1 diff --git a/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java b/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java index ff238d8b59..1fb2824599 100644 --- a/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java @@ -108,6 +108,10 @@ public class TrackActivity extends TabActivity { } } + public void addLine() { + + } + protected void setGpxDataItem(GpxDataItem gpxDataItem) { this.gpxDataItem = gpxDataItem; } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java index 84e293891c..8cbd52b5d6 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java @@ -99,6 +99,8 @@ public class TrackPointFragment extends OsmandExpandableListFragment { private View waypointTextLayout; private FloatingActionButton routePointFab; private View routePointTextLayout; + private FloatingActionButton lineFab; + private View lineTextLayout; @Override public void onCreate(@Nullable Bundle savedInstanceState) { @@ -166,6 +168,15 @@ public class TrackPointFragment extends OsmandExpandableListFragment { }); routePointTextLayout = view.findViewById(R.id.route_text_layout); + lineFab = (FloatingActionButton) view.findViewById(R.id.line_fab); + lineFab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + addLine(); + } + }); + lineTextLayout = view.findViewById(R.id.line_text_layout); + TextView tv = new TextView(getActivity()); tv.setText(R.string.none_selected_gpx); tv.setTextSize(24); @@ -181,12 +192,18 @@ public class TrackPointFragment extends OsmandExpandableListFragment { getTrackActivity().addPoint(pointDescription); } + private void addLine() { + getTrackActivity().addLine(); + } + private void openMenu() { menuFab.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_action_remove_dark)); waypointFab.setVisibility(View.VISIBLE); waypointTextLayout.setVisibility(View.VISIBLE); routePointFab.setVisibility(View.VISIBLE); routePointTextLayout.setVisibility(View.VISIBLE); + lineFab.setVisibility(View.VISIBLE); + lineTextLayout.setVisibility(View.VISIBLE); menuOpened = true; } @@ -196,6 +213,8 @@ public class TrackPointFragment extends OsmandExpandableListFragment { waypointTextLayout.setVisibility(View.GONE); routePointFab.setVisibility(View.GONE); routePointTextLayout.setVisibility(View.GONE); + lineFab.setVisibility(View.GONE); + lineTextLayout.setVisibility(View.GONE); menuOpened = false; } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java index 6e6ad2846a..a66ec133d4 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java @@ -148,6 +148,8 @@ public class TrackSegmentFragment extends OsmAndListFragment { private View waypointTextLayout; private FloatingActionButton routePointFab; private View routePointTextLayout; + private FloatingActionButton lineFab; + private View lineTextLayout; @Override public void onCreate(@Nullable Bundle savedInstanceState) { @@ -209,6 +211,15 @@ public class TrackSegmentFragment extends OsmAndListFragment { }); routePointTextLayout = view.findViewById(R.id.route_text_layout); + lineFab = (FloatingActionButton) view.findViewById(R.id.line_fab); + lineFab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + addLine(); + } + }); + lineTextLayout = view.findViewById(R.id.line_text_layout); + paint = new Paint(); paint.setStyle(Paint.Style.STROKE); paint.setAntiAlias(true); @@ -236,12 +247,18 @@ public class TrackSegmentFragment extends OsmAndListFragment { getTrackActivity().addPoint(pointDescription); } + private void addLine() { + getTrackActivity().addLine(); + } + private void openMenu() { menuFab.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_action_remove_dark)); waypointFab.setVisibility(View.VISIBLE); waypointTextLayout.setVisibility(View.VISIBLE); routePointFab.setVisibility(View.VISIBLE); routePointTextLayout.setVisibility(View.VISIBLE); + lineFab.setVisibility(View.VISIBLE); + lineTextLayout.setVisibility(View.VISIBLE); menuOpened = true; } @@ -251,6 +268,8 @@ public class TrackSegmentFragment extends OsmAndListFragment { waypointTextLayout.setVisibility(View.GONE); routePointFab.setVisibility(View.GONE); routePointTextLayout.setVisibility(View.GONE); + lineFab.setVisibility(View.GONE); + lineTextLayout.setVisibility(View.GONE); menuOpened = false; } From a6381c86efa0b1db939a832989dae45fa0c8e40d Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 8 Aug 2017 13:28:19 +0300 Subject: [PATCH 2/3] Close fab menu on scroll in overview screen --- .../osmand/plus/myplaces/TrackSegmentFragment.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java index a66ec133d4..ba65930194 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java @@ -160,6 +160,20 @@ public class TrackSegmentFragment extends OsmAndListFragment { @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); + getListView().setOnScrollListener(new AbsListView.OnScrollListener() { + @Override + public void onScrollStateChanged(AbsListView absListView, int i) { + if (i == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) { + if (menuOpened) { + closeMenu(); + } + } + } + + @Override + public void onScroll(AbsListView absListView, int i, int i1, int i2) { + } + }); getListView().setBackgroundColor(getResources().getColor( getMyApplication().getSettings().isLightContent() ? R.color.ctx_menu_info_view_bg_light : R.color.ctx_menu_info_view_bg_dark)); From 59ed65326ec29da867f29ab4f26bb70683be235a Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 8 Aug 2017 13:29:22 +0300 Subject: [PATCH 3/3] Fix fab drawables --- OsmAnd/res/layout/points_tree.xml | 2 +- OsmAnd/res/layout/track_segments_tree.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/layout/points_tree.xml b/OsmAnd/res/layout/points_tree.xml index 6d9af2a4ab..fabb898d62 100644 --- a/OsmAnd/res/layout/points_tree.xml +++ b/OsmAnd/res/layout/points_tree.xml @@ -27,7 +27,7 @@ android:layout_alignParentRight="true" android:layout_margin="16dp" android:contentDescription="@string/quick_action_new_action" - tools:src="@drawable/ic_action_plus" + android:src="@drawable/ic_action_plus" app:backgroundTint="@color/dashboard_blue" app:fabSize="normal"/> diff --git a/OsmAnd/res/layout/track_segments_tree.xml b/OsmAnd/res/layout/track_segments_tree.xml index ee8115cfe9..b084bde401 100644 --- a/OsmAnd/res/layout/track_segments_tree.xml +++ b/OsmAnd/res/layout/track_segments_tree.xml @@ -23,7 +23,7 @@ android:layout_alignParentRight="true" android:layout_margin="16dp" android:contentDescription="@string/quick_action_new_action" - tools:src="@drawable/ic_action_plus" + android:src="@drawable/ic_action_plus" app:backgroundTint="@color/dashboard_blue" app:fabSize="normal"/>