Exemplo n.º 1
0
  public static void SendFiles(Context applicationContext, IActionListener callback) {

    final String currentFileName = Session.getCurrentFileName();

    File gpxFolder = new File(Environment.getExternalStorageDirectory(), "GPSLogger");

    if (!gpxFolder.exists()) {
      callback.OnFailure();
      return;
    }

    List<File> files =
        new ArrayList<File>(
            Arrays.asList(
                gpxFolder.listFiles(
                    new FilenameFilter() {
                      @Override
                      public boolean accept(File file, String s) {
                        return s.contains(currentFileName) && !s.contains("zip");
                      }
                    })));

    if (files.size() == 0) {
      callback.OnFailure();
      return;
    }

    if (AppSettings.shouldSendZipFile()) {
      File zipFile = new File(gpxFolder.getPath(), currentFileName + ".zip");
      ArrayList<String> filePaths = new ArrayList<String>();

      for (File f : files) {
        filePaths.add(f.getAbsolutePath());
      }

      Utilities.LogInfo("Zipping file");
      ZipHelper zh =
          new ZipHelper(filePaths.toArray(new String[filePaths.size()]), zipFile.getAbsolutePath());
      zh.Zip();

      // files.clear();
      files.add(zipFile);
    }

    List<IFileSender> senders = GetFileSenders(applicationContext, callback);

    for (IFileSender sender : senders) {
      sender.UploadFile(files);
    }
  }
Exemplo n.º 2
0
  public void onFileName(String newFileName) {
    if (newFileName == null || newFileName.length() <= 0) {
      return;
    }

    TextView txtFilename = (TextView) findViewById(R.id.txtFileName);

    if (AppSettings.shouldLogToGpx() || AppSettings.shouldLogToKml()) {

      txtFilename.setText(
          getString(R.string.summary_current_filename_format, Session.getCurrentFileName()));
    } else {
      txtFilename.setText("");
    }
  }
Exemplo n.º 3
0
  /** Displays a human readable summary of the preferences chosen by the user on the main form */
  private void ShowPreferencesSummary() {
    Utilities.LogDebug("GpsMainActivity.ShowPreferencesSummary");
    try {
      TextView txtLoggingTo = (TextView) findViewById(R.id.txtLoggingTo);
      TextView txtFrequency = (TextView) findViewById(R.id.txtFrequency);
      TextView txtDistance = (TextView) findViewById(R.id.txtDistance);
      TextView txtAutoEmail = (TextView) findViewById(R.id.txtAutoEmail);

      if (!AppSettings.shouldLogToKml() && !AppSettings.shouldLogToGpx()) {
        txtLoggingTo.setText(R.string.summary_loggingto_screen);

      } else if (AppSettings.shouldLogToGpx() && AppSettings.shouldLogToKml()) {
        txtLoggingTo.setText(R.string.summary_loggingto_both);
      } else {
        txtLoggingTo.setText((AppSettings.shouldLogToGpx() ? "GPX" : "KML"));
      }

      if (AppSettings.getMinimumSeconds() > 0) {
        String descriptiveTime =
            Utilities.GetDescriptiveTimeString(
                AppSettings.getMinimumSeconds(), getApplicationContext());

        txtFrequency.setText(descriptiveTime);
      } else {
        txtFrequency.setText(R.string.summary_freq_max);
      }

      if (AppSettings.getMinimumDistanceInMeters() > 0) {
        if (AppSettings.shouldUseImperial()) {
          int minimumDistanceInFeet =
              Utilities.MetersToFeet(AppSettings.getMinimumDistanceInMeters());
          txtDistance.setText(
              ((minimumDistanceInFeet == 1)
                  ? getString(R.string.foot)
                  : String.valueOf(minimumDistanceInFeet) + getString(R.string.feet)));
        } else {
          txtDistance.setText(
              ((AppSettings.getMinimumDistanceInMeters() == 1)
                  ? getString(R.string.meter)
                  : String.valueOf(AppSettings.getMinimumDistanceInMeters())
                      + getString(R.string.meters)));
        }
      } else {
        txtDistance.setText(R.string.summary_dist_regardless);
      }

      if (AppSettings.isAutoEmailEnabled()) {
        String autoEmailResx;

        if (AppSettings.getAutoEmailDelay() == 0) {
          autoEmailResx = "autoemail_frequency_whenistop";
        } else {

          autoEmailResx =
              "autoemail_frequency_"
                  + String.valueOf(AppSettings.getAutoEmailDelay()).replace(".", "");
        }

        String autoEmailDesc =
            getString(getResources().getIdentifier(autoEmailResx, "string", getPackageName()));

        txtAutoEmail.setText(autoEmailDesc);
      } else {
        TableRow trAutoEmail = (TableRow) findViewById(R.id.trAutoEmail);
        trAutoEmail.setVisibility(View.INVISIBLE);
      }

      onFileName(Session.getCurrentFileName());
    } catch (Exception ex) {
      Utilities.LogError("ShowPreferencesSummary", ex);
    }
  }