Fabs styling

This commit is contained in:
PavelRatushny 2017-08-10 19:09:52 +03:00
parent 1b821e8ab7
commit eba9b73841
5 changed files with 185 additions and 117 deletions

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/MainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -19,11 +19,19 @@
android:drawSelectorOnTop="false"
android:groupIndicator="@android:color/transparent"/>
<View
android:id="@+id/overlay_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white_80_transparent"
android:visibility="gone"/>
<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_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:contentDescription="@string/quick_action_new_action"
@ -36,36 +44,40 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/menu_fab"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="24dp"
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:backgroundTint="@color/fab_green"
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_above="@id/menu_fab"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_toLeftOf="@id/waypoint_fab"
android:layout_toStartOf="@id/waypoint_fab"
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:layout_gravity="center_vertical"
android:background="?attr/bg_card"
android:gravity="center_vertical"
android:text="@string/add_waypoint"/>
android:padding="8dp"
android:text="@string/add_waypoint"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"/>
</FrameLayout>
@ -74,38 +86,42 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/waypoint_fab"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="16dp"
android:layout_marginEnd="24dp"
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:backgroundTint="@color/fab_green"
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_above="@id/waypoint_fab"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_toLeftOf="@id/route_fab"
android:layout_toStartOf="@id/route_fab"
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:layout_gravity="center_vertical"
android:background="?attr/bg_card"
android:gravity="center_vertical"
android:text="@string/add_route_point"/>
android:padding="8dp"
android:text="@string/add_route_point"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"/>
</FrameLayout>
@ -114,38 +130,42 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/route_fab"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="16dp"
android:layout_marginEnd="24dp"
android:layout_marginRight="24dp"
android:contentDescription="@string/quick_action_new_action"
android:src="@drawable/ic_action_polygom_dark"
android:visibility="gone"
app:backgroundTint="@color/dashboard_blue"
app:backgroundTint="@color/fab_green"
app:fabSize="mini"
tools:visibility="visible"/>
<FrameLayout
android:id="@+id/line_text_layout"
android:layout_toLeftOf="@id/line_fab"
android:layout_toStartOf="@id/line_fab"
android:layout_above="@id/route_fab"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_above="@id/route_fab"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_toLeftOf="@id/line_fab"
android:layout_toStartOf="@id/line_fab"
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/line_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="?attr/bg_card"
android:gravity="center_vertical"
android:text="@string/add_line"/>
android:padding="8dp"
android:text="@string/add_line"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"/>
</FrameLayout>

View file

@ -1,10 +1,10 @@
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
@ -15,11 +15,19 @@
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"/>
<View
android:id="@+id/overlay_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white_80_transparent"
android:visibility="gone"/>
<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_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:contentDescription="@string/quick_action_new_action"
@ -32,36 +40,40 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/menu_fab"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="24dp"
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:backgroundTint="@color/fab_green"
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_above="@id/menu_fab"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_toLeftOf="@id/waypoint_fab"
android:layout_toStartOf="@id/waypoint_fab"
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:layout_gravity="center_vertical"
android:background="?attr/bg_card"
android:gravity="center_vertical"
android:text="@string/add_waypoint"/>
android:padding="8dp"
android:text="@string/add_waypoint"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"/>
</FrameLayout>
@ -70,38 +82,42 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/waypoint_fab"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="16dp"
android:layout_marginEnd="24dp"
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:backgroundTint="@color/fab_green"
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_above="@id/waypoint_fab"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_toLeftOf="@id/route_fab"
android:layout_toStartOf="@id/route_fab"
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:layout_gravity="center_vertical"
android:background="?attr/bg_card"
android:gravity="center_vertical"
android:text="@string/add_route_point"/>
android:padding="8dp"
android:text="@string/add_route_point"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"/>
</FrameLayout>
@ -110,38 +126,43 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/route_fab"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="16dp"
android:layout_marginEnd="24dp"
android:layout_marginRight="24dp"
android:contentDescription="@string/quick_action_new_action"
android:src="@drawable/ic_action_polygom_dark"
android:visibility="gone"
app:backgroundTint="@color/dashboard_blue"
app:backgroundTint="@color/fab_green"
app:fabSize="mini"
tools:visibility="visible"/>
<FrameLayout
android:id="@+id/line_text_layout"
android:layout_toLeftOf="@id/line_fab"
android:layout_toStartOf="@id/line_fab"
android:layout_above="@id/route_fab"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_above="@id/route_fab"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_toLeftOf="@id/line_fab"
android:layout_toStartOf="@id/line_fab"
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/line_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="?attr/bg_card"
android:gravity="center_vertical"
android:text="@string/add_line"/>
android:padding="8dp"
android:text="@string/add_line"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"/>
</FrameLayout>
</RelativeLayout>

View file

@ -257,4 +257,6 @@
<color name="map_background_color_light">#fafafa</color>
<color name="map_background_color_dark">#101821</color>
<color name="fab_green">#46bd2a</color>
</resources>

View file

@ -57,7 +57,6 @@ import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.OsmandExpandableListFragment;
import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint;
import net.osmand.util.Algorithms;
import java.io.File;
@ -101,6 +100,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
private View routePointTextLayout;
private FloatingActionButton lineFab;
private View lineTextLayout;
private View overlayView;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
@ -130,51 +130,63 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
: R.color.ctx_menu_info_view_bg_dark));
}
private View.OnClickListener onFabClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.menu_fab:
if (menuOpened) {
closeMenu();
} else {
openMenu();
private void hideTransparentOverlay() {
overlayView.setVisibility(View.GONE);
}
break;
case R.id.waypoint_fab:
PointDescription pointWptDescription = new PointDescription(PointDescription.POINT_TYPE_WPT, getString(R.string.add_waypoint));
addPoint(pointWptDescription);
break;
case R.id.route_fab:
PointDescription pointRteDescription = new PointDescription(PointDescription.POINT_TYPE_RTE, getString(R.string.add_route_point));
addPoint(pointRteDescription);
break;
case R.id.line_fab:
addLine();
break;
private void showTransparentOverlay() {
overlayView.setVisibility(View.VISIBLE);
}
}
};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.points_tree, container, false);
View view = inflater.inflate(R.layout.track_points_tree, container, false);
ExpandableListView listView = (ExpandableListView) view.findViewById(android.R.id.list);
setHasOptionsMenu(true);
overlayView = view.findViewById(R.id.overlay_view);
menuFab = (FloatingActionButton) view.findViewById(R.id.menu_fab);
menuFab.setOnClickListener(onFabClickListener);
menuFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (menuOpened) {
hideTransparentOverlay();
closeMenu();
} else {
showTransparentOverlay();
openMenu();
}
}
});
waypointFab = (FloatingActionButton) view.findViewById(R.id.waypoint_fab);
waypointFab.setOnClickListener(onFabClickListener);
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(onFabClickListener);
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);
lineFab = (FloatingActionButton) view.findViewById(R.id.line_fab);
lineFab.setOnClickListener(onFabClickListener);
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());

View file

@ -150,6 +150,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
private View routePointTextLayout;
private FloatingActionButton lineFab;
private View lineTextLayout;
private View overlayView;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
@ -179,31 +180,13 @@ public class TrackSegmentFragment extends OsmAndListFragment {
: R.color.ctx_menu_info_view_bg_dark));
}
private View.OnClickListener onFabClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.menu_fab:
if (menuOpened) {
closeMenu();
} else {
openMenu();
private void hideTransparentOverlay() {
overlayView.setVisibility(View.GONE);
}
break;
case R.id.waypoint_fab:
PointDescription pointWptDescription = new PointDescription(PointDescription.POINT_TYPE_WPT, getString(R.string.add_waypoint));
addPoint(pointWptDescription);
break;
case R.id.route_fab:
PointDescription pointRteDescription = new PointDescription(PointDescription.POINT_TYPE_RTE, getString(R.string.add_route_point));
addPoint(pointRteDescription);
break;
case R.id.line_fab:
addLine();
break;
private void showTransparentOverlay() {
overlayView.setVisibility(View.VISIBLE);
}
}
};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -219,19 +202,49 @@ public class TrackSegmentFragment extends OsmAndListFragment {
tv.setTextSize(24);
listView.setEmptyView(tv);
overlayView = view.findViewById(R.id.overlay_view);
menuFab = (FloatingActionButton) view.findViewById(R.id.menu_fab);
menuFab.setOnClickListener(onFabClickListener);
menuFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (menuOpened) {
hideTransparentOverlay();
closeMenu();
} else {
showTransparentOverlay();
openMenu();
}
}
});
waypointFab = (FloatingActionButton) view.findViewById(R.id.waypoint_fab);
waypointFab.setOnClickListener(onFabClickListener);
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(onFabClickListener);
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);
lineFab = (FloatingActionButton) view.findViewById(R.id.line_fab);
lineFab.setOnClickListener(onFabClickListener);
lineFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
addLine();
}
});
lineTextLayout = view.findViewById(R.id.line_text_layout);
paint = new Paint();