Beispiel #1
0
 public static CharSequence formatRoutingTime(
     Context context, int seconds, @DimenRes int unitsSize) {
   long minutes = TimeUnit.SECONDS.toMinutes(seconds) % 60;
   long hours = TimeUnit.SECONDS.toHours(seconds);
   String min = context.getString(R.string.minute);
   String hour = context.getString(R.string.hour);
   @DimenRes int textSize = R.dimen.text_size_routing_number;
   SpannableStringBuilder displayedH =
       Utils.formatUnitsText(context, textSize, unitsSize, String.valueOf(hours), hour);
   SpannableStringBuilder displayedM =
       Utils.formatUnitsText(context, textSize, unitsSize, String.valueOf(minutes), min);
   return hours == 0 ? displayedM : TextUtils.concat(displayedH + " ", displayedM);
 }
  protected void processAuth(@Size(2) String[] auth, OsmOAuth.AuthType type, String username) {
    if (auth == null) {
      if (mFragment.isAdded()) {
        new AlertDialog.Builder(mFragment.getActivity())
            .setTitle(R.string.editor_login_error_dialog)
            .setPositiveButton(android.R.string.ok, null)
            .show();

        Statistics.INSTANCE.trackEvent(
            Statistics.EventName.EDITOR_AUTH_REQUEST_RESULT,
            Statistics.params()
                .add(Statistics.EventParam.IS_SUCCESS, false)
                .add(Statistics.EventParam.TYPE, type.name));
      }
      return;
    }

    OsmOAuth.setAuthorization(auth[0], auth[1], username);
    if (mFragment.isAdded()) Utils.navigateToParent(mFragment.getActivity());
    Statistics.INSTANCE.trackEvent(
        Statistics.EventName.EDITOR_AUTH_REQUEST_RESULT,
        Statistics.params()
            .add(Statistics.EventParam.IS_SUCCESS, true)
            .add(Statistics.EventParam.TYPE, type.name));
  }
  private void updateVehicle(RoutingInfo info) {
    mDistanceTurn.setText(
        Utils.formatUnitsText(
            R.dimen.text_size_display_1, R.dimen.text_size_toolbar,
            info.distToTurn, info.turnUnits));
    info.vehicleTurnDirection.setTurnDrawable(mTurnDirection);
    if (RoutingInfo.VehicleTurnDirection.isRoundAbout(info.vehicleTurnDirection))
      UiUtils.setTextAndShow(mExitNumber, String.valueOf(info.exitNum));
    else UiUtils.hide(mExitNumber);

    if (info.vehicleNextTurnDirection.containsNextTurn()) {
      UiUtils.appearSlidingDown(mNextTurnFrame, null);
      info.vehicleNextTurnDirection.setNextTurnDrawable(mNextTurnImage);
    } else UiUtils.disappearSlidingUp(mNextTurnFrame, null);
  }
  public void update(RoutingInfo info) {
    if (info == null) return;

    if (Framework.nativeGetRouter() == Framework.ROUTER_TYPE_VEHICLE) updateVehicle(info);
    else updatePedestrian(info);

    mTimeTotal.setText(
        RoutingController.formatRoutingTime(
            info.totalTimeInSeconds, R.dimen.text_size_routing_dimension));
    mDistanceTotal.setText(
        Utils.formatUnitsText(
            R.dimen.text_size_routing_number, R.dimen.text_size_routing_dimension,
            info.distToTarget, info.targetUnits));
    mTimeArrival.setText(RoutingController.formatArrivalTime(info.totalTimeInSeconds));
    UiUtils.setTextAndHideIfEmpty(mNextStreet, info.nextStreet);
    mRouteProgress.setProgress((int) info.completionPercent);
  }
 private void updatePedestrian(RoutingInfo info) {
   Location next = info.pedestrianNextDirection;
   Location location = LocationHelper.INSTANCE.getLastLocation();
   DistanceAndAzimut da =
       Framework.nativeGetDistanceAndAzimutFromLatLon(
           next.getLatitude(),
           next.getLongitude(),
           location.getLatitude(),
           location.getLongitude(),
           mNorth);
   String[] splitDistance = da.getDistance().split(" ");
   mDistanceTurn.setText(
       Utils.formatUnitsText(
           R.dimen.text_size_display_1,
           R.dimen.text_size_toolbar,
           splitDistance[0],
           splitDistance[1]));
   if (info.pedestrianTurnDirection != null)
     info.pedestrianTurnDirection.setTurnDrawable(mTurnDirection, da);
 }
Beispiel #6
0
 public void onUpClick() {
   Utils.navigateToParent(mActivity);
 }
 protected void onUpClick() {
   Utils.navigateToParent(mActivity);
 }
Beispiel #8
0
  @Override
  public void onClick(View v) {
    try {
      switch (v.getId()) {
        case R.id.web:
          Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.WEB_SITE);
          AlohaHelper.logClick(AlohaHelper.Settings.WEB_SITE);

          startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.Url.WEB_SITE)));
          break;

        case R.id.blog:
          Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.WEB_BLOG);
          AlohaHelper.logClick(AlohaHelper.Settings.WEB_BLOG);

          startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.Url.WEB_BLOG)));
          break;

        case R.id.facebook:
          Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.FACEBOOK);
          AlohaHelper.logClick(AlohaHelper.Settings.FACEBOOK);

          Utils.showFacebookPage(getActivity());
          break;

        case R.id.twitter:
          Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.TWITTER);
          AlohaHelper.logClick(AlohaHelper.Settings.TWITTER);

          Utils.showTwitterPage(getActivity());
          break;

        case R.id.subscribe:
          Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.SUBSCRIBE);
          AlohaHelper.logClick(AlohaHelper.Settings.MAIL_SUBSCRIBE);

          startActivity(
              new Intent(Intent.ACTION_SENDTO)
                  .setData(
                      Utils.buildMailUri(
                          Constants.Email.SUBSCRIBE,
                          getString(R.string.subscribe_me_subject),
                          getString(R.string.subscribe_me_body))));
          break;

        case R.id.rate:
          Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.RATE);
          AlohaHelper.logClick(AlohaHelper.Settings.RATE);

          Utils.openAppInMarket(getActivity(), BuildConfig.REVIEW_URL);
          break;

        case R.id.share:
          Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.TELL_FRIEND);
          AlohaHelper.logClick(AlohaHelper.Settings.TELL_FRIEND);

          ShareOption.ANY.share(
              getActivity(), getString(R.string.tell_friends_text), R.string.tell_friends);
          break;

        case R.id.copyright:
          Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.COPYRIGHT);
          AlohaHelper.logClick(AlohaHelper.Settings.COPYRIGHT);

          ((SettingsActivity) getActivity())
              .switchToFragment(CopyrightFragment.class, R.string.copyright);
          break;
      }
    } catch (ActivityNotFoundException e) {
      AlohaHelper.logException(e);
    }
  }