update map buttons
This commit is contained in:
parent
8f8c4b0874
commit
dcb3996a5b
7 changed files with 264 additions and 24 deletions
13
OsmAnd/res/drawable/btn_circle_blue.xml
Normal file
13
OsmAnd/res/drawable/btn_circle_blue.xml
Normal 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="oval">
|
||||
<solid android:color="@color/color_myloc_distance" />
|
||||
<stroke android:color="@color/map_widget_stroke" android:width="@dimen/map_button_stroke"/>
|
||||
</shape></item>
|
||||
<item><shape android:shape="oval">
|
||||
<solid android:color="@color/map_widget_blue" />
|
||||
<stroke android:color="@color/map_widget_stroke" android:width="@dimen/map_button_stroke"/>
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
13
OsmAnd/res/drawable/btn_circle_trans.xml
Normal file
13
OsmAnd/res/drawable/btn_circle_trans.xml
Normal 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="oval">
|
||||
<solid android:color="@color/map_widget_light_pressed" />
|
||||
<stroke android:color="@color/map_widget_stroke" android:width="@dimen/map_button_stroke"/>
|
||||
</shape></item>
|
||||
<item><shape android:shape="oval">
|
||||
<solid android:color="@color/map_widget_light_trans" />
|
||||
<stroke android:color="@color/map_widget_stroke" android:width="@dimen/map_button_stroke"/>
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
15
OsmAnd/res/drawable/btn_round_night.xml
Normal file
15
OsmAnd/res/drawable/btn_round_night.xml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?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_light_pressed" />
|
||||
<corners android:radius="@dimen/map_button_rect_rad" />
|
||||
<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" />
|
||||
<corners android:radius="@dimen/map_button_rect_rad" />
|
||||
<stroke android:width="@dimen/map_button_stroke" android:color="@color/map_widget_stroke" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
|
@ -20,6 +20,7 @@
|
|||
android:layout_width="@dimen/map_button_size"
|
||||
android:layout_height="@dimen/map_button_size"
|
||||
android:background="@drawable/btn_round"
|
||||
android:id="@+id/map_menu_button"
|
||||
android:src="@drawable/ic_action_remove_light" />
|
||||
|
||||
<ImageButton
|
||||
|
@ -27,6 +28,7 @@
|
|||
android:layout_height="@dimen/map_button_size"
|
||||
android:layout_marginLeft="@dimen/map_button_spacing"
|
||||
android:background="@drawable/btn_round"
|
||||
android:id="@+id/map_route_info_button"
|
||||
android:src="@drawable/ic_action_remove_light" />
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -38,6 +40,7 @@
|
|||
android:layout_marginRight="@dimen/map_button_margin" >
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/map_my_location_button"
|
||||
android:layout_width="@dimen/map_button_size"
|
||||
android:layout_height="@dimen/map_button_size"
|
||||
android:layout_gravity="bottom"
|
||||
|
@ -52,14 +55,14 @@
|
|||
android:orientation="vertical" >
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/"
|
||||
android:id="@+id/map_zoom_in_button"
|
||||
android:layout_width="@dimen/map_button_size"
|
||||
android:layout_height="@dimen/map_button_size"
|
||||
android:background="@drawable/btn_circle"
|
||||
|
||||
android:src="@drawable/ic_action_remove_light" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/map_zoom_out_button"
|
||||
android:layout_width="@dimen/map_button_size"
|
||||
android:layout_height="@dimen/map_button_size"
|
||||
android:layout_marginTop="@dimen/map_button_spacing"
|
||||
|
@ -75,24 +78,52 @@
|
|||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="30dp"
|
||||
android:background="@drawable/btn_flat"
|
||||
android:layout_height="@dimen/map_route_buttons_height"
|
||||
android:id="@+id/map_route_preparation_layout"
|
||||
android:layout_gravity="bottom" >
|
||||
|
||||
<ImageButton
|
||||
android:layout_width="@dimen/map_route_buttons_width"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/map_cancel_route_button"
|
||||
android:background="@drawable/btn_flat"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@drawable/ic_action_remove_light" />
|
||||
|
||||
<ImageButton
|
||||
android:layout_width="@dimen/map_route_buttons_width"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/map_waypoints_route_button"
|
||||
android:background="@drawable/btn_flat"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@drawable/ic_action_remove_light" />
|
||||
|
||||
<ImageButton
|
||||
android:layout_width="@dimen/map_route_buttons_width"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/btn_flat"
|
||||
android:id="@+id/map_options_route_button"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@drawable/ic_action_remove_light" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:text="Route preparation" >
|
||||
</TextView>
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/btn_flat"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/map_go_route_button"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="12dp"
|
||||
android:drawableLeft="@drawable/ic_action_remove_light"
|
||||
android:textSize="20sp"
|
||||
android:drawablePadding="4dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/map_context_menu_layout"
|
||||
android:visibility="gone"
|
||||
android:background="@drawable/btn_flat"
|
||||
android:layout_gravity="bottom">
|
||||
|
||||
|
@ -101,11 +132,7 @@
|
|||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/color_black"
|
||||
android:textSize="24sp"
|
||||
android:maxLines="1"
|
||||
android:text="Context menu" >
|
||||
android:gravity="center">
|
||||
</TextView>
|
||||
|
||||
<ImageButton
|
||||
|
|
|
@ -11,8 +11,11 @@
|
|||
<color name="list_item_background_dark_pressed">#be39464d</color>
|
||||
|
||||
<color name="map_widget_stroke">#333333</color>
|
||||
<color name="map_widget_light">#eeffffff</color>
|
||||
<color name="map_widget_light">#aaffffff</color>
|
||||
<color name="map_widget_dark">#aa3f3f3f</color>
|
||||
<color name="map_widget_light_trans">#eeffffff</color>
|
||||
<color name="map_widget_light_pressed">#ddcccccc</color>
|
||||
<color name="map_widget_blue">#3030FF</color>
|
||||
|
||||
|
||||
<color name="actionbar_dark_color">#39464d</color>
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
<dimen name="dashboard_parking_left_margin">16dp</dimen>
|
||||
<dimen name="dashboard_parking_icon_size">48dp</dimen>
|
||||
<!-- map buttons -->
|
||||
<dimen name="map_route_buttons_width">60dp</dimen>
|
||||
<dimen name="map_route_buttons_height">54dp</dimen>
|
||||
<dimen name="map_address_height">40dp</dimen>
|
||||
<dimen name="map_button_size">48dp</dimen>
|
||||
<dimen name="map_widget_icon">24dp</dimen>
|
||||
|
|
|
@ -4,12 +4,14 @@ import java.util.ArrayList;
|
|||
import java.util.Calendar;
|
||||
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.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -30,6 +32,7 @@ import net.osmand.plus.views.controls.SmallMapMenuControls;
|
|||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -38,12 +41,90 @@ import android.view.View.OnClickListener;
|
|||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
public class MapControlsLayer extends OsmandMapLayer {
|
||||
|
||||
private static final int TIMEOUT_TO_SHOW_BUTTONS = 5000;
|
||||
private static class MapControl {
|
||||
ImageView iv;
|
||||
int bgDark;
|
||||
int bgLight;
|
||||
int resId;
|
||||
int resLight = R.color.icon_color_light;
|
||||
int resDark = 0;
|
||||
|
||||
boolean nightMode = false;
|
||||
boolean f = true;
|
||||
|
||||
|
||||
public MapControl setRoundTransparent() {
|
||||
setBg(R.drawable.btn_circle_trans);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MapControl setBg(int dayBg, int nightBg) {
|
||||
bgDark = nightBg;
|
||||
bgLight = dayBg;
|
||||
f = true;
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public MapControl setBg(int bg) {
|
||||
bgDark = bg;
|
||||
bgLight = bg;
|
||||
f = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static MapControl create(ImageView iv, int resId) {
|
||||
MapControl mc = new MapControl();
|
||||
mc.iv = iv;
|
||||
mc.resId = resId;
|
||||
mc.setBg(R.drawable.btn_circle);
|
||||
return mc;
|
||||
}
|
||||
|
||||
public boolean setIconResId(int resId) {
|
||||
if(this.resId == resId) {
|
||||
return false;
|
||||
}
|
||||
this.resId = resId;
|
||||
f = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setIconColorId(int clr) {
|
||||
if(resLight == clr && resDark == clr) {
|
||||
return false;
|
||||
}
|
||||
resLight = clr;
|
||||
resDark = clr;
|
||||
f = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void update(OsmandApplication ctx, boolean night) {
|
||||
if (nightMode == night && !f) {
|
||||
return;
|
||||
}
|
||||
f = false;
|
||||
nightMode = night;
|
||||
iv.setBackgroundDrawable(ctx.getResources().getDrawable(night ? bgDark : bgLight));
|
||||
iv.setImageDrawable(ctx.getIconsCache().getIcon(resId, nightMode ? resDark : resLight));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private List<MapControl> controls = new ArrayList<MapControlsLayer.MapControl>();
|
||||
|
||||
|
||||
private final MapActivity mapActivity;
|
||||
private int shadowColor = -1;
|
||||
|
||||
|
@ -68,12 +149,21 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
private OsmandSettings settings;
|
||||
|
||||
|
||||
private MapControl backToLocationControl;
|
||||
|
||||
|
||||
private MapControl menuControl;
|
||||
|
||||
|
||||
public MapControlsLayer(MapActivity activity){
|
||||
this.mapActivity = activity;
|
||||
settings = activity.getMyApplication().getSettings();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean drawInScreenPixels() {
|
||||
return true;
|
||||
|
@ -132,13 +222,63 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
|
||||
private void initNewControls() {
|
||||
initZooms();
|
||||
initControls();
|
||||
}
|
||||
|
||||
|
||||
private void initControls() {
|
||||
View backToLocation = mapActivity.findViewById(R.id.map_my_location_button);
|
||||
backToLocationControl = MapControl.create((ImageView) backToLocation, R.drawable.ic_action_get_my_location).setBg(R.drawable.btn_circle_blue)
|
||||
;
|
||||
controls.add(backToLocationControl);
|
||||
|
||||
backToLocation.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
|
||||
}
|
||||
});
|
||||
|
||||
View backToMenuButton = mapActivity.findViewById(R.id.map_menu_button);
|
||||
menuControl = MapControl.create((ImageView) backToMenuButton, R.drawable.ic_navigation_drawer).
|
||||
setBg(R.drawable.btn_round, R.drawable.btn_round_night);
|
||||
controls.add(menuControl);
|
||||
backToMenuButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// double lat = activity.getMapView().getLatitude();
|
||||
// double lon = activity.getMapView().getLongitude();
|
||||
// MainMenuActivity.backToMainMenuDialog(activity, new LatLon(lat, lon));
|
||||
notifyClicked();
|
||||
if(mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.get()) {
|
||||
mapActivity.getDashboard().setDashboardVisibility(true);
|
||||
} else {
|
||||
mapActivity.getMapActions().onDrawerBack();
|
||||
mapActivity.getMapActions().toggleDrawer();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
View routePlanButton = mapActivity.findViewById(R.id.map_route_info_button);
|
||||
controls.add(MapControl.create((ImageView) routePlanButton, R.drawable.ic_action_info_dark).
|
||||
setBg(R.drawable.btn_round, R.drawable.btn_round_night));
|
||||
routePlanButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
notifyClicked();
|
||||
mapActivity.getRoutingHelper().setRoutePlanningMode(true);
|
||||
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void initZooms() {
|
||||
final OsmandMapTileView view = mapActivity.getMapView();
|
||||
mapActivity.findViewById(id)
|
||||
View zoomInButton = mapActivity.findViewById(R.id.map_zoom_in_button);
|
||||
controls.add(MapControl.create((ImageView) zoomInButton, R.drawable.ic_action_zoom_in).setRoundTransparent()
|
||||
);
|
||||
zoomInButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -153,6 +293,9 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
});
|
||||
final View.OnLongClickListener listener = MapZoomControls.getOnClickMagnifierListener(view);
|
||||
zoomInButton.setOnLongClickListener(listener);
|
||||
View zoomOutButton = mapActivity.findViewById(R.id.map_zoom_out_button);
|
||||
controls.add(MapControl.create((ImageView) zoomOutButton, R.drawable.ic_action_zoom_out).setRoundTransparent()
|
||||
);
|
||||
zoomOutButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -198,7 +341,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
|
||||
@Override
|
||||
public void destroyLayer() {
|
||||
|
||||
controls.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -246,7 +389,30 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
(zoomControls.getHeight() + zoomControls.getTotalVerticalMargin()) : 0;
|
||||
rulerControl.setVerticalMargin(vmargin);
|
||||
checkVisibilityAndDraw(true, rulerControl, canvas, tileBox, nightMode);
|
||||
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// new update
|
||||
boolean enabled = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation() != null;
|
||||
boolean tracked = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
|
||||
if (!enabled) {
|
||||
backToLocationControl.setIconColorId(R.color.icon_color_light);
|
||||
} else if (tracked) {
|
||||
backToLocationControl.setIconColorId(R.color.color_distance);
|
||||
} else {
|
||||
backToLocationControl.setIconColorId(R.color.color_white);
|
||||
}
|
||||
menuControl.setIconResId(mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.get() ?
|
||||
R.drawable.ic_dashboard_dark : R.drawable.ic_navigation_drawer);
|
||||
|
||||
for(MapControl mc : controls) {
|
||||
mc.update(mapActivity.getMyApplication(),
|
||||
nightMode == null ? false : nightMode.isNightMode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void updatextColor(int textColor, int shadowColor, MapControls... mc) {
|
||||
for(MapControls m : mc) {
|
||||
|
@ -264,7 +430,8 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
}
|
||||
}
|
||||
if(controls.isVisible()) {
|
||||
controls.onDraw(canvas, tileBox, nightMode);
|
||||
// FIXME
|
||||
// controls.onDraw(canvas, tileBox, nightMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue