Example #1
0
  public static Spanned getUpdateComment(
      String actionCode,
      String user,
      String targetName,
      String message,
      String otherUser,
      String action,
      String linkColor,
      String fromView) {
    if (TextUtils.isEmpty(user)) {
      user = ContextManager.getString(R.string.ENA_no_user);
    }

    String userLink = linkify(user, linkColor);
    String targetNameLink = linkify(targetName, linkColor);
    String otherUserLink = linkify(otherUser, linkColor);

    int commentResource = 0;
    if (actionCode.equals(UPDATE_FRIENDS)) {
      commentResource = R.string.update_string_friends;
    } else if (actionCode.equals(UPDATE_REQUEST_FRIENDSHIP)) {
      commentResource = R.string.update_string_request_friendship;
    } else if (actionCode.equals(UPDATE_CONFIRMED_FRIENDSHIP)) {
      commentResource = R.string.update_string_confirmed_friendship;
    } else if (actionCode.equals(UPDATE_TASK_CREATED)) {
      if (fromView.equals(FROM_TAG_VIEW))
        commentResource = R.string.update_string_task_created_on_list;
      else commentResource = R.string.update_string_task_created;
    } else if (actionCode.equals(UPDATE_TASK_COMPLETED)) {
      commentResource = R.string.update_string_task_completed;
    } else if (actionCode.equals(UPDATE_TASK_UNCOMPLETED)) {
      commentResource = R.string.update_string_task_uncompleted;
    } else if (actionCode.equals(UPDATE_TASK_TAGGED) && !TextUtils.isEmpty(otherUser)) {
      if (fromView.equals(FROM_TAG_VIEW)) commentResource = R.string.update_string_task_tagged_list;
      else commentResource = R.string.update_string_task_tagged;
    } else if (actionCode.equals(UPDATE_TASK_ASSIGNED) && !TextUtils.isEmpty(otherUser)) {
      commentResource = R.string.update_string_task_assigned;
    } else if (actionCode.equals(UPDATE_TASK_COMMENT)) {
      if (fromView.equals(FROM_TASK_VIEW) || TextUtils.isEmpty(targetName))
        commentResource = R.string.update_string_default_comment;
      else commentResource = R.string.update_string_task_comment;
    } else if (actionCode.equals(UPDATE_TAG_COMMENT)) {
      if (fromView.equals(FROM_TAG_VIEW) || TextUtils.isEmpty(targetName))
        commentResource = R.string.update_string_default_comment;
      else commentResource = R.string.update_string_tag_comment;
    }

    if (commentResource == 0) {
      return Html.fromHtml(String.format("%s %s", userLink, action)); // $NON-NLS-1$
    }

    return Html.fromHtml(
        ContextManager.getString(
            commentResource, userLink, targetNameLink, message, otherUserLink));
  }
Example #2
0
  private void setupNotification() {
    try {
      NotificationCompat.Builder builder =
          new NotificationCompat.Builder(ContextManager.getContext());
      builder
          .setContentText(ContextManager.getString(R.string.actfm_sync_ongoing))
          .setContentTitle(ContextManager.getString(R.string.app_name))
          .setOngoing(true)
          .setSmallIcon(android.R.drawable.stat_notify_sync)
          .setContentIntent(
              PendingIntent.getActivity(
                  ContextManager.getContext().getApplicationContext(), 0, new Intent(), 0));

      notificationManager.notify(0, builder.getNotification());
      notificationId = 0;
    } catch (Exception e) {
      Log.e(ERROR_TAG, "Exception creating notification", e); // $NON-NLS-1$
    } catch (Error e) {
      Log.e(ERROR_TAG, "Error creating notification", e); // $NON-NLS-1$
    }
  }
 @Override
 public String getName() {
   return ContextManager.getString(R.string.gtasks_GPr_header);
 }