Esempio n. 1
0
  @Override
  public void onSortSelected(boolean always, int flags, int sort) {
    boolean manualSettingChanged =
        SortHelper.isManualSort(sortFlags) != SortHelper.isManualSort(flags);

    sortFlags = flags;
    sortSort = sort;

    if (always) {
      preferences.setSortFlags(flags);
      preferences.setSortMode(sort);
      TasksWidget.updateWidgets(context);
    }

    try {
      if (manualSettingChanged) {
        toggleDragDrop(SortHelper.isManualSort(sortFlags));
      } else {
        setUpTaskList();
      }
    } catch (IllegalStateException e) {
      log.error(e.getMessage(), e);
      // TODO: Fragment got detached somehow (rare)
    }
  }
Esempio n. 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    preferences.applyThemeAndStatusBarColor();

    setContentView(R.layout.custom_filter_activity);
    ButterKnife.inject(this);

    setSupportActionBar(toolbar);
    ActionBar supportActionBar = getSupportActionBar();
    if (supportActionBar != null) {
      supportActionBar.setDisplayHomeAsUpEnabled(true);
      supportActionBar.setHomeAsUpIndicator(R.drawable.ic_close_white_24dp);
      supportActionBar.setTitle(R.string.FLA_new_filter);
    }

    listView = (ListView) findViewById(android.R.id.list);

    database.openForReading();

    List<CriterionInstance> startingCriteria = new ArrayList<>();
    startingCriteria.add(getStartingUniverse());
    adapter = new CustomFilterAdapter(this, dialogBuilder, startingCriteria);
    listView.setAdapter(adapter);
    updateList();

    setUpListeners();
  }
Esempio n. 3
0
  protected void setUpUiComponents() {
    // set listener for quick-changing task priority
    getListView()
        .setOnKeyListener(
            new OnKeyListener() {
              @Override
              public boolean onKey(View view, int keyCode, KeyEvent event) {
                if (event.getAction() != KeyEvent.ACTION_UP || view == null) {
                  return false;
                }

                boolean filterOn = getListView().isTextFilterEnabled();
                View selected = getListView().getSelectedView();

                // hot-key to set task priority - 1-4 or ALT + Q-R
                if (!filterOn
                    && event.getUnicodeChar() >= '1'
                    && event.getUnicodeChar() <= '4'
                    && selected != null) {
                  int importance = event.getNumber() - '1';
                  Task task = ((ViewHolder) selected.getTag()).task;
                  task.setImportance(importance);
                  taskService.save(task);
                  taskAdapter.setFieldContentsAndVisibility(selected);
                }
                // filter
                else if (!filterOn && event.getUnicodeChar() != 0) {
                  getListView().setTextFilterEnabled(true);
                  getListView().setFilterText(Character.toString((char) event.getUnicodeChar()));
                }
                // turn off filter if nothing is selected
                else if (filterOn && TextUtils.isEmpty(getListView().getTextFilter())) {
                  getListView().setTextFilterEnabled(false);
                }

                return false;
              }
            });

    sortFlags = preferences.getSortFlags();
    sortSort = preferences.getSortMode();
    sortFlags = SortHelper.setManualSort(sortFlags, isDraggable());
  }
Esempio n. 4
0
  /** @see android.app.Activity#onCreate(Bundle) */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    preferences.applyThemeAndStatusBarColor();

    setContentView(R.layout.task_edit_wrapper_activity);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
      setSupportActionBar(toolbar);

      ActionBar actionBar = getSupportActionBar();
      actionBar.setDisplayHomeAsUpEnabled(true);
      actionBar.setDisplayShowTitleEnabled(false);
      toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
    }
  }
Esempio n. 5
0
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (quickAddBar.onActivityResult(requestCode, resultCode, data)) {
      return;
    }

    if (requestCode == ACTIVITY_SETTINGS) {
      if (resultCode == EditPreferences.RESULT_CODE_THEME_CHANGED
          || resultCode == EditPreferences.RESULT_CODE_PERFORMANCE_PREF_CHANGED) {
        getActivity().finish();
        getActivity().startActivity(getActivity().getIntent());
        TasksWidget.updateWidgets(getActivity());
        return;
      } else if (resultCode == GtasksPreferences.RESULT_CODE_SYNCHRONIZE) {
        preferences.setLong(
            SyncActionHelper.PREF_LAST_AUTO_SYNC, 0); // Forces autosync to occur after login
      }
    }

    super.onActivityResult(requestCode, resultCode, data);
  }
Esempio n. 6
0
 protected void initializeTaskListMetadata() {
   TagData td = getActiveTagData();
   String tdId;
   if (td == null) {
     String filterId = null;
     String prefId = null;
     if (isInbox) {
       filterId = TaskListMetadata.FILTER_ID_ALL;
       prefId = SubtasksUpdater.ACTIVE_TASKS_ORDER;
     } else if (isTodayFilter) {
       filterId = TaskListMetadata.FILTER_ID_TODAY;
       prefId = SubtasksUpdater.TODAY_TASKS_ORDER;
     }
     if (!TextUtils.isEmpty(filterId)) {
       taskListMetadata = taskListMetadataDao.fetchByTagId(filterId, TaskListMetadata.PROPERTIES);
       if (taskListMetadata == null) {
         String defaultOrder = preferences.getStringValue(prefId);
         if (TextUtils.isEmpty(defaultOrder)) {
           defaultOrder = "[]"; // $NON-NLS-1$
         }
         defaultOrder = SubtasksHelper.convertTreeToRemoteIds(taskService, defaultOrder);
         taskListMetadata = new TaskListMetadata();
         taskListMetadata.setFilter(filterId);
         taskListMetadata.setTaskIDs(defaultOrder);
         taskListMetadataDao.createNew(taskListMetadata);
       }
     }
   } else {
     tdId = td.getUuid();
     taskListMetadata =
         taskListMetadataDao.fetchByTagId(td.getUuid(), TaskListMetadata.PROPERTIES);
     if (taskListMetadata == null && !RemoteModel.isUuidEmpty(tdId)) {
       taskListMetadata = new TaskListMetadata();
       taskListMetadata.setTagUUID(tdId);
       taskListMetadataDao.createNew(taskListMetadata);
     }
   }
   postLoadTaskListMetadata();
 }