Update controls layer
This commit is contained in:
parent
2aef8cc8d0
commit
407500211d
6 changed files with 134 additions and 313 deletions
|
@ -14,7 +14,7 @@
|
||||||
<color name="map_widget_light">#eeffffff</color>
|
<color name="map_widget_light">#eeffffff</color>
|
||||||
<color name="map_widget_dark">#aa3f3f3f</color>
|
<color name="map_widget_dark">#aa3f3f3f</color>
|
||||||
<color name="map_widget_dark_pressed">#ddcccccc</color>
|
<color name="map_widget_dark_pressed">#ddcccccc</color>
|
||||||
<color name="map_widget_light_trans">#88ffffff</color>
|
<color name="map_widget_light_trans">#88bbbbbb</color>
|
||||||
<color name="map_widget_light_pressed">#ddcccccc</color>
|
<color name="map_widget_light_pressed">#ddcccccc</color>
|
||||||
<color name="map_widget_blue">#30A0FF</color>
|
<color name="map_widget_blue">#30A0FF</color>
|
||||||
<color name="map_widget_blue_pressed">#dd30D0FF</color>
|
<color name="map_widget_blue_pressed">#dd30D0FF</color>
|
||||||
|
|
|
@ -172,7 +172,8 @@ public class DashboardOnMap {
|
||||||
dashboardView.setVisibility(View.VISIBLE);
|
dashboardView.setVisibility(View.VISIBLE);
|
||||||
fabButton.showFloatingActionButton();
|
fabButton.showFloatingActionButton();
|
||||||
open(dashboardView.findViewById(R.id.animateContent));
|
open(dashboardView.findViewById(R.id.animateContent));
|
||||||
switchButton.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_navigation_drawer));
|
switchButton.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getIcon(R.drawable.ic_navigation_drawer,
|
||||||
|
R.color.icon_color_light));
|
||||||
|
|
||||||
mapActivity.getMapActions().disableDrawer();
|
mapActivity.getMapActions().disableDrawer();
|
||||||
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.GONE);
|
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.GONE);
|
||||||
|
|
|
@ -1,48 +1,29 @@
|
||||||
package net.osmand.plus.views;
|
package net.osmand.plus.views;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.pm.ActivityInfo;
|
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Surface;
|
|
||||||
import net.osmand.PlatformUtil;
|
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.helpers.ScreenOrientationHelper;
|
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
import net.osmand.plus.helpers.WaypointDialogHelper;
|
|
||||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
|
||||||
import net.osmand.plus.views.controls.MapRoutePlanControl;
|
|
||||||
import net.osmand.plus.views.controls.MapRoutePreferencesControl;
|
|
||||||
import net.osmand.plus.views.controls.MapCancelControl;
|
|
||||||
import net.osmand.plus.views.controls.MapControls;
|
import net.osmand.plus.views.controls.MapControls;
|
||||||
import net.osmand.plus.views.controls.MapRouteInfoControl;
|
import net.osmand.plus.views.controls.MapRouteInfoControl;
|
||||||
import net.osmand.plus.views.controls.MapMenuControls;
|
import net.osmand.plus.views.controls.MapRoutePreferencesControl;
|
||||||
import net.osmand.plus.views.controls.MapNavigateControl;
|
|
||||||
import net.osmand.plus.views.controls.MapZoomControls;
|
import net.osmand.plus.views.controls.MapZoomControls;
|
||||||
import net.osmand.plus.views.controls.RulerControl;
|
|
||||||
import net.osmand.plus.views.controls.SmallMapMenuControls;
|
|
||||||
import net.osmand.plus.views.mapwidgets.ImageViewWidget;
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.ColorFilter;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Handler;
|
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup.LayoutParams;
|
import android.view.ViewGroup.LayoutParams;
|
||||||
import android.view.animation.Animation;
|
|
||||||
import android.view.animation.RotateAnimation;
|
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
@ -54,80 +35,13 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private static final int TIMEOUT_TO_SHOW_BUTTONS = 5000;
|
private static final int TIMEOUT_TO_SHOW_BUTTONS = 5000;
|
||||||
|
|
||||||
private static class MapHudButton {
|
|
||||||
View iv;
|
|
||||||
int bgDark;
|
public MapHudButton createHudButton(View iv, int resId) {
|
||||||
int bgLight;
|
MapHudButton mc = new MapHudButton();
|
||||||
int resId;
|
mc.iv = iv;
|
||||||
int resLight = R.color.icon_color_light;
|
mc.resId = resId;
|
||||||
int resDark = 0;
|
return mc;
|
||||||
|
|
||||||
boolean nightMode = false;
|
|
||||||
boolean f = true;
|
|
||||||
|
|
||||||
public MapHudButton setRoundTransparent() {
|
|
||||||
setBg(R.drawable.btn_circle_trans);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MapHudButton setBg(int dayBg, int nightBg) {
|
|
||||||
bgDark = nightBg;
|
|
||||||
bgLight = dayBg;
|
|
||||||
f = true;
|
|
||||||
return this;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public MapHudButton setBg(int bg) {
|
|
||||||
bgDark = bg;
|
|
||||||
bgLight = bg;
|
|
||||||
f = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MapHudButton create(View iv, int resId) {
|
|
||||||
MapHudButton mc = new MapHudButton();
|
|
||||||
mc.iv = iv;
|
|
||||||
mc.resId = resId;
|
|
||||||
return mc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean setIconResId(int resId) {
|
|
||||||
if (this.resId == resId) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this.resId = resId;
|
|
||||||
f = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MapHudButton setIconColorId(int clr) {
|
|
||||||
if (resLight == clr && resDark == clr) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
resLight = clr;
|
|
||||||
resDark = clr;
|
|
||||||
f = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(OsmandApplication ctx, boolean night) {
|
|
||||||
if (nightMode == night && !f) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
f = false;
|
|
||||||
nightMode = night;
|
|
||||||
if (bgDark != 0 && bgLight != 0) {
|
|
||||||
iv.setBackgroundDrawable(ctx.getResources().getDrawable(night ? bgDark : bgLight));
|
|
||||||
}
|
|
||||||
if (iv instanceof ImageView) {
|
|
||||||
((ImageView) iv).setImageDrawable(ctx.getIconsCache().getIcon(resId, nightMode ? resDark : resLight));
|
|
||||||
} else if (iv instanceof TextView) {
|
|
||||||
((TextView) iv).setCompoundDrawables(
|
|
||||||
ctx.getIconsCache().getIcon(resId, nightMode ? resDark : resLight), null, null, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<MapHudButton> controls = new ArrayList<MapControlsLayer.MapHudButton>();
|
private List<MapHudButton> controls = new ArrayList<MapControlsLayer.MapHudButton>();
|
||||||
|
@ -152,7 +66,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
private MapHudButton routeGoControl;
|
private MapHudButton routeGoControl;
|
||||||
private MapHudButton compassHud;
|
private MapHudButton compassHud;
|
||||||
private float cachedRotate = 0;
|
private float cachedRotate = 0;
|
||||||
private RotateAnimation rotateAnimation;
|
|
||||||
|
|
||||||
public MapControlsLayer(MapActivity activity) {
|
public MapControlsLayer(MapActivity activity) {
|
||||||
this.mapActivity = activity;
|
this.mapActivity = activity;
|
||||||
|
@ -177,10 +90,43 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
initRouteControls();
|
initRouteControls();
|
||||||
initTopControls();
|
initTopControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class CompassDrawable extends Drawable {
|
||||||
|
|
||||||
|
private Drawable original;
|
||||||
|
|
||||||
|
public CompassDrawable(Drawable original) {
|
||||||
|
this.original = original;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Canvas canvas) {
|
||||||
|
canvas.save();
|
||||||
|
canvas.rotate(cachedRotate, canvas.getWidth() / 2, canvas.getHeight() / 2);
|
||||||
|
original.draw(canvas);
|
||||||
|
canvas.restore();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAlpha(int alpha) {
|
||||||
|
original.setAlpha(alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setColorFilter(ColorFilter cf) {
|
||||||
|
original.setColorFilter(cf);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOpacity() {
|
||||||
|
return original.getOpacity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void initTopControls() {
|
private void initTopControls() {
|
||||||
View configureMap = mapActivity.findViewById(R.id.map_layers_button);
|
View configureMap = mapActivity.findViewById(R.id.map_layers_button);
|
||||||
controls.add(MapHudButton.create((ImageView) configureMap, R.drawable.ic_action_layers_dark).setBg(
|
controls.add(createHudButton((ImageView) configureMap, R.drawable.ic_action_layers_dark).setBg(
|
||||||
R.drawable.btn_inset_circle, R.drawable.btn_inset_circle_night));
|
R.drawable.btn_inset_circle, R.drawable.btn_inset_circle_night));
|
||||||
configureMap.setOnClickListener(new View.OnClickListener() {
|
configureMap.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -192,7 +138,9 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
});
|
});
|
||||||
|
|
||||||
View compass = mapActivity.findViewById(R.id.map_compass_button);
|
View compass = mapActivity.findViewById(R.id.map_compass_button);
|
||||||
compassHud = MapHudButton.create((ImageView) compass, R.drawable.map_compass).setIconColorId(0)
|
// protected void onDraw(Canvas canvas) {
|
||||||
|
// }
|
||||||
|
compassHud = createHudButton((ImageView) compass, R.drawable.map_compass).setIconColorId(0)
|
||||||
.setBg(R.drawable.btn_inset_circle, R.drawable.btn_inset_circle_night);
|
.setBg(R.drawable.btn_inset_circle, R.drawable.btn_inset_circle_night);
|
||||||
controls.add(compassHud);
|
controls.add(compassHud);
|
||||||
compass.setOnClickListener(new View.OnClickListener() {
|
compass.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -208,7 +156,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
private void initRouteControls() {
|
private void initRouteControls() {
|
||||||
routePreparationLayout = mapActivity.findViewById(R.id.map_route_preparation_layout);
|
routePreparationLayout = mapActivity.findViewById(R.id.map_route_preparation_layout);
|
||||||
View cancelRouteButton = mapActivity.findViewById(R.id.map_cancel_route_button);
|
View cancelRouteButton = mapActivity.findViewById(R.id.map_cancel_route_button);
|
||||||
controls.add(MapHudButton.create((ImageView) cancelRouteButton, R.drawable.ic_action_remove_dark).setBg(
|
controls.add(createHudButton((ImageView) cancelRouteButton, R.drawable.ic_action_remove_dark).setBg(
|
||||||
R.drawable.btn_flat, R.drawable.btn_flat_night));
|
R.drawable.btn_flat, R.drawable.btn_flat_night));
|
||||||
|
|
||||||
cancelRouteButton.setOnClickListener(new View.OnClickListener() {
|
cancelRouteButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -226,7 +174,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
mapActivity);
|
mapActivity);
|
||||||
|
|
||||||
View waypointsButton = mapActivity.findViewById(R.id.map_waypoints_route_button);
|
View waypointsButton = mapActivity.findViewById(R.id.map_waypoints_route_button);
|
||||||
controls.add(MapHudButton.create((ImageView) waypointsButton, R.drawable.ic_action_flage_dark).setBg(
|
controls.add(createHudButton((ImageView) waypointsButton, R.drawable.ic_action_flage_dark).setBg(
|
||||||
R.drawable.btn_flat, R.drawable.btn_flat_night));
|
R.drawable.btn_flat, R.drawable.btn_flat_night));
|
||||||
waypointsButton.setOnClickListener(new View.OnClickListener() {
|
waypointsButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -237,7 +185,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
});
|
});
|
||||||
|
|
||||||
View optionsRouteButton = mapActivity.findViewById(R.id.map_options_route_button);
|
View optionsRouteButton = mapActivity.findViewById(R.id.map_options_route_button);
|
||||||
optionsRouteControl = MapHudButton.create((ImageView) optionsRouteButton,
|
optionsRouteControl = createHudButton((ImageView) optionsRouteButton,
|
||||||
settings.getApplicationMode().getSmallIcon(true)).setBg(R.drawable.btn_flat, R.drawable.btn_flat_night);
|
settings.getApplicationMode().getSmallIcon(true)).setBg(R.drawable.btn_flat, R.drawable.btn_flat_night);
|
||||||
optionsRouteControlDialog = new MapRoutePreferencesControl(mapActivity);
|
optionsRouteControlDialog = new MapRoutePreferencesControl(mapActivity);
|
||||||
controls.add(optionsRouteControl);
|
controls.add(optionsRouteControl);
|
||||||
|
@ -250,7 +198,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
});
|
});
|
||||||
|
|
||||||
TextView routeGoButton = (TextView) mapActivity.findViewById(R.id.map_go_route_button);
|
TextView routeGoButton = (TextView) mapActivity.findViewById(R.id.map_go_route_button);
|
||||||
routeGoControl = MapHudButton.create(routeGoButton, R.drawable.ic_destination_arrow_white).setBg(
|
routeGoControl = createHudButton(routeGoButton, R.drawable.ic_destination_arrow_white).setBg(
|
||||||
R.drawable.btn_flat, R.drawable.btn_flat_night);
|
R.drawable.btn_flat, R.drawable.btn_flat_night);
|
||||||
controls.add(routeGoControl);
|
controls.add(routeGoControl);
|
||||||
routeGoButton.setText(mapActivity.getString(R.string.shared_string_go).toUpperCase());
|
routeGoButton.setText(mapActivity.getString(R.string.shared_string_go).toUpperCase());
|
||||||
|
@ -269,7 +217,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private void initControls() {
|
private void initControls() {
|
||||||
View backToLocation = mapActivity.findViewById(R.id.map_my_location_button);
|
View backToLocation = mapActivity.findViewById(R.id.map_my_location_button);
|
||||||
backToLocationControl = MapHudButton.create((ImageView) backToLocation, R.drawable.ic_action_get_my_location)
|
backToLocationControl = createHudButton((ImageView) backToLocation, R.drawable.ic_action_get_my_location)
|
||||||
.setBg(R.drawable.btn_circle_blue);
|
.setBg(R.drawable.btn_circle_blue);
|
||||||
controls.add(backToLocationControl);
|
controls.add(backToLocationControl);
|
||||||
|
|
||||||
|
@ -281,7 +229,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
});
|
});
|
||||||
|
|
||||||
View backToMenuButton = mapActivity.findViewById(R.id.map_menu_button);
|
View backToMenuButton = mapActivity.findViewById(R.id.map_menu_button);
|
||||||
menuControl = MapHudButton.create((ImageView) backToMenuButton, R.drawable.ic_navigation_drawer).setBg(
|
menuControl = createHudButton((ImageView) backToMenuButton, R.drawable.ic_navigation_drawer).setBg(
|
||||||
R.drawable.btn_round, R.drawable.btn_round_night);
|
R.drawable.btn_round, R.drawable.btn_round_night);
|
||||||
controls.add(menuControl);
|
controls.add(menuControl);
|
||||||
backToMenuButton.setOnClickListener(new View.OnClickListener() {
|
backToMenuButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -301,7 +249,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
});
|
});
|
||||||
|
|
||||||
View routePlanButton = mapActivity.findViewById(R.id.map_route_info_button);
|
View routePlanButton = mapActivity.findViewById(R.id.map_route_info_button);
|
||||||
controls.add(MapHudButton.create((ImageView) routePlanButton, R.drawable.ic_action_gdirections_dark).setBg(
|
controls.add(createHudButton((ImageView) routePlanButton, R.drawable.ic_action_gdirections_dark).setBg(
|
||||||
R.drawable.btn_round, R.drawable.btn_round_night));
|
R.drawable.btn_round, R.drawable.btn_round_night));
|
||||||
routePlanButton.setOnClickListener(new View.OnClickListener() {
|
routePlanButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -318,7 +266,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
private void initZooms() {
|
private void initZooms() {
|
||||||
final OsmandMapTileView view = mapActivity.getMapView();
|
final OsmandMapTileView view = mapActivity.getMapView();
|
||||||
View zoomInButton = mapActivity.findViewById(R.id.map_zoom_in_button);
|
View zoomInButton = mapActivity.findViewById(R.id.map_zoom_in_button);
|
||||||
controls.add(MapHudButton.create((ImageView) zoomInButton, R.drawable.ic_action_zoom_in).setRoundTransparent());
|
controls.add(createHudButton((ImageView) zoomInButton, R.drawable.ic_action_zoom_in).setRoundTransparent());
|
||||||
zoomInButton.setOnClickListener(new View.OnClickListener() {
|
zoomInButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -334,7 +282,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
final View.OnLongClickListener listener = MapZoomControls.getOnClickMagnifierListener(view);
|
final View.OnLongClickListener listener = MapZoomControls.getOnClickMagnifierListener(view);
|
||||||
zoomInButton.setOnLongClickListener(listener);
|
zoomInButton.setOnLongClickListener(listener);
|
||||||
View zoomOutButton = mapActivity.findViewById(R.id.map_zoom_out_button);
|
View zoomOutButton = mapActivity.findViewById(R.id.map_zoom_out_button);
|
||||||
controls.add(MapHudButton.create((ImageView) zoomOutButton, R.drawable.ic_action_zoom_out)
|
controls.add(createHudButton((ImageView) zoomOutButton, R.drawable.ic_action_zoom_out)
|
||||||
.setRoundTransparent());
|
.setRoundTransparent());
|
||||||
zoomOutButton.setOnClickListener(new View.OnClickListener() {
|
zoomOutButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -438,23 +386,11 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
float mapRotate = mapActivity.getMapView().getRotate();
|
float mapRotate = mapActivity.getMapView().getRotate();
|
||||||
if (mapRotate != cachedRotate && (rotateAnimation == null || rotateAnimation.hasEnded())) {
|
if (mapRotate != cachedRotate) {
|
||||||
float c = cachedRotate - mapRotate;
|
float c = cachedRotate - mapRotate;
|
||||||
cachedRotate = mapRotate;
|
cachedRotate = mapRotate;
|
||||||
// compassHud.iv.setPivotX();
|
|
||||||
// compassHud.iv.setPivotY();
|
|
||||||
// compassHud.iv.setRotation(mapRotate);
|
|
||||||
rotateAnimation = new RotateAnimation(0.0f, c, compassHud.iv.getWidth() / 2,
|
|
||||||
compassHud.iv.getHeight() / 2);
|
|
||||||
// Set the animation's parameters
|
|
||||||
rotateAnimation.setDuration(100); // duration in ms
|
|
||||||
rotateAnimation.setRepeatCount(0); // -1 = infinite repeated
|
|
||||||
rotateAnimation.setRepeatMode(Animation.REVERSE); // reverses each repeat
|
|
||||||
rotateAnimation.setFillAfter(true); // keep rotation after animation
|
|
||||||
|
|
||||||
// Aply animation to image view
|
// Aply animation to image view
|
||||||
compassHud.iv.setAnimation(rotateAnimation);
|
compassHud.iv.invalidate();
|
||||||
// compassHud.iv.invalidate();
|
|
||||||
}
|
}
|
||||||
if (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_NONE) {
|
if (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_NONE) {
|
||||||
compassHud.setIconResId(isNight ? R.drawable.map_compass_niu_white : R.drawable.map_compass_niu);
|
compassHud.setIconResId(isNight ? R.drawable.map_compass_niu_white : R.drawable.map_compass_niu);
|
||||||
|
@ -469,35 +405,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public ImageViewWidget createCompassView(final MapActivity map){
|
|
||||||
// final OsmandMapTileView view = map.getMapView();
|
|
||||||
// final OsmandApplication app = map.getMyApplication();
|
|
||||||
// final int mw = (int) compass.getMinimumWidth() ;
|
|
||||||
// final int mh = (int) compass.getMinimumHeight() ;
|
|
||||||
// ImageViewWidget compassView = new ImageViewWidget(map) {
|
|
||||||
// private float cachedRotate = 0;
|
|
||||||
// private int cachedRotateMap = 0;
|
|
||||||
// private boolean nm;
|
|
||||||
// @Override
|
|
||||||
// protected void onDraw(Canvas canvas) {
|
|
||||||
// canvas.save();
|
|
||||||
// canvas.rotate(view.getRotate(), mw / 2, mh / 2);
|
|
||||||
// getDrawable().draw(canvas);
|
|
||||||
// canvas.restore();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// };
|
|
||||||
// compassView.setOnClickListener(new View.OnClickListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onClick(View v) {
|
|
||||||
// map.getMapViewTrackingUtilities().switchRotateMapMode();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// return compassView;
|
|
||||||
// }
|
|
||||||
|
|
||||||
private FrameLayout getParent() {
|
private FrameLayout getParent() {
|
||||||
return (FrameLayout) mapActivity.findViewById(R.id.MapButtons);
|
return (FrameLayout) mapActivity.findViewById(R.id.MapButtons);
|
||||||
}
|
}
|
||||||
|
@ -594,4 +501,78 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private class MapHudButton {
|
||||||
|
View iv;
|
||||||
|
int bgDark;
|
||||||
|
int bgLight;
|
||||||
|
int resId;
|
||||||
|
int resLight = R.color.icon_color_light;
|
||||||
|
int resDark = 0;
|
||||||
|
|
||||||
|
boolean nightMode = false;
|
||||||
|
boolean f = true;
|
||||||
|
boolean compass;
|
||||||
|
|
||||||
|
public MapHudButton setRoundTransparent() {
|
||||||
|
setBg(R.drawable.btn_circle_trans);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapHudButton setBg(int dayBg, int nightBg) {
|
||||||
|
bgDark = nightBg;
|
||||||
|
bgLight = dayBg;
|
||||||
|
f = true;
|
||||||
|
return this;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapHudButton setBg(int bg) {
|
||||||
|
bgDark = bg;
|
||||||
|
bgLight = bg;
|
||||||
|
f = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setIconResId(int resId) {
|
||||||
|
if (this.resId == resId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.resId = resId;
|
||||||
|
f = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapHudButton setIconColorId(int clr) {
|
||||||
|
if (resLight == clr && resDark == clr) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
resLight = clr;
|
||||||
|
resDark = clr;
|
||||||
|
f = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(OsmandApplication ctx, boolean night) {
|
||||||
|
if (nightMode == night && !f) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
f = false;
|
||||||
|
nightMode = night;
|
||||||
|
if (bgDark != 0 && bgLight != 0) {
|
||||||
|
iv.setBackgroundDrawable(ctx.getResources().getDrawable(night ? bgDark : bgLight));
|
||||||
|
}
|
||||||
|
if (iv instanceof ImageView) {
|
||||||
|
if(compass) {
|
||||||
|
((ImageView) iv).setImageDrawable(new CompassDrawable(ctx.getIconsCache().getIcon(resId, nightMode ? resDark : resLight)));
|
||||||
|
} else {
|
||||||
|
((ImageView) iv).setImageDrawable(ctx.getIconsCache().getIcon(resId, nightMode ? resDark : resLight));
|
||||||
|
}
|
||||||
|
} else if (iv instanceof TextView) {
|
||||||
|
((TextView) iv).setCompoundDrawables(
|
||||||
|
ctx.getIconsCache().getIcon(resId, nightMode ? resDark : resLight), null, null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
package net.osmand.plus.views.controls;
|
|
||||||
|
|
||||||
import net.osmand.data.RotatedTileBox;
|
|
||||||
import net.osmand.plus.R;
|
|
||||||
import net.osmand.plus.activities.MapActivity;
|
|
||||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
|
|
||||||
public class MapCancelControl extends MapControls {
|
|
||||||
private Button cancelButton;
|
|
||||||
|
|
||||||
|
|
||||||
public MapCancelControl(MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
|
|
||||||
super(mapActivity, showUIHandler, scaleCoefficient);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showControls(FrameLayout parent) {
|
|
||||||
cancelButton = addButton(parent, R.string.cancel_navigation, R.drawable.map_btn_cancel);
|
|
||||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
notifyClicked();
|
|
||||||
if(mapActivity.getRoutingHelper().isFollowingMode()) {
|
|
||||||
mapActivity.getMapActions().stopNavigationActionConfirm(mapActivity.getMapView());
|
|
||||||
} else {
|
|
||||||
mapActivity.getMapActions().stopNavigationWithoutConfirm();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hideControls(FrameLayout layout) {
|
|
||||||
removeButton(layout, cancelButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth() {
|
|
||||||
if (width == 0) {
|
|
||||||
Drawable buttonDrawable = mapActivity.getResources().getDrawable(R.drawable.map_btn_cancel);
|
|
||||||
width = buttonDrawable.getMinimumWidth();
|
|
||||||
}
|
|
||||||
return width ;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
package net.osmand.plus.views.controls;
|
|
||||||
|
|
||||||
import net.osmand.data.RotatedTileBox;
|
|
||||||
import net.osmand.plus.R;
|
|
||||||
import net.osmand.plus.activities.MapActivity;
|
|
||||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
|
|
||||||
public class MapRoutePlanControl extends MapControls {
|
|
||||||
private Button routePlanButton;
|
|
||||||
|
|
||||||
|
|
||||||
public MapRoutePlanControl(MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
|
|
||||||
super(mapActivity, showUIHandler, scaleCoefficient);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showControls(FrameLayout parent) {
|
|
||||||
routePlanButton = addButton(parent, R.string.info_button, R.drawable.map_btn_info);
|
|
||||||
routePlanButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
notifyClicked();
|
|
||||||
mapActivity.getRoutingHelper().setRoutePlanningMode(true);
|
|
||||||
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
|
|
||||||
mapActivity.refreshMap();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hideControls(FrameLayout layout) {
|
|
||||||
removeButton(layout, routePlanButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth() {
|
|
||||||
if (width == 0) {
|
|
||||||
Drawable buttonDrawable = mapActivity.getResources().getDrawable(R.drawable.map_btn_info);
|
|
||||||
width = buttonDrawable.getMinimumWidth();
|
|
||||||
}
|
|
||||||
return width ;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
package net.osmand.plus.views.controls;
|
|
||||||
|
|
||||||
import net.osmand.data.RotatedTileBox;
|
|
||||||
import net.osmand.plus.R;
|
|
||||||
import net.osmand.plus.activities.MapActivity;
|
|
||||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
|
|
||||||
public class SmallMapMenuControls extends MapControls {
|
|
||||||
private Button backToMenuButton;
|
|
||||||
|
|
||||||
public SmallMapMenuControls(MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
|
|
||||||
super(mapActivity, showUIHandler, scaleCoefficient);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showControls(FrameLayout parent) {
|
|
||||||
backToMenuButton = addButton(parent, R.string.backToMenu, R.drawable.map_btn_menu);
|
|
||||||
mapActivity.accessibleContent.add(backToMenuButton);
|
|
||||||
backToMenuButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
notifyClicked();
|
|
||||||
if(mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.get()) {
|
|
||||||
mapActivity.getDashboard().setDashboardVisibility(true);
|
|
||||||
} else {
|
|
||||||
mapActivity.getMapActions().onDrawerBack();
|
|
||||||
mapActivity.getMapActions().toggleDrawer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hideControls(FrameLayout layout) {
|
|
||||||
removeButton(layout, backToMenuButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth() {
|
|
||||||
if (width == 0) {
|
|
||||||
Drawable buttonDrawable = mapActivity.getResources().getDrawable(R.drawable.map_btn_menu);
|
|
||||||
width = buttonDrawable.getMinimumWidth();
|
|
||||||
}
|
|
||||||
return width ;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue