Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
2a65598135
8 changed files with 136 additions and 103 deletions
|
@ -2,10 +2,11 @@
|
|||
<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="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!--
|
||||
<net.osmand.plus.quickaction.QuickActionsWidget
|
||||
android:id="@+id/quick_action_widget"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -32,6 +33,7 @@
|
|||
tools:src="@drawable/ic_action_test_light"/>
|
||||
|
||||
</FrameLayout>
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/bottom_controls_container"
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
</FrameLayout>
|
||||
|
||||
<RelativeLayout
|
||||
<FrameLayout
|
||||
android:id="@+id/MapHudButtonsOverlay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
@ -47,7 +47,9 @@
|
|||
<include layout="@layout/map_hud_top"/>
|
||||
|
||||
<include layout="@layout/map_hud_bottom"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<include layout="@layout/map_hud_quick_actions"/>
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/progress_layout_external"
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
<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="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:orientation="vertical">
|
||||
|
||||
<net.osmand.plus.quickaction.QuickActionsWidget
|
||||
<!--<net.osmand.plus.quickaction.QuickActionsWidget
|
||||
android:id="@+id/quick_action_widget"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -32,7 +32,7 @@
|
|||
tools:visibility="visible"
|
||||
tools:src="@drawable/ic_action_test_light"/>
|
||||
|
||||
</FrameLayout>
|
||||
</FrameLayout>-->
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/bottom_controls_container"
|
||||
|
|
26
OsmAnd/res/layout/map_hud_quick_actions.xml
Normal file
26
OsmAnd/res/layout/map_hud_quick_actions.xml
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<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:layout_gravity="bottom|right"
|
||||
android:layout_marginBottom="196dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
tools:src="@drawable/ic_action_test_light"/>
|
||||
|
||||
<net.osmand.plus.quickaction.QuickActionsWidget
|
||||
android:id="@+id/quick_action_widget"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:visibility="visible"
|
||||
android:visibility="gone"/>
|
||||
</FrameLayout>
|
|
@ -173,6 +173,7 @@ public class MapActivityLayers {
|
|||
mapQuickActionLayer = new MapQuickActionLayer(activity, contextMenuLayer);
|
||||
mapView.addLayer(mapQuickActionLayer, 12);
|
||||
contextMenuLayer.setMapQuickActionLayer(mapQuickActionLayer);
|
||||
mapControlsLayer.setMapQuickActionLayer(mapQuickActionLayer);
|
||||
|
||||
transparencyListener = new StateChangedListener<Integer>() {
|
||||
@Override
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.graphics.drawable.Drawable;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.view.MotionEventCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
@ -278,9 +277,10 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
|
|||
}
|
||||
notifyItemRangeChanged(position, itemsList.size() - position);
|
||||
|
||||
if (itemsList.size() == 1){
|
||||
itemsList.remove(0);
|
||||
notifyItemRemoved(0);
|
||||
int lastPosition = itemsList.size() - 1;
|
||||
if (getItemViewType(lastPosition) == SCREEN_HEADER_TYPE){
|
||||
itemsList.remove(lastPosition);
|
||||
notifyItemRemoved(lastPosition);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -99,6 +99,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
private long lastZoom;
|
||||
private boolean hasTargets;
|
||||
private ContextMenuLayer contextMenuLayer;
|
||||
private MapQuickActionLayer mapQuickActionLayer;
|
||||
private boolean forceShowCompass;
|
||||
|
||||
public MapControlsLayer(MapActivity activity) {
|
||||
|
@ -395,9 +396,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
backToMenuButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mapActivity.getMapView().getLayerByClass(MapQuickActionLayer.class).setLayerState(true))
|
||||
return;
|
||||
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
if (dash) {
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD);
|
||||
|
@ -415,9 +413,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
routePlanButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mapActivity.getMapView().getLayerByClass(MapQuickActionLayer.class).setLayerState(true))
|
||||
return;
|
||||
|
||||
doRoute(false);
|
||||
}
|
||||
});
|
||||
|
@ -634,7 +629,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
boolean showRouteCalculationControls = routePlanningMode ||
|
||||
((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode);
|
||||
updateMyLocation(rh, dialogOpened);
|
||||
boolean showButtons = (showRouteCalculationControls || !routeFollowingMode) && !contextMenuLayer.isInChangeMarkerPositionMode();
|
||||
boolean showButtons = (showRouteCalculationControls || !routeFollowingMode) && !isInChangeMarkerPositionMode();
|
||||
//routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions);
|
||||
if (rh.isFollowingMode()) {
|
||||
routePlanningBtn.setIconResId(R.drawable.map_start_navigation);
|
||||
|
@ -1035,6 +1030,15 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
return zoomText;
|
||||
}
|
||||
|
||||
public void setMapQuickActionLayer(MapQuickActionLayer mapQuickActionLayer) {
|
||||
this.mapQuickActionLayer = mapQuickActionLayer;
|
||||
}
|
||||
|
||||
private boolean isInChangeMarkerPositionMode(){
|
||||
return mapQuickActionLayer == null ? contextMenuLayer.isInChangeMarkerPositionMode() :
|
||||
mapQuickActionLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInChangeMarkerPositionMode();
|
||||
}
|
||||
|
||||
public static View.OnLongClickListener getOnClickMagnifierListener(final OsmandMapTileView view) {
|
||||
return new View.OnLongClickListener() {
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.views;
|
|||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.PointF;
|
||||
import android.os.Vibrator;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
@ -22,6 +23,8 @@ import net.osmand.plus.quickaction.QuickActionFactory;
|
|||
import net.osmand.plus.quickaction.QuickActionRegistry;
|
||||
import net.osmand.plus.quickaction.QuickActionsWidget;
|
||||
|
||||
import static net.osmand.plus.views.ContextMenuLayer.VIBRATE_SHORT;
|
||||
|
||||
/**
|
||||
* Created by okorsun on 23.12.16.
|
||||
*/
|
||||
|
@ -79,66 +82,16 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
|||
int minh = contextMarker.getDrawable().getMinimumHeight();
|
||||
contextMarker.layout(0, 0, minw, minh);
|
||||
|
||||
setCloseWidgetOnTouch(mapActivity.findViewById(R.id.map_quick_actions_button_container));
|
||||
setCloseWidgetOnTouch(mapActivity.findViewById(R.id.bottom_controls_container));
|
||||
|
||||
// quickActionButton.setOnTouchListener(new View.OnTouchListener() {
|
||||
// private int lastAction;
|
||||
// private int initialMarginX;
|
||||
// private int initialMarginY;
|
||||
// private float initialTouchX;
|
||||
// private float initialTouchY;
|
||||
//
|
||||
// @Override
|
||||
// public boolean onTouch(View v, MotionEvent event) {
|
||||
// switch (event.getAction()) {
|
||||
// case MotionEvent.ACTION_DOWN:
|
||||
// FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) v.getLayoutParams();
|
||||
//
|
||||
//
|
||||
// initialMarginX = params.rightMargin;
|
||||
// initialMarginY = params.bottomMargin;
|
||||
//
|
||||
// //get the touch location
|
||||
// initialTouchX = event.getRawX();
|
||||
// initialTouchY = event.getRawY();
|
||||
//
|
||||
// lastAction = event.getAction();
|
||||
// return true;
|
||||
//
|
||||
// case MotionEvent.ACTION_UP:
|
||||
// if (lastAction == MotionEvent.ACTION_DOWN) {
|
||||
// setLayerState();
|
||||
// }
|
||||
// lastAction = event.getAction();
|
||||
// return true;
|
||||
// case MotionEvent.ACTION_MOVE:
|
||||
// int deltaX = (int) (initialTouchX - event.getRawX());
|
||||
// int deltaY = (int) (initialTouchY - event.getRawY());
|
||||
// if (deltaX < 10 && deltaY < 10)
|
||||
// return false;
|
||||
//
|
||||
// int newMarginX = initialMarginX + deltaX;
|
||||
// int newMarginY = initialMarginY + deltaY;
|
||||
//
|
||||
// FrameLayout parent = (FrameLayout) v.getParent();
|
||||
// FrameLayout.LayoutParams param = (FrameLayout.LayoutParams) v.getLayoutParams();
|
||||
// if (v.getHeight() + newMarginY <= parent.getHeight() && newMarginY > 0)
|
||||
// param.bottomMargin = newMarginY;
|
||||
//
|
||||
// if (v.getWidth() + newMarginX <= parent.getWidth() && newMarginX > 0) {
|
||||
// param.rightMargin = newMarginX;
|
||||
// }
|
||||
//
|
||||
// v.setLayoutParams(param);
|
||||
//
|
||||
//
|
||||
// lastAction = event.getAction();
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
// });
|
||||
quickActionButton.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
Vibrator vibrator = (Vibrator) mapActivity.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
vibrator.vibrate(VIBRATE_SHORT);
|
||||
quickActionButton.setOnTouchListener(onQuickActionTouchListener);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -174,38 +127,13 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
|||
return true;
|
||||
}
|
||||
|
||||
private void setCloseWidgetOnTouch(View view) {
|
||||
view.setOnTouchListener(new View.OnTouchListener() {
|
||||
private float initialTouchX;
|
||||
private float initialTouchY;
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
initialTouchX = event.getRawX();
|
||||
initialTouchY = event.getRawY();
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
int deltaX = (int) (initialTouchX - event.getRawX());
|
||||
int deltaY = (int) (initialTouchY - event.getRawY());
|
||||
if (deltaX < 10 && deltaY < 10) {
|
||||
setLayerState(true);
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void enterMovingMode(RotatedTileBox tileBox) {
|
||||
MapContextMenu menu = mapActivity.getContextMenu();
|
||||
LatLon ll = menu.isActive() && tileBox.containsLatLon(menu.getLatLon()) ? menu.getLatLon() : tileBox.getCenterLatLon();
|
||||
|
||||
menu.updateMapCenter(null);
|
||||
menu.hide();
|
||||
menu.close();
|
||||
|
||||
LatLon ll = tileBox.getCenterLatLon();
|
||||
RotatedTileBox rb = new RotatedTileBox(tileBox);
|
||||
rb.setCenterLocation(0.5f, 0.5f);
|
||||
rb.setLatLonCenter(ll.getLatitude(), ll.getLongitude());
|
||||
|
@ -249,6 +177,19 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
||||
if (isInChangeMarkerPositionMode() && !pressedQuickActionWidget(point.x, point.y)){
|
||||
setLayerState(true);
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean pressedQuickActionWidget(float px , float py) {
|
||||
return py <= quickActionsWidget.getHeight();
|
||||
}
|
||||
|
||||
public void refreshLayer() {
|
||||
quickActionButton.setVisibility(settings.QUICK_ACTION.get() ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
@ -259,6 +200,11 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
|||
canvas.translate(box.getPixWidth() / 2 - contextMarker.getWidth() / 2, box.getPixHeight() / 2 - contextMarker.getHeight());
|
||||
contextMarker.draw(canvas);
|
||||
}
|
||||
boolean hideQuickButton = contextMenuLayer.isInChangeMarkerPositionMode() ||
|
||||
mapActivity.getContextMenu().isVisible() ||
|
||||
mapActivity.getContextMenu().getMultiSelectionMenu().isVisible() ||
|
||||
mapActivity.getRoutingHelper().isRoutePlanningMode();
|
||||
quickActionButton.setVisibility(hideQuickButton ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -293,4 +239,56 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
|||
public boolean onBackPressed() {
|
||||
return setLayerState(true);
|
||||
}
|
||||
|
||||
View.OnTouchListener onQuickActionTouchListener = new View.OnTouchListener() {
|
||||
private int initialMarginX;
|
||||
private int initialMarginY;
|
||||
private float initialTouchX;
|
||||
private float initialTouchY;
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
setUpInitialValues(v, event);
|
||||
return true;
|
||||
case MotionEvent.ACTION_UP:
|
||||
quickActionButton.setOnTouchListener(null);
|
||||
return true;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
if (initialMarginX == 0 && initialMarginY == 0 && initialTouchX == 0 && initialTouchY == 0)
|
||||
setUpInitialValues(v, event);
|
||||
|
||||
int deltaX = (int) (initialTouchX - event.getRawX());
|
||||
int deltaY = (int) (initialTouchY - event.getRawY());
|
||||
|
||||
int newMarginX = initialMarginX + deltaX;
|
||||
int newMarginY = initialMarginY + deltaY;
|
||||
|
||||
FrameLayout parent = (FrameLayout) v.getParent();
|
||||
FrameLayout.LayoutParams param = (FrameLayout.LayoutParams) v.getLayoutParams();
|
||||
if (v.getHeight() + newMarginY <= parent.getHeight() && newMarginY > 0)
|
||||
param.bottomMargin = newMarginY;
|
||||
|
||||
if (v.getWidth() + newMarginX <= parent.getWidth() && newMarginX > 0) {
|
||||
param.rightMargin = newMarginX;
|
||||
}
|
||||
|
||||
v.setLayoutParams(param);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setUpInitialValues(View v, MotionEvent event) {
|
||||
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) v.getLayoutParams();
|
||||
|
||||
initialMarginX = params.rightMargin;
|
||||
initialMarginY = params.bottomMargin;
|
||||
|
||||
initialTouchX = event.getRawX();
|
||||
initialTouchY = event.getRawY();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue