Refactor
This commit is contained in:
parent
f846093a56
commit
c249c05dc5
6 changed files with 254 additions and 36 deletions
|
@ -11,6 +11,8 @@
|
||||||
-->
|
-->
|
||||||
<string name="test_native_render">Test native render</string>
|
<string name="test_native_render">Test native render</string>
|
||||||
<string name="test_native_render_msg">Starts activity with native render</string>
|
<string name="test_native_render_msg">Starts activity with native render</string>
|
||||||
|
<string name="use_native_render">Use native render</string>
|
||||||
|
<string name="use_native_render_descr">Use C++ render instead of Java</string>
|
||||||
<string name="text_size_descr">Set the text size on the map.</string>
|
<string name="text_size_descr">Set the text size on the map.</string>
|
||||||
<string name="text_size">Text size</string>
|
<string name="text_size">Text size</string>
|
||||||
<string name="traffic_warning_speed_limit">Speed limit</string>
|
<string name="traffic_warning_speed_limit">Speed limit</string>
|
||||||
|
|
|
@ -699,6 +699,8 @@ public class OsmandSettings {
|
||||||
// magnetic field doesn'torkmost of the time on some phones
|
// magnetic field doesn'torkmost of the time on some phones
|
||||||
public final OsmandPreference<Boolean> USE_MAGNETIC_FIELD_SENSOR_COMPASS = new BooleanPreference("use_magnetic_field_sensor_compass", false).makeGlobal().cache();
|
public final OsmandPreference<Boolean> USE_MAGNETIC_FIELD_SENSOR_COMPASS = new BooleanPreference("use_magnetic_field_sensor_compass", false).makeGlobal().cache();
|
||||||
public final OsmandPreference<Boolean> USE_KALMAN_FILTER_FOR_COMPASS = new BooleanPreference("use_kalman_filter_compass", true).makeGlobal().cache();
|
public final OsmandPreference<Boolean> USE_KALMAN_FILTER_FOR_COMPASS = new BooleanPreference("use_kalman_filter_compass", true).makeGlobal().cache();
|
||||||
|
|
||||||
|
public final OsmandPreference<Boolean> USE_NATIVE_RENDER = new BooleanPreference("use_native_render", false).makeGlobal().cache();
|
||||||
|
|
||||||
public final CommonPreference<Float> TEXT_SCALE = new FloatPreference("text_scale", 1f).makeProfile().cache();
|
public final CommonPreference<Float> TEXT_SCALE = new FloatPreference("text_scale", 1f).makeProfile().cache();
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import android.opengl.GLSurfaceView;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.StateChangedListener;
|
import net.osmand.StateChangedListener;
|
||||||
import net.osmand.access.AccessibilityPlugin;
|
import net.osmand.access.AccessibilityPlugin;
|
||||||
|
@ -42,6 +43,7 @@ import net.osmand.plus.routing.RoutingHelper.RouteCalculationProgressCallback;
|
||||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||||
import net.osmand.plus.views.OsmandMapLayer;
|
import net.osmand.plus.views.OsmandMapLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
import net.osmand.plus.views.controllers.MapViewController;
|
||||||
import net.osmand.render.RenderingRulesStorage;
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
@ -78,8 +80,7 @@ public class MapActivity extends AccessibleActivity {
|
||||||
private static MapViewTrackingUtilities mapViewTrackingUtilities;
|
private static MapViewTrackingUtilities mapViewTrackingUtilities;
|
||||||
|
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
private OsmandMapTileView mapView;
|
|
||||||
|
|
||||||
private MapActivityActions mapActions;
|
private MapActivityActions mapActions;
|
||||||
private MapActivityLayers mapLayers;
|
private MapActivityLayers mapLayers;
|
||||||
|
|
||||||
|
@ -100,6 +101,7 @@ public class MapActivity extends AccessibleActivity {
|
||||||
private StateChangedListener<ApplicationMode> applicationModeListener;
|
private StateChangedListener<ApplicationMode> applicationModeListener;
|
||||||
private FrameLayout lockView;
|
private FrameLayout lockView;
|
||||||
private GpxImportHelper gpxImportHelper;
|
private GpxImportHelper gpxImportHelper;
|
||||||
|
private MapViewController mapViewController;
|
||||||
|
|
||||||
|
|
||||||
private Notification getNotification() {
|
private Notification getNotification() {
|
||||||
|
@ -126,32 +128,39 @@ public class MapActivity extends AccessibleActivity {
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
// Full screen is not used here
|
// Full screen is not used here
|
||||||
//getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
//getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
setContentView(R.layout.main);
|
|
||||||
startProgressDialog = new ProgressDialog(this);
|
startProgressDialog = new ProgressDialog(this);
|
||||||
startProgressDialog.setCancelable(true);
|
startProgressDialog.setCancelable(true);
|
||||||
app.checkApplicationIsBeingInitialized(this, startProgressDialog);
|
app.checkApplicationIsBeingInitialized(this, startProgressDialog);
|
||||||
parseLaunchIntentLocation();
|
parseLaunchIntentLocation();
|
||||||
|
|
||||||
mapView = (OsmandMapTileView) findViewById(R.id.MapView);
|
if (settings.USE_NATIVE_RENDER.get()){
|
||||||
mapView.setTrackBallDelegate(new OsmandMapTileView.OnTrackBallListener(){
|
setContentView(R.layout.main);
|
||||||
|
mapViewController = new MapViewController((OsmandMapTileView) findViewById(R.id.MapView), this);
|
||||||
|
} else {
|
||||||
|
setContentView(R.layout.activity_gl);
|
||||||
|
mapViewController = new MapViewController((GLSurfaceView) findViewById(R.id.glSurfaceView), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
mapViewController.setTrackBallDelegate(new MapViewController.OnTrackBallListener(){
|
||||||
@Override
|
@Override
|
||||||
public boolean onTrackBallEvent(MotionEvent e) {
|
public boolean onTrackBallEvent(MotionEvent e) {
|
||||||
showAndHideMapPosition();
|
showAndHideMapPosition();
|
||||||
return MapActivity.this.onTrackballEvent(e);
|
return MapActivity.this.onTrackballEvent(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mapView.setAccessibilityActions(new MapAccessibilityActions(this));
|
mapViewController.setAccessibilityActions(new MapAccessibilityActions(this));
|
||||||
if(mapViewTrackingUtilities == null) {
|
if(mapViewTrackingUtilities == null) {
|
||||||
mapViewTrackingUtilities = new MapViewTrackingUtilities(app);
|
mapViewTrackingUtilities = new MapViewTrackingUtilities(app);
|
||||||
}
|
}
|
||||||
mapViewTrackingUtilities.setMapView(mapView);
|
mapViewController.setTrackingUtilities(mapViewTrackingUtilities);
|
||||||
|
|
||||||
// Do some action on close
|
// Do some action on close
|
||||||
startProgressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
startProgressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDismiss(DialogInterface dialog) {
|
public void onDismiss(DialogInterface dialog) {
|
||||||
app.getResourceManager().getRenderer().clearCache();
|
app.getResourceManager().getRenderer().clearCache();
|
||||||
mapView.refreshMap(true);
|
mapViewController.refreshMap(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -163,12 +172,12 @@ public class MapActivity extends AccessibleActivity {
|
||||||
mgr.tileDownloaded(request);
|
mgr.tileDownloaded(request);
|
||||||
}
|
}
|
||||||
if(request == null || !request.error){
|
if(request == null || !request.error){
|
||||||
mapView.tileDownloaded(request);
|
mapViewController.tileDownloaded(request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
createProgressBarForRouting();
|
createProgressBarForRouting();
|
||||||
mapLayers.createLayers(mapView);
|
mapViewController.createLayers(mapLayers);
|
||||||
// This situtation could be when navigation suddenly crashed and after restarting
|
// This situtation could be when navigation suddenly crashed and after restarting
|
||||||
// it tries to continue the last route
|
// it tries to continue the last route
|
||||||
if (settings.FOLLOW_THE_ROUTE.get() && !app.getRoutingHelper().isRouteCalculated()
|
if (settings.FOLLOW_THE_ROUTE.get() && !app.getRoutingHelper().isRouteCalculated()
|
||||||
|
@ -180,14 +189,15 @@ public class MapActivity extends AccessibleActivity {
|
||||||
// show first time when application ran
|
// show first time when application ran
|
||||||
net.osmand.Location location = app.getLocationProvider().getFirstTimeRunDefaultLocation();
|
net.osmand.Location location = app.getLocationProvider().getFirstTimeRunDefaultLocation();
|
||||||
if(location != null){
|
if(location != null){
|
||||||
mapView.setLatLon(location.getLatitude(), location.getLongitude());
|
mapViewController.setLatLon(location.getLatitude(), location.getLongitude());
|
||||||
mapView.setIntZoom(14);
|
mapViewController.setIntZoom(14);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addDialogProvider(mapActions);
|
addDialogProvider(mapActions);
|
||||||
OsmandPlugin.onMapActivityCreate(this);
|
OsmandPlugin.onMapActivityCreate(this);
|
||||||
if(lockView != null) {
|
if(lockView != null) {
|
||||||
((FrameLayout)mapView.getParent()).addView(lockView);
|
mapViewController.addView(lockView);
|
||||||
|
|
||||||
}
|
}
|
||||||
gpxImportHelper = new GpxImportHelper(this, getMyApplication(), getMapView());
|
gpxImportHelper = new GpxImportHelper(this, getMyApplication(), getMapView());
|
||||||
}
|
}
|
||||||
|
@ -197,7 +207,7 @@ public class MapActivity extends AccessibleActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createProgressBarForRouting() {
|
private void createProgressBarForRouting() {
|
||||||
FrameLayout parent = (FrameLayout) mapView.getParent();
|
FrameLayout parent = (FrameLayout) mapViewController.getParentView();
|
||||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
|
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
|
||||||
Gravity.CENTER_HORIZONTAL | Gravity.TOP);
|
Gravity.CENTER_HORIZONTAL | Gravity.TOP);
|
||||||
DisplayMetrics dm = getResources().getDisplayMetrics();
|
DisplayMetrics dm = getResources().getDisplayMetrics();
|
||||||
|
@ -238,7 +248,7 @@ public class MapActivity extends AccessibleActivity {
|
||||||
@Override
|
@Override
|
||||||
public Object onRetainCustomNonConfigurationInstance() {
|
public Object onRetainCustomNonConfigurationInstance() {
|
||||||
LinkedHashMap<String, Object> l = new LinkedHashMap<String, Object>();
|
LinkedHashMap<String, Object> l = new LinkedHashMap<String, Object>();
|
||||||
for(OsmandMapLayer ml : mapView.getLayers() ) {
|
for(OsmandMapLayer ml : mapViewController.getLayers() ) {
|
||||||
ml.onRetainNonConfigurationInstance(l);
|
ml.onRetainNonConfigurationInstance(l);
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
|
@ -301,8 +311,8 @@ public class MapActivity extends AccessibleActivity {
|
||||||
|
|
||||||
if (settings != null && settings.isLastKnownMapLocation()) {
|
if (settings != null && settings.isLastKnownMapLocation()) {
|
||||||
LatLon l = settings.getLastKnownMapLocation();
|
LatLon l = settings.getLastKnownMapLocation();
|
||||||
mapView.setLatLon(l.getLatitude(), l.getLongitude());
|
mapViewController.setLatLon(l.getLatitude(), l.getLongitude());
|
||||||
mapView.setIntZoom(settings.getLastKnownMapZoom());
|
mapViewController.setIntZoom(settings.getLastKnownMapZoom());
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.MAP_ACTIVITY_ENABLED.set(true);
|
settings.MAP_ACTIVITY_ENABLED.set(true);
|
||||||
|
@ -310,7 +320,7 @@ public class MapActivity extends AccessibleActivity {
|
||||||
checkExternalStorage();
|
checkExternalStorage();
|
||||||
showAndHideMapPosition();
|
showAndHideMapPosition();
|
||||||
|
|
||||||
LatLon cur = new LatLon(mapView.getLatitude(), mapView.getLongitude());
|
LatLon cur = new LatLon(mapViewController.getLatitude(), mapViewController.getLongitude());
|
||||||
LatLon latLonToShow = settings.getAndClearMapLocationToShow();
|
LatLon latLonToShow = settings.getAndClearMapLocationToShow();
|
||||||
String mapLabelToShow = settings.getAndClearMapLabelToShow();
|
String mapLabelToShow = settings.getAndClearMapLabelToShow();
|
||||||
Object toShow = settings.getAndClearObjectToShow();
|
Object toShow = settings.getAndClearObjectToShow();
|
||||||
|
@ -318,8 +328,8 @@ public class MapActivity extends AccessibleActivity {
|
||||||
if(status != 0){
|
if(status != 0){
|
||||||
// always enable and follow and let calculate it (i.e.GPS is not accessible in a garage)
|
// always enable and follow and let calculate it (i.e.GPS is not accessible in a garage)
|
||||||
Location loc = new Location("map");
|
Location loc = new Location("map");
|
||||||
loc.setLatitude(mapView.getLatitude());
|
loc.setLatitude(mapViewController.getLatitude());
|
||||||
loc.setLongitude(mapView.getLongitude());
|
loc.setLongitude(mapViewController.getLongitude());
|
||||||
getMapActions().enterRoutePlanningMode(null, null, status == OsmandSettings.NAVIGATE_CURRENT_GPX);
|
getMapActions().enterRoutePlanningMode(null, null, status == OsmandSettings.NAVIGATE_CURRENT_GPX);
|
||||||
}
|
}
|
||||||
if(mapLabelToShow != null && latLonToShow != null){
|
if(mapLabelToShow != null && latLonToShow != null){
|
||||||
|
@ -327,7 +337,7 @@ public class MapActivity extends AccessibleActivity {
|
||||||
mapLayers.getContextMenuLayer().setLocation(latLonToShow, mapLabelToShow);
|
mapLayers.getContextMenuLayer().setLocation(latLonToShow, mapLabelToShow);
|
||||||
}
|
}
|
||||||
if (latLonToShow != null && !latLonToShow.equals(cur)) {
|
if (latLonToShow != null && !latLonToShow.equals(cur)) {
|
||||||
mapView.getAnimatedDraggingThread().startMoving(latLonToShow.getLatitude(), latLonToShow.getLongitude(),
|
mapViewController.startMoving(latLonToShow.getLatitude(), latLonToShow.getLongitude(),
|
||||||
settings.getMapZoomToShow(), true);
|
settings.getMapZoomToShow(), true);
|
||||||
}
|
}
|
||||||
if(latLonToShow != null) {
|
if(latLonToShow != null) {
|
||||||
|
@ -376,7 +386,7 @@ public class MapActivity extends AccessibleActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
OsmandPlugin.onMapActivityResume(this);
|
OsmandPlugin.onMapActivityResume(this);
|
||||||
mapView.refreshMap(true);
|
mapViewController.refreshMap(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -417,8 +427,8 @@ public class MapActivity extends AccessibleActivity {
|
||||||
// if (settings.AUTO_ZOOM_MAP.get() == AutoZoomMap.NONE) {
|
// if (settings.AUTO_ZOOM_MAP.get() == AutoZoomMap.NONE) {
|
||||||
// changeLocation = false;
|
// changeLocation = false;
|
||||||
// }
|
// }
|
||||||
final int newZoom = mapView.getZoom() + stp;
|
final int newZoom = mapViewController.getZoom() + stp;
|
||||||
mapView.getAnimatedDraggingThread().startZooming(newZoom, changeLocation);
|
mapViewController.startZooming(newZoom, changeLocation);
|
||||||
if (app.accessibilityEnabled())
|
if (app.accessibilityEnabled())
|
||||||
AccessibleToast.makeText(this, getString(R.string.zoomIs) + " " + newZoom, Toast.LENGTH_SHORT).show(); //$NON-NLS-1$
|
AccessibleToast.makeText(this, getString(R.string.zoomIs) + " " + newZoom, Toast.LENGTH_SHORT).show(); //$NON-NLS-1$
|
||||||
showAndHideMapPosition();
|
showAndHideMapPosition();
|
||||||
|
@ -455,7 +465,7 @@ public class MapActivity extends AccessibleActivity {
|
||||||
OsmandPlugin.getEnabledPlugin(AccessibilityPlugin.class) != null) {
|
OsmandPlugin.getEnabledPlugin(AccessibilityPlugin.class) != null) {
|
||||||
// Find more appropriate plugin for it?
|
// Find more appropriate plugin for it?
|
||||||
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP && event.getRepeatCount() == 0) {
|
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP && event.getRepeatCount() == 0) {
|
||||||
if (mapView.isZooming()) {
|
if (mapViewController.isZooming()) {
|
||||||
changeZoom(+ 2);
|
changeZoom(+ 2);
|
||||||
} else {
|
} else {
|
||||||
changeZoom(+ 1);
|
changeZoom(+ 1);
|
||||||
|
@ -470,7 +480,7 @@ public class MapActivity extends AccessibleActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMapLocation(double lat, double lon){
|
public void setMapLocation(double lat, double lon){
|
||||||
mapView.setLatLon(lat, lon);
|
mapViewController.setLatLon(lat, lon);
|
||||||
mapViewTrackingUtilities.locationChanged(lat, lon, this);
|
mapViewTrackingUtilities.locationChanged(lat, lon, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,7 +489,7 @@ public class MapActivity extends AccessibleActivity {
|
||||||
if(event.getAction() == MotionEvent.ACTION_MOVE && settings.USE_TRACKBALL_FOR_MOVEMENTS.get()){
|
if(event.getAction() == MotionEvent.ACTION_MOVE && settings.USE_TRACKBALL_FOR_MOVEMENTS.get()){
|
||||||
float x = event.getX();
|
float x = event.getX();
|
||||||
float y = event.getY();
|
float y = event.getY();
|
||||||
final RotatedTileBox tb = mapView.getCurrentRotatedTileBox();
|
final RotatedTileBox tb = mapViewController.getCurrentRotatedTileBox();
|
||||||
final QuadPoint cp = tb.getCenterPixelPoint();
|
final QuadPoint cp = tb.getCenterPixelPoint();
|
||||||
final LatLon l = tb.getLatLonFromPixel(cp.x + x * 15, cp.y + y * 15);
|
final LatLon l = tb.getLatLonFromPixel(cp.x + x * 15, cp.y + y * 15);
|
||||||
setMapLocation(l.getLatitude(), l.getLongitude());
|
setMapLocation(l.getLatitude(), l.getLongitude());
|
||||||
|
@ -538,7 +548,7 @@ public class MapActivity extends AccessibleActivity {
|
||||||
|
|
||||||
|
|
||||||
public LatLon getMapLocation(){
|
public LatLon getMapLocation(){
|
||||||
return new LatLon(mapView.getLatitude(), mapView.getLongitude());
|
return new LatLon(mapViewController.getLatitude(), mapViewController.getLongitude());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Duplicate methods to OsmAndApplication
|
// Duplicate methods to OsmAndApplication
|
||||||
|
@ -557,14 +567,14 @@ public class MapActivity extends AccessibleActivity {
|
||||||
app.getDaynightHelper().stopSensorIfNeeded();
|
app.getDaynightHelper().stopSensorIfNeeded();
|
||||||
settings.APPLICATION_MODE.removeListener(applicationModeListener);
|
settings.APPLICATION_MODE.removeListener(applicationModeListener);
|
||||||
|
|
||||||
settings.setLastKnownMapLocation((float) mapView.getLatitude(), (float) mapView.getLongitude());
|
settings.setLastKnownMapLocation((float) mapViewController.getLatitude(), (float) mapViewController.getLongitude());
|
||||||
AnimateDraggingMapThread animatedThread = mapView.getAnimatedDraggingThread();
|
AnimateDraggingMapThread animatedThread = mapView.getAnimatedDraggingThread();
|
||||||
if(animatedThread.isAnimating() && animatedThread.getTargetIntZoom() != 0){
|
if(animatedThread.isAnimating() && animatedThread.getTargetIntZoom() != 0){
|
||||||
settings.setMapLocationToShow(animatedThread.getTargetLatitude(), animatedThread.getTargetLongitude(),
|
settings.setMapLocationToShow(animatedThread.getTargetLatitude(), animatedThread.getTargetLongitude(),
|
||||||
animatedThread.getTargetIntZoom());
|
animatedThread.getTargetIntZoom());
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.setLastKnownMapZoom(mapView.getZoom());
|
settings.setLastKnownMapZoom(mapViewController.getZoom());
|
||||||
settings.MAP_ACTIVITY_ENABLED.set(false);
|
settings.MAP_ACTIVITY_ENABLED.set(false);
|
||||||
app.setMapActivity(null);
|
app.setMapActivity(null);
|
||||||
app.getResourceManager().interruptRendering();
|
app.getResourceManager().interruptRendering();
|
||||||
|
|
|
@ -41,6 +41,8 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
|
||||||
cat.addPreference(createCheckBoxPreference(settings.DISABLE_COMPLEX_ROUTING, R.string.disable_complex_routing, R.string.disable_complex_routing_descr));
|
cat.addPreference(createCheckBoxPreference(settings.DISABLE_COMPLEX_ROUTING, R.string.disable_complex_routing, R.string.disable_complex_routing_descr));
|
||||||
|
|
||||||
cat.addPreference(createCheckBoxPreference(settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS, R.string.use_magnetic_sensor, R.string.use_magnetic_sensor_descr));
|
cat.addPreference(createCheckBoxPreference(settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS, R.string.use_magnetic_sensor, R.string.use_magnetic_sensor_descr));
|
||||||
|
|
||||||
|
cat.addPreference(createCheckBoxPreference(settings.USE_NATIVE_RENDER, R.string.use_native_render,R.string.use_native_render_descr));
|
||||||
|
|
||||||
Preference pref = new Preference(this);
|
Preference pref = new Preference(this);
|
||||||
pref.setTitle(R.string.test_voice_prompts);
|
pref.setTitle(R.string.test_voice_prompts);
|
||||||
|
|
|
@ -26,6 +26,7 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.helpers.SimpleTwoFingerTapDetector;
|
import net.osmand.plus.helpers.SimpleTwoFingerTapDetector;
|
||||||
import net.osmand.plus.views.MultiTouchSupport.MultiTouchZoomListener;
|
import net.osmand.plus.views.MultiTouchSupport.MultiTouchZoomListener;
|
||||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||||
|
import net.osmand.plus.views.controllers.MapViewController;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -81,9 +82,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
protected static final int emptyTileDivisor = 16;
|
protected static final int emptyTileDivisor = 16;
|
||||||
|
|
||||||
|
|
||||||
public interface OnTrackBallListener {
|
|
||||||
public boolean onTrackBallEvent(MotionEvent e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface OnLongClickListener {
|
public interface OnLongClickListener {
|
||||||
public boolean onLongPressEvent(PointF point);
|
public boolean onLongPressEvent(PointF point);
|
||||||
|
@ -110,7 +109,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
|
|
||||||
private OnClickListener onClickListener;
|
private OnClickListener onClickListener;
|
||||||
|
|
||||||
private OnTrackBallListener trackBallDelegate;
|
private MapViewController.OnTrackBallListener trackBallDelegate;
|
||||||
|
|
||||||
private AccessibilityActionsProvider accessibilityActions;
|
private AccessibilityActionsProvider accessibilityActions;
|
||||||
|
|
||||||
|
@ -746,7 +745,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
return super.onTrackballEvent(event);
|
return super.onTrackballEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTrackBallDelegate(OnTrackBallListener trackBallDelegate) {
|
public void setTrackBallDelegate(MapViewController.OnTrackBallListener trackBallDelegate) {
|
||||||
this.trackBallDelegate = trackBallDelegate;
|
this.trackBallDelegate = trackBallDelegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,203 @@
|
||||||
|
package net.osmand.plus.views.controllers;
|
||||||
|
|
||||||
|
import android.opengl.GLSurfaceView;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewParent;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import net.osmand.access.MapAccessibilityActions;
|
||||||
|
import net.osmand.data.RotatedTileBox;
|
||||||
|
import net.osmand.map.MapTileDownloader;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.activities.MapActivityLayers;
|
||||||
|
import net.osmand.plus.base.MapViewTrackingUtilities;
|
||||||
|
import net.osmand.plus.views.OsmandMapLayer;
|
||||||
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Натали on 29.09.2014.
|
||||||
|
*/
|
||||||
|
public class MapViewController {
|
||||||
|
private GLSurfaceView glSurfaceView;
|
||||||
|
private OsmandMapTileView mapTileView;
|
||||||
|
private OsmandSettings settings;
|
||||||
|
private MapActivity mapActivity;
|
||||||
|
private boolean isNative = false;
|
||||||
|
|
||||||
|
public void setAccessibilityActions(MapAccessibilityActions accessibilityActions) {
|
||||||
|
if (isNative){
|
||||||
|
|
||||||
|
} else {
|
||||||
|
mapTileView.setAccessibilityActions(accessibilityActions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshMap(boolean b) {
|
||||||
|
if (isNative){
|
||||||
|
|
||||||
|
} else {
|
||||||
|
mapTileView.refreshMap(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createLayers(MapActivityLayers mapLayers) {
|
||||||
|
if (isNative) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
mapLayers.createLayers(mapTileView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLatLon(double latitude, double longitude) {
|
||||||
|
if (isNative){
|
||||||
|
|
||||||
|
} else {
|
||||||
|
mapTileView.setLatLon(latitude, longitude);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIntZoom(int i) {
|
||||||
|
if (isNative) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
mapTileView.setIntZoom(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addView(FrameLayout view) {
|
||||||
|
if (isNative) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
((FrameLayout)mapTileView.getParent()).addView(view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTrackingUtilities(MapViewTrackingUtilities mapViewTrackingUtilities) {
|
||||||
|
if (isNative) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
mapViewTrackingUtilities.setMapView(mapTileView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tileDownloaded(MapTileDownloader.DownloadRequest request) {
|
||||||
|
if (isNative) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
mapTileView.tileDownloaded(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ViewParent getParentView() {
|
||||||
|
if (isNative) {
|
||||||
|
return glSurfaceView.getParent();
|
||||||
|
} else {
|
||||||
|
return mapTileView.getParent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OsmandMapLayer> getLayers() {
|
||||||
|
if (isNative) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return mapTileView.getLayers();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getLatitude() {
|
||||||
|
if (isNative){
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return mapTileView.getLatitude();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getLongitude() {
|
||||||
|
if (isNative){
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return mapTileView.getLongitude();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startMoving(double latitude, double longitude, int mapZoomToShow, boolean b) {
|
||||||
|
if (isNative){
|
||||||
|
|
||||||
|
} else {
|
||||||
|
mapTileView.getAnimatedDraggingThread().startMoving(latitude, longitude,
|
||||||
|
settings.getMapZoomToShow(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getZoom() {
|
||||||
|
if (isNative) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return mapTileView.getZoom();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startZooming(int newZoom, boolean changeLocation) {
|
||||||
|
if (isNative){
|
||||||
|
|
||||||
|
} else {
|
||||||
|
mapTileView.getAnimatedDraggingThread().startZooming(newZoom, changeLocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isZooming() {
|
||||||
|
if (isNative){
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return mapTileView.isZooming();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RotatedTileBox getCurrentRotatedTileBox() {
|
||||||
|
if (isNative) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return mapTileView.getCurrentRotatedTileBox();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public interface OnTrackBallListener {
|
||||||
|
public boolean onTrackBallEvent(MotionEvent e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapViewController(GLSurfaceView surfaceView, MapActivity activity){
|
||||||
|
this.glSurfaceView = surfaceView;
|
||||||
|
this.settings = activity.getMyApplication().getSettings();
|
||||||
|
this.mapActivity = activity;
|
||||||
|
isNative = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapViewController(OsmandMapTileView mapTileView, MapActivity activity){
|
||||||
|
this.mapTileView = mapTileView;
|
||||||
|
this.settings = activity.getMyApplication().getSettings();
|
||||||
|
this.mapActivity = activity;
|
||||||
|
isNative = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTrackBallDelegate(OnTrackBallListener trackBallDelegate) {
|
||||||
|
if (isNative){
|
||||||
|
|
||||||
|
} else {
|
||||||
|
mapTileView.setTrackBallDelegate(trackBallDelegate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue