Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
b15139b9d9
1 changed files with 35 additions and 33 deletions
|
@ -3,7 +3,6 @@ package net.osmand.plus.views;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.support.annotation.DimenRes;
|
import android.support.annotation.DimenRes;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
@ -53,10 +52,11 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
private boolean wasCollapseButtonVisible;
|
private boolean wasCollapseButtonVisible;
|
||||||
private int previousMapPosition;
|
private int previousMapPosition;
|
||||||
|
|
||||||
|
|
||||||
private boolean inChangeMarkerPositionMode;
|
private boolean inChangeMarkerPositionMode;
|
||||||
private boolean isLayerOn;
|
private boolean isLayerOn;
|
||||||
|
|
||||||
|
private boolean nightMode;
|
||||||
|
|
||||||
public MapQuickActionLayer(MapActivity activity, ContextMenuLayer contextMenuLayer) {
|
public MapQuickActionLayer(MapActivity activity, ContextMenuLayer contextMenuLayer) {
|
||||||
this.mapActivity = activity;
|
this.mapActivity = activity;
|
||||||
this.contextMenuLayer = contextMenuLayer;
|
this.contextMenuLayer = contextMenuLayer;
|
||||||
|
@ -74,13 +74,14 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
quickActionButton = (ImageButton) mapActivity.findViewById(R.id.map_quick_actions_button);
|
quickActionButton = (ImageButton) mapActivity.findViewById(R.id.map_quick_actions_button);
|
||||||
setQuickActionButtonMargin();
|
setQuickActionButtonMargin();
|
||||||
isLayerOn = quickActionRegistry.isQuickActionOn();
|
isLayerOn = quickActionRegistry.isQuickActionOn();
|
||||||
setUpQuickActionBtnResources(app.getDaynightHelper().isNightModeForMapControls());
|
nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
||||||
|
updateQuickActionButton(false);
|
||||||
quickActionButton.setContentDescription(mapActivity.getString(R.string.configure_screen_quick_action));
|
quickActionButton.setContentDescription(mapActivity.getString(R.string.configure_screen_quick_action));
|
||||||
quickActionButton.setOnClickListener(new View.OnClickListener() {
|
quickActionButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (!showTutorialIfNeeded())
|
if (!showTutorialIfNeeded())
|
||||||
setLayerState(quickActionsWidget.getVisibility() == View.VISIBLE);
|
setLayerState(!isWidgetVisible());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -110,9 +111,9 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshLayer() {
|
public void refreshLayer() {
|
||||||
setLayerState(true);
|
setLayerState(false);
|
||||||
isLayerOn = quickActionRegistry.isQuickActionOn();
|
isLayerOn = quickActionRegistry.isQuickActionOn();
|
||||||
setUpQuickActionBtnVisibility();
|
setupQuickActionBtnVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean showTutorialIfNeeded() {
|
private boolean showTutorialIfNeeded() {
|
||||||
|
@ -173,19 +174,22 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isWidgetVisible() {
|
||||||
|
return quickActionsWidget.getVisibility() == View.VISIBLE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param isClosed
|
* @param showWidget
|
||||||
* @return true, if state was changed
|
* @return true, if state was changed
|
||||||
*/
|
*/
|
||||||
public boolean setLayerState(boolean isClosed) {
|
public boolean setLayerState(boolean showWidget) {
|
||||||
if ((quickActionsWidget.getVisibility() == View.VISIBLE) != isClosed) // check if state change is needed
|
if (isWidgetVisible() == showWidget) // check if state change is needed
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
quickActionButton.setImageResource(isClosed ? R.drawable.map_quick_action : R.drawable.map_action_cancel);
|
updateQuickActionButton(showWidget);
|
||||||
quickActionButton.setContentDescription(mapActivity.getString(isClosed ? R.string.configure_screen_quick_action : R.string.shared_string_cancel));
|
quickActionsWidget.setVisibility(!showWidget ? View.GONE : View.VISIBLE);
|
||||||
quickActionsWidget.setVisibility(isClosed ? View.GONE : View.VISIBLE);
|
|
||||||
|
|
||||||
if (isClosed) {
|
if (!showWidget) {
|
||||||
quitMovingMarker();
|
quitMovingMarker();
|
||||||
quickActionRegistry.setUpdatesListener(null);
|
quickActionRegistry.setUpdatesListener(null);
|
||||||
quickActionsWidget.setSelectionListener(null);
|
quickActionsWidget.setSelectionListener(null);
|
||||||
|
@ -199,6 +203,14 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateQuickActionButton(boolean widgetVisible) {
|
||||||
|
quickActionButton.setImageDrawable(app.getIconsCache().getIcon(
|
||||||
|
!widgetVisible ? R.drawable.map_quick_action : R.drawable.map_action_cancel, !nightMode));
|
||||||
|
quickActionButton.setBackgroundResource(
|
||||||
|
nightMode ? R.drawable.btn_circle_night : R.drawable.btn_circle_trans);
|
||||||
|
quickActionButton.setContentDescription(mapActivity.getString(!widgetVisible ? R.string.configure_screen_quick_action : R.string.shared_string_cancel));
|
||||||
|
}
|
||||||
|
|
||||||
private void enterMovingMode(RotatedTileBox tileBox) {
|
private void enterMovingMode(RotatedTileBox tileBox) {
|
||||||
previousMapPosition = view.getMapPosition();
|
previousMapPosition = view.getMapPosition();
|
||||||
view.setMapPosition(OsmandSettings.MIDDLE_CONSTANT);
|
view.setMapPosition(OsmandSettings.MIDDLE_CONSTANT);
|
||||||
|
@ -277,7 +289,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
@Override
|
@Override
|
||||||
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
||||||
if (isInChangeMarkerPositionMode() && !pressedQuickActionWidget(point.x, point.y)) {
|
if (isInChangeMarkerPositionMode() && !pressedQuickActionWidget(point.x, point.y)) {
|
||||||
setLayerState(true);
|
setLayerState(false);
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
|
@ -289,15 +301,19 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings settings) {
|
public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings settings) {
|
||||||
|
boolean nightMode = settings != null && settings.isNightMode();
|
||||||
if (isInChangeMarkerPositionMode()) {
|
if (isInChangeMarkerPositionMode()) {
|
||||||
canvas.translate(box.getCenterPixelX() - contextMarker.getWidth() / 2, box.getCenterPixelY() - contextMarker.getHeight());
|
canvas.translate(box.getCenterPixelX() - contextMarker.getWidth() / 2, box.getCenterPixelY() - contextMarker.getHeight());
|
||||||
contextMarker.draw(canvas);
|
contextMarker.draw(canvas);
|
||||||
}
|
}
|
||||||
setUpQuickActionBtnVisibility();
|
if (this.nightMode != nightMode) {
|
||||||
setUpQuickActionBtnResources(settings.isNightMode());
|
this.nightMode = nightMode;
|
||||||
|
updateQuickActionButton(isWidgetVisible());
|
||||||
|
}
|
||||||
|
setupQuickActionBtnVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpQuickActionBtnVisibility() {
|
private void setupQuickActionBtnVisibility() {
|
||||||
boolean hideQuickButton = !isLayerOn ||
|
boolean hideQuickButton = !isLayerOn ||
|
||||||
contextMenuLayer.isInChangeMarkerPositionMode() ||
|
contextMenuLayer.isInChangeMarkerPositionMode() ||
|
||||||
contextMenuLayer.isInGpxDetailsMode() ||
|
contextMenuLayer.isInGpxDetailsMode() ||
|
||||||
|
@ -308,20 +324,6 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
quickActionButton.setVisibility(hideQuickButton ? View.GONE : View.VISIBLE);
|
quickActionButton.setVisibility(hideQuickButton ? View.GONE : View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpQuickActionBtnResources(boolean nightMode) {
|
|
||||||
Drawable icon;
|
|
||||||
int backgroundId;
|
|
||||||
if (nightMode) {
|
|
||||||
backgroundId = R.drawable.btn_circle_night;
|
|
||||||
icon = app.getIconsCache().getIcon(R.drawable.map_quick_action, 0);
|
|
||||||
} else {
|
|
||||||
backgroundId = R.drawable.btn_circle_trans;
|
|
||||||
icon = app.getIconsCache().getIcon(R.drawable.map_quick_action, R.color.icon_color);
|
|
||||||
}
|
|
||||||
quickActionButton.setBackgroundResource(backgroundId);
|
|
||||||
quickActionButton.setImageDrawable(icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroyLayer() {
|
public void destroyLayer() {
|
||||||
|
|
||||||
|
@ -341,7 +343,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
@Override
|
@Override
|
||||||
public void onActionSelected(QuickAction action) {
|
public void onActionSelected(QuickAction action) {
|
||||||
QuickActionFactory.produceAction(action).execute(mapActivity);
|
QuickActionFactory.produceAction(action).execute(mapActivity);
|
||||||
setLayerState(true);
|
setLayerState(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PointF getMovableCenterPoint(RotatedTileBox tb) {
|
public PointF getMovableCenterPoint(RotatedTileBox tb) {
|
||||||
|
@ -357,7 +359,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onBackPressed() {
|
public boolean onBackPressed() {
|
||||||
return setLayerState(true);
|
return setLayerState(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
View.OnTouchListener onQuickActionTouchListener = new View.OnTouchListener() {
|
View.OnTouchListener onQuickActionTouchListener = new View.OnTouchListener() {
|
||||||
|
|
Loading…
Reference in a new issue