示例#1
0
 @SuppressWarnings("unchecked")
 @Override
 public boolean onPreferenceClick(Preference preference) {
   if (preference.getKey().equals(OsmandSettings.LOCAL_INDEXES)) {
     boolean empty = getMyApplication().getResourceManager().getIndexFileNames().isEmpty();
     if (empty) {
       File folder =
           getMyApplication().getSettings().extendOsmandPath(ResourceManager.BACKUP_PATH);
       if (folder.exists() && folder.isDirectory()) {
         String[] l = folder.list();
         empty = l == null || l.length == 0;
       }
     }
     if (empty) {
       startActivity(new Intent(this, OsmandIntents.getDownloadIndexActivity()));
     } else {
       startActivity(new Intent(this, OsmandIntents.getLocalIndexActivity()));
     }
     return true;
   } else if (preference == bidforfix) {
     startActivity(new Intent(this, OsmandBidForFixActivity.class));
     return true;
   } else if (preference == plugins) {
     startActivity(new Intent(this, PluginsActivity.class));
     return true;
   } else if (preference == avoidRouting) {
     showBooleanSettings(
         new String[] {
           getString(R.string.avoid_toll_roads),
           getString(R.string.avoid_ferries),
           getString(R.string.avoid_unpaved),
           getString(R.string.avoid_motorway)
         },
         new OsmandPreference[] {
           osmandSettings.AVOID_TOLL_ROADS,
           osmandSettings.AVOID_FERRIES,
           osmandSettings.AVOID_UNPAVED_ROADS,
           osmandSettings.AVOID_MOTORWAY
         });
     return true;
   } else if (preference == showAlarms) {
     showBooleanSettings(
         new String[] {
           getString(R.string.show_speed_limits),
           getString(R.string.show_cameras),
           getString(R.string.show_lanes)
         },
         new OsmandPreference[] {
           osmandSettings.SHOW_SPEED_LIMITS, osmandSettings.SHOW_CAMERAS, osmandSettings.SHOW_LANES
         });
     return true;
   }
   return false;
 }
示例#2
0
 private Notification getNotification() {
   Intent notificationIndent = new Intent(this, OsmandIntents.getMapActivity());
   notificationIndent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
   Notification notification =
       new Notification(
           R.drawable.icon,
           "", //$NON-NLS-1$
           System.currentTimeMillis());
   notification.flags |= Notification.FLAG_AUTO_CANCEL;
   notification.setLatestEventInfo(
       this,
       Version.getAppName(app),
       getString(R.string.go_back_to_osmand),
       PendingIntent.getActivity(this, 0, notificationIndent, PendingIntent.FLAG_UPDATE_CURRENT));
   return notification;
 }
示例#3
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);
 }
示例#4
0
 public static void launchMapActivityMoveToTop(Context activity) {
   Intent newIntent = new Intent(activity, OsmandIntents.getMapActivity());
   newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
   activity.startActivity(newIntent);
 }