Exemplo n.º 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;
  }
Exemplo n.º 2
0
  private void UploadToDropBox() {
    Utilities.LogDebug("GpsMainActivity.UploadToDropBox");

    final DropBoxHelper dropBoxHelper = new DropBoxHelper(getApplicationContext(), this);

    if (!dropBoxHelper.IsLinked()) {
      startActivity(new Intent("com.mendhak.gpslogger.DROPBOX_SETUP"));
      return;
    }

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

    if (gpxFolder.exists()) {

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

      final Dialog dialog = new Dialog(this);
      dialog.setTitle(R.string.dropbox_upload);
      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];
              Utilities.ShowProgress(
                  GpsMainActivity.this,
                  getString(R.string.dropbox_uploading),
                  getString(R.string.please_wait));
              dropBoxHelper.UploadFile(chosenFileName);
            }
          });
      dialog.show();
    } else {
      Utilities.MsgBox(getString(R.string.sorry), getString(R.string.no_files_found), this);
    }
  }
  @Override
  protected void onResume() {
    super.onResume();

    try {
      if (helper.FinishAuthorization()) {
        startActivity(new Intent(getApplicationContext(), GpsMainActivity.class));
        finish();
      }
    } catch (Exception e) {
      Utilities.MsgBox(
          getString(R.string.error),
          getString(R.string.dropbox_couldnotauthorize),
          DropBoxAuthorizationActivity.this);
      tracer.error("DropBoxAuthorizationActivity.onResume", e);
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    addPreferencesFromResource(R.xml.dropboxsettings);

    Preference pref = findPreference("dropbox_resetauth");

    helper = new DropBoxHelper(getApplicationContext(), null);

    if (helper.IsLinked()) {
      pref.setTitle(R.string.dropbox_unauthorize);
      pref.setSummary(R.string.dropbox_unauthorize_description);
    } else {
      pref.setTitle(R.string.dropbox_authorize);
      pref.setSummary(R.string.dropbox_authorize_description);
    }

    pref.setOnPreferenceClickListener(
        new Preference.OnPreferenceClickListener() {
          @Override
          public boolean onPreferenceClick(Preference preference) {
            // This logs you out if you're logged in, or vice versa
            if (helper.IsLinked()) {
              helper.UnLink();
              startActivity(new Intent(getApplicationContext(), GpsMainActivity.class));
              finish();
            } else {
              try {
                helper.StartAuthentication(DropBoxAuthorizationActivity.this);
              } catch (Exception e) {
                tracer.error("DropBoxAuthorizationActivity.onPreferenceClick", e);
              }
            }

            return true;
          }
        });
  }