Ejemplo n.º 1
0
 public void stopRecording() {
   settings.SAVE_GLOBAL_TRACK_TO_GPX.set(false);
   if (app.getNavigationService() != null) {
     app.getNavigationService().stopIfNeeded(app, NavigationService.USED_BY_GPX);
     app.getNotificationHelper().showNotification();
   }
 }
Ejemplo n.º 2
0
  private void controlDialog(final Activity map) {
    final boolean wasTrackMonitored = settings.SAVE_GLOBAL_TRACK_TO_GPX.get();

    AlertDialog.Builder bld = new AlertDialog.Builder(map);
    final TIntArrayList items = new TIntArrayList();
    if (wasTrackMonitored) {
      items.add(R.string.gpx_monitoring_stop);
      items.add(R.string.gpx_start_new_segment);
      if (settings.LIVE_MONITORING.get()) {
        items.add(R.string.live_monitoring_stop);
      } else if (!settings
          .LIVE_MONITORING_URL
          .getProfileDefaultValue(settings.APPLICATION_MODE.get())
          .equals(settings.LIVE_MONITORING_URL.get())) {
        items.add(R.string.live_monitoring_start);
      }
    } else {
      items.add(R.string.gpx_monitoring_start);
    }
    if (app.getSavingTrackHelper().hasDataToSave()) {
      items.add(R.string.save_current_track);
    }
    String[] strings = new String[items.size()];
    for (int i = 0; i < strings.length; i++) {
      strings[i] = app.getString(items.get(i));
    }
    final int[] holder = new int[] {0};
    final Runnable run =
        new Runnable() {
          public void run() {
            int which = holder[0];
            int item = items.get(which);
            if (item == R.string.save_current_track) {
              saveCurrentTrack();
            } else if (item == R.string.gpx_monitoring_start) {
              if (app.getLocationProvider().checkGPSEnabled(map)) {
                startGPXMonitoring(map);
              }
            } else if (item == R.string.gpx_monitoring_stop) {
              stopRecording();
            } else if (item == R.string.gpx_start_new_segment) {
              app.getSavingTrackHelper().startNewSegment();
            } else if (item == R.string.live_monitoring_stop) {
              settings.LIVE_MONITORING.set(false);
            } else if (item == R.string.live_monitoring_start) {
              final ValueHolder<Integer> vs = new ValueHolder<Integer>();
              vs.value = settings.LIVE_MONITORING_INTERVAL.get();
              showIntervalChooseDialog(
                  map,
                  app.getString(R.string.live_monitoring_interval) + " : %s",
                  app.getString(R.string.save_track_to_gpx_globally),
                  SECONDS,
                  MINUTES,
                  null,
                  vs,
                  new OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      settings.LIVE_MONITORING_INTERVAL.set(vs.value);
                      settings.LIVE_MONITORING.set(true);
                    }
                  });
            }
            monitoringControl.updateInfo(null);
          }
        };
    if (strings.length == 1) {
      run.run();
    } else {
      bld.setItems(
          strings,
          new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
              holder[0] = which;
              run.run();
            }
          });
      bld.show();
    }
  }