示例#1
0
 @Override
 protected void onPostExecute(Boolean result) {
   if (null != activity) {
     progress.dismiss();
     if (result) {
       ActivityMixin.showToast(
           activity,
           getName()
               + ' '
               + getString(R.string.export_exportedto)
               + ": "
               + exportFile.toString());
       if (Settings.getShareAfterExport()) {
         Intent shareIntent = new Intent();
         shareIntent.setAction(Intent.ACTION_SEND);
         shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(exportFile));
         shareIntent.setType("application/xml");
         activity.startActivity(
             Intent.createChooser(shareIntent, getString(R.string.export_gpx_to)));
       }
     } else {
       ActivityMixin.showToast(activity, getString(R.string.export_failed));
     }
   }
 }
    @Override
    protected void onPostExecuteInternal(Boolean result) {
      if (null != activity) {
        if (result) {
          //                    if (onlyNew) {
          //                        // update last export time in settings when doing it ourself
          // (currently we use the date check from gc.com)
          //                    }

          ActivityMixin.showToast(
              activity,
              getName()
                  + ' '
                  + getString(R.string.export_exportedto)
                  + ": "
                  + exportFile.toString());

          if (upload) {
            ActivityMixin.showToast(activity, getString(R.string.export_fieldnotes_upload_success));
          }
        } else {
          ActivityMixin.showToast(activity, getString(R.string.export_failed));
        }
      }
    }
 @Override
 public void goManual(View view) {
   if (id >= 0) {
     ActivityMixin.goManual(this, "c:geo-waypoint-edit");
   } else {
     ActivityMixin.goManual(this, "c:geo-waypoint-new");
   }
 }
  @Override
  public boolean invoke(
      final cgGeo geo,
      final Activity activity,
      final Resources res,
      final cgCache cache,
      final Long searchId,
      final cgWaypoint waypoint,
      final Double latitude,
      final Double longitude) {
    if (activity == null) {
      return false;
    }

    boolean navigationResult = false;
    if (latitude != null && longitude != null) {
      navigationResult = navigateToCoordinates(geo, activity, latitude, longitude);
    } else if (waypoint != null) {
      navigationResult =
          navigateToCoordinates(geo, activity, waypoint.latitude, waypoint.longitude);
    } else if (cache != null) {
      navigationResult = navigateToCoordinates(geo, activity, cache.latitude, cache.longitude);
    }

    if (!navigationResult) {
      if (res != null) {
        ActivityMixin.showToast(activity, res.getString(R.string.err_navigation_no));
      }
      return false;
    }

    return true;
  }
示例#5
0
 /**
  * Starts the default navigation tool if correctly set and installed or the compass app as default
  * fallback.
  */
 public static void startDefaultNavigationApplication(
     final int defaultNavigation, final Activity activity, final Waypoint waypoint) {
   if (waypoint == null || waypoint.getCoords() == null) {
     ActivityMixin.showToast(
         activity, CgeoApplication.getInstance().getString(R.string.err_location_unknown));
     return;
   }
   navigateWaypoint(activity, waypoint, getDefaultNavigationApplication(defaultNavigation));
 }
示例#6
0
  /**
   * Starts the default navigation tool if correctly set and installed or the compass app as default
   * fallback.
   */
  public static void startDefaultNavigationApplication(
      final int defaultNavigation, final Activity activity, final Geopoint destination) {
    if (destination == null) {
      ActivityMixin.showToast(
          activity, CgeoApplication.getInstance().getString(R.string.err_location_unknown));
      return;
    }

    navigateGeopoint(activity, destination, getDefaultNavigationApplication(defaultNavigation));
  }
示例#7
0
  /**
   * Starts the default navigation tool if correctly set and installed or the compass app as default
   * fallback.
   */
  public static void startDefaultNavigationApplication(
      final int defaultNavigation, final Activity activity, final Geocache cache) {
    if (cache == null || cache.getCoords() == null) {
      ActivityMixin.showToast(
          activity, CgeoApplication.getInstance().getString(R.string.err_location_unknown));
      return;
    }

    navigateCache(activity, cache, getDefaultNavigationApplication(defaultNavigation));
  }
 @Override
 public void onClick(final View view) {
   final Activity activity = AbstractCredentialsAuthorizationActivity.this;
   try {
     activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getCreateAccountUrl())));
   } catch (final ActivityNotFoundException e) {
     Log.e("Cannot find suitable activity", e);
     ActivityMixin.showToast(activity, R.string.err_application_no);
   }
 }
  private void checkCredentials(final String username, final String password) {
    final String nam = StringUtils.defaultString(username);
    final String pwd = StringUtils.defaultString(password);

    if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
      ActivityMixin.showToast(this, R.string.err_missing_auth);
      return;
    }

    final Credentials credentials = new Credentials(nam, pwd);
    final AbstractCredentialsAuthorizationActivity authorizationActivity = this;

    final ProgressDialog loginDialog =
        ProgressDialog.show(
            authorizationActivity,
            res.getString(R.string.init_login_popup),
            getAuthDialogWait(),
            true);
    loginDialog.setCancelable(false);

    AppObservable.bindActivity(
            authorizationActivity,
            Observable.defer(
                new Func0<Observable<StatusCode>>() {
                  @Override
                  public Observable<StatusCode> call() {
                    return Observable.just(checkCredentials(credentials));
                  }
                }))
        .subscribeOn(AndroidRxUtils.networkScheduler)
        .subscribe(
            new Action1<StatusCode>() {
              @Override
              public void call(StatusCode statusCode) {
                loginDialog.dismiss();
                if (statusCode == StatusCode.NO_ERROR) {
                  setCredentials(credentials);
                  showToast(getAuthDialogCompleted());
                  setResult(RESULT_OK);
                  finish();
                } else {
                  Dialogs.message(
                      authorizationActivity,
                      R.string.init_login_popup,
                      res.getString(
                          R.string.init_login_popup_failed_reason, statusCode.getErrorString(res)));
                  checkButton.setText(getAuthCheckAgain());
                  checkButton.setOnClickListener(new CheckListener());
                  checkButton.setEnabled(true);
                }
              }
            });
  }
示例#10
0
    @Override
    protected void onPostExecuteInternal(Boolean result) {
      if (null != activity) {
        if (result) {
          Settings.setFieldnoteExportDate(System.currentTimeMillis());

          ActivityMixin.showToast(
              activity,
              getName()
                  + ' '
                  + getString(R.string.export_exportedto)
                  + ": "
                  + exportFile.toString());

          if (upload) {
            ActivityMixin.showToast(activity, getString(R.string.export_fieldnotes_upload_success));
          }
        } else {
          ActivityMixin.showToast(activity, getString(R.string.export_failed));
        }
      }
    }
示例#11
0
  @Override
  public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    supportRequestWindowFeature(Window.FEATURE_NO_TITLE);

    this.setTheme(ActivityMixin.getDialogTheme());

    final Bundle extras = getIntent().getExtras();
    if (extras != null) {
      waypointId = extras.getInt(Intents.EXTRA_WAYPOINT_ID);
      geocode = extras.getString(Intents.EXTRA_GEOCODE);
    }
    showDialog();
  }
示例#12
0
  public CoordinatesInputDialog(
      final AbstractActivity context, final Geocache cache, final Geopoint gp, final IGeoData geo) {
    super(context, ActivityMixin.getDialogTheme());
    this.context = context;
    this.geo = geo;
    this.cache = cache;

    if (gp != null) {
      this.gp = gp;
    } else if (geo != null && geo.getCoords() != null) {
      this.gp = geo.getCoords();
    } else {
      this.gp = new Geopoint(0.0, 0.0);
    }
  }
 public final void showProgress(final boolean show) {
   ActivityMixin.showProgress(this, show);
 }
示例#14
0
 protected final void insertIntoLog(final String newText, final boolean moveCursor) {
   final EditText log = ButterKnife.findById(this, R.id.log);
   ActivityMixin.insertAtPosition(log, newText, moveCursor);
 }
 public void addVisitMenu(Menu menu, cgCache cache) {
   ActivityMixin.addVisitMenu(this, menu, cache);
 }
 public final void helpDialog(final String title, final String message, final Drawable icon) {
   ActivityMixin.helpDialog(this, title, message, icon);
 }
 public final void helpDialog(final String title, final String message) {
   ActivityMixin.helpDialog(this, title, message, null);
 }
 public final void showShortToast(String text) {
   ActivityMixin.showShortToast(this, text);
 }
 public final void setTheme() {
   ActivityMixin.setTheme(this);
 }
 public final void setTitle(final String title) {
   ActivityMixin.setTitle(this, title);
 }
 public void goManual(final View view) {
   ActivityMixin.goManual(this, helpTopic);
 }
 public final void goHome(final View view) {
   ActivityMixin.goHome(this);
 }