Merge branch 'master' into lollipop

pull/253/head
Alex Baker 10 years ago
commit 7b36a10950

@ -58,7 +58,6 @@ import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.TaskAttachment;
import com.todoroo.astrid.data.TaskListMetadata;
import com.todoroo.astrid.gtasks.GtasksListFragment;
import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import com.todoroo.astrid.helper.SyncActionHelper;
import com.todoroo.astrid.service.SyncV2Service;
@ -66,6 +65,7 @@ import com.todoroo.astrid.service.TaskDeleter;
import com.todoroo.astrid.service.TaskDuplicator;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.subtasks.SubtasksHelper;
import com.todoroo.astrid.subtasks.SubtasksListFragment;
import com.todoroo.astrid.subtasks.SubtasksUpdater;
import com.todoroo.astrid.tags.TaskToTagMetadata;
import com.todoroo.astrid.timers.TimerPlugin;
@ -325,7 +325,7 @@ public class TaskListFragment extends InjectingListFragment implements OnSortSel
getListView().setItemsCanFocus(false);
}
if (!(this instanceof GtasksListFragment)) {
if (!(this instanceof SubtasksListFragment)) {
getListView().setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
@ -912,7 +912,7 @@ public class TaskListFragment extends InjectingListFragment implements OnSortSel
extras.putParcelable(TOKEN_FILTER, filter);
if(newState) {
((AstridActivity) getActivity()).setupTasklistFragmentWithFilterAndCustomTaskList(filter,
extras, GtasksListFragment.class);
extras, SubtasksListFragment.class);
} else {
filter.setFilterQueryOverride(null);
((AstridActivity)getActivity()).setupTasklistFragmentWithFilterAndCustomTaskList(filter,

@ -11,27 +11,22 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.adapter.TaskAdapter;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.dao.MetadataDao;
import com.todoroo.astrid.dao.StoreObjectDao;
import com.todoroo.astrid.dao.TaskAttachmentDao;
import com.todoroo.astrid.data.StoreObject;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.TaskListMetadata;
import com.todoroo.astrid.service.SyncV2Service;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.subtasks.AstridOrderedListFragmentHelper;
import com.todoroo.astrid.subtasks.OrderedListFragmentHelperInterface;
import com.todoroo.astrid.subtasks.SubtasksListFragment;
import org.tasks.R;
import org.tasks.injection.ForActivity;
@ -41,11 +36,7 @@ import org.tasks.sync.SyncThrottle;
import javax.inject.Inject;
public class GtasksListFragment extends TaskListFragment {
protected OrderedListFragmentHelperInterface<?> helper;
private int lastVisibleIndex = -1;
public class GtasksListFragment extends SubtasksListFragment {
public static final String TOKEN_STORE_ID = "storeId"; //$NON-NLS-1$
@ -72,6 +63,7 @@ public class GtasksListFragment extends TaskListFragment {
GtasksList.LAST_SYNC
};
@Override
protected OrderedListFragmentHelperInterface<?> createFragmentHelper() {
return new OrderedMetadataListFragmentHelper<>(preferences, taskAttachmentDao, taskService, metadataDao, this, gtasksTaskListUpdater);
}
@ -174,72 +166,4 @@ public class GtasksListFragment extends TaskListFragment {
public Property<?>[] taskProperties() {
return helper.taskProperties();
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
helper = createFragmentHelper();
}
@Override
protected View getListBody(ViewGroup root) {
return getActivity().getLayoutInflater().inflate(R.layout.task_list_body_subtasks, root, false);
}
@Override
protected void setUpUiComponents() {
super.setUpUiComponents();
helper.setUpUiComponents();
}
@Override
public void setUpTaskList() {
if (helper instanceof AstridOrderedListFragmentHelper) {
((AstridOrderedListFragmentHelper<TaskListMetadata>) helper).setList(taskListMetadata);
}
helper.beforeSetUpTaskList(filter);
super.setUpTaskList();
unregisterForContextMenu(getListView());
}
@Override
public void onPause() {
super.onPause();
lastVisibleIndex = getListView().getFirstVisiblePosition();
}
@Override
public void onResume() {
super.onResume();
if (lastVisibleIndex >=0) {
getListView().setSelection(lastVisibleIndex);
}
}
@Override
protected boolean isDraggable() {
return true;
}
@Override
public void onTaskCreated(Task task) {
super.onTaskCreated(task);
helper.onCreateTask(task);
}
@Override
protected TaskAdapter createTaskAdapter(TodorooCursor<Task> cursor) {
return helper.createTaskAdapter(cursor, sqlQueryTemplate);
}
@Override
protected void refresh() {
initializeTaskListMetadata();
setUpTaskList();
setSyncOngoing(false);
}
}

@ -18,7 +18,6 @@ import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.TaskListMetadata;
import com.todoroo.astrid.gtasks.GtasksListFragment;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.subtasks.AstridOrderedListUpdater.Node;
@ -48,7 +47,7 @@ public class SubtasksHelper {
if (SubtasksHelper.isTagFilter(filter)) {
return SubtasksTagListFragment.class;
}
return GtasksListFragment.class;
return SubtasksListFragment.class;
}
public static boolean isTagFilter(Filter filter) {

@ -0,0 +1,120 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.subtasks;
import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.adapter.TaskAdapter;
import com.todoroo.astrid.dao.TaskAttachmentDao;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.TaskListMetadata;
import com.todoroo.astrid.service.TaskService;
import org.tasks.R;
import org.tasks.preferences.ActivityPreferences;
import javax.inject.Inject;
/**
* Fragment for subtasks
*
* @author Tim Su <tim@astrid.com>
*
*/
public class SubtasksListFragment extends TaskListFragment {
protected OrderedListFragmentHelperInterface<?> helper;
private int lastVisibleIndex = -1;
@Inject TaskService taskService;
@Inject SubtasksFilterUpdater subtasksFilterUpdater;
@Inject TaskAttachmentDao taskAttachmentDao;
@Inject ActivityPreferences preferences;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
helper = createFragmentHelper();
}
protected OrderedListFragmentHelperInterface<?> createFragmentHelper() {
return new AstridOrderedListFragmentHelper<>(preferences, taskAttachmentDao, taskService, this, subtasksFilterUpdater);
}
@Override
protected View getListBody(ViewGroup root) {
return getActivity().getLayoutInflater().inflate(R.layout.task_list_body_subtasks, root, false);
}
@Override
protected void setUpUiComponents() {
super.setUpUiComponents();
helper.setUpUiComponents();
}
@Override
public void setUpTaskList() {
if (helper instanceof AstridOrderedListFragmentHelper) {
((AstridOrderedListFragmentHelper<TaskListMetadata>) helper).setList(taskListMetadata);
}
helper.beforeSetUpTaskList(filter);
super.setUpTaskList();
unregisterForContextMenu(getListView());
}
@Override
public void onPause() {
super.onPause();
lastVisibleIndex = getListView().getFirstVisiblePosition();
}
@Override
public void onResume() {
super.onResume();
if (lastVisibleIndex >=0) {
getListView().setSelection(lastVisibleIndex);
}
}
@Override
protected boolean isDraggable() {
return true;
}
@Override
public void onTaskCreated(Task task) {
super.onTaskCreated(task);
helper.onCreateTask(task);
}
@Override
protected void onTaskDelete(Task task) {
super.onTaskDelete(task);
helper.onDeleteTask(task);
}
@Override
protected TaskAdapter createTaskAdapter(TodorooCursor<Task> cursor) {
return helper.createTaskAdapter(cursor, sqlQueryTemplate);
}
@Override
protected void refresh() {
initializeTaskListMetadata();
setUpTaskList();
setSyncOngoing(false);
}
}

@ -12,6 +12,7 @@ import com.todoroo.astrid.core.CustomFilterExposer;
import com.todoroo.astrid.gtasks.GtasksFilterExposer;
import com.todoroo.astrid.gtasks.GtasksListFragment;
import com.todoroo.astrid.reminders.NotificationFragment;
import com.todoroo.astrid.subtasks.SubtasksListFragment;
import com.todoroo.astrid.subtasks.SubtasksTagListFragment;
import com.todoroo.astrid.tags.TagFilterExposer;
import com.todoroo.astrid.timers.TimerFilterExposer;
@ -29,6 +30,7 @@ import dagger.Provides;
TaskListFragment.class,
GtasksListFragment.class,
NotificationFragment.class,
SubtasksListFragment.class,
SubtasksTagListFragment.class,
TagViewFragment.class,
TaskEditFragment.class,

Loading…
Cancel
Save