Implement native qt window
This commit is contained in:
parent
5b15d3fc8f
commit
a284304275
12 changed files with 314 additions and 124 deletions
|
@ -1,34 +1,52 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v4.widget.DrawerLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" android:keepScreenOn="true" android:clipChildren="false">
|
||||
<android.opengl.GLSurfaceView
|
||||
android:id="@+id/glSurfaceView"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
<net.osmand.plus.views.OsmandMapTileView android:id="@+id/MapView" android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:contentDescription="@string/map_view"/>
|
||||
<LinearLayout android:layout_gravity="bottom"
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/dialog_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
</FrameLayout>
|
||||
<ListView android:id="@+id/left_drawer"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:choiceMode="singleChoice"
|
||||
android:divider="@drawable/divider"
|
||||
android:dividerHeight="1px"/>
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:clipChildren="false"
|
||||
android:keepScreenOn="true"
|
||||
android:orientation="vertical" >
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
||||
<android.opengl.GLSurfaceView
|
||||
android:id="@+id/glSurfaceView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone" />
|
||||
|
||||
<net.osmand.plus.views.OsmAndMapSurfaceView
|
||||
android:id="@+id/MapView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:contentDescription="@string/map_view"
|
||||
android:visibility="gone" />
|
||||
|
||||
<net.osmand.plus.views.OsmAndMapLayersView
|
||||
android:id="@+id/MapLayersView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:contentDescription="@string/map_view"
|
||||
android:visibility="gone" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dialog_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:orientation="horizontal" />
|
||||
</FrameLayout>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/left_drawer"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:choiceMode="singleChoice"
|
||||
android:divider="@drawable/divider"
|
||||
android:dividerHeight="1px" />
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
|
@ -4,7 +4,7 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<net.osmand.plus.views.OsmandMapTileView
|
||||
<net.osmand.plus.views.OsmAndMapSurfaceView
|
||||
android:id="@+id/MapView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="300dp"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.OsmAndMapSurfaceView;
|
||||
import android.content.Context;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.AttributeSet;
|
||||
|
@ -18,7 +18,7 @@ public class CustomPager extends ViewPager {
|
|||
|
||||
@Override
|
||||
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
|
||||
if (v instanceof OsmandMapTileView) {
|
||||
if (v instanceof OsmAndMapSurfaceView) {
|
||||
return true;
|
||||
}
|
||||
return super.canScroll(v, checkV, dx, x, y);
|
||||
|
|
|
@ -40,6 +40,8 @@ import net.osmand.plus.resources.ResourceManager;
|
|||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.routing.RoutingHelper.RouteCalculationProgressCallback;
|
||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||
import net.osmand.plus.views.OsmAndMapLayersView;
|
||||
import net.osmand.plus.views.OsmAndMapSurfaceView;
|
||||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.corenative.NativeQtLibrary;
|
||||
|
@ -135,7 +137,23 @@ public class MapActivity extends AccessibleActivity {
|
|||
app.checkApplicationIsBeingInitialized(this, startProgressDialog);
|
||||
parseLaunchIntentLocation();
|
||||
|
||||
mapView = (OsmandMapTileView) findViewById(R.id.MapView);
|
||||
if(settings.USE_NATIVE_RENDER.get() && NativeQtLibrary.isInit()) {
|
||||
findViewById(R.id.MapView).setVisibility(View.GONE);
|
||||
glSurfaceView = (GLSurfaceView) findViewById(R.id.glSurfaceView);
|
||||
glSurfaceView.setVisibility(View.VISIBLE);
|
||||
OsmAndMapLayersView ml = (OsmAndMapLayersView) findViewById(R.id.MapLayersView);
|
||||
ml.setVisibility(View.VISIBLE);
|
||||
NativeQtLibrary.initView(glSurfaceView);
|
||||
mapView = ml.getMapView();
|
||||
mapView.setMapRender(NativeQtLibrary.getMapRenderer());
|
||||
} else {
|
||||
findViewById(R.id.MapLayersView).setVisibility(View.GONE);
|
||||
findViewById(R.id.glSurfaceView).setVisibility(View.GONE);
|
||||
OsmAndMapSurfaceView surf = (OsmAndMapSurfaceView) findViewById(R.id.MapView);
|
||||
surf.setVisibility(View.VISIBLE);
|
||||
mapView = surf.getMapView();
|
||||
}
|
||||
|
||||
mapView.setTrackBallDelegate(new OsmandMapTileView.OnTrackBallListener(){
|
||||
@Override
|
||||
public boolean onTrackBallEvent(MotionEvent e) {
|
||||
|
@ -149,12 +167,7 @@ public class MapActivity extends AccessibleActivity {
|
|||
}
|
||||
mapViewTrackingUtilities.setMapView(mapView);
|
||||
|
||||
if(settings.USE_NATIVE_RENDER.get() && NativeQtLibrary.isInit()) {
|
||||
glSurfaceView = (GLSurfaceView) findViewById(R.id.glSurfaceView);
|
||||
glSurfaceView.setVisibility(View.VISIBLE);
|
||||
NativeQtLibrary.initView(glSurfaceView);
|
||||
mapView.setMapRender(NativeQtLibrary.getMapRenderer());
|
||||
}
|
||||
|
||||
|
||||
// Do some action on close
|
||||
startProgressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
|
|
|
@ -94,12 +94,12 @@ public class EditingPOIActivity implements DialogProvider {
|
|||
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
|
||||
this.openstreetmapUtil = new OpenstreetmapLocalUtil(ctx);
|
||||
if (settings.isInternetConnectionAvailable(true)) {
|
||||
this.openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(ctx, ctx.getMapView());
|
||||
this.openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(ctx, ctx.getMapView().getView());
|
||||
} else {
|
||||
this.openstreetmapUtilToLoad = openstreetmapUtil;
|
||||
}
|
||||
} else {
|
||||
this.openstreetmapUtil = new OpenstreetmapRemoteUtil(ctx, ctx.getMapView());
|
||||
this.openstreetmapUtil = new OpenstreetmapRemoteUtil(ctx, ctx.getMapView().getView());
|
||||
this.openstreetmapUtilToLoad= openstreetmapUtil;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import net.osmand.plus.OsmAndFormatter;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.sherpafy.TourInformation.StageInformation;
|
||||
import net.osmand.plus.views.OsmAndMapSurfaceView;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
|
@ -66,7 +67,8 @@ public class SherpafyStageInfoFragment extends SherlockFragment {
|
|||
TextView additional = (TextView) view.findViewById(R.id.AdditionalText);
|
||||
TextView text = (TextView) view.findViewById(R.id.Text);
|
||||
TextView header = (TextView) view.findViewById(R.id.HeaderText);
|
||||
osmandMapTileView = (OsmandMapTileView) view.findViewById(R.id.MapView);
|
||||
OsmAndMapSurfaceView surf = (OsmAndMapSurfaceView) view.findViewById(R.id.MapView);
|
||||
osmandMapTileView = surf.getMapView();
|
||||
updateView(description, icon, additional, text, header);
|
||||
return view;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class SherpafyStageItineraryFragment extends SherpafyStageInfoFragment im
|
|||
|
||||
protected void updateView(WebView description, ImageView icon, TextView additional, TextView text, TextView header) {
|
||||
app.getResourceManager().getMapTileDownloader().addDownloaderCallback(this);
|
||||
osmandMapTileView.setVisibility(View.VISIBLE);
|
||||
osmandMapTileView.getView().setVisibility(View.VISIBLE);
|
||||
osmandMapTileView.removeAllLayers();
|
||||
MapVectorLayer mapVectorLayer = new MapVectorLayer(null);
|
||||
MapTextLayer mapTextLayer = new MapTextLayer();
|
||||
|
|
67
OsmAnd/src/net/osmand/plus/views/OsmAndMapLayersView.java
Normal file
67
OsmAnd/src/net/osmand/plus/views/OsmAndMapLayersView.java
Normal file
|
@ -0,0 +1,67 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.View;
|
||||
|
||||
public class OsmAndMapLayersView extends View {
|
||||
|
||||
private OsmandMapTileView mapView;
|
||||
|
||||
public OsmAndMapLayersView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
|
||||
}
|
||||
|
||||
public OsmAndMapLayersView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mapView = new OsmandMapTileView();
|
||||
mapView.initView(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTrackballEvent(MotionEvent event) {
|
||||
Boolean r = mapView.onTrackballEvent(event);
|
||||
if(r == null) {
|
||||
return super.onTrackballEvent(event);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
Boolean r = mapView.onKeyDown(keyCode, event);
|
||||
if(r == null) {
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
return mapView.onTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
boolean nightMode = mapView.getApplication().getDaynightHelper().isNightMode();
|
||||
DrawSettings drawSettings = new DrawSettings(nightMode, false);
|
||||
mapView.drawOverMap(canvas, mapView.getCurrentRotatedTileBox().copy(), drawSettings);
|
||||
}
|
||||
|
||||
|
||||
public OsmandMapTileView getMapView() {
|
||||
return mapView;
|
||||
}
|
||||
|
||||
}
|
74
OsmAnd/src/net/osmand/plus/views/OsmAndMapSurfaceView.java
Normal file
74
OsmAnd/src/net/osmand/plus/views/OsmAndMapSurfaceView.java
Normal file
|
@ -0,0 +1,74 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceHolder.Callback;
|
||||
import android.view.SurfaceView;
|
||||
|
||||
public class OsmAndMapSurfaceView extends SurfaceView implements Callback {
|
||||
|
||||
private OsmandMapTileView mapView;
|
||||
|
||||
public OsmAndMapSurfaceView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
|
||||
}
|
||||
|
||||
public OsmAndMapSurfaceView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
getHolder().addCallback(this);
|
||||
mapView = new OsmandMapTileView();
|
||||
mapView.initView(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||
mapView.refreshMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
mapView.refreshMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTrackballEvent(MotionEvent event) {
|
||||
Boolean r = mapView.onTrackballEvent(event);
|
||||
if(r == null) {
|
||||
return super.onTrackballEvent(event);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
Boolean r = mapView.onKeyDown(keyCode, event);
|
||||
if(r == null) {
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
return mapView.onTouchEvent(event);
|
||||
}
|
||||
|
||||
|
||||
public OsmandMapTileView getMapView() {
|
||||
return mapView;
|
||||
}
|
||||
|
||||
}
|
|
@ -6,7 +6,6 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import android.view.*;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.access.AccessibilityActionsProvider;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
|
@ -32,6 +31,7 @@ import net.osmand.util.MapUtils;
|
|||
import org.apache.commons.logging.Log;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.Canvas;
|
||||
|
@ -43,14 +43,21 @@ import android.graphics.RectF;
|
|||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.GestureDetector.OnDoubleTapListener;
|
||||
import android.view.GestureDetector.OnGestureListener;
|
||||
import android.view.SurfaceHolder.Callback;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCallback, Callback {
|
||||
public class OsmandMapTileView implements IMapDownloaderCallback {
|
||||
|
||||
private static final int MAP_REFRESH_MESSAGE = OsmAndConstants.UI_HANDLER_MAP_VIEW + 4;
|
||||
private static final int MAP_FORCE_REFRESH_MESSAGE = OsmAndConstants.UI_HANDLER_MAP_VIEW + 5;
|
||||
|
@ -59,6 +66,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
private boolean MEASURE_FPS = false;
|
||||
private FPSMeasurement main = new FPSMeasurement();
|
||||
private FPSMeasurement additional = new FPSMeasurement();
|
||||
private View view;
|
||||
|
||||
private class FPSMeasurement {
|
||||
int fpsMeasureCount = 0;
|
||||
|
@ -141,7 +149,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
|
||||
private IMapRenderer mapRenderer;
|
||||
|
||||
private final OsmandApplication application;
|
||||
private OsmandApplication application;
|
||||
|
||||
protected OsmandSettings settings = null;
|
||||
|
||||
|
@ -162,21 +170,12 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
|
||||
|
||||
|
||||
public OsmandMapTileView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
application = (OsmandApplication) context.getApplicationContext();
|
||||
initView();
|
||||
|
||||
}
|
||||
|
||||
public OsmandMapTileView(Context context) {
|
||||
super(context);
|
||||
application = (OsmandApplication) context.getApplicationContext();
|
||||
initView();
|
||||
}
|
||||
|
||||
// ///////////////////////////// INITIALIZING UI PART ///////////////////////////////////
|
||||
public void initView() {
|
||||
public void initView(View view) {
|
||||
application = (OsmandApplication) view.getContext().getApplicationContext();
|
||||
this.view = view;
|
||||
paintGrayFill = new Paint();
|
||||
paintGrayFill.setColor(Color.GRAY);
|
||||
paintGrayFill.setStyle(Style.FILL);
|
||||
|
@ -205,46 +204,31 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
paintImg.setFilterBitmap(true);
|
||||
// paintImg.setDither(true);
|
||||
|
||||
setClickable(true);
|
||||
setLongClickable(true);
|
||||
setFocusable(true);
|
||||
view.setClickable(true);
|
||||
view.setLongClickable(true);
|
||||
view.setFocusable(true);
|
||||
|
||||
|
||||
handler = new Handler();
|
||||
|
||||
baseHandler = new Handler(application.getResourceManager().getRenderingBufferImageThread().getLooper());
|
||||
getHolder().addCallback(this);
|
||||
|
||||
animatedDraggingThread = new AnimateDraggingMapThread(this);
|
||||
gestureDetector = new GestureDetector(getContext(), new MapExplorer(this, new MapTileViewOnGestureListener()));
|
||||
multiTouchSupport = new MultiTouchSupport(getContext(), new MapTileViewMultiTouchZoomListener());
|
||||
gestureDetector = new GestureDetector(view.getContext(), new MapExplorer(this, new MapTileViewOnGestureListener()));
|
||||
multiTouchSupport = new MultiTouchSupport(view.getContext(), new MapTileViewMultiTouchZoomListener());
|
||||
gestureDetector.setOnDoubleTapListener(new MapTileViewOnDoubleTapListener());
|
||||
|
||||
WindowManager mgr = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
|
||||
WindowManager mgr = (WindowManager) view.getContext().getSystemService(Context.WINDOW_SERVICE);
|
||||
dm = new DisplayMetrics();
|
||||
mgr.getDefaultDisplay().getMetrics(dm);
|
||||
currentViewport = new RotatedTileBox.RotatedTileBoxBuilder().
|
||||
setLocation(0, 0).setZoomAndScale(3, 0).setPixelDimensions(getWidth(), getHeight()).build();
|
||||
setLocation(0, 0).setZoomAndScale(3, 0).setPixelDimensions(view.getWidth(), view.getHeight()).build();
|
||||
currentViewport.setDensity(dm.density);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||
refreshMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
refreshMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
return application.accessibilityEnabled() ? false : super.onKeyDown(keyCode, event);
|
||||
public Boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
return application.accessibilityEnabled() ? false : null;
|
||||
}
|
||||
|
||||
public boolean isLayerVisible(OsmandMapLayer layer) {
|
||||
|
@ -476,32 +460,33 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
}
|
||||
|
||||
private void refreshMapInternal(DrawSettings drawSettings) {
|
||||
SurfaceHolder holder = getHolder();
|
||||
long ms = SystemClock.elapsedRealtime();
|
||||
synchronized (holder) {
|
||||
Canvas canvas = holder.lockCanvas();
|
||||
if (canvas != null) {
|
||||
try {
|
||||
final float ratioy = mapPosition == OsmandSettings.BOTTOM_CONSTANT ? 0.85f : 0.5f;
|
||||
final int cy = (int) (ratioy * getHeight());
|
||||
if (currentViewport.getPixWidth() != getWidth() || currentViewport.getPixHeight() != getHeight() ||
|
||||
currentViewport.getCenterPixelY() != cy) {
|
||||
currentViewport.setPixelDimensions(getWidth(), getHeight(), 0.5f, ratioy);
|
||||
refreshBufferImage(drawSettings);
|
||||
final float ratioy = mapPosition == OsmandSettings.BOTTOM_CONSTANT ? 0.85f : 0.5f;
|
||||
final int cy = (int) (ratioy * view.getHeight());
|
||||
if (currentViewport.getPixWidth() != view.getWidth() || currentViewport.getPixHeight() != view.getHeight() ||
|
||||
currentViewport.getCenterPixelY() != cy) {
|
||||
currentViewport.setPixelDimensions(view.getWidth(), view.getHeight(), 0.5f, ratioy);
|
||||
refreshBufferImage(drawSettings);
|
||||
}
|
||||
if (view instanceof SurfaceView) {
|
||||
SurfaceHolder holder = ((SurfaceView) view).getHolder();
|
||||
long ms = SystemClock.elapsedRealtime();
|
||||
synchronized (holder) {
|
||||
Canvas canvas = holder.lockCanvas();
|
||||
if (canvas != null) {
|
||||
try {
|
||||
// make copy to avoid concurrency
|
||||
RotatedTileBox viewportToDraw = currentViewport.copy();
|
||||
drawOverMap(canvas, viewportToDraw, drawSettings);
|
||||
} finally {
|
||||
holder.unlockCanvasAndPost(canvas);
|
||||
}
|
||||
// make copy to avoid concurrency
|
||||
RotatedTileBox viewportToDraw = currentViewport.copy();
|
||||
if(mapRenderer != null) {
|
||||
fillCanvas(canvas, drawSettings);
|
||||
}
|
||||
drawOverMap(canvas, viewportToDraw, drawSettings);
|
||||
} finally {
|
||||
holder.unlockCanvasAndPost(canvas);
|
||||
}
|
||||
if (MEASURE_FPS) {
|
||||
main.calculateFPS(ms, SystemClock.elapsedRealtime());
|
||||
}
|
||||
}
|
||||
if (MEASURE_FPS) {
|
||||
main.calculateFPS(ms, SystemClock.elapsedRealtime());
|
||||
}
|
||||
} else {
|
||||
view.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -530,10 +515,13 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
return additional.fps;
|
||||
}
|
||||
|
||||
private void drawOverMap(Canvas canvas, RotatedTileBox tileBox, DrawSettings drawSettings) {
|
||||
public void drawOverMap(Canvas canvas, RotatedTileBox tileBox, DrawSettings drawSettings) {
|
||||
if(mapRenderer == null) {
|
||||
fillCanvas(canvas, drawSettings);
|
||||
}
|
||||
final QuadPoint c = tileBox.getCenterPixelPoint();
|
||||
synchronized (this) {
|
||||
if (bufferBitmap != null && !bufferBitmap.isRecycled()) {
|
||||
if (bufferBitmap != null && !bufferBitmap.isRecycled() && mapRenderer == null) {
|
||||
canvas.save();
|
||||
canvas.rotate(tileBox.getRotate(), c.x, c.y);
|
||||
drawBasemap(canvas);
|
||||
|
@ -549,6 +537,9 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
if (!layer.drawInScreenPixels()) {
|
||||
canvas.rotate(tileBox.getRotate(), c.x, c.y);
|
||||
}
|
||||
if(mapRenderer != null) {
|
||||
layer.onPrepareBufferImage(canvas, tileBox, drawSettings);
|
||||
}
|
||||
layer.onDraw(canvas, tileBox, drawSettings);
|
||||
canvas.restore();
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
|
@ -568,6 +559,9 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
}
|
||||
|
||||
private void refreshBufferImage(final DrawSettings drawSettings) {
|
||||
if(mapRenderer != null) {
|
||||
return;
|
||||
}
|
||||
if (!baseHandler.hasMessages(BASE_REFRESH_MESSAGE) || drawSettings.isUpdateVectorRendering()) {
|
||||
Message msg = Message.obtain(baseHandler, new Runnable() {
|
||||
@Override
|
||||
|
@ -601,7 +595,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
|
||||
// this method could be called in non UI thread
|
||||
public void refreshMap(final boolean updateVectorRendering) {
|
||||
if (isShown()) {
|
||||
if (view.isShown()) {
|
||||
boolean nightMode = application.getDaynightHelper().isNightMode();
|
||||
DrawSettings drawSettings = new DrawSettings(nightMode, updateVectorRendering);
|
||||
sendRefreshMapMsg(drawSettings, 20);
|
||||
|
@ -723,7 +717,6 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if (twoFingerTapDetector.onTouchEvent(event)) {
|
||||
return true;
|
||||
|
@ -752,12 +745,11 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
return mapRenderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTrackballEvent(MotionEvent event) {
|
||||
public Boolean onTrackballEvent(MotionEvent event) {
|
||||
if (trackBallDelegate != null) {
|
||||
trackBallDelegate.onTrackBallEvent(event);
|
||||
return trackBallDelegate.onTrackBallEvent(event);
|
||||
}
|
||||
return super.onTrackballEvent(event);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setTrackBallDelegate(OnTrackBallListener trackBallDelegate) {
|
||||
|
@ -785,7 +777,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AccessibleToast.makeText(getContext(), msg, Toast.LENGTH_SHORT).show(); //$NON-NLS-1$
|
||||
AccessibleToast.makeText(view.getContext(), msg, Toast.LENGTH_SHORT).show(); //$NON-NLS-1$
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -815,7 +807,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
final int newZoom = getZoom();
|
||||
if (application.accessibilityEnabled()) {
|
||||
if (newZoom != initialViewport.getZoom()) {
|
||||
showMessage(getContext().getString(R.string.zoomIs) + " " + newZoom); //$NON-NLS-1$
|
||||
showMessage(view.getContext().getString(R.string.zoomIs) + " " + newZoom); //$NON-NLS-1$
|
||||
} else {
|
||||
final LatLon p1 = initialViewport.getLatLonFromPixel(x1, y1);
|
||||
final LatLon p2 = initialViewport.getLatLonFromPixel(x2, y2);
|
||||
|
@ -968,4 +960,28 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
}
|
||||
|
||||
|
||||
public Context getContext() {
|
||||
return view.getContext();
|
||||
}
|
||||
|
||||
public Resources getResources() {
|
||||
return view.getResources();
|
||||
}
|
||||
|
||||
public ViewParent getParent() {
|
||||
return view.getParent();
|
||||
}
|
||||
|
||||
public View getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return view.getHeight();
|
||||
}
|
||||
|
||||
public float getWidth() {
|
||||
return view.getWidth();
|
||||
}
|
||||
|
||||
}
|
|
@ -165,9 +165,9 @@ public class NativeQtLibrary {
|
|||
BinaryMapRasterBitmapTileProvider_Software binaryMapRasterBitmapTileProvider = notGc(new BinaryMapRasterBitmapTileProvider_Software(
|
||||
binaryMapPrimitivesProvider));
|
||||
mapRenderer.setRasterLayerProvider(RasterMapLayerId.BaseLayer, binaryMapRasterBitmapTileProvider);
|
||||
BinaryMapStaticSymbolsProvider binaryMapStaticSymbolsProvider = notGc(new BinaryMapStaticSymbolsProvider(
|
||||
binaryMapPrimitivesProvider, rasterTileSize));
|
||||
mapRenderer.addSymbolProvider(binaryMapStaticSymbolsProvider);
|
||||
// BinaryMapStaticSymbolsProvider binaryMapStaticSymbolsProvider = notGc(new BinaryMapStaticSymbolsProvider(
|
||||
// binaryMapPrimitivesProvider, rasterTileSize));
|
||||
// mapRenderer.addSymbolProvider(binaryMapStaticSymbolsProvider);
|
||||
} else {
|
||||
OnlineRasterMapTileProvider onlineMapRasterBitmapTileProvider = notGc(OnlineTileSources.getBuiltIn()
|
||||
.createProviderFor("Mapnik (OsmAnd)"));
|
||||
|
|
|
@ -249,7 +249,7 @@ public class MapInfoWidgetsFactory {
|
|||
|
||||
private void blinkIcon() {
|
||||
lockView.setBackgroundDrawable(lockDisabled);
|
||||
view.postDelayed(new Runnable() {
|
||||
view.getView().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
lockView.setBackgroundDrawable(lockEnabled);
|
||||
|
|
Loading…
Reference in a new issue