예제 #1
0
  /** Create filter from new tag object */
  @SuppressWarnings("nls")
  public static FilterWithCustomIntent filterFromTag(
      Context context, Tag tag, Criterion criterion) {
    String listTitle = tag.tag + " (" + tag.count + ")";
    String title = context.getString(R.string.tag_FEx_name, tag.tag);
    QueryTemplate tagTemplate = tag.queryTemplate(criterion);
    ContentValues contentValues = new ContentValues();
    contentValues.put(Metadata.KEY.name, TagService.KEY);
    contentValues.put(TagService.TAG.name, tag.tag);

    FilterWithCustomIntent filter =
        new FilterWithCustomIntent(listTitle, title, tagTemplate, contentValues);
    if (tag.count == 0) filter.color = Color.GRAY;

    filter.contextMenuLabels =
        new String[] {
          context.getString(R.string.tag_cm_rename), context.getString(R.string.tag_cm_delete)
        };
    filter.contextMenuIntents =
        new Intent[] {
          newTagIntent(context, RenameTagActivity.class, tag),
          newTagIntent(context, DeleteTagActivity.class, tag)
        };
    filter.customTaskList = new ComponentName(ContextManager.getContext(), TagViewActivity.class);
    Bundle extras = new Bundle();
    extras.putString(TagViewActivity.EXTRA_TAG_NAME, tag.tag);
    extras.putLong(TagViewActivity.EXTRA_TAG_REMOTE_ID, tag.remoteId);
    filter.customExtras = extras;

    return filter;
  }