Fix issues
This commit is contained in:
parent
47ab27b5d1
commit
7f93abc332
9 changed files with 312 additions and 542 deletions
15
OsmAnd/res/drawable/btn_round_trans.xml
Normal file
15
OsmAnd/res/drawable/btn_round_trans.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_light_trans" />
|
||||
<corners android:radius="@dimen/map_button_rect_rad" />
|
||||
<stroke android:width="@dimen/map_button_stroke" android:color="@color/map_widget_stroke" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
|
@ -9,6 +9,57 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/map_app_mode_shadow"
|
||||
android:layout_width="@dimen/map_button_shadow_width"
|
||||
android:layout_height="@dimen/map_button_shadow_height"
|
||||
android:layout_gravity="bottom|left"
|
||||
android:layout_marginBottom="@dimen/map_button_shadow_margin"
|
||||
android:layout_marginLeft="@dimen/map_button_shadow_margin"
|
||||
android:background="@drawable/btn_round_trans" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/map_app_mode_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top|center"
|
||||
android:layout_marginTop="3dp"
|
||||
android:src="@drawable/ic_action_remove_light" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/map_app_mode_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top|center"
|
||||
android:layout_marginTop="3dp"
|
||||
android:textSize="@dimen/map_button_text_size" />
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/map_transparency_layout"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="bottom|center"
|
||||
android:layout_marginBottom="@dimen/map_button_size"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/map_transparency_seekbar"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="@dimen/map_trans_seek_size"
|
||||
android:layout_gravity="center"
|
||||
/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/map_transparency_hide"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/btn_circle_transparent"
|
||||
android:src="@drawable/headliner_close" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -17,18 +68,18 @@
|
|||
android:layout_marginLeft="@dimen/map_button_margin" >
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/map_menu_button"
|
||||
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
|
||||
android:id="@+id/map_route_info_button"
|
||||
android:layout_width="@dimen/map_button_size"
|
||||
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>
|
||||
|
||||
|
@ -77,56 +128,56 @@
|
|||
android:layout_height="wrap_content" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/map_route_preparation_layout"
|
||||
android:layout_width="match_parent"
|
||||
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_width="@dimen/map_route_buttons_width"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@drawable/btn_flat"
|
||||
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_width="@dimen/map_route_buttons_width"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@drawable/btn_flat"
|
||||
android:src="@drawable/ic_action_remove_light" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/map_options_route_button"
|
||||
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:background="@drawable/btn_flat"
|
||||
android:src="@drawable/ic_action_remove_light" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/map_go_route_button"
|
||||
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:background="@drawable/btn_flat"
|
||||
android:drawableLeft="@drawable/ic_action_remove_light"
|
||||
android:drawablePadding="4dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="12dp"
|
||||
android:drawableLeft="@drawable/ic_action_remove_light"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
android:drawablePadding="4dp" />
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/map_context_menu_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/map_context_menu_layout"
|
||||
android:visibility="gone"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/btn_flat"
|
||||
android:layout_gravity="bottom">
|
||||
android:visibility="gone" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
|
|
|
@ -48,15 +48,21 @@
|
|||
<dimen name="dashboard_parking_left_margin">16dp</dimen>
|
||||
<dimen name="dashboard_parking_icon_size">48dp</dimen>
|
||||
<!-- map buttons -->
|
||||
|
||||
<dimen name="map_trans_seek_size">80dp</dimen>
|
||||
<dimen name="map_button_text_size">18sp</dimen>
|
||||
<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_button_shadow_width">52dp</dimen>
|
||||
<dimen name="map_button_shadow_height">85dp</dimen>
|
||||
<dimen name="map_widget_icon">24dp</dimen>
|
||||
<dimen name="map_widget_height">32dp</dimen>
|
||||
<dimen name="map_widget_image">80dp</dimen>
|
||||
<dimen name="map_button_spacing">15dp</dimen>
|
||||
<dimen name="map_button_margin">4dp</dimen>
|
||||
<dimen name="map_button_shadow_margin">2dp</dimen>
|
||||
<dimen name="map_button_inset">4dp</dimen>
|
||||
<dimen name="map_button_rect_rad">3dp</dimen>
|
||||
<dimen name="map_button_stroke">1px</dimen>
|
||||
|
|
|
@ -48,6 +48,7 @@ public class QuickAction extends CustomPopupWindow {
|
|||
private boolean animateTrack;
|
||||
private ViewGroup mTrack;
|
||||
private ArrayList<ActionItem> actionList;
|
||||
private boolean top;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -86,6 +87,11 @@ public class QuickAction extends CustomPopupWindow {
|
|||
animateTrack = true;
|
||||
}
|
||||
|
||||
public void setOnAnchorOnTop(boolean top) {
|
||||
this.top = top;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Animate track
|
||||
*
|
||||
|
@ -150,7 +156,7 @@ public class QuickAction extends CustomPopupWindow {
|
|||
boolean onTop = true;
|
||||
|
||||
// display on bottom
|
||||
if (rootHeight > anchor.getTop()) {
|
||||
if (rootHeight > anchor.getTop() || onTop) {
|
||||
yPos = anchorRect.bottom;
|
||||
onTop = false;
|
||||
}
|
||||
|
|
|
@ -291,6 +291,7 @@ public class DashboardOnMap {
|
|||
if(!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
|
||||
mapActivity.getMapActions().enterRoutePlanningMode(null, null, false);
|
||||
} else {
|
||||
mapActivity.getRoutingHelper().setRoutePlanningMode(true);
|
||||
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.londatiga.android.ActionItem;
|
||||
import net.londatiga.android.QuickAction;
|
||||
import net.osmand.core.android.MapRendererContext;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -13,19 +20,18 @@ import net.osmand.plus.routing.RoutingHelper;
|
|||
import net.osmand.plus.views.controls.MapControls;
|
||||
import net.osmand.plus.views.controls.MapRouteInfoControl;
|
||||
import net.osmand.plus.views.controls.MapRoutePreferencesControl;
|
||||
import net.osmand.plus.views.controls.MapZoomControls;
|
||||
import net.osmand.plus.views.corenative.NativeCoreContext;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
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;
|
||||
|
@ -36,8 +42,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
|
||||
private static final int TIMEOUT_TO_SHOW_BUTTONS = 5000;
|
||||
|
||||
|
||||
|
||||
public MapHudButton createHudButton(View iv, int resId) {
|
||||
MapHudButton mc = new MapHudButton();
|
||||
mc.iv = iv;
|
||||
|
@ -70,10 +74,17 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
private static long startCounter;
|
||||
private Runnable delayStart;
|
||||
private Handler showUIHandler;
|
||||
private ImageView appModeIcon;
|
||||
private TextView zoomText;
|
||||
private OsmandMapTileView mapView;
|
||||
private OsmandApplication app;
|
||||
private View mapAppModeShadow;
|
||||
|
||||
public MapControlsLayer(MapActivity activity) {
|
||||
this.mapActivity = activity;
|
||||
app = activity.getMyApplication();
|
||||
settings = activity.getMyApplication().getSettings();
|
||||
mapView = mapActivity.getMapView();
|
||||
|
||||
}
|
||||
|
||||
|
@ -85,12 +96,11 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
@Override
|
||||
public void initLayer(final OsmandMapTileView view) {
|
||||
scaleCoefficient = view.getScaleCoefficient();
|
||||
FrameLayout parent = getParent();
|
||||
// TODO
|
||||
// rulerControl = init(new RulerControl(zoomControls, mapActivity, showUIHandler, scaleCoefficient), parent,
|
||||
// rightGravity);
|
||||
showUIHandler = new Handler();
|
||||
initTransparencyBar(view, parent);
|
||||
initTransparencyBar();
|
||||
initZooms();
|
||||
initControls();
|
||||
initRouteControls();
|
||||
|
@ -177,8 +187,8 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
View compass = mapActivity.findViewById(R.id.map_compass_button);
|
||||
// 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);
|
||||
compassHud = createHudButton((ImageView) compass, R.drawable.map_compass).setIconColorId(0).setBg(
|
||||
R.drawable.btn_inset_circle, R.drawable.btn_inset_circle_night);
|
||||
compassHud.compass = true;
|
||||
controls.add(compassHud);
|
||||
compass.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -290,6 +300,16 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
}
|
||||
}
|
||||
});
|
||||
mapAppModeShadow = mapActivity.findViewById(R.id.map_app_mode_shadow);
|
||||
mapAppModeShadow.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onApplicationModePress(v);
|
||||
}
|
||||
});
|
||||
appModeIcon = (ImageView) mapActivity.findViewById(R.id.map_app_mode_icon);
|
||||
zoomText = (TextView) mapActivity.findViewById(R.id.map_app_mode_text);
|
||||
|
||||
View routePlanButton = mapActivity.findViewById(R.id.map_route_info_button);
|
||||
controls.add(createHudButton((ImageView) routePlanButton, R.drawable.ic_action_gdirections_dark).setBg(
|
||||
|
@ -298,10 +318,15 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
notifyClicked();
|
||||
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
|
||||
if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
|
||||
mapActivity.getMapActions().enterRoutePlanningMode(null, null, false);
|
||||
} else {
|
||||
mapActivity.getRoutingHelper().setRoutePlanningMode(true);
|
||||
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -322,11 +347,10 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
|
||||
}
|
||||
});
|
||||
final View.OnLongClickListener listener = MapZoomControls.getOnClickMagnifierListener(view);
|
||||
final View.OnLongClickListener listener = MapControlsLayer.getOnClickMagnifierListener(view);
|
||||
zoomInButton.setOnLongClickListener(listener);
|
||||
View zoomOutButton = mapActivity.findViewById(R.id.map_zoom_out_button);
|
||||
controls.add(createHudButton((ImageView) zoomOutButton, R.drawable.ic_action_zoom_out)
|
||||
.setRoundTransparent());
|
||||
controls.add(createHudButton((ImageView) zoomOutButton, R.drawable.ic_action_zoom_out).setRoundTransparent());
|
||||
zoomOutButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -440,10 +464,23 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
backToLocationControl.setIconColorId(R.color.color_white);
|
||||
}
|
||||
|
||||
menuControl
|
||||
.setIconResId(mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.get() ? R.drawable.ic_dashboard_dark
|
||||
menuControl.setIconResId(settings.USE_DASHBOARD_INSTEAD_OF_DRAWER.get() ? R.drawable.ic_dashboard_dark
|
||||
: R.drawable.ic_navigation_drawer);
|
||||
|
||||
if(routeFollowingMode || routePlanningMode) {
|
||||
mapAppModeShadow.setVisibility(View.GONE);
|
||||
} else {
|
||||
mapAppModeShadow.setVisibility(View.VISIBLE);
|
||||
if (!mapView.isZooming() || !OsmandPlugin.isDevelopment()) {
|
||||
zoomText.setVisibility(View.GONE);
|
||||
appModeIcon.setVisibility(View.VISIBLE);
|
||||
appModeIcon.setImageResource(settings.getApplicationMode().getSmallIcon(isNight));
|
||||
} else {
|
||||
zoomText.setVisibility(View.VISIBLE);
|
||||
appModeIcon.setVisibility(View.GONE);
|
||||
zoomText.setText(getZoomLevel(tileBox));
|
||||
}
|
||||
}
|
||||
optionsRouteControl.setIconResId(settings.getApplicationMode().getSmallIcon(true));
|
||||
int vis = showRouteCalculationControls ? View.VISIBLE : View.GONE;
|
||||
if (showRouteCalculationControls) {
|
||||
|
@ -462,7 +499,8 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
routePreparationLayout.setVisibility(vis);
|
||||
mapRouteInfoControlDialog.setVisible(showRouteCalculationControls);
|
||||
if (showRouteCalculationControls) {
|
||||
if(!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper().isPauseNavigation()) {
|
||||
if (!mapActivity.getRoutingHelper().isFollowingMode()
|
||||
&& !mapActivity.getRoutingHelper().isPauseNavigation()) {
|
||||
startCounter();
|
||||
}
|
||||
} else {
|
||||
|
@ -489,9 +527,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
}
|
||||
}
|
||||
|
||||
private FrameLayout getParent() {
|
||||
return (FrameLayout) mapActivity.findViewById(R.id.MapButtons);
|
||||
}
|
||||
|
||||
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
||||
if (mapRouteInfoControlDialog.onSingleTap(point, tileBox)) {
|
||||
|
@ -508,16 +543,9 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
// /////////////// Transparency bar /////////////////////////
|
||||
private void initTransparencyBar(final OsmandMapTileView view, FrameLayout parent) {
|
||||
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, Gravity.BOTTOM | Gravity.CENTER);
|
||||
params.setMargins(0, 0, 0, minimumHeight + 3);
|
||||
transparencyBarLayout = new LinearLayout(view.getContext());
|
||||
transparencyBarLayout.setVisibility(settingsToTransparency != null ? View.VISIBLE : View.GONE);
|
||||
parent.addView(transparencyBarLayout, params);
|
||||
|
||||
transparencyBar = new SeekBar(view.getContext());
|
||||
private void initTransparencyBar() {
|
||||
transparencyBarLayout = (LinearLayout) mapActivity.findViewById(R.id.map_transparency_layout);
|
||||
transparencyBar = (SeekBar) mapActivity.findViewById(R.id.map_transparency_seekbar);
|
||||
transparencyBar.setMax(255);
|
||||
if (settingsToTransparency != null) {
|
||||
transparencyBar.setProgress(settingsToTransparency.get());
|
||||
|
@ -540,12 +568,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
}
|
||||
}
|
||||
});
|
||||
android.widget.LinearLayout.LayoutParams prms = new LinearLayout.LayoutParams((int) (scaleCoefficient * 100),
|
||||
LayoutParams.WRAP_CONTENT);
|
||||
transparencyBarLayout.addView(transparencyBar, prms);
|
||||
ImageButton imageButton = new ImageButton(view.getContext());
|
||||
prms = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||
prms.setMargins((int) (2 * scaleCoefficient), (int) (2 * scaleCoefficient), 0, 0);
|
||||
ImageButton imageButton = (ImageButton) mapActivity.findViewById(R.id.map_transparency_hide);
|
||||
imageButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -553,9 +576,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
hideTransparencyBar(settingsToTransparency);
|
||||
}
|
||||
});
|
||||
imageButton.setContentDescription(view.getContext().getString(R.string.shared_string_close));
|
||||
imageButton.setBackgroundResource(R.drawable.headliner_close);
|
||||
transparencyBarLayout.addView(imageButton, prms);
|
||||
}
|
||||
|
||||
public void showTransparencyBar(CommonPreference<Integer> transparenPreference) {
|
||||
|
@ -575,7 +595,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
// TODO
|
||||
}
|
||||
|
||||
|
||||
private class MapHudButton {
|
||||
View iv;
|
||||
int bgDark;
|
||||
|
@ -638,9 +657,11 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
}
|
||||
if (iv instanceof ImageView) {
|
||||
if (compass) {
|
||||
((ImageView) iv).setImageDrawable(new CompassDrawable(ctx.getIconsCache().getIcon(resId, nightMode ? resDark : resLight)));
|
||||
((ImageView) iv).setImageDrawable(new CompassDrawable(ctx.getIconsCache().getIcon(resId,
|
||||
nightMode ? resDark : resLight)));
|
||||
} else {
|
||||
((ImageView) iv).setImageDrawable(ctx.getIconsCache().getIcon(resId, nightMode ? resDark : resLight));
|
||||
((ImageView) iv).setImageDrawable(ctx.getIconsCache()
|
||||
.getIcon(resId, nightMode ? resDark : resLight));
|
||||
}
|
||||
} else if (iv instanceof TextView) {
|
||||
((TextView) iv).setCompoundDrawablesWithIntrinsicBounds(
|
||||
|
@ -649,4 +670,99 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
private void onApplicationModePress(View v) {
|
||||
final QuickAction mQuickAction = new QuickAction(v);
|
||||
mQuickAction.setOnAnchorOnTop(true);
|
||||
List<ApplicationMode> vls = ApplicationMode.values(mapActivity.getMyApplication().getSettings());
|
||||
final ApplicationMode[] modes = vls.toArray(new ApplicationMode[vls.size()]);
|
||||
int[] icons = new int[vls.size()];
|
||||
int[] values = new int[vls.size()];
|
||||
for (int k = 0; k < modes.length; k++) {
|
||||
icons[k] = modes[k].getSmallIcon(false);
|
||||
values[k] = modes[k].getStringResource();
|
||||
}
|
||||
for (int i = 0; i < modes.length; i++) {
|
||||
final ActionItem action = new ActionItem();
|
||||
action.setTitle(mapActivity.getResources().getString(values[i]));
|
||||
action.setIcon(mapActivity.getResources().getDrawable(icons[i]));
|
||||
final int j = i;
|
||||
action.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mapActivity.getMyApplication().getSettings().APPLICATION_MODE.set(modes[j]);
|
||||
mQuickAction.dismiss();
|
||||
}
|
||||
});
|
||||
mQuickAction.addActionItem(action);
|
||||
}
|
||||
mQuickAction.setAnimStyle(QuickAction.ANIM_AUTO);
|
||||
mQuickAction.show();
|
||||
}
|
||||
|
||||
private String getZoomLevel(RotatedTileBox tb) {
|
||||
String zoomText = tb.getZoom() + "";
|
||||
double frac = tb.getMapDensity();
|
||||
if (frac != 0) {
|
||||
int ifrac = (int) (frac * 10);
|
||||
zoomText += " ";
|
||||
zoomText += Math.abs(ifrac) / 10;
|
||||
if (ifrac % 10 != 0) {
|
||||
zoomText += "." + Math.abs(ifrac) % 10;
|
||||
}
|
||||
}
|
||||
return zoomText;
|
||||
}
|
||||
|
||||
public static View.OnLongClickListener getOnClickMagnifierListener(final OsmandMapTileView view) {
|
||||
final View.OnLongClickListener listener = new View.OnLongClickListener() {
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View notUseCouldBeNull) {
|
||||
final OsmandSettings.OsmandPreference<Float> mapDensity = view.getSettings().MAP_DENSITY;
|
||||
final AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
|
||||
int p = (int) (mapDensity.get() * 100);
|
||||
final TIntArrayList tlist = new TIntArrayList(new int[] { 33, 50, 75, 100, 150, 200, 300, 400 });
|
||||
final List<String> values = new ArrayList<String>();
|
||||
int i = -1;
|
||||
for (int k = 0; k <= tlist.size(); k++) {
|
||||
final boolean end = k == tlist.size();
|
||||
if (i == -1) {
|
||||
if ((end || p < tlist.get(k))) {
|
||||
values.add(p + "%");
|
||||
i = k;
|
||||
} else if (p == tlist.get(k)) {
|
||||
i = k;
|
||||
}
|
||||
|
||||
}
|
||||
if (k < tlist.size()) {
|
||||
values.add(tlist.get(k) + "%");
|
||||
}
|
||||
}
|
||||
if (values.size() != tlist.size()) {
|
||||
tlist.insert(i, p);
|
||||
}
|
||||
|
||||
bld.setTitle(R.string.map_magnifier);
|
||||
bld.setSingleChoiceItems(values.toArray(new String[values.size()]), i,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int p = tlist.get(which);
|
||||
mapDensity.set(p / 100.0f);
|
||||
view.setComplexZoom(view.getZoom(), view.getSettingsMapDensity());
|
||||
MapRendererContext mapContext = NativeCoreContext.getMapRendererContext();
|
||||
if (mapContext != null) {
|
||||
mapContext.updateMapSettings();
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
bld.show();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
return listener;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,139 +0,0 @@
|
|||
package net.osmand.plus.views.controls;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.londatiga.android.ActionItem;
|
||||
import net.londatiga.android.QuickAction;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
public class MapMenuControls extends MapControls {
|
||||
private Button backToMenuButton;
|
||||
private Drawable modeShadow;
|
||||
private Drawable cacheAppModeIcon = null;
|
||||
private ApplicationMode cacheApplicationMode = null;
|
||||
|
||||
|
||||
public MapMenuControls(MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
|
||||
super(mapActivity, showUIHandler, scaleCoefficient);
|
||||
}
|
||||
|
||||
private void initBackToMenuButton(final OsmandMapTileView view, FrameLayout parent) {
|
||||
backToMenuButton = addButton(parent, R.string.backToMenu, R.drawable.map_btn_menu);
|
||||
modeShadow = view.getResources().getDrawable(R.drawable.zoom_background);
|
||||
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();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showControls(FrameLayout layout) {
|
||||
initBackToMenuButton(mapActivity.getMapView(), layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideControls(FrameLayout layout) {
|
||||
removeButton(layout, backToMenuButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
|
||||
if(mapActivity.findViewById(R.id.MapButtons).getVisibility() == View.GONE) {
|
||||
return;
|
||||
}
|
||||
drawApplicationMode(canvas, nightMode != null && nightMode.isNightMode());
|
||||
}
|
||||
|
||||
|
||||
private void drawApplicationMode(Canvas canvas, boolean nightMode) {
|
||||
OsmandMapTileView view = mapActivity.getMapView();
|
||||
ApplicationMode appMode = view.getSettings().getApplicationMode();
|
||||
if(appMode != cacheApplicationMode){
|
||||
modeShadow.setBounds(backToMenuButton.getLeft() + (int) (2 * scaleCoefficient), backToMenuButton.getTop() - (int) (24 * scaleCoefficient),
|
||||
backToMenuButton.getRight() - (int) (4 * scaleCoefficient), backToMenuButton.getBottom());
|
||||
cacheAppModeIcon = view.getResources().getDrawable(appMode.getSmallIcon(nightMode));
|
||||
int l = modeShadow.getBounds().left + (modeShadow.getBounds().width() - cacheAppModeIcon.getMinimumWidth()) / 2;
|
||||
int t = (int) (modeShadow.getBounds().top + 2 * scaleCoefficient);
|
||||
cacheAppModeIcon.setBounds(l, t, l + cacheAppModeIcon.getMinimumWidth(), t + cacheAppModeIcon.getMinimumHeight());
|
||||
}
|
||||
modeShadow.draw(canvas);
|
||||
if(cacheAppModeIcon != null){
|
||||
cacheAppModeIcon.draw(canvas);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
||||
if (modeShadow.getBounds().contains((int) point.x, (int) point.y)) {
|
||||
onApplicationModePress();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void onApplicationModePress() {
|
||||
final QuickAction mQuickAction = new QuickAction(backToMenuButton);
|
||||
List<ApplicationMode> vls = ApplicationMode.values(mapActivity.getMyApplication().getSettings());
|
||||
final ApplicationMode[] modes = vls.toArray(new ApplicationMode[vls.size()]);
|
||||
int[] icons = new int[vls.size()];
|
||||
int[] values = new int[vls.size()];
|
||||
for(int k = 0; k < modes.length; k++) {
|
||||
icons[k] = modes[k].getSmallIcon(false);
|
||||
values[k] = modes[k].getStringResource();
|
||||
}
|
||||
for (int i = 0; i < modes.length; i++) {
|
||||
final ActionItem action = new ActionItem();
|
||||
action.setTitle(mapActivity.getResources().getString(values[i]));
|
||||
action.setIcon(mapActivity.getResources().getDrawable(icons[i]));
|
||||
final int j = i;
|
||||
action.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mapActivity.getMyApplication().getSettings().APPLICATION_MODE.set(modes[j]);
|
||||
mQuickAction.dismiss();
|
||||
}
|
||||
});
|
||||
mQuickAction.addActionItem(action);
|
||||
}
|
||||
mQuickAction.setAnimStyle(QuickAction.ANIM_AUTO);
|
||||
mQuickAction.show();
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
if (width == 0) {
|
||||
Drawable buttonDrawable = mapActivity.getResources().getDrawable(R.drawable.map_btn_menu);
|
||||
width = buttonDrawable.getMinimumWidth();
|
||||
}
|
||||
return width ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,288 +0,0 @@
|
|||
package net.osmand.plus.views.controls;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.core.android.MapRendererContext;
|
||||
import net.osmand.core.android.MapRendererView;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.OsmAndConstants;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.views.BaseMapLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.ShadowText;
|
||||
import net.osmand.plus.views.corenative.NativeCoreContext;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextPaint;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
public class MapZoomControls extends MapControls {
|
||||
private static final int SHOW_ZOOM_LEVEL_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_CONTROLS + 1;
|
||||
private static final int SHOW_ZOOM_BUTTON_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_CONTROLS + 2;
|
||||
private static final int SHOW_ZOOM_LEVEL_DELAY = 1000;
|
||||
private static final int SHOW_ZOOM_LEVEL_BUTTON_DELAY = 1500;
|
||||
|
||||
private Button zoomInButton;
|
||||
private Button zoomOutButton;
|
||||
|
||||
private TextPaint zoomTextPaint;
|
||||
private Drawable zoomShadow;
|
||||
private Bitmap mapMagnifier;
|
||||
private Paint bitmapPaint;
|
||||
private boolean showZoomLevel = false;
|
||||
private boolean showZoomLevelButton = false;
|
||||
private OsmandMapTileView view;
|
||||
|
||||
public MapZoomControls(MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
|
||||
super(mapActivity, showUIHandler, scaleCoefficient);
|
||||
view = mapActivity.getMapView();
|
||||
zoomTextPaint = new TextPaint();
|
||||
zoomTextPaint.setTextSize(18 * scaleCoefficient);
|
||||
zoomTextPaint.setAntiAlias(true);
|
||||
zoomTextPaint.setFakeBoldText(true);
|
||||
}
|
||||
|
||||
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
||||
if (isShowZoomLevel() && zoomShadow.getBounds().contains((int) point.x, (int) point.y)) {
|
||||
getOnClickMagnifierListener(view).onLongClick(null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void showControls(FrameLayout parent) {
|
||||
int minimumWidth = view.getResources().getDrawable(R.drawable.map_zoom_in).getMinimumWidth();
|
||||
int minimumHeight = view.getResources().getDrawable(R.drawable.map_zoom_in).getMinimumWidth();
|
||||
vmargin = 0;
|
||||
zoomInButton = addButton(parent, R.string.zoomIn, R.drawable.map_zoom_in);
|
||||
if(isBottom()) {
|
||||
zoomOutButton = addButton(parent, R.string.zoomOut, R.drawable.map_zoom_out, minimumWidth);
|
||||
} else {
|
||||
vmargin = minimumHeight - (minimumHeight / 6);
|
||||
zoomOutButton = addButton(parent, R.string.zoomOut, R.drawable.map_zoom_out);
|
||||
}
|
||||
zoomInButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
notifyClicked();
|
||||
if (view.isZooming()) {
|
||||
mapActivity.changeZoom(2, System.currentTimeMillis());
|
||||
} else {
|
||||
mapActivity.changeZoom(1, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
final View.OnLongClickListener listener = getOnClickMagnifierListener(view);
|
||||
zoomInButton.setOnLongClickListener(listener);
|
||||
zoomOutButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
long time = Calendar.getInstance().getTime().getTime();
|
||||
notifyClicked();
|
||||
mapActivity.changeZoom(-1, System.currentTimeMillis());
|
||||
}
|
||||
});
|
||||
zoomOutButton.setOnLongClickListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initControls(FrameLayout parent) {
|
||||
if(isBottom()) {
|
||||
zoomShadow = view.getResources().getDrawable(R.drawable.zoom_background).mutate();
|
||||
}
|
||||
mapMagnifier = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_magnifier);
|
||||
bitmapPaint = new Paint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideControls(FrameLayout layout) {
|
||||
removeButton(layout, zoomInButton);
|
||||
removeButton(layout, zoomOutButton);
|
||||
}
|
||||
|
||||
private void drawZoomLevel(Canvas canvas, RotatedTileBox tb, boolean drawZoomLevel) {
|
||||
if (zoomShadow.getBounds().width() == 0) {
|
||||
zoomShadow.setBounds(zoomInButton.getLeft() - 2, zoomInButton.getTop() - (int) (18 * scaleCoefficient),
|
||||
zoomInButton.getRight(), zoomInButton.getBottom());
|
||||
}
|
||||
zoomShadow.draw(canvas);
|
||||
if (drawZoomLevel) {
|
||||
String zoomText = tb.getZoom() + "";
|
||||
double frac = tb.getMapDensity();
|
||||
if (frac != 0) {
|
||||
int ifrac = (int) (frac * 10);
|
||||
zoomText += " ";
|
||||
zoomText += Math.abs(ifrac) / 10;
|
||||
if (ifrac % 10 != 0) {
|
||||
zoomText += "." + Math.abs(ifrac) % 10;
|
||||
}
|
||||
}
|
||||
float length = zoomTextPaint.measureText(zoomText);
|
||||
|
||||
ShadowText.draw(zoomText, canvas, zoomInButton.getLeft() + (zoomInButton.getWidth() - length - 2) / 2,
|
||||
zoomInButton.getTop() + 4 * scaleCoefficient, zoomTextPaint, shadowColor);
|
||||
} else {
|
||||
int size = (int) (16 * scaleCoefficient);
|
||||
int top = (int) (zoomInButton.getTop() - size - 4 * scaleCoefficient);
|
||||
int left = (int) (zoomInButton.getLeft() + (zoomInButton.getWidth() - mapMagnifier.getWidth() - 2 * scaleCoefficient) / 2);
|
||||
// canvas density /2 ? size * 2
|
||||
canvas.drawBitmap(mapMagnifier, null, new Rect(left, top, left + size * 2, top + size * 2), bitmapPaint);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
|
||||
BaseMapLayer mainLayer = view.getMainLayer();
|
||||
boolean zoomInEnabled = mainLayer != null && tileBox.getZoom() < mainLayer.getMaximumShownMapZoom();
|
||||
boolean zoomOutEnabled = mainLayer != null && tileBox.getZoom() > mainLayer.getMinimumShownMapZoom();
|
||||
if (zoomInButton.isEnabled() != zoomInEnabled) {
|
||||
zoomInButton.setEnabled(zoomInEnabled);
|
||||
}
|
||||
if (zoomOutButton.isEnabled() != zoomOutEnabled) {
|
||||
zoomOutButton.setEnabled(zoomOutEnabled);
|
||||
}
|
||||
if (isBottom()) {
|
||||
if (view.isZooming()) {
|
||||
showZoomLevel = true;
|
||||
showZoomLevelButton = false;
|
||||
showUIHandler.removeMessages(SHOW_ZOOM_LEVEL_MSG_ID);
|
||||
showUIHandler.removeMessages(SHOW_ZOOM_BUTTON_MSG_ID);
|
||||
} else {
|
||||
if (isShowZoomLevel() && view.getSettings().SHOW_RULER.get()) {
|
||||
hideZoomLevelInTime();
|
||||
}
|
||||
}
|
||||
boolean drawZoomLevel = isShowZoomLevel() || !view.getSettings().SHOW_RULER.get();
|
||||
if (drawZoomLevel) {
|
||||
drawZoomLevel(canvas, tileBox, !showZoomLevelButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendMessageToShowZoomLevel() {
|
||||
Message msg = Message.obtain(showUIHandler, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showZoomLevelButton = true;
|
||||
sendMessageToShowZoomButton();
|
||||
view.refreshMap();
|
||||
}
|
||||
|
||||
});
|
||||
msg.what = SHOW_ZOOM_LEVEL_MSG_ID;
|
||||
showUIHandler.sendMessageDelayed(msg, SHOW_ZOOM_LEVEL_DELAY);
|
||||
}
|
||||
|
||||
private void sendMessageToShowZoomButton() {
|
||||
Message msg = Message.obtain(showUIHandler, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showZoomLevelButton = false;
|
||||
showZoomLevel = false;
|
||||
view.refreshMap();
|
||||
}
|
||||
|
||||
});
|
||||
msg.what = SHOW_ZOOM_BUTTON_MSG_ID;
|
||||
showUIHandler.sendMessageDelayed(msg, SHOW_ZOOM_LEVEL_BUTTON_DELAY);
|
||||
}
|
||||
|
||||
private void hideZoomLevelInTime() {
|
||||
if (!showUIHandler.hasMessages(SHOW_ZOOM_LEVEL_MSG_ID) && !showUIHandler.hasMessages(SHOW_ZOOM_BUTTON_MSG_ID)) {
|
||||
sendMessageToShowZoomLevel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTextColor(int textColor, int shadowColor) {
|
||||
super.updateTextColor(textColor, shadowColor);
|
||||
zoomTextPaint.setColor(textColor);
|
||||
}
|
||||
|
||||
public boolean isShowZoomLevel() {
|
||||
return showZoomLevel;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
if (height == 0) {
|
||||
Drawable buttonDrawable = view.getResources().getDrawable(R.drawable.map_zoom_in);
|
||||
height = buttonDrawable.getMinimumHeight();
|
||||
}
|
||||
return height;
|
||||
}
|
||||
|
||||
|
||||
public static View.OnLongClickListener getOnClickMagnifierListener(final OsmandMapTileView view) {
|
||||
final View.OnLongClickListener listener = new View.OnLongClickListener() {
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View notUseCouldBeNull) {
|
||||
final OsmandSettings.OsmandPreference<Float> mapDensity = view.getSettings().MAP_DENSITY;
|
||||
final AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
|
||||
int p = (int) (mapDensity.get() * 100);
|
||||
final TIntArrayList tlist = new TIntArrayList(new int[] {33, 50, 75, 100, 150, 200, 300, 400 });
|
||||
final List<String> values = new ArrayList<String>();
|
||||
int i = -1;
|
||||
for (int k = 0; k <= tlist.size(); k++) {
|
||||
final boolean end = k == tlist.size();
|
||||
if (i == -1) {
|
||||
if ((end || p < tlist.get(k))) {
|
||||
values.add(p + "%");
|
||||
i = k;
|
||||
} else if (p == tlist.get(k)) {
|
||||
i = k;
|
||||
}
|
||||
|
||||
}
|
||||
if (k < tlist.size()) {
|
||||
values.add(tlist.get(k) + "%");
|
||||
}
|
||||
}
|
||||
if (values.size() != tlist.size()) {
|
||||
tlist.insert(i, p);
|
||||
}
|
||||
|
||||
bld.setTitle(R.string.map_magnifier);
|
||||
bld.setSingleChoiceItems(values.toArray(new String[values.size()]), i,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int p = tlist.get(which);
|
||||
mapDensity.set(p / 100.0f);
|
||||
view.setComplexZoom(view.getZoom(), view.getSettingsMapDensity());
|
||||
MapRendererContext mapContext = NativeCoreContext.getMapRendererContext();
|
||||
if(mapContext != null) {
|
||||
mapContext.updateMapSettings();
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
bld.show();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
return listener;
|
||||
}
|
||||
|
||||
}
|
|
@ -27,15 +27,13 @@ public class RulerControl extends MapControls {
|
|||
double cacheRulerTileX = 0;
|
||||
double cacheRulerTileY = 0;
|
||||
float cacheRulerTextLen = 0;
|
||||
MapZoomControls zoomControls;
|
||||
Drawable rulerDrawable;
|
||||
TextPaint rulerTextPaint;
|
||||
final static double screenRulerPercent = 0.25;
|
||||
boolean isNightRemembered = false;
|
||||
|
||||
public RulerControl(MapZoomControls zoomControls, MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
|
||||
public RulerControl(MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
|
||||
super(mapActivity, showUIHandler, scaleCoefficient);
|
||||
this.zoomControls = zoomControls;
|
||||
rulerTextPaint = new TextPaint();
|
||||
rulerTextPaint.setTextSize(20 * scaleCoefficient);
|
||||
rulerTextPaint.setAntiAlias(true);
|
||||
|
@ -58,7 +56,7 @@ public class RulerControl extends MapControls {
|
|||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings nightMode) {
|
||||
if( (zoomControls.isVisible() && zoomControls.isShowZoomLevel()) || !mapActivity.getMyApplication().getSettings().SHOW_RULER.get()){
|
||||
if (!mapActivity.getMyApplication().getSettings().SHOW_RULER.get()) {
|
||||
return;
|
||||
}
|
||||
if (mapActivity.findViewById(R.id.MapButtons).getVisibility() == View.GONE) {
|
||||
|
@ -69,9 +67,10 @@ public class RulerControl extends MapControls {
|
|||
// update cache
|
||||
if (view.isZooming()) {
|
||||
cacheRulerText = null;
|
||||
} else if (((isNight != isNightRemembered) || (tb.getZoom() != cacheRulerZoom) ||
|
||||
Math.abs(tb.getCenterTileX() - cacheRulerTileX) + Math.abs(tb.getCenterTileY() - cacheRulerTileY) > 1) &&
|
||||
tb.getPixWidth() > 0){
|
||||
} else if (((isNight != isNightRemembered) || (tb.getZoom() != cacheRulerZoom) || Math.abs(tb.getCenterTileX()
|
||||
- cacheRulerTileX)
|
||||
+ Math.abs(tb.getCenterTileY() - cacheRulerTileY) > 1)
|
||||
&& tb.getPixWidth() > 0) {
|
||||
cacheRulerZoom = (tb.getZoom());
|
||||
cacheRulerTileX = tb.getCenterTileX();
|
||||
cacheRulerTileY = tb.getCenterTileY();
|
||||
|
@ -80,9 +79,11 @@ public class RulerControl extends MapControls {
|
|||
double roundedDist = OsmAndFormatter.calculateRoundedDist(dist * screenRulerPercent, view.getApplication());
|
||||
|
||||
int cacheRulerDistPix = (int) (pixDensity * roundedDist);
|
||||
cacheRulerText = ShadowText.create(OsmAndFormatter.getFormattedDistance((float) roundedDist, view.getApplication()));
|
||||
cacheRulerText = ShadowText.create(OsmAndFormatter.getFormattedDistance((float) roundedDist,
|
||||
view.getApplication()));
|
||||
cacheRulerTextLen = rulerTextPaint.measureText(cacheRulerText.getText());
|
||||
rulerDrawable = (isNight ? mapActivity.getResources().getDrawable(R.drawable.ruler_night) : mapActivity.getResources().getDrawable(R.drawable.ruler));
|
||||
rulerDrawable = (isNight ? mapActivity.getResources().getDrawable(R.drawable.ruler_night) : mapActivity
|
||||
.getResources().getDrawable(R.drawable.ruler));
|
||||
Rect bounds = rulerDrawable.getBounds();
|
||||
bounds.right = (int) (view.getWidth() - 7 * scaleCoefficient);
|
||||
bounds.left = bounds.right - cacheRulerDistPix;
|
||||
|
@ -100,9 +101,10 @@ public class RulerControl extends MapControls {
|
|||
rulerDrawable.invalidateSelf();
|
||||
}
|
||||
rulerDrawable.draw(canvas);
|
||||
int shadowColor = isNight == true ? mapActivity.getResources().getColor(R.color.widgettext_shadow_night) : Color.WHITE;
|
||||
cacheRulerText.draw(canvas, bounds.left + (bounds.width() - cacheRulerTextLen) / 2, bounds.bottom - 8 * scaleCoefficient,
|
||||
rulerTextPaint, shadowColor);
|
||||
int shadowColor = isNight == true ? mapActivity.getResources().getColor(R.color.widgettext_shadow_night)
|
||||
: Color.WHITE;
|
||||
cacheRulerText.draw(canvas, bounds.left + (bounds.width() - cacheRulerTextLen) / 2, bounds.bottom - 8
|
||||
* scaleCoefficient, rulerTextPaint, shadowColor);
|
||||
}
|
||||
isNightRemembered = isNight;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue