Пример #1
0
  public static List<IFileSender> GetFileSenders(
      Context applicationContext, IActionListener callback) {
    List<IFileSender> senders = new ArrayList<IFileSender>();

    //        if (GDocsHelper.IsLinked(applicationContext))
    //        {
    //            senders.add(new GDocsHelper(applicationContext, callback));
    //        }

    if (OSMHelper.IsOsmAuthorized(applicationContext)) {
      senders.add(new OSMHelper(applicationContext, callback));
    }

    if (AppSettings.isAutoEmailEnabled()) {
      senders.add(new AutoEmailHelper(callback));
    }

    DropBoxHelper dh = new DropBoxHelper(applicationContext, callback);

    if (dh.IsLinked()) {
      senders.add(dh);
    }

    if (AppSettings.isAutoOpenGTSEnabled()) {
      senders.add(new OpenGTSHelper(applicationContext, callback));
    }

    if (AppSettings.isAutoFtpEnabled()) {
      senders.add(new FtpHelper(callback));
    }

    return senders;
  }
Пример #2
0
  /** Uploads a GPS Trace to OpenStreetMap.org. */
  private void UploadToOpenStreetMap() {
    Utilities.LogDebug("GpsMainactivity.UploadToOpenStreetMap");

    if (!OSMHelper.IsOsmAuthorized(getApplicationContext())) {
      startActivity(OSMHelper.GetOsmSettingsIntent(getApplicationContext()));
      return;
    }

    final String goToOsmSettings = getString(R.string.menu_settings);

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

    if (gpxFolder.exists()) {
      FilenameFilter select =
          new FilenameFilter() {

            public boolean accept(File dir, String filename) {
              return filename.toLowerCase().contains(".gpx");
            }
          };

      String[] enumeratedFiles = gpxFolder.list(select);
      List<String> fileList = new ArrayList<String>(Arrays.asList(enumeratedFiles));
      Collections.reverse(fileList);
      fileList.add(0, goToOsmSettings);
      final String[] files = fileList.toArray(new String[fileList.size()]);

      final Dialog dialog = new Dialog(this);
      dialog.setTitle(R.string.osm_pick_file);
      dialog.setContentView(R.layout.filelist);
      ListView thelist = (ListView) dialog.findViewById(R.id.listViewFiles);

      thelist.setAdapter(
          new ArrayAdapter<String>(
              getApplicationContext(), android.R.layout.simple_list_item_single_choice, files));

      thelist.setOnItemClickListener(
          new OnItemClickListener() {

            public void onItemClick(AdapterView<?> av, View v, int index, long arg) {

              dialog.dismiss();
              String chosenFileName = files[index];

              if (chosenFileName.equalsIgnoreCase(goToOsmSettings)) {
                startActivity(OSMHelper.GetOsmSettingsIntent(getApplicationContext()));
              } else {
                OSMHelper osm = new OSMHelper(GpsMainActivity.this, GpsMainActivity.this);
                Utilities.ShowProgress(
                    GpsMainActivity.this,
                    getString(R.string.osm_uploading),
                    getString(R.string.please_wait));
                osm.UploadGpsTrace(chosenFileName);
              }
            }
          });
      dialog.show();
    } else {
      Utilities.MsgBox(getString(R.string.sorry), getString(R.string.no_files_found), this);
    }
  }