예제 #1
0
  private Filter[] buildSavedFilters(Context context, Resources r) {
    int themeFlags = ThemeService.getFilterThemeFlags();

    StoreObjectDao dao = PluginServices.getStoreObjectDao();
    TodorooCursor<StoreObject> cursor =
        dao.query(
            Query.select(StoreObject.PROPERTIES)
                .where(StoreObject.TYPE.eq(SavedFilter.TYPE))
                .orderBy(Order.asc(SavedFilter.NAME)));
    try {
      ArrayList<Filter> list = new ArrayList<>();

      // stock filters
      if (Preferences.getBoolean(R.string.p_show_recently_modified_filter, true)) {
        Filter recent =
            new Filter(
                r.getString(R.string.BFE_Recent),
                r.getString(R.string.BFE_Recent),
                new QueryTemplate()
                    .where(TaskCriteria.ownedByMe())
                    .orderBy(Order.desc(Task.MODIFICATION_DATE))
                    .limit(15),
                null);
        recent.listingIcon =
            ((BitmapDrawable)
                    r.getDrawable(ThemeService.getDrawable(R.drawable.filter_pencil, themeFlags)))
                .getBitmap();

        list.add(recent);
      }

      if (cursor != null) {
        StoreObject savedFilter = new StoreObject();
        for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
          savedFilter.readFromCursor(cursor);
          Filter f = SavedFilter.load(savedFilter);

          Intent deleteIntent = new Intent(context, DeleteActivity.class);
          deleteIntent.putExtra(TOKEN_FILTER_ID, savedFilter.getId());
          deleteIntent.putExtra(TOKEN_FILTER_NAME, f.title);
          f.contextMenuLabels = new String[] {context.getString(R.string.BFE_Saved_delete)};
          f.contextMenuIntents = new Intent[] {deleteIntent};
          f.listingIcon =
              ((BitmapDrawable)
                      r.getDrawable(
                          ThemeService.getDrawable(R.drawable.filter_sliders, themeFlags)))
                  .getBitmap();
          list.add(f);
        }
      }

      return list.toArray(new Filter[list.size()]);
    } finally {
      if (cursor != null) {
        cursor.close();
      }
    }
  }
예제 #2
0
파일: TagDataDao.java 프로젝트: kflux/tasks
 public void tagDataOrderedByName(Callback<TagData> callback) {
   query(
       callback,
       Query.select(TagData.PROPERTIES)
           .where(Criterion.and(TagData.DELETION_DATE.eq(0), TagData.NAME.isNotNull()))
           .orderBy(Order.asc(Functions.upper(TagData.NAME))));
 }
예제 #3
0
 /**
  * Return alarms for the given task. PLEASE CLOSE THE CURSOR!
  *
  * @param taskId
  */
 public TodorooCursor<Metadata> getAlarms(long taskId) {
   return PluginServices.getMetadataService()
       .query(
           Query.select(Metadata.PROPERTIES)
               .where(MetadataCriteria.byTaskAndwithKey(taskId, AlarmFields.METADATA_KEY))
               .orderBy(Order.asc(AlarmFields.TIME)));
 }
예제 #4
0
파일: TagDataDao.java 프로젝트: kflux/tasks
 public void allTags(Callback<TagData> callback) {
   // TODO: does this need to be ordered?
   query(
       callback,
       Query.select(TagData.PROPERTIES)
           .where(TagData.DELETION_DATE.eq(0))
           .orderBy(Order.asc(TagData.ID)));
 }
예제 #5
0
  private void serializeTasks() throws IOException {
    TodorooCursor<Task> cursor;
    cursor = taskService.query(Query.select(Task.PROPERTIES).orderBy(Order.asc(Task.ID)));
    try {
      int length = cursor.getCount();
      for (int i = 0; i < length; i++) {
        cursor.moveToNext();
        Task task = new Task(cursor);

        setProgress(i, length);

        xml.startTag(null, BackupConstants.TASK_TAG);
        serializeModel(task, Task.PROPERTIES, Task.ID);
        serializeMetadata(task);
        xml.endTag(null, BackupConstants.TASK_TAG);
        this.exportCount++;
      }
    } finally {
      cursor.close();
    }
  }
예제 #6
0
  private Filter[] buildSavedFilters(Context context, Resources r) {
    int themeFlags = ThemeService.getFilterThemeFlags();

    boolean useCustomFilters = Preferences.getBoolean(R.string.p_use_filters, true);
    StoreObjectDao dao = PluginServices.getStoreObjectDao();
    TodorooCursor<StoreObject> cursor = null;
    if (useCustomFilters)
      cursor =
          dao.query(
              Query.select(StoreObject.PROPERTIES)
                  .where(StoreObject.TYPE.eq(SavedFilter.TYPE))
                  .orderBy(Order.asc(SavedFilter.NAME)));
    try {
      Filter[] list;
      if (useCustomFilters && cursor != null) list = new Filter[cursor.getCount() + 3];
      else list = new Filter[3];

      // stock filters
      list[0] = getTodayFilter(r);

      list[1] =
          new Filter(
              r.getString(R.string.BFE_Recent),
              r.getString(R.string.BFE_Recent),
              new QueryTemplate()
                  .where(TaskCriteria.ownedByMe())
                  .orderBy(Order.desc(Task.MODIFICATION_DATE))
                  .limit(15),
              null);
      list[1].listingIcon =
          ((BitmapDrawable)
                  r.getDrawable(ThemeService.getDrawable(R.drawable.filter_pencil, themeFlags)))
              .getBitmap();

      list[2] = getAssignedByMeFilter(r);

      if (useCustomFilters && cursor != null) {
        StoreObject savedFilter = new StoreObject();
        for (int i = 3; i < list.length; i++) {
          cursor.moveToNext();
          savedFilter.readFromCursor(cursor);
          list[i] = SavedFilter.load(savedFilter);

          Intent deleteIntent = new Intent(context, DeleteActivity.class);
          deleteIntent.putExtra(TOKEN_FILTER_ID, savedFilter.getId());
          deleteIntent.putExtra(TOKEN_FILTER_NAME, list[i].title);
          list[i].contextMenuLabels = new String[] {context.getString(R.string.BFE_Saved_delete)};
          list[i].contextMenuIntents = new Intent[] {deleteIntent};
          list[i].listingIcon =
              ((BitmapDrawable)
                      r.getDrawable(
                          ThemeService.getDrawable(R.drawable.filter_sliders, themeFlags)))
                  .getBitmap();
        }
      }

      return list;
    } finally {
      if (cursor != null) cursor.close();
    }
  }