quick actions button and widget on map
This commit is contained in:
parent
8b16be751d
commit
def51a0dc2
7 changed files with 139 additions and 15 deletions
|
@ -2,10 +2,22 @@
|
|||
<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:layout_height="match_parent"
|
||||
android:layout_gravity="bottom"
|
||||
android:animateLayoutChanges="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<net.osmand.plus.quickaction.QuickActionsWidget
|
||||
android:id="@+id/quick_action_widget"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -232,6 +244,16 @@
|
|||
android:layout_marginLeft="@dimen/map_button_spacing_land"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/map_quick_actions_button"
|
||||
android:layout_width="@dimen/map_button_size"
|
||||
android:layout_height="@dimen/map_button_size"
|
||||
android:background="@drawable/btn_circle_blue"
|
||||
android:contentDescription="@string/zoomIn"
|
||||
android:visibility="gone"
|
||||
android:layout_marginBottom="@dimen/map_button_spacing"
|
||||
tools:src="@drawable/ic_action_test_light"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/map_zoom_in_button"
|
||||
android:layout_width="@dimen/map_button_size"
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
<RelativeLayout
|
||||
android:id="@+id/MapHudButtonsOverlay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
@ -47,7 +47,7 @@
|
|||
<include layout="@layout/map_hud_top"/>
|
||||
|
||||
<include layout="@layout/map_hud_bottom"/>
|
||||
</FrameLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/progress_layout_external"
|
||||
|
|
|
@ -2,10 +2,22 @@
|
|||
<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:layout_height="match_parent"
|
||||
android:layout_gravity="bottom"
|
||||
android:animateLayoutChanges="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<net.osmand.plus.quickaction.QuickActionsWidget
|
||||
android:id="@+id/quick_action_widget"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
@ -164,6 +176,16 @@
|
|||
android:layout_marginLeft="@dimen/map_button_spacing"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/map_quick_actions_button"
|
||||
android:layout_width="@dimen/map_button_size"
|
||||
android:layout_height="@dimen/map_button_size"
|
||||
android:background="@drawable/btn_circle_blue"
|
||||
android:contentDescription="@string/zoomIn"
|
||||
android:visibility="gone"
|
||||
android:layout_marginBottom="@dimen/map_button_spacing"
|
||||
tools:src="@drawable/ic_action_test_light"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/map_zoom_in_button"
|
||||
android:layout_width="@dimen/map_button_size"
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:grid="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="100dp"
|
||||
grid:layout_columnWeight="1">
|
||||
xmlns:grid="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="100dp"
|
||||
android:animateLayoutChanges="true"
|
||||
android:background="?android:selectableItemBackground"
|
||||
grid:layout_columnWeight="1">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:foreground="?android:selectableItemBackground"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
@ -20,7 +21,7 @@
|
|||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="24dp"
|
||||
android:scaleType="centerInside" />
|
||||
android:scaleType="centerInside"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
|
@ -33,7 +34,7 @@
|
|||
android:maxLines="2"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
tools:text="Add marker" />
|
||||
tools:text="Add marker"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ import net.osmand.plus.views.ImpassableRoadsLayer;
|
|||
import net.osmand.plus.views.MapControlsLayer;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.MapMarkersLayer;
|
||||
import net.osmand.plus.views.MapQuickActionLayer;
|
||||
import net.osmand.plus.views.MapTextLayer;
|
||||
import net.osmand.plus.views.MapTileLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
@ -80,6 +81,7 @@ public class MapActivityLayers {
|
|||
private MapTextLayer mapTextLayer;
|
||||
private ContextMenuLayer contextMenuLayer;
|
||||
private MapControlsLayer mapControlsLayer;
|
||||
private MapQuickActionLayer mapQuickActionLayer;
|
||||
private DownloadedRegionsLayer downloadedRegionsLayer;
|
||||
private MapWidgetRegistry mapWidgetRegistry;
|
||||
|
||||
|
@ -160,6 +162,9 @@ public class MapActivityLayers {
|
|||
// 11. route info layer
|
||||
mapControlsLayer = new MapControlsLayer(activity);
|
||||
mapView.addLayer(mapControlsLayer, 11);
|
||||
// 12. quick actions layer
|
||||
mapQuickActionLayer = new MapQuickActionLayer(activity);
|
||||
mapView.addLayer(mapQuickActionLayer, 12);
|
||||
|
||||
transparencyListener = new StateChangedListener<Integer>() {
|
||||
@Override
|
||||
|
@ -579,6 +584,10 @@ public class MapActivityLayers {
|
|||
return mapControlsLayer;
|
||||
}
|
||||
|
||||
public MapQuickActionLayer getMapQuickActionLayer() {
|
||||
return mapQuickActionLayer;
|
||||
}
|
||||
|
||||
public MapMarkersLayer getMapMarkersLayer() {
|
||||
return mapMarkersLayer;
|
||||
}
|
||||
|
|
68
OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java
Normal file
68
OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java
Normal file
|
@ -0,0 +1,68 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.quickaction.QuickActionFactory;
|
||||
import net.osmand.plus.quickaction.QuickActionsWidget;
|
||||
|
||||
/**
|
||||
* Created by okorsun on 23.12.16.
|
||||
*/
|
||||
|
||||
public class MapQuickActionLayer extends OsmandMapLayer {
|
||||
|
||||
private final MapActivity mapActivity;
|
||||
private final OsmandApplication app;
|
||||
private final OsmandSettings settings;
|
||||
|
||||
private ImageButton quickActionButton;
|
||||
private QuickActionsWidget quickActionsWidget;
|
||||
|
||||
public MapQuickActionLayer(MapActivity activity) {
|
||||
this.mapActivity = activity;
|
||||
app = activity.getMyApplication();
|
||||
settings = activity.getMyApplication().getSettings();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initLayer(OsmandMapTileView view) {
|
||||
quickActionsWidget = (QuickActionsWidget) mapActivity.findViewById(R.id.quick_action_widget);
|
||||
quickActionButton = (ImageButton) mapActivity.findViewById(R.id.map_quick_actions_button);
|
||||
quickActionButton.setVisibility(settings.QUICK_ACTION.get() ? View.VISIBLE : View.GONE);
|
||||
quickActionButton.setImageResource(R.drawable.ic_action_quit_dark);
|
||||
quickActionButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
quickActionsWidget.setVisibility(quickActionsWidget.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
|
||||
quickActionsWidget.setActions(QuickActionFactory.parseActiveActionsList(settings.QUICK_ACTION_LIST.get()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void refreshLayer() {
|
||||
quickActionButton.setVisibility(settings.QUICK_ACTION.get() ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyLayer() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean drawInScreenPixels() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ import net.osmand.plus.activities.MapActivity;
|
|||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||
import net.osmand.plus.quickaction.QuickActionListFragment;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.MapQuickActionLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.widgets.IconPopupMenu;
|
||||
|
@ -421,16 +422,17 @@ public class MapWidgetRegistry {
|
|||
int position,
|
||||
boolean visible) {
|
||||
|
||||
MapInfoLayer mil = mapActivity.getMapLayers().getMapInfoLayer();
|
||||
settings.QUICK_ACTION.set(visible);
|
||||
|
||||
MapQuickActionLayer mil = mapActivity.getMapLayers().getMapQuickActionLayer();
|
||||
if (mil != null) {
|
||||
mil.recreateControls();
|
||||
mil.refreshLayer();
|
||||
}
|
||||
ContextMenuItem item = adapter.getItem(position);
|
||||
item.setSelected(visible);
|
||||
item.setColorRes(visible ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
settings.QUICK_ACTION.set(visible);
|
||||
}
|
||||
})
|
||||
.createItem());
|
||||
|
|
Loading…
Reference in a new issue