示例#1
0
 /**
  * Build inbox filter
  *
  * @return
  */
 public static Filter buildInboxFilter(Resources r) {
   Filter inbox =
       new Filter(
           r.getString(R.string.BFE_Active),
           r.getString(R.string.BFE_Active),
           new QueryTemplate()
               .where(
                   Criterion.and(
                       TaskCriteria.activeVisibleMine(),
                       Criterion.not(
                           Task.ID.in(
                               Query.select(Metadata.TASK)
                                   .from(Metadata.TABLE)
                                   .where(
                                       Criterion.and(
                                           MetadataCriteria.withKey(TaskToTagMetadata.KEY),
                                           TaskToTagMetadata.TAG_NAME.like(
                                               "x_%", "x"))))))), // $NON-NLS-1$ //$NON-NLS-2$
           null);
   int themeFlags = ThemeService.getFilterThemeFlags();
   inbox.listingIcon =
       ((BitmapDrawable)
               r.getDrawable(ThemeService.getDrawable(R.drawable.filter_inbox, themeFlags)))
           .getBitmap();
   return inbox;
 }
 public static Filter getAssignedByMeFilter(Resources r) {
   int themeFlags = ThemeService.getFilterThemeFlags();
   Filter f =
       new Filter(
           r.getString(R.string.BFE_Assigned),
           r.getString(R.string.BFE_Assigned),
           new QueryTemplate()
               .join(
                   Join.left(
                       Metadata.TABLE,
                       Criterion.and(
                           Metadata.KEY.eq(TaskRabbitMetadata.METADATA_KEY),
                           Task.ID.eq(Metadata.TASK))))
               .where(
                   Criterion.and(
                       TaskCriteria.isActive(),
                       Criterion.or(
                           Task.CREATOR_ID.eq(0),
                           Task.CREATOR_ID.eq(ActFmPreferenceService.userId())),
                       Criterion.or(Task.USER_ID.neq(0), TaskRabbitMetadata.ID.gt(0)))),
           null);
   f.listingIcon =
       ((BitmapDrawable)
               r.getDrawable(ThemeService.getDrawable(R.drawable.filter_assigned, themeFlags)))
           .getBitmap();
   return f;
 }
示例#3
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();
      }
    }
  }
  protected void addMenuItems(Menu menu, Activity activity) {
    boolean isTablet = AstridPreferences.useTabletLayout(activity);
    TaskListActivity tla = null;
    if (activity instanceof TaskListActivity) {
      tla = (TaskListActivity) activity;
      tla.getMainMenuPopover().clear();
    }
    // --- sync
    if (tla == null || tla.getTaskEditFragment() == null)
      addSyncRefreshMenuItem(menu, isTablet ? ThemeService.FLAG_INVERT : 0);

    // --- sort
    if (allowResorting()) {
      addMenuItem(
          menu,
          R.string.TLA_menu_sort,
          ThemeService.getDrawable(
              R.drawable.icn_menu_sort_by_size, isTablet ? ThemeService.FLAG_FORCE_DARK : 0),
          MENU_SORT_ID,
          false);
    }

    // --- new filter
    if (Preferences.getBoolean(R.string.p_use_filters, true))
      addMenuItem(
          menu,
          R.string.FLA_new_filter,
          ThemeService.getDrawable(
              R.drawable.icn_menu_filters, isTablet ? ThemeService.FLAG_FORCE_DARK : 0),
          MENU_NEW_FILTER_ID,
          false);

    // --- addons
    if (Constants.MARKET_STRATEGY.showAddonMenu())
      addMenuItem(
          menu,
          R.string.TLA_menu_addons,
          ThemeService.getDrawable(
              R.drawable.icn_menu_plugins, isTablet ? ThemeService.FLAG_FORCE_DARK : 0),
          MENU_ADDONS_ID,
          false);

    // ask about plug-ins
    Intent queryIntent = new Intent(AstridApiConstants.ACTION_TASK_LIST_MENU);

    PackageManager pm = getActivity().getPackageManager();
    List<ResolveInfo> resolveInfoList = pm.queryIntentActivities(queryIntent, 0);
    int length = resolveInfoList.size();
    for (int i = 0; i < length; i++) {
      ResolveInfo resolveInfo = resolveInfoList.get(i);
      Intent intent = new Intent(AstridApiConstants.ACTION_TASK_LIST_MENU);
      intent.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name);
      addMenuItem(
          menu, resolveInfo.loadLabel(pm), resolveInfo.loadIcon(pm), intent, MENU_ADDON_INTENT_ID);
    }
  }
示例#5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    ThemeService.applyTheme(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tag_updates_activity);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);

    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setCustomView(R.layout.header_title_view);
    ((TextView) actionBar.getCustomView().findViewById(R.id.title))
        .setText(R.string.TAd_contextEditTask);

    Fragment fragment;
    String tag;
    if (getIntent().getExtras().containsKey(TaskCommentsFragment.EXTRA_TASK)) {
      fragment = new TaskCommentsFragment();
      tag = "taskupdates_fragment"; // $NON-NLS-1$
    } else {
      fragment = new TagCommentsFragment();
      tag = "tagupdates_fragment"; // $NON-NLS-1$
    }

    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.add(R.id.comments_fragment_container, fragment, tag);
    transaction.commit();
  }
示例#6
0
  private void setupSpeechBubble() {
    Resources r = getActivity().getResources();
    TextView snooze = (TextView) getView().findViewById(R.id.reminder_snooze);
    snooze.setBackgroundColor(r.getColor(ThemeService.getThemeColor()));
    TextView reminder = (TextView) getView().findViewById(R.id.reminder_message);
    if (taskAdapter.getCount() == 0) {
      snooze.setText(R.string.rmd_reengage_add_tasks);
      snooze.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              quickAddBar.performButtonClick();
            }
          });
    } else {
      snooze.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              getActivity().finish();
            }
          });
    }

    reminder.setText(extras.getString(EXTRA_TEXT));
  }
示例#7
0
 protected void addSyncRefreshMenuItem(Menu menu, int themeFlags) {
   addMenuItem(
       menu,
       R.string.TLA_menu_sync,
       ThemeService.getDrawable(R.drawable.icn_menu_refresh, themeFlags),
       MENU_SYNC_ID,
       true);
 }
示例#8
0
 @Override
 protected void addSyncRefreshMenuItem(Menu menu, int themeFlags) {
   if (gtasksPreferenceService.isLoggedIn()) {
     addMenuItem(
         menu,
         R.string.actfm_TVA_menu_refresh,
         ThemeService.getDrawable(R.drawable.icn_menu_refresh, themeFlags),
         MENU_REFRESH_ID,
         true);
   } else {
     super.addSyncRefreshMenuItem(menu, themeFlags);
   }
 }
 public static Filter getTodayFilter(Resources r) {
   int themeFlags = ThemeService.getFilterThemeFlags();
   String todayTitle = AndroidUtilities.capitalize(r.getString(R.string.today));
   ContentValues todayValues = new ContentValues();
   todayValues.put(Task.DUE_DATE.name, PermaSql.VALUE_NOON);
   Filter todayFilter =
       new Filter(
           todayTitle,
           todayTitle,
           new QueryTemplate()
               .where(
                   Criterion.and(
                       TaskCriteria.activeVisibleMine(),
                       Task.DUE_DATE.gt(0),
                       Task.DUE_DATE.lte(PermaSql.VALUE_EOD))),
           todayValues);
   todayFilter.listingIcon =
       ((BitmapDrawable)
               r.getDrawable(ThemeService.getDrawable(R.drawable.filter_calendar, themeFlags)))
           .getBitmap();
   return todayFilter;
 }
示例#10
0
  @Override
  public void onCreate(Bundle icicle) {
    ThemeService.applyTheme(this);
    ThemeService.setForceFilterInvert(true);
    super.onCreate(icicle);

    // Set the result to CANCELED.  This will cause the widget host to cancel
    // out of the widget placement if they press the back button.
    setResult(RESULT_CANCELED);

    // Set the view layout resource to use.
    setContentView(R.layout.widget_config_activity);

    setTitle(R.string.WCA_title);

    // Find the widget id from the intent.
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    if (extras != null) {
      mAppWidgetId =
          extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
    }

    // If they gave us an intent without the widget id, just bail.
    if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
      finish();
    }

    // set up ui
    adapter = new FilterAdapter(this, getListView(), R.layout.filter_adapter_row, true, true);
    adapter.filterStyle = R.style.TextAppearance_FLA_Filter_Widget;
    setListAdapter(adapter);

    Button button = (Button) findViewById(R.id.ok);
    button.setOnClickListener(mOnClickListener);

    StatisticsService.reportEvent(StatisticsConstants.WIDGET_CONFIG);
  }
  /** @see android.app.Activity#onCreate(Bundle) */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    ThemeService.applyTheme(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.task_edit_wrapper_activity);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);

    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setCustomView(R.layout.header_title_view);
    ((TextView) actionBar.getCustomView().findViewById(R.id.title))
        .setText(R.string.TAd_contextEditTask);
  }
  private void showSubtasksHelp() {
    String body =
        String.format(
            "<h3>%s</h3><img src='%s'>" + "<br>%s<br><br><br><img src='%s'><br>%s",
            getActivity().getString(R.string.subtasks_help_1),
            "subtasks_vertical.png",
            getActivity().getString(R.string.subtasks_help_2),
            "subtasks_horizontal.png",
            getActivity().getString(R.string.subtasks_help_3));

    String color = ThemeService.getDialogTextColorString();
    String html =
        String.format(
            "<html><body style='text-align:center;color:%s'>%s</body></html>", color, body);

    DialogUtilities.htmlDialog(getActivity(), html, R.string.subtasks_help_title);
    Preferences.setInt(AstridPreferences.P_SUBTASKS_HELP, 1);
  }
示例#13
0
  @Override
  protected void refreshDisplayView() {
    StringBuilder displayString = new StringBuilder();
    boolean isOverdue;
    if (initialized) {
      isOverdue = !dateAndTimePicker.isAfterNow();
      displayString.append(dateAndTimePicker.getDisplayString(activity, isQuickadd, isQuickadd));
    } else {
      isOverdue = model.getValue(Task.DUE_DATE) < DateUtilities.now();
      displayString.append(
          DateAndTimePicker.getDisplayString(
              activity, model.getValue(Task.DUE_DATE), isQuickadd, isQuickadd, false));
    }

    if (!isQuickadd && repeatControlSet != null) {
      String repeatString = repeatControlSet.getStringForExternalDisplay();
      if (!TextUtils.isEmpty(repeatString)) {
        displayString.append("\n"); // $NON-NLS-1$
        displayString.append(repeatString);
      }
    }
    TextView dateDisplay = (TextView) getDisplayView().findViewById(R.id.display_row_edit);
    if (TextUtils.isEmpty(displayString)) {
      dateDisplay.setText(R.string.TEA_deadline_hint);
      dateDisplay.setTextColor(unsetColor);
      image.setImageResource(R.drawable.tea_icn_date_gray);
    } else {
      dateDisplay.setText(displayString);
      if (isOverdue) {
        dateDisplay.setTextColor(activity.getResources().getColor(R.color.red_theme_color));
        image.setImageResource(R.drawable.tea_icn_date_red);
      } else {
        dateDisplay.setTextColor(themeColor);
        image.setImageResource(
            ThemeService.getTaskEditDrawable(
                R.drawable.tea_icn_date, R.drawable.tea_icn_date_lightblue));
      }
    }
  }
示例#14
0
  @Override
  protected void refreshDisplayView() {
    int reminderCount = 0;
    StringBuilder reminderString = new StringBuilder();

    // Has random reminder?
    if ((randomControlSet != null && randomControlSet.hasRandomReminder())
        || (randomControlSet == null && model.getValue(Task.REMINDER_PERIOD) > 0)) {
      reminderString.append(activity.getString(R.string.TEA_reminder_randomly_short));
      reminderCount++;
    }

    int value;
    if (initialized) {
      value = getValue();
    } else {
      value = model.getValue(Task.REMINDER_FLAGS);
    }

    boolean appendedWhen = false;
    if ((value & Task.NOTIFY_AT_DEADLINE) > 0) {
      if (reminderCount > 0) {
        reminderString.append(" & "); // $NON-NLS-1$
      }

      reminderString
          .append(activity.getString(R.string.TEA_reminder_when))
          .append(" "); // $NON-NLS-1$
      reminderString.append(activity.getString(R.string.TEA_reminder_due_short));
      reminderCount++;
      appendedWhen = true;
    }

    if ((value & Task.NOTIFY_AFTER_DEADLINE) > 0 && reminderCount < 2) {
      if (reminderCount > 0) {
        reminderString.append(" & "); // $NON-NLS-1$
      }

      if (!appendedWhen) {
        reminderString
            .append(activity.getString(R.string.TEA_reminder_when))
            .append(" "); // $NON-NLS-1$
      }
      reminderString.append(activity.getString(R.string.TEA_reminder_overdue_short));
      reminderCount++;
    }

    if (reminderCount > 0) {
      String toDisplay;
      if (reminderCount == 1) {
        toDisplay =
            activity.getString(R.string.TEA_reminder_display_one, reminderString.toString());
      } else {
        toDisplay =
            activity.getString(R.string.TEA_reminder_display_multiple, reminderString.toString());
      }

      label.setText(toDisplay);
      label.setTextColor(themeColor);
      image.setImageResource(
          ThemeService.getTaskEditDrawable(
              R.drawable.tea_icn_reminder, R.drawable.tea_icn_reminder_lightblue));
    } else {
      label.setText(R.string.TEA_reminders_group_label);
      label.setTextColor(unsetColor);
      image.setImageResource(R.drawable.tea_icn_reminder_gray);
    }
  }
示例#15
0
 @Override
 protected void onStop() {
   super.onStop();
   StatisticsService.sessionStop(this);
   ThemeService.setForceFilterInvert(false);
 }
  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();
    }
  }