コード例 #1
0
 public void changeZoom(float newZoom) {
   newZoom = Math.round(newZoom * OsmandMapTileView.ZOOM_DELTA) * OsmandMapTileView.ZOOM_DELTA_1;
   boolean changeLocation = settings.AUTO_ZOOM_MAP.get();
   mapView.getAnimatedDraggingThread().startZooming(newZoom, changeLocation);
   if (app.getInternalAPI().accessibilityEnabled())
     AccessibleToast.makeText(
             this, getString(R.string.zoomIs) + " " + String.valueOf(newZoom), Toast.LENGTH_SHORT)
         .show(); //$NON-NLS-1$
   showAndHideMapPosition();
 }
コード例 #2
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER && app.getInternalAPI().accessibilityEnabled()) {
     if (!uiHandler.hasMessages(LONG_KEYPRESS_MSG_ID)) {
       Message msg =
           Message.obtain(
               uiHandler,
               new Runnable() {
                 @Override
                 public void run() {
                   app.getLocationProvider().emitNavigationHint();
                 }
               });
       msg.what = LONG_KEYPRESS_MSG_ID;
       uiHandler.sendMessageDelayed(msg, LONG_KEYPRESS_DELAY);
     }
     return true;
   } else if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0) {
     mapActions.openOptionsMenuAsList();
     return true;
   } else if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
     Intent newIntent = new Intent(MapActivity.this, OsmandIntents.getSearchActivity());
     // causes wrong position caching:  newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
     LatLon loc = getMapLocation();
     newIntent.putExtra(SearchActivity.SEARCH_LAT, loc.getLatitude());
     newIntent.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude());
     startActivity(newIntent);
     newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
     return true;
   } else if (!app.getRoutingHelper().isFollowingMode()
       && OsmandPlugin.getEnabledPlugin(AccessibilityPlugin.class) != null) {
     // Find more appropriate plugin for it?
     if (keyCode == KeyEvent.KEYCODE_VOLUME_UP && event.getRepeatCount() == 0) {
       if (mapView.isZooming()) {
         changeZoom(mapView.getZoom() + 2);
       } else {
         changeZoom(mapView.getZoom() + 1);
       }
       return true;
     } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN && event.getRepeatCount() == 0) {
       changeZoom(mapView.getZoom() - 1);
       return true;
     }
   }
   return super.onKeyDown(keyCode, event);
 }
コード例 #3
0
 @Override
 public boolean onKeyUp(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
     if (!app.getInternalAPI().accessibilityEnabled()) {
       mapActions.contextMenuPoint(mapView.getLatitude(), mapView.getLongitude());
     } else if (uiHandler.hasMessages(LONG_KEYPRESS_MSG_ID)) {
       uiHandler.removeMessages(LONG_KEYPRESS_MSG_ID);
       mapActions.contextMenuPoint(mapView.getLatitude(), mapView.getLongitude());
     }
     return true;
   } else if (settings.ZOOM_BY_TRACKBALL.get()) {
     // Parrot device has only dpad left and right
     if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
       changeZoom(mapView.getZoom() - 1);
       return true;
     } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
       changeZoom(mapView.getZoom() + 1);
       return true;
     }
   } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT
       || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT
       || keyCode == KeyEvent.KEYCODE_DPAD_DOWN
       || keyCode == KeyEvent.KEYCODE_DPAD_UP) {
     int dx =
         keyCode == KeyEvent.KEYCODE_DPAD_RIGHT
             ? 15
             : (keyCode == KeyEvent.KEYCODE_DPAD_LEFT ? -15 : 0);
     int dy =
         keyCode == KeyEvent.KEYCODE_DPAD_DOWN
             ? 15
             : (keyCode == KeyEvent.KEYCODE_DPAD_UP ? -15 : 0);
     LatLon l =
         mapView.getLatLonFromScreenPoint(
             mapView.getCenterPointX() + dx, mapView.getCenterPointY() + dy);
     setMapLocation(l.getLatitude(), l.getLongitude());
     return true;
   } else if (OsmandPlugin.onMapActivityKeyUp(this, keyCode)) {
     return true;
   }
   return super.onKeyUp(keyCode, event);
 }
コード例 #4
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   return application.getInternalAPI().accessibilityEnabled()
       ? false
       : super.onKeyDown(keyCode, event);
 }