update buttons

This commit is contained in:
Victor Shcherb 2015-03-12 01:45:53 +01:00
parent 86bbdabb4c
commit 2aef8cc8d0
12 changed files with 274 additions and 135 deletions

View file

@ -4,7 +4,6 @@
<item android:state_pressed="true"><shape android:shape="rectangle"> <item android:state_pressed="true"><shape android:shape="rectangle">
<solid android:color="@color/map_widget_light_pressed" /> <solid android:color="@color/map_widget_light_pressed" />
<stroke android:width="@dimen/map_button_stroke" android:color="@color/map_widget_stroke" /> <stroke android:width="@dimen/map_button_stroke" android:color="@color/map_widget_stroke" />
<corners android:radius="@dimen/map_button_rect_rad" />
</shape></item> </shape></item>
<item><shape android:shape="rectangle"> <item><shape android:shape="rectangle">
<solid android:color="@color/map_widget_light" /> <solid android:color="@color/map_widget_light" />

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"><shape android:shape="rectangle">
<solid android:color="@color/map_widget_dark_pressed" />
<stroke android:width="@dimen/map_button_stroke" android:color="@color/map_widget_stroke" />
</shape></item>
<item><shape android:shape="rectangle">
<solid android:color="@color/map_widget_dark" />
<stroke android:width="@dimen/map_button_stroke" android:color="@color/map_widget_stroke" />
</shape></item>
</selector>

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"><inset android:insetBottom="@dimen/map_button_inset" android:insetLeft="@dimen/map_button_inset" android:insetRight="@dimen/map_button_inset" android:insetTop="@dimen/map_button_inset">
<shape android:shape="oval">
<solid android:color="@color/map_widget_dark_pressed" />
<stroke android:color="@color/map_widget_stroke" android:width="@dimen/map_button_stroke"/>
</shape>
</inset></item>
<item><inset android:insetBottom="@dimen/map_button_inset" android:insetLeft="@dimen/map_button_inset" android:insetRight="@dimen/map_button_inset" android:insetTop="@dimen/map_button_inset">
<shape android:shape="oval">
<solid android:color="@color/map_widget_dark" />
<stroke android:color="@color/map_widget_stroke" android:width="@dimen/map_button_stroke"/>
</shape>
</inset></item>
</selector>

View file

@ -2,7 +2,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"><shape android:shape="rectangle"> <item android:state_pressed="true"><shape android:shape="rectangle">
<solid android:color="@color/map_widget_light_pressed" /> <solid android:color="@color/map_widget_dark_pressed" />
<corners android:radius="@dimen/map_button_rect_rad" /> <corners android:radius="@dimen/map_button_rect_rad" />
<stroke android:width="@dimen/map_button_stroke" android:color="@color/map_widget_stroke" /> <stroke android:width="@dimen/map_button_stroke" android:color="@color/map_widget_stroke" />
</shape></item> </shape></item>

View file

@ -116,6 +116,7 @@
android:paddingLeft="12dp" android:paddingLeft="12dp"
android:drawableLeft="@drawable/ic_action_remove_light" android:drawableLeft="@drawable/ic_action_remove_light"
android:textSize="20sp" android:textSize="20sp"
android:textStyle="bold"
android:drawablePadding="4dp" /> android:drawablePadding="4dp" />
</LinearLayout> </LinearLayout>

View file

@ -11,7 +11,7 @@
android:layout_marginLeft="@dimen/map_button_margin" android:layout_marginLeft="@dimen/map_button_margin"
android:layout_marginTop="@dimen/map_button_margin" android:layout_marginTop="@dimen/map_button_margin"
android:background="@drawable/btn_inset_circle" android:background="@drawable/btn_inset_circle"
android:src="@drawable/ic_action_layers_light" /> android:src="@drawable/ic_action_remove_light" />
<Button <Button
android:id="@+id/map_download_button" android:id="@+id/map_download_button"

View file

@ -13,6 +13,7 @@
<color name="map_widget_stroke">#333333</color> <color name="map_widget_stroke">#333333</color>
<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_light_trans">#88ffffff</color> <color name="map_widget_light_trans">#88ffffff</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>

View file

@ -55,7 +55,7 @@
<dimen name="map_widget_icon">24dp</dimen> <dimen name="map_widget_icon">24dp</dimen>
<dimen name="map_widget_height">32dp</dimen> <dimen name="map_widget_height">32dp</dimen>
<dimen name="map_widget_image">80dp</dimen> <dimen name="map_widget_image">80dp</dimen>
<dimen name="map_button_spacing">18dp</dimen> <dimen name="map_button_spacing">15dp</dimen>
<dimen name="map_button_margin">4dp</dimen> <dimen name="map_button_margin">4dp</dimen>
<dimen name="map_button_inset">4dp</dimen> <dimen name="map_button_inset">4dp</dimen>
<dimen name="map_button_rect_rad">3dp</dimen> <dimen name="map_button_rect_rad">3dp</dimen>

View file

@ -9,6 +9,7 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="shared_string_go">Go</string>
<string name="action_create">Action create</string> <string name="action_create">Action create</string>
<string name="action_modify">Action modify</string> <string name="action_modify">Action modify</string>
<string name="action_delete">Action delete</string> <string name="action_delete">Action delete</string>

View file

@ -52,6 +52,7 @@ public class ApplicationMode {
static { static {
ApplicationMode[] exceptPedestrianAndDefault = new ApplicationMode[] { CAR, BICYCLE, BOAT, AIRCRAFT }; ApplicationMode[] exceptPedestrianAndDefault = new ApplicationMode[] { CAR, BICYCLE, BOAT, AIRCRAFT };
ApplicationMode[] exceptAirBoat = new ApplicationMode[] { DEFAULT, CAR, BICYCLE, PEDESTRIAN }; ApplicationMode[] exceptAirBoat = new ApplicationMode[] { DEFAULT, CAR, BICYCLE, PEDESTRIAN };
ApplicationMode[] exceptAirBoatDefault = new ApplicationMode[] { CAR, BICYCLE, PEDESTRIAN };
ApplicationMode[] pedestrian = new ApplicationMode[] { PEDESTRIAN }; ApplicationMode[] pedestrian = new ApplicationMode[] { PEDESTRIAN };
ApplicationMode[] pedestrianBicycle = new ApplicationMode[] { PEDESTRIAN, BICYCLE }; ApplicationMode[] pedestrianBicycle = new ApplicationMode[] { PEDESTRIAN, BICYCLE };
@ -75,7 +76,7 @@ public class ApplicationMode {
// top // top
regWidget("compass", all); regWidget("compass", all);
regWidget("config", none); regWidget("config", none);
regWidget("street_name", exceptAirBoat); regWidget("street_name", exceptAirBoatDefault);
regWidget("back_to_location", all); regWidget("back_to_location", all);
regWidget("monitoring_services", none); regWidget("monitoring_services", none);
regWidget("bgService", none); regWidget("bgService", none);

View file

@ -38,6 +38,7 @@ import android.view.animation.Animation.AnimationListener;
import android.view.animation.TranslateAnimation; import android.view.animation.TranslateAnimation;
import android.widget.Button; import android.widget.Button;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ScrollView; import android.widget.ScrollView;
/** /**
@ -66,6 +67,7 @@ public class DashboardOnMap {
private float mapRotation; private float mapRotation;
private boolean inLocationUpdate = false; private boolean inLocationUpdate = false;
private boolean saveBackAction; private boolean saveBackAction;
private ImageView switchButton;
public DashboardOnMap(MapActivity ma) { public DashboardOnMap(MapActivity ma) {
@ -90,12 +92,13 @@ public class DashboardOnMap {
dashboardView.setOnClickListener(listener); dashboardView.setOnClickListener(listener);
dashboardView.findViewById(R.id.map_layers_button).setOnClickListener(new View.OnClickListener() { switchButton = (ImageView) dashboardView.findViewById(R.id.map_layers_button);
switchButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
setDashboardVisibility(false); setDashboardVisibility(false);
mapActivity.getMapActions().prepareConfigureMap(); mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.set(false);
mapActivity.getMapActions().toggleDrawer(); mapActivity.getMapActions().toggleDrawer();
} }
}); });
@ -169,18 +172,17 @@ 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));
mapActivity.getMapActions().disableDrawer(); mapActivity.getMapActions().disableDrawer();
mapActivity.findViewById(R.id.MapInfoControls).setVisibility(View.GONE); mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.GONE);
mapActivity.findViewById(R.id.MapButtons).setVisibility(View.GONE);
updateLocation(true, true, false); updateLocation(true, true, false);
} else { } else {
mapActivity.getMapActions().enableDrawer(); mapActivity.getMapActions().enableDrawer();
mapActivity.getMapViewTrackingUtilities().setDashboard(null); mapActivity.getMapViewTrackingUtilities().setDashboard(null);
hide(dashboardView.findViewById(R.id.animateContent)); hide(dashboardView.findViewById(R.id.animateContent));
mapActivity.findViewById(R.id.MapInfoControls).setVisibility(View.VISIBLE); mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE);
mapActivity.findViewById(R.id.MapButtons).setVisibility(View.VISIBLE);
fabButton.hideFloatingActionButton(); fabButton.hideFloatingActionButton();
for (WeakReference<DashBaseFragment> df : fragList) { for (WeakReference<DashBaseFragment> df : fragList) {
if (df.get() != null) { if (df.get() != null) {

View file

@ -19,6 +19,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.ScreenOrientationHelper; 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.helpers.WaypointDialogHelper;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.controls.MapRoutePlanControl; import net.osmand.plus.views.controls.MapRoutePlanControl;
import net.osmand.plus.views.controls.MapRoutePreferencesControl; import net.osmand.plus.views.controls.MapRoutePreferencesControl;
import net.osmand.plus.views.controls.MapCancelControl; import net.osmand.plus.views.controls.MapCancelControl;
@ -29,6 +30,7 @@ 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.RulerControl;
import net.osmand.plus.views.controls.SmallMapMenuControls; 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.PointF; import android.graphics.PointF;
@ -39,17 +41,21 @@ 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;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.SeekBar; import android.widget.SeekBar;
import android.widget.TextView;
public class MapControlsLayer extends OsmandMapLayer { 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 { private static class MapHudButton {
ImageView iv; View iv;
int bgDark; int bgDark;
int bgLight; int bgLight;
int resId; int resId;
@ -59,7 +65,6 @@ public class MapControlsLayer extends OsmandMapLayer {
boolean nightMode = false; boolean nightMode = false;
boolean f = true; boolean f = true;
public MapHudButton setRoundTransparent() { public MapHudButton setRoundTransparent() {
setBg(R.drawable.btn_circle_trans); setBg(R.drawable.btn_circle_trans);
return this; return this;
@ -80,16 +85,15 @@ public class MapControlsLayer extends OsmandMapLayer {
return this; return this;
} }
public static MapHudButton create(ImageView iv, int resId) { public static MapHudButton create(View iv, int resId) {
MapHudButton mc = new MapHudButton(); MapHudButton mc = new MapHudButton();
mc.iv = iv; mc.iv = iv;
mc.resId = resId; mc.resId = resId;
mc.setBg(R.drawable.btn_circle);
return mc; return mc;
} }
public boolean setIconResId(int resId) { public boolean setIconResId(int resId) {
if(this.resId == resId) { if (this.resId == resId) {
return false; return false;
} }
this.resId = resId; this.resId = resId;
@ -97,14 +101,14 @@ public class MapControlsLayer extends OsmandMapLayer {
return true; return true;
} }
public boolean setIconColorId(int clr) { public MapHudButton setIconColorId(int clr) {
if(resLight == clr && resDark == clr) { if (resLight == clr && resDark == clr) {
return false; return this;
} }
resLight = clr; resLight = clr;
resDark = clr; resDark = clr;
f = true; f = true;
return true; return this;
} }
public void update(OsmandApplication ctx, boolean night) { public void update(OsmandApplication ctx, boolean night) {
@ -113,21 +117,24 @@ public class MapControlsLayer extends OsmandMapLayer {
} }
f = false; f = false;
nightMode = night; nightMode = night;
if(bgDark != 0 && bgLight != 0) { if (bgDark != 0 && bgLight != 0) {
iv.setBackgroundDrawable(ctx.getResources().getDrawable(night ? bgDark : bgLight)); iv.setBackgroundDrawable(ctx.getResources().getDrawable(night ? bgDark : bgLight));
} }
iv.setImageDrawable(ctx.getIconsCache().getIcon(resId, nightMode ? resDark : resLight)); 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>();
private final MapActivity mapActivity; private final MapActivity mapActivity;
private int shadowColor = -1; private int shadowColor = -1;
// private RulerControl rulerControl; // private RulerControl rulerControl;
// private List<MapControls> allControls = new ArrayList<MapControls>(); // private List<MapControls> allControls = new ArrayList<MapControls>();
private float scaleCoefficient; private float scaleCoefficient;
@ -136,25 +143,22 @@ public class MapControlsLayer extends OsmandMapLayer {
private static CommonPreference<Integer> settingsToTransparency; private static CommonPreference<Integer> settingsToTransparency;
private OsmandSettings settings; private OsmandSettings settings;
private MapRoutePreferencesControl optionsRouteControlDialog;
private MapRouteInfoControl mapRouteInfoControlDialog;
private View routePreparationLayout;
private MapHudButton backToLocationControl; private MapHudButton backToLocationControl;
private MapHudButton menuControl; private MapHudButton menuControl;
private View routePreparationLayout;
private MapRouteInfoControl mapRouteInfoControl;
private MapHudButton optionsRouteControl; private MapHudButton optionsRouteControl;
private MapHudButton routeGoControl;
private MapHudButton compassHud;
private float cachedRotate = 0;
private RotateAnimation rotateAnimation;
public MapControlsLayer(MapActivity activity) {
private MapRoutePreferencesControl optionsRouteControlDialog;
public MapControlsLayer(MapActivity activity){
this.mapActivity = activity; this.mapActivity = activity;
settings = activity.getMyApplication().getSettings(); settings = activity.getMyApplication().getSettings();
} }
@Override @Override
public boolean drawInScreenPixels() { public boolean drawInScreenPixels() {
return true; return true;
@ -164,51 +168,77 @@ public class MapControlsLayer extends OsmandMapLayer {
public void initLayer(final OsmandMapTileView view) { public void initLayer(final OsmandMapTileView view) {
scaleCoefficient = view.getScaleCoefficient(); scaleCoefficient = view.getScaleCoefficient();
FrameLayout parent = getParent(); FrameLayout parent = getParent();
initNewControls();
// TODO // TODO
// rulerControl = init(new RulerControl(zoomControls, mapActivity, showUIHandler, scaleCoefficient), parent, // rulerControl = init(new RulerControl(zoomControls, mapActivity, showUIHandler, scaleCoefficient), parent,
// rightGravity); // rightGravity);
initTransparencyBar(view, parent); initTransparencyBar(view, parent);
}
private void initNewControls() {
initZooms(); initZooms();
initControls(); initControls();
initRouteControls(); initRouteControls();
initTopControls();
} }
private void initTopControls() {
View configureMap = mapActivity.findViewById(R.id.map_layers_button);
controls.add(MapHudButton.create((ImageView) configureMap, R.drawable.ic_action_layers_dark).setBg(
R.drawable.btn_inset_circle, R.drawable.btn_inset_circle_night));
configureMap.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
notifyClicked();
mapActivity.getMapActions().prepareConfigureMap();
mapActivity.getMapActions().toggleDrawer();
}
});
View compass = mapActivity.findViewById(R.id.map_compass_button);
compassHud = MapHudButton.create((ImageView) compass, R.drawable.map_compass).setIconColorId(0)
.setBg(R.drawable.btn_inset_circle, R.drawable.btn_inset_circle_night);
controls.add(compassHud);
compass.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
notifyClicked();
mapActivity.getMapViewTrackingUtilities().switchRotateMapMode();
}
});
}
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)); controls.add(MapHudButton.create((ImageView) cancelRouteButton, R.drawable.ic_action_remove_dark).setBg(
R.drawable.btn_flat, R.drawable.btn_flat_night));
cancelRouteButton.setOnClickListener(new View.OnClickListener() { cancelRouteButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
notifyClicked(); notifyClicked();
if(mapActivity.getRoutingHelper().isFollowingMode()) { if (mapActivity.getRoutingHelper().isFollowingMode()) {
mapActivity.getMapActions().stopNavigationActionConfirm(mapActivity.getMapView()); mapActivity.getMapActions().stopNavigationActionConfirm(mapActivity.getMapView());
} else { } else {
mapActivity.getMapActions().stopNavigationWithoutConfirm(); mapActivity.getMapActions().stopNavigationWithoutConfirm();
} }
} }
}); });
mapRouteInfoControl = new MapRouteInfoControl(mapActivity.getMapLayers().getContextMenuLayer(), mapRouteInfoControlDialog = new MapRouteInfoControl(mapActivity.getMapLayers().getContextMenuLayer(),
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)); controls.add(MapHudButton.create((ImageView) waypointsButton, R.drawable.ic_action_flage_dark).setBg(
R.drawable.btn_flat, R.drawable.btn_flat_night));
waypointsButton.setOnClickListener(new View.OnClickListener() { waypointsButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
notifyClicked(); notifyClicked();
mapRouteInfoControl.showHideDialog(); mapRouteInfoControlDialog.showHideDialog();
} }
}); });
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, settings.getApplicationMode().getSmallIcon(false)); optionsRouteControl = MapHudButton.create((ImageView) optionsRouteButton,
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);
optionsRouteButton.setOnClickListener(new View.OnClickListener() { optionsRouteButton.setOnClickListener(new View.OnClickListener() {
@ -218,16 +248,29 @@ public class MapControlsLayer extends OsmandMapLayer {
optionsRouteControlDialog.showAndHideDialog(); optionsRouteControlDialog.showAndHideDialog();
} }
}); });
TextView routeGoButton = (TextView) mapActivity.findViewById(R.id.map_go_route_button);
routeGoControl = MapHudButton.create(routeGoButton, R.drawable.ic_destination_arrow_white).setBg(
R.drawable.btn_flat, R.drawable.btn_flat_night);
controls.add(routeGoControl);
routeGoButton.setText(mapActivity.getString(R.string.shared_string_go).toUpperCase());
routeGoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
notifyClicked();
startNavigation();
}
});
} }
public void showDialog(){ public void showDialog() {
mapRouteInfoControl.setShowDialog(); mapRouteInfoControlDialog.setShowDialog();
} }
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).setBg(R.drawable.btn_circle_blue) backToLocationControl = MapHudButton.create((ImageView) backToLocation, R.drawable.ic_action_get_my_location)
; .setBg(R.drawable.btn_circle_blue);
controls.add(backToLocationControl); controls.add(backToLocationControl);
backToLocation.setOnClickListener(new View.OnClickListener() { backToLocation.setOnClickListener(new View.OnClickListener() {
@ -238,8 +281,8 @@ 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). menuControl = MapHudButton.create((ImageView) backToMenuButton, R.drawable.ic_navigation_drawer).setBg(
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() {
@Override @Override
@ -248,7 +291,7 @@ public class MapControlsLayer extends OsmandMapLayer {
// double lon = activity.getMapView().getLongitude(); // double lon = activity.getMapView().getLongitude();
// MainMenuActivity.backToMainMenuDialog(activity, new LatLon(lat, lon)); // MainMenuActivity.backToMainMenuDialog(activity, new LatLon(lat, lon));
notifyClicked(); notifyClicked();
if(mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.get()) { if (mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.get()) {
mapActivity.getDashboard().setDashboardVisibility(true); mapActivity.getDashboard().setDashboardVisibility(true);
} else { } else {
mapActivity.getMapActions().onDrawerBack(); mapActivity.getMapActions().onDrawerBack();
@ -258,8 +301,8 @@ 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_info_dark). controls.add(MapHudButton.create((ImageView) routePlanButton, R.drawable.ic_action_gdirections_dark).setBg(
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
public void onClick(View v) { public void onClick(View v) {
@ -269,14 +312,13 @@ public class MapControlsLayer extends OsmandMapLayer {
mapActivity.refreshMap(); mapActivity.refreshMap();
} }
}); });
}
}
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(MapHudButton.create((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) {
@ -292,8 +334,8 @@ 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).setRoundTransparent() controls.add(MapHudButton.create((ImageView) zoomOutButton, R.drawable.ic_action_zoom_out)
); .setRoundTransparent());
zoomOutButton.setOnClickListener(new View.OnClickListener() { zoomOutButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -304,27 +346,39 @@ public class MapControlsLayer extends OsmandMapLayer {
zoomOutButton.setOnLongClickListener(listener); zoomOutButton.setOnLongClickListener(listener);
} }
public void startNavigation() { public void startNavigation() {
// TODO stopCounter();
// if (mapNavigationControl == null) { OsmandApplication app = mapActivity.getMyApplication();
// return; RoutingHelper routingHelper = app.getRoutingHelper();
// } if (routingHelper.isFollowingMode()) {
// mapNavigationControl.startNavigation(); routingHelper.setRoutePlanningMode(false);
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
} else {
if (!app.getTargetPointsHelper().checkPointToNavigateShort()) {
mapRouteInfoControlDialog.showDialog();
} else {
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
app.getSettings().FOLLOW_THE_ROUTE.set(true);
routingHelper.setFollowingMode(true);
routingHelper.setRoutePlanningMode(false);
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
routingHelper.setCurrentLocation(app.getLocationProvider().getLastKnownLocation(), false);
app.getRoutingHelper().notifyIfRouteIsCalculated();
}
}
} }
private void stopCounter() {
// TODO stop counter
}
protected void notifyClicked(MapControls m) { protected void notifyClicked(MapControls m) {
notifyClicked(); notifyClicked();
} }
protected void notifyClicked() { protected void notifyClicked() {
// TODO stopCounter();
// if(mapNavigationControl != null) {
// mapNavigationControl.stopCounter();
// }
} }
@Override @Override
@ -340,7 +394,7 @@ public class MapControlsLayer extends OsmandMapLayer {
if (shadowColor != shadw) { if (shadowColor != shadw) {
shadowColor = shadw; shadowColor = shadw;
// TODO // TODO
// updatextColor(textColor, shadw, rulerControl, zoomControls, mapMenuControls); // updatextColor(textColor, shadw, rulerControl, zoomControls, mapMenuControls);
} }
// default buttons // default buttons
boolean routePlanningMode = false; boolean routePlanningMode = false;
@ -357,6 +411,7 @@ public class MapControlsLayer extends OsmandMapLayer {
&& (!routeFollowingMode || settings.SHOW_ZOOM_BUTTONS_NAVIGATION.get()); && (!routeFollowingMode || settings.SHOW_ZOOM_BUTTONS_NAVIGATION.get());
// ///////////////////////////////////////////// // /////////////////////////////////////////////
// new update // new update
boolean enabled = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation() != null; boolean enabled = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation() != null;
boolean tracked = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation(); boolean tracked = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
if (!enabled) { if (!enabled) {
@ -366,63 +421,116 @@ public class MapControlsLayer extends OsmandMapLayer {
} else { } else {
backToLocationControl.setIconColorId(R.color.color_white); backToLocationControl.setIconColorId(R.color.color_white);
} }
menuControl.setIconResId(mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.get() ? R.drawable.ic_dashboard_dark
menuControl
.setIconResId(mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.get() ? R.drawable.ic_dashboard_dark
: R.drawable.ic_navigation_drawer); : R.drawable.ic_navigation_drawer);
optionsRouteControl.setIconResId(settings.getApplicationMode().getSmallIcon(false));
int vis = showRouteCalculationControls? View.VISIBLE : View.GONE; optionsRouteControl.setIconResId(settings.getApplicationMode().getSmallIcon(true));
if(routePreparationLayout.getVisibility() != vis) { int vis = showRouteCalculationControls ? View.VISIBLE : View.GONE;
if (showRouteCalculationControls) {
((TextView) routeGoControl.iv).setTextColor(textColor);
}
if (routePreparationLayout.getVisibility() != vis) {
routePreparationLayout.setVisibility(vis); routePreparationLayout.setVisibility(vis);
mapRouteInfoControl.setVisible(showRouteCalculationControls); mapRouteInfoControlDialog.setVisible(showRouteCalculationControls);
}
float mapRotate = mapActivity.getMapView().getRotate();
if (mapRotate != cachedRotate && (rotateAnimation == null || rotateAnimation.hasEnded())) {
float c = 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
compassHud.iv.setAnimation(rotateAnimation);
// compassHud.iv.invalidate();
}
if (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_NONE) {
compassHud.setIconResId(isNight ? R.drawable.map_compass_niu_white : R.drawable.map_compass_niu);
} else if (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_BEARING) {
compassHud.setIconResId(isNight ? R.drawable.map_compass_bearing_white : R.drawable.map_compass_bearing);
} else {
compassHud.setIconResId(isNight ? R.drawable.map_compass_white : R.drawable.map_compass);
} }
for (MapHudButton mc : controls) { for (MapHudButton mc : controls) {
mc.update(mapActivity.getMyApplication(), nightMode == null ? false : nightMode.isNightMode()); mc.update(mapActivity.getMyApplication(), nightMode == null ? false : nightMode.isNightMode());
} }
} }
// 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 void updatextColor(int textColor, int shadowColor, MapControls... mc) {
for(MapControls m : mc) {
m.updateTextColor(textColor, shadowColor);
}
}
private FrameLayout getParent() { private FrameLayout getParent() {
return (FrameLayout) mapActivity.findViewById(R.id.MapButtons); return (FrameLayout) mapActivity.findViewById(R.id.MapButtons);
} }
@Override
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) { public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
// TODO stop counter & show buttons // TODO stop counter & show buttons
// for(MapControls m : allControls) { // for(MapControls m : allControls) {
// if(m.isVisible() && m.onSingleTap(point, tileBox)){ // if(m.isVisible() && m.onSingleTap(point, tileBox)){
// return true; // return true;
// } // }
// } // }
return false; return false;
} }
@Override @Override
public boolean onTouchEvent(MotionEvent event, RotatedTileBox tileBox) { public boolean onTouchEvent(MotionEvent event, RotatedTileBox tileBox) {
// TODO stop counter & show buttons // TODO stop counter & show buttons
// if(!mapActivity.getRoutingHelper().isRoutePlanningMode() && mapActivity.getRoutingHelper().isFollowingMode()) { // if(!mapActivity.getRoutingHelper().isRoutePlanningMode() && mapActivity.getRoutingHelper().isFollowingMode())
// if(!settings.SHOW_ZOOM_BUTTONS_NAVIGATION.get()) { // {
// zoomControls.showWithDelay(getParent(), TIMEOUT_TO_SHOW_BUTTONS); // if(!settings.SHOW_ZOOM_BUTTONS_NAVIGATION.get()) {
// mapMenuControls.showWithDelay(getParent(), TIMEOUT_TO_SHOW_BUTTONS); // zoomControls.showWithDelay(getParent(), TIMEOUT_TO_SHOW_BUTTONS);
// } // mapMenuControls.showWithDelay(getParent(), TIMEOUT_TO_SHOW_BUTTONS);
// mapRoutePlanControl.showWithDelay(getParent(), TIMEOUT_TO_SHOW_BUTTONS); // }
// } // mapRoutePlanControl.showWithDelay(getParent(), TIMEOUT_TO_SHOW_BUTTONS);
// }
return false; return false;
} }
// /////////////// Transparency bar /////////////////////////
///////////////// Transparency bar /////////////////////////
private void initTransparencyBar(final OsmandMapTileView view, FrameLayout parent) { private void initTransparencyBar(final OsmandMapTileView view, FrameLayout parent) {
int minimumHeight = view.getResources().getDrawable(R.drawable.map_zoom_in).getMinimumHeight(); int minimumHeight = view.getResources().getDrawable(R.drawable.map_zoom_in).getMinimumHeight();
android.widget.FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, android.widget.FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
Gravity.BOTTOM | Gravity.CENTER); LayoutParams.WRAP_CONTENT, Gravity.BOTTOM | Gravity.CENTER);
params.setMargins(0, 0, 0, minimumHeight + 3); params.setMargins(0, 0, 0, minimumHeight + 3);
transparencyBarLayout = new LinearLayout(view.getContext()); transparencyBarLayout = new LinearLayout(view.getContext());
transparencyBarLayout.setVisibility(settingsToTransparency != null ? View.VISIBLE : View.GONE); transparencyBarLayout.setVisibility(settingsToTransparency != null ? View.VISIBLE : View.GONE);
@ -430,7 +538,7 @@ public class MapControlsLayer extends OsmandMapLayer {
transparencyBar = new SeekBar(view.getContext()); transparencyBar = new SeekBar(view.getContext());
transparencyBar.setMax(255); transparencyBar.setMax(255);
if(settingsToTransparency != null) { if (settingsToTransparency != null) {
transparencyBar.setProgress(settingsToTransparency.get()); transparencyBar.setProgress(settingsToTransparency.get());
} }
transparencyBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { transparencyBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@ -476,7 +584,7 @@ public class MapControlsLayer extends OsmandMapLayer {
} }
public void hideTransparencyBar(CommonPreference<Integer> transparentPreference) { public void hideTransparencyBar(CommonPreference<Integer> transparentPreference) {
if(settingsToTransparency == transparentPreference) { if (settingsToTransparency == transparentPreference) {
transparencyBarLayout.setVisibility(View.GONE); transparencyBarLayout.setVisibility(View.GONE);
settingsToTransparency = null; settingsToTransparency = null;
} }
@ -486,7 +594,4 @@ public class MapControlsLayer extends OsmandMapLayer {
// TODO // TODO
} }
} }