Add fabs on overview screen
This commit is contained in:
parent
1f4edccf1f
commit
e32243a56e
5 changed files with 197 additions and 21 deletions
|
@ -5,8 +5,7 @@
|
||||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/MainLayout"
|
android:id="@+id/MainLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<ExpandableListView
|
<ExpandableListView
|
||||||
android:id="@android:id/list"
|
android:id="@android:id/list"
|
||||||
|
|
107
OsmAnd/res/layout/track_segments_tree.xml
Normal file
107
OsmAnd/res/layout/track_segments_tree.xml
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@android:id/list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginLeft="0dp"
|
||||||
|
android:layout_marginRight="0dp"
|
||||||
|
android:layout_marginTop="0dp"/>
|
||||||
|
|
||||||
|
<android.support.design.widget.FloatingActionButton
|
||||||
|
android:id="@+id/menu_fab"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:contentDescription="@string/quick_action_new_action"
|
||||||
|
android:src="@drawable/ic_action_plus"
|
||||||
|
app:backgroundTint="@color/dashboard_blue"
|
||||||
|
app:fabSize="normal"/>
|
||||||
|
|
||||||
|
<android.support.design.widget.FloatingActionButton
|
||||||
|
android:id="@+id/waypoint_fab"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_above="@id/menu_fab"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_marginRight="24dp"
|
||||||
|
android:contentDescription="@string/quick_action_new_action"
|
||||||
|
android:src="@drawable/ic_action_marker_dark"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:backgroundTint="@color/dashboard_blue"
|
||||||
|
app:fabSize="mini"
|
||||||
|
tools:visibility="visible"/>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/waypoint_text_layout"
|
||||||
|
android:layout_toLeftOf="@id/waypoint_fab"
|
||||||
|
android:layout_toStartOf="@id/waypoint_fab"
|
||||||
|
android:layout_above="@id/menu_fab"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:id="@+id/waypoint_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:text="@string/add_waypoint"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<android.support.design.widget.FloatingActionButton
|
||||||
|
android:id="@+id/route_fab"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_above="@id/waypoint_fab"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:layout_marginRight="24dp"
|
||||||
|
android:contentDescription="@string/quick_action_new_action"
|
||||||
|
android:src="@drawable/ic_action_markers_dark"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:backgroundTint="@color/dashboard_blue"
|
||||||
|
app:fabSize="mini"
|
||||||
|
tools:visibility="visible"/>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/route_text_layout"
|
||||||
|
android:layout_toLeftOf="@id/route_fab"
|
||||||
|
android:layout_toStartOf="@id/route_fab"
|
||||||
|
android:layout_above="@id/waypoint_fab"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:id="@+id/route_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:text="@string/add_route_point"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
</RelativeLayout>
|
|
@ -13,6 +13,8 @@ import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||||
import net.osmand.plus.GPXUtilities;
|
import net.osmand.plus.GPXUtilities;
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
|
@ -21,11 +23,13 @@ import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
import net.osmand.plus.OsmAndAppCustomization;
|
import net.osmand.plus.OsmAndAppCustomization;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||||
import net.osmand.plus.myplaces.SplitSegmentFragment;
|
import net.osmand.plus.myplaces.SplitSegmentFragment;
|
||||||
import net.osmand.plus.myplaces.TrackPointFragment;
|
import net.osmand.plus.myplaces.TrackPointFragment;
|
||||||
import net.osmand.plus.myplaces.TrackSegmentFragment;
|
import net.osmand.plus.myplaces.TrackSegmentFragment;
|
||||||
|
import net.osmand.plus.views.AddGpxPointBottomSheetHelper;
|
||||||
import net.osmand.plus.views.controls.PagerSlidingTabStrip;
|
import net.osmand.plus.views.controls.PagerSlidingTabStrip;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -39,6 +43,7 @@ public class TrackActivity extends TabActivity {
|
||||||
public static final String OPEN_POINTS_TAB = "OPEN_POINTS_TAB";
|
public static final String OPEN_POINTS_TAB = "OPEN_POINTS_TAB";
|
||||||
public static final String CURRENT_RECORDING = "CURRENT_RECORDING";
|
public static final String CURRENT_RECORDING = "CURRENT_RECORDING";
|
||||||
protected List<WeakReference<Fragment>> fragList = new ArrayList<>();
|
protected List<WeakReference<Fragment>> fragList = new ArrayList<>();
|
||||||
|
private OsmandApplication app;
|
||||||
protected PagerSlidingTabStrip slidingTabLayout;
|
protected PagerSlidingTabStrip slidingTabLayout;
|
||||||
private File file = null;
|
private File file = null;
|
||||||
private GPXFile gpxFile;
|
private GPXFile gpxFile;
|
||||||
|
@ -56,7 +61,8 @@ public class TrackActivity extends TabActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
((OsmandApplication) getApplication()).applyTheme(this);
|
this.app = getMyApplication();
|
||||||
|
app.applyTheme(this);
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
if (intent == null || (!intent.hasExtra(TRACK_FILE_NAME) &&
|
if (intent == null || (!intent.hasExtra(TRACK_FILE_NAME) &&
|
||||||
|
@ -83,6 +89,25 @@ public class TrackActivity extends TabActivity {
|
||||||
setContentView(R.layout.tab_content);
|
setContentView(R.layout.tab_content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addPoint(PointDescription pointDescription) {
|
||||||
|
Intent currentIntent = getIntent();
|
||||||
|
if (currentIntent != null) {
|
||||||
|
currentIntent.putExtra(TrackActivity.OPEN_POINTS_TAB, true);
|
||||||
|
}
|
||||||
|
final OsmandSettings settings = app.getSettings();
|
||||||
|
GPXFile gpx = getGpx();
|
||||||
|
LatLon location = settings.getLastKnownMapLocation();
|
||||||
|
if (gpx != null && location != null) {
|
||||||
|
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(),
|
||||||
|
settings.getLastKnownMapZoom(),
|
||||||
|
pointDescription,
|
||||||
|
false,
|
||||||
|
new AddGpxPointBottomSheetHelper.NewGpxPoint(gpx, pointDescription));
|
||||||
|
|
||||||
|
MapActivity.launchMapActivityMoveToTop(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void setGpxDataItem(GpxDataItem gpxDataItem) {
|
protected void setGpxDataItem(GpxDataItem gpxDataItem) {
|
||||||
this.gpxDataItem = gpxDataItem;
|
this.gpxDataItem = gpxDataItem;
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,22 +178,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPoint(PointDescription pointDescription) {
|
private void addPoint(PointDescription pointDescription) {
|
||||||
Intent currentIntent = getTrackActivity().getIntent();
|
getTrackActivity().addPoint(pointDescription);
|
||||||
if (currentIntent != null) {
|
|
||||||
currentIntent.putExtra(TrackActivity.OPEN_POINTS_TAB, true);
|
|
||||||
}
|
|
||||||
final OsmandSettings settings = app.getSettings();
|
|
||||||
GPXFile gpx = getGpx();
|
|
||||||
LatLon location = settings.getLastKnownMapLocation();
|
|
||||||
if (gpx != null && location != null) {
|
|
||||||
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(),
|
|
||||||
settings.getLastKnownMapZoom(),
|
|
||||||
pointDescription,
|
|
||||||
false,
|
|
||||||
new NewGpxPoint(gpx, pointDescription));
|
|
||||||
|
|
||||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openMenu() {
|
private void openMenu() {
|
||||||
|
|
|
@ -17,6 +17,7 @@ import android.os.Handler;
|
||||||
import android.support.annotation.ColorInt;
|
import android.support.annotation.ColorInt;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.view.MenuItemCompat;
|
import android.support.v4.view.MenuItemCompat;
|
||||||
import android.support.v4.view.PagerAdapter;
|
import android.support.v4.view.PagerAdapter;
|
||||||
|
@ -140,6 +141,12 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
private Bitmap mapBitmap;
|
private Bitmap mapBitmap;
|
||||||
private Bitmap mapTrackBitmap;
|
private Bitmap mapTrackBitmap;
|
||||||
private boolean chartClicked;
|
private boolean chartClicked;
|
||||||
|
private boolean menuOpened = false;
|
||||||
|
private FloatingActionButton menuFab;
|
||||||
|
private FloatingActionButton waypointFab;
|
||||||
|
private View waypointTextLayout;
|
||||||
|
private FloatingActionButton routePointFab;
|
||||||
|
private View routePointTextLayout;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
@ -158,8 +165,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
View view = getActivity().getLayoutInflater().inflate(R.layout.update_index, container, false);
|
View view = getActivity().getLayoutInflater().inflate(R.layout.track_segments_tree, container, false);
|
||||||
view.findViewById(R.id.header_layout).setVisibility(View.GONE);
|
|
||||||
|
|
||||||
ListView listView = (ListView) view.findViewById(android.R.id.list);
|
ListView listView = (ListView) view.findViewById(android.R.id.list);
|
||||||
listView.setDivider(null);
|
listView.setDivider(null);
|
||||||
|
@ -170,6 +176,38 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
tv.setTextSize(24);
|
tv.setTextSize(24);
|
||||||
listView.setEmptyView(tv);
|
listView.setEmptyView(tv);
|
||||||
|
|
||||||
|
menuFab = (FloatingActionButton) view.findViewById(R.id.menu_fab);
|
||||||
|
menuFab.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (menuOpened) {
|
||||||
|
closeMenu();
|
||||||
|
} else {
|
||||||
|
openMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
waypointFab = (FloatingActionButton) view.findViewById(R.id.waypoint_fab);
|
||||||
|
waypointFab.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_WPT, getString(R.string.add_waypoint));
|
||||||
|
addPoint(pointDescription);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
waypointTextLayout = view.findViewById(R.id.waypoint_text_layout);
|
||||||
|
|
||||||
|
routePointFab = (FloatingActionButton) view.findViewById(R.id.route_fab);
|
||||||
|
routePointFab.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_RTE, getString(R.string.add_route_point));
|
||||||
|
addPoint(pointDescription);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
routePointTextLayout = view.findViewById(R.id.route_text_layout);
|
||||||
|
|
||||||
paint = new Paint();
|
paint = new Paint();
|
||||||
paint.setStyle(Paint.Style.STROKE);
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
|
@ -188,6 +226,28 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addPoint(PointDescription pointDescription) {
|
||||||
|
getTrackActivity().addPoint(pointDescription);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
menuOpened = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void closeMenu() {
|
||||||
|
menuFab.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_action_plus));
|
||||||
|
waypointFab.setVisibility(View.GONE);
|
||||||
|
waypointTextLayout.setVisibility(View.GONE);
|
||||||
|
routePointFab.setVisibility(View.GONE);
|
||||||
|
routePointTextLayout.setVisibility(View.GONE);
|
||||||
|
menuOpened = false;
|
||||||
|
}
|
||||||
|
|
||||||
public TrackActivity getTrackActivity() {
|
public TrackActivity getTrackActivity() {
|
||||||
return (TrackActivity) getActivity();
|
return (TrackActivity) getActivity();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue