|
|
|
@ -8,11 +8,11 @@ package com.todoroo.astrid.activity;
|
|
|
|
import android.app.Activity;
|
|
|
|
import android.app.Activity;
|
|
|
|
import android.app.FragmentManager;
|
|
|
|
import android.app.FragmentManager;
|
|
|
|
import android.app.FragmentTransaction;
|
|
|
|
import android.app.FragmentTransaction;
|
|
|
|
|
|
|
|
import android.content.ContentValues;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.IntentFilter;
|
|
|
|
import android.content.IntentFilter;
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.support.design.widget.Snackbar;
|
|
|
|
|
|
|
|
import android.support.v4.graphics.drawable.DrawableCompat;
|
|
|
|
import android.support.v4.graphics.drawable.DrawableCompat;
|
|
|
|
import android.support.v4.view.MenuItemCompat;
|
|
|
|
import android.support.v4.view.MenuItemCompat;
|
|
|
|
import android.support.v4.widget.DrawerLayout;
|
|
|
|
import android.support.v4.widget.DrawerLayout;
|
|
|
|
@ -23,64 +23,101 @@ import android.view.KeyEvent;
|
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View;
|
|
|
|
|
|
|
|
import android.view.inputmethod.InputMethodManager;
|
|
|
|
|
|
|
|
|
|
|
|
import com.todoroo.andlib.data.Callback;
|
|
|
|
import com.todoroo.andlib.data.Callback;
|
|
|
|
import com.todoroo.andlib.sql.Criterion;
|
|
|
|
import com.todoroo.andlib.sql.Criterion;
|
|
|
|
import com.todoroo.andlib.sql.QueryTemplate;
|
|
|
|
import com.todoroo.andlib.sql.QueryTemplate;
|
|
|
|
import com.todoroo.andlib.utility.AndroidUtilities;
|
|
|
|
import com.todoroo.andlib.utility.AndroidUtilities;
|
|
|
|
|
|
|
|
import com.todoroo.andlib.utility.DateUtilities;
|
|
|
|
import com.todoroo.astrid.actfm.FilterSettingsActivity;
|
|
|
|
import com.todoroo.astrid.actfm.FilterSettingsActivity;
|
|
|
|
import com.todoroo.astrid.actfm.TagSettingsActivity;
|
|
|
|
import com.todoroo.astrid.actfm.TagSettingsActivity;
|
|
|
|
import com.todoroo.astrid.actfm.TagViewFragment;
|
|
|
|
import com.todoroo.astrid.actfm.TagViewFragment;
|
|
|
|
import com.todoroo.astrid.adapter.FilterAdapter;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.api.AstridApiConstants;
|
|
|
|
import com.todoroo.astrid.api.AstridApiConstants;
|
|
|
|
import com.todoroo.astrid.api.CustomFilter;
|
|
|
|
import com.todoroo.astrid.api.CustomFilter;
|
|
|
|
import com.todoroo.astrid.api.Filter;
|
|
|
|
import com.todoroo.astrid.api.Filter;
|
|
|
|
import com.todoroo.astrid.api.FilterListItem;
|
|
|
|
import com.todoroo.astrid.api.FilterListItem;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.api.FilterWithCustomIntent;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.api.PermaSql;
|
|
|
|
import com.todoroo.astrid.core.BuiltInFilterExposer;
|
|
|
|
import com.todoroo.astrid.core.BuiltInFilterExposer;
|
|
|
|
import com.todoroo.astrid.dao.TagDataDao;
|
|
|
|
import com.todoroo.astrid.dao.TagDataDao;
|
|
|
|
import com.todoroo.astrid.data.RemoteModel;
|
|
|
|
import com.todoroo.astrid.data.RemoteModel;
|
|
|
|
import com.todoroo.astrid.data.TagData;
|
|
|
|
import com.todoroo.astrid.data.TagData;
|
|
|
|
import com.todoroo.astrid.data.Task;
|
|
|
|
import com.todoroo.astrid.data.Task;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.files.FilesControlSet;
|
|
|
|
import com.todoroo.astrid.gtasks.GtasksListFragment;
|
|
|
|
import com.todoroo.astrid.gtasks.GtasksListFragment;
|
|
|
|
import com.todoroo.astrid.gtasks.GtasksPreferenceService;
|
|
|
|
import com.todoroo.astrid.repeats.RepeatControlSet;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.service.StartupService;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.service.TaskCreator;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.service.TaskService;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.service.UpgradeActivity;
|
|
|
|
import com.todoroo.astrid.subtasks.SubtasksHelper;
|
|
|
|
import com.todoroo.astrid.subtasks.SubtasksHelper;
|
|
|
|
import com.todoroo.astrid.subtasks.SubtasksListFragment;
|
|
|
|
import com.todoroo.astrid.subtasks.SubtasksListFragment;
|
|
|
|
import com.todoroo.astrid.subtasks.SubtasksTagListFragment;
|
|
|
|
import com.todoroo.astrid.subtasks.SubtasksTagListFragment;
|
|
|
|
import com.todoroo.astrid.tags.TagFilterExposer;
|
|
|
|
import com.todoroo.astrid.tags.TagFilterExposer;
|
|
|
|
import com.todoroo.astrid.utility.Flags;
|
|
|
|
import com.todoroo.astrid.tags.TagsControlSet;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.timers.TimerControlSet;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.ui.EditTitleControlSet;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.ui.HideUntilControlSet;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.ui.ReminderControlSet;
|
|
|
|
import com.todoroo.astrid.voice.VoiceInputAssistant;
|
|
|
|
import com.todoroo.astrid.voice.VoiceInputAssistant;
|
|
|
|
import com.todoroo.astrid.widget.TasksWidget;
|
|
|
|
import com.todoroo.astrid.widget.TasksWidget;
|
|
|
|
|
|
|
|
|
|
|
|
import org.tasks.R;
|
|
|
|
import org.tasks.R;
|
|
|
|
import org.tasks.activities.SortActivity;
|
|
|
|
import org.tasks.activities.SortActivity;
|
|
|
|
import org.tasks.analytics.Tracker;
|
|
|
|
import org.tasks.injection.InjectingAppCompatActivity;
|
|
|
|
import org.tasks.preferences.ActivityPreferences;
|
|
|
|
import org.tasks.preferences.ActivityPreferences;
|
|
|
|
import org.tasks.preferences.BasicPreferences;
|
|
|
|
|
|
|
|
import org.tasks.receivers.RepeatConfirmationReceiver;
|
|
|
|
import org.tasks.receivers.RepeatConfirmationReceiver;
|
|
|
|
|
|
|
|
import org.tasks.ui.CalendarControlSet;
|
|
|
|
|
|
|
|
import org.tasks.ui.DeadlineControlSet;
|
|
|
|
|
|
|
|
import org.tasks.ui.DescriptionControlSet;
|
|
|
|
import org.tasks.ui.MenuColorizer;
|
|
|
|
import org.tasks.ui.MenuColorizer;
|
|
|
|
import org.tasks.ui.NavigationDrawerFragment;
|
|
|
|
import org.tasks.ui.NavigationDrawerFragment;
|
|
|
|
|
|
|
|
import org.tasks.ui.PriorityControlSet;
|
|
|
|
|
|
|
|
import org.tasks.ui.TaskEditControlFragment;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.inject.Inject;
|
|
|
|
import javax.inject.Inject;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import butterknife.Bind;
|
|
|
|
|
|
|
|
import butterknife.ButterKnife;
|
|
|
|
import timber.log.Timber;
|
|
|
|
import timber.log.Timber;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.todoroo.astrid.activity.TaskEditFragment.newTaskEditFragment;
|
|
|
|
import static com.todoroo.astrid.voice.VoiceInputAssistant.voiceInputAvailable;
|
|
|
|
import static com.todoroo.astrid.voice.VoiceInputAssistant.voiceInputAvailable;
|
|
|
|
import static org.tasks.ui.NavigationDrawerFragment.OnFilterItemClickedListener;
|
|
|
|
import static org.tasks.ui.NavigationDrawerFragment.OnFilterItemClickedListener;
|
|
|
|
|
|
|
|
|
|
|
|
public class TaskListActivity extends AstridActivity implements OnFilterItemClickedListener {
|
|
|
|
public class TaskListActivity extends InjectingAppCompatActivity implements
|
|
|
|
|
|
|
|
OnFilterItemClickedListener,
|
|
|
|
|
|
|
|
TaskListFragment.OnTaskListItemClickedListener,
|
|
|
|
|
|
|
|
PriorityControlSet.OnPriorityChanged,
|
|
|
|
|
|
|
|
TimerControlSet.TimerControlSetCallback,
|
|
|
|
|
|
|
|
RepeatControlSet.RepeatChangedListener,
|
|
|
|
|
|
|
|
TaskEditFragment.TaskEditFragmentCallbackHandler {
|
|
|
|
|
|
|
|
|
|
|
|
@Inject TagDataDao tagDataDao;
|
|
|
|
@Inject TagDataDao tagDataDao;
|
|
|
|
@Inject ActivityPreferences preferences;
|
|
|
|
@Inject ActivityPreferences preferences;
|
|
|
|
@Inject GtasksPreferenceService gtasksPreferenceService;
|
|
|
|
|
|
|
|
@Inject VoiceInputAssistant voiceInputAssistant;
|
|
|
|
@Inject VoiceInputAssistant voiceInputAssistant;
|
|
|
|
@Inject Tracker tracker;
|
|
|
|
@Inject StartupService startupService;
|
|
|
|
|
|
|
|
@Inject SubtasksHelper subtasksHelper;
|
|
|
|
|
|
|
|
@Inject TaskService taskService;
|
|
|
|
|
|
|
|
@Inject TaskCreator taskCreator;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bind(R.id.toolbar) Toolbar toolbar;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static final int REQUEST_UPGRADE = 505;
|
|
|
|
private static final int REQUEST_EDIT_TAG = 11543;
|
|
|
|
private static final int REQUEST_EDIT_TAG = 11543;
|
|
|
|
private static final int REQUEST_EDIT_FILTER = 11544;
|
|
|
|
private static final int REQUEST_EDIT_FILTER = 11544;
|
|
|
|
private static final int REQUEST_SORT = 11545;
|
|
|
|
private static final int REQUEST_SORT = 11545;
|
|
|
|
|
|
|
|
|
|
|
|
private final RepeatConfirmationReceiver repeatConfirmationReceiver = new RepeatConfirmationReceiver(this);
|
|
|
|
private final RepeatConfirmationReceiver repeatConfirmationReceiver = new RepeatConfirmationReceiver(this);
|
|
|
|
|
|
|
|
private final Map<String, Integer> controlSetFragments = new HashMap<>();
|
|
|
|
private NavigationDrawerFragment navigationDrawer;
|
|
|
|
private NavigationDrawerFragment navigationDrawer;
|
|
|
|
|
|
|
|
private ArrayList<String> controlOrder;
|
|
|
|
|
|
|
|
|
|
|
|
public static final String TOKEN_SWITCH_TO_FILTER = "newListCreated"; //$NON-NLS-1$
|
|
|
|
public static final String TOKEN_SWITCH_TO_FILTER = "newListCreated"; //$NON-NLS-1$
|
|
|
|
|
|
|
|
|
|
|
|
@ -96,23 +133,24 @@ public class TaskListActivity extends AstridActivity implements OnFilterItemClic
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
startupService.onStartupApplication(this);
|
|
|
|
preferences.applyTheme();
|
|
|
|
preferences.applyTheme();
|
|
|
|
|
|
|
|
|
|
|
|
setContentView(R.layout.task_list_wrapper);
|
|
|
|
setContentView(R.layout.task_list_wrapper);
|
|
|
|
|
|
|
|
ButterKnife.bind(this);
|
|
|
|
|
|
|
|
|
|
|
|
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
|
|
|
|
|
|
|
setSupportActionBar(toolbar);
|
|
|
|
setSupportActionBar(toolbar);
|
|
|
|
ActionBar supportActionBar = getSupportActionBar();
|
|
|
|
updateToolbar(R.drawable.ic_menu_24dp, true);
|
|
|
|
if (supportActionBar != null) {
|
|
|
|
|
|
|
|
supportActionBar.setDisplayHomeAsUpEnabled(true);
|
|
|
|
|
|
|
|
Drawable drawable = DrawableCompat.wrap(getResources().getDrawable(R.drawable.ic_menu_24dp));
|
|
|
|
|
|
|
|
DrawableCompat.setTint(drawable, getResources().getColor(android.R.color.white));
|
|
|
|
|
|
|
|
toolbar.setNavigationIcon(drawable);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
|
|
|
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
|
|
TaskEditFragment taskEditFragment = getTaskEditFragment();
|
|
|
|
|
|
|
|
if (isDoublePaneLayout() || taskEditFragment == null) {
|
|
|
|
|
|
|
|
hideKeyboard();
|
|
|
|
navigationDrawer.openDrawer();
|
|
|
|
navigationDrawer.openDrawer();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
taskEditFragment.onBackPressed();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
@ -120,13 +158,20 @@ public class TaskListActivity extends AstridActivity implements OnFilterItemClic
|
|
|
|
DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
|
|
|
DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
|
|
|
navigationDrawer.setUp(drawerLayout);
|
|
|
|
navigationDrawer.setUp(drawerLayout);
|
|
|
|
|
|
|
|
|
|
|
|
View editFragment = findViewById(R.id.taskedit_fragment_container);
|
|
|
|
registerFragment(EditTitleControlSet.TAG);
|
|
|
|
|
|
|
|
registerFragment(DeadlineControlSet.TAG);
|
|
|
|
if(editFragment != null) {
|
|
|
|
registerFragment(CalendarControlSet.TAG);
|
|
|
|
fragmentLayout = LAYOUT_DOUBLE;
|
|
|
|
registerFragment(PriorityControlSet.TAG);
|
|
|
|
} else {
|
|
|
|
registerFragment(DescriptionControlSet.TAG);
|
|
|
|
fragmentLayout = LAYOUT_SINGLE;
|
|
|
|
registerFragment(HideUntilControlSet.TAG);
|
|
|
|
}
|
|
|
|
registerFragment(ReminderControlSet.TAG);
|
|
|
|
|
|
|
|
registerFragment(FilesControlSet.TAG);
|
|
|
|
|
|
|
|
registerFragment(TimerControlSet.TAG);
|
|
|
|
|
|
|
|
registerFragment(TagsControlSet.TAG);
|
|
|
|
|
|
|
|
registerFragment(RepeatControlSet.TAG);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
controlOrder = BeastModePreferences.constructOrderedControlList(preferences, this);
|
|
|
|
|
|
|
|
controlOrder.add(0, getString(EditTitleControlSet.TAG));
|
|
|
|
|
|
|
|
|
|
|
|
readIntent();
|
|
|
|
readIntent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -141,7 +186,8 @@ public class TaskListActivity extends AstridActivity implements OnFilterItemClic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void readIntent() {
|
|
|
|
private void readIntent() {
|
|
|
|
Bundle extras = getIntent().getExtras();
|
|
|
|
Intent intent = getIntent();
|
|
|
|
|
|
|
|
Bundle extras = intent.getExtras();
|
|
|
|
if (extras != null) {
|
|
|
|
if (extras != null) {
|
|
|
|
extras = (Bundle) extras.clone();
|
|
|
|
extras = (Bundle) extras.clone();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -150,15 +196,76 @@ public class TaskListActivity extends AstridActivity implements OnFilterItemClic
|
|
|
|
extras = new Bundle();
|
|
|
|
extras = new Bundle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Filter savedFilter = getIntent().getParcelableExtra(TaskListFragment.TOKEN_FILTER);
|
|
|
|
TaskListFragment taskListFragment;
|
|
|
|
if (savedFilter == null) {
|
|
|
|
if (intent.hasExtra(TaskListFragment.TOKEN_FILTER)) {
|
|
|
|
savedFilter = getDefaultFilter();
|
|
|
|
Filter filter = intent.getParcelableExtra(TaskListFragment.TOKEN_FILTER);
|
|
|
|
extras.putAll(configureIntentAndExtrasWithFilter(getIntent(), savedFilter));
|
|
|
|
extras.putAll(configureIntentAndExtrasWithFilter(intent, filter));
|
|
|
|
|
|
|
|
setListsTitle(filter.listingTitle);
|
|
|
|
|
|
|
|
taskListFragment = newTaskListFragment(filter, extras);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
taskListFragment = getTaskListFragment();
|
|
|
|
|
|
|
|
if (taskListFragment == null) {
|
|
|
|
|
|
|
|
Filter filter = getDefaultFilter();
|
|
|
|
|
|
|
|
extras.putAll(configureIntentAndExtrasWithFilter(intent, filter));
|
|
|
|
|
|
|
|
setListsTitle(filter.listingTitle);
|
|
|
|
|
|
|
|
taskListFragment = newTaskListFragment(filter, extras);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extras.putParcelable(TaskListFragment.TOKEN_FILTER, savedFilter);
|
|
|
|
TaskEditFragment taskEditFragment = getTaskEditFragment();
|
|
|
|
setupTasklistFragmentWithFilter(savedFilter, extras);
|
|
|
|
List<TaskEditControlFragment> taskEditControlFragments = new ArrayList<>();
|
|
|
|
setListsTitle(savedFilter.listingTitle);
|
|
|
|
if (taskEditFragment != null) {
|
|
|
|
|
|
|
|
for (int rowId : TaskEditFragment.rowIds) {
|
|
|
|
|
|
|
|
TaskEditControlFragment fragment = (TaskEditControlFragment) getFragmentManager().findFragmentById(rowId);
|
|
|
|
|
|
|
|
if (fragment == null) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
taskEditControlFragments.add(fragment);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loadTaskListFragment(true, taskListFragment);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (taskEditFragment != null) {
|
|
|
|
|
|
|
|
loadTaskEditFragment(true, taskEditFragment, taskEditControlFragments);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void loadTaskListFragment(boolean onCreate, TaskListFragment taskListFragment) {
|
|
|
|
|
|
|
|
FragmentManager fragmentManager = getFragmentManager();
|
|
|
|
|
|
|
|
if (onCreate) {
|
|
|
|
|
|
|
|
fragmentManager.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
|
|
|
|
.replace(isDoublePaneLayout() ? R.id.master_dual : R.id.single_pane, taskListFragment, TaskListFragment.TAG_TASKLIST_FRAGMENT)
|
|
|
|
|
|
|
|
.addToBackStack(TaskListFragment.TAG_TASKLIST_FRAGMENT)
|
|
|
|
|
|
|
|
.commit();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void loadTaskEditFragment(boolean onCreate, TaskEditFragment taskEditFragment, List<TaskEditControlFragment> taskEditControlFragments) {
|
|
|
|
|
|
|
|
if (isSinglePaneLayout()) {
|
|
|
|
|
|
|
|
updateToolbar(R.drawable.ic_arrow_back_24dp, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
FragmentManager fragmentManager = getFragmentManager();
|
|
|
|
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
|
|
|
|
.replace(isDoublePaneLayout() ? R.id.detail_dual : R.id.single_pane, taskEditFragment, TaskEditFragment.TAG_TASKEDIT_FRAGMENT)
|
|
|
|
|
|
|
|
.addToBackStack(TaskEditFragment.TAG_TASKEDIT_FRAGMENT)
|
|
|
|
|
|
|
|
.commit();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (onCreate) {
|
|
|
|
|
|
|
|
fragmentManager.executePendingTransactions();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
|
|
|
|
|
|
|
for (int i = 0 ; i < taskEditControlFragments.size() ; i++) {
|
|
|
|
|
|
|
|
TaskEditControlFragment taskEditControlFragment = taskEditControlFragments.get(i);
|
|
|
|
|
|
|
|
String tag = getString(taskEditControlFragment.controlId());
|
|
|
|
|
|
|
|
fragmentTransaction.replace(TaskEditFragment.rowIds[i], taskEditControlFragment, tag);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fragmentTransaction.addToBackStack(null);
|
|
|
|
|
|
|
|
fragmentTransaction.commit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public NavigationDrawerFragment getNavigationDrawerFragment() {
|
|
|
|
public NavigationDrawerFragment getNavigationDrawerFragment() {
|
|
|
|
@ -173,7 +280,6 @@ public class TaskListActivity extends AstridActivity implements OnFilterItemClic
|
|
|
|
registerReceiver(
|
|
|
|
registerReceiver(
|
|
|
|
repeatConfirmationReceiver,
|
|
|
|
repeatConfirmationReceiver,
|
|
|
|
new IntentFilter(AstridApiConstants.BROADCAST_EVENT_TASK_REPEATED));
|
|
|
|
new IntentFilter(AstridApiConstants.BROADCAST_EVENT_TASK_REPEATED));
|
|
|
|
getTaskListFragment().setSyncOngoing(gtasksPreferenceService.isOngoing());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@ -226,17 +332,17 @@ public class TaskListActivity extends AstridActivity implements OnFilterItemClic
|
|
|
|
Filter savedFilter = new Filter(title,
|
|
|
|
Filter savedFilter = new Filter(title,
|
|
|
|
new QueryTemplate().where
|
|
|
|
new QueryTemplate().where
|
|
|
|
(Criterion.or(Task.NOTES.
|
|
|
|
(Criterion.or(Task.NOTES.
|
|
|
|
like (
|
|
|
|
like(
|
|
|
|
"%" + //$NON-NLS-1$
|
|
|
|
"%" + //$NON-NLS-1$
|
|
|
|
query + "%"
|
|
|
|
query + "%"
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Task.TITLE.
|
|
|
|
Task.TITLE.
|
|
|
|
like (
|
|
|
|
like(
|
|
|
|
"%" + //$NON-NLS-1$
|
|
|
|
"%" + //$NON-NLS-1$
|
|
|
|
query + "%"
|
|
|
|
query + "%"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),null);
|
|
|
|
), null);
|
|
|
|
|
|
|
|
|
|
|
|
onFilterItemClicked(savedFilter);
|
|
|
|
onFilterItemClicked(savedFilter);
|
|
|
|
MenuItemCompat.collapseActionView(item);
|
|
|
|
MenuItemCompat.collapseActionView(item);
|
|
|
|
@ -256,11 +362,11 @@ public class TaskListActivity extends AstridActivity implements OnFilterItemClic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean onFilterItemClicked(FilterListItem item) {
|
|
|
|
public void onFilterItemClicked(FilterListItem item) {
|
|
|
|
TaskEditFragment.removeExtrasFromIntent(getIntent());
|
|
|
|
TaskEditFragment.removeExtrasFromIntent(getIntent());
|
|
|
|
TaskEditFragment tef = getTaskEditFragment();
|
|
|
|
TaskEditFragment tef = getTaskEditFragment();
|
|
|
|
if (tef != null) {
|
|
|
|
if (tef != null) {
|
|
|
|
onBackPressed();
|
|
|
|
getTaskEditFragment().onBackPressed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((item instanceof Filter)) {
|
|
|
|
if ((item instanceof Filter)) {
|
|
|
|
@ -273,73 +379,53 @@ public class TaskListActivity extends AstridActivity implements OnFilterItemClic
|
|
|
|
Filter filter = (Filter)item;
|
|
|
|
Filter filter = (Filter)item;
|
|
|
|
|
|
|
|
|
|
|
|
Bundle extras = configureIntentAndExtrasWithFilter(intent, filter);
|
|
|
|
Bundle extras = configureIntentAndExtrasWithFilter(intent, filter);
|
|
|
|
if (fragmentLayout == LAYOUT_DOUBLE && getTaskEditFragment() != null) {
|
|
|
|
TaskListFragment newFragment = newTaskListFragment(filter, extras);
|
|
|
|
onBackPressed(); // remove the task edit fragment when switching between lists
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
setupTasklistFragmentWithFilter(filter, extras);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// no animation for dualpane-layout
|
|
|
|
loadTaskListFragment(false, newFragment);
|
|
|
|
AndroidUtilities.callOverridePendingTransition(this, 0, 0);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setupTasklistFragmentWithFilter(Filter filter, Bundle extras) {
|
|
|
|
private TaskListFragment newTaskListFragment(Filter filter, Bundle extras) {
|
|
|
|
Class<?> customTaskList = null;
|
|
|
|
Class<?> customTaskList = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (subtasksHelper.shouldUseSubtasksFragmentForFilter(filter)) {
|
|
|
|
if (subtasksHelper.shouldUseSubtasksFragmentForFilter(filter)) {
|
|
|
|
customTaskList = SubtasksHelper.subtasksClassForFilter(filter);
|
|
|
|
customTaskList = SubtasksHelper.subtasksClassForFilter(filter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TaskListFragment newFragment = TaskListFragment.instantiateWithFilterAndExtras(filter, extras, customTaskList);
|
|
|
|
Class<?> component = customTaskList;
|
|
|
|
|
|
|
|
if (filter instanceof FilterWithCustomIntent && component == null) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
FragmentManager manager = getFragmentManager();
|
|
|
|
component = Class.forName(((FilterWithCustomIntent) filter).customTaskList.getClassName());
|
|
|
|
FragmentTransaction transaction = manager.beginTransaction();
|
|
|
|
|
|
|
|
transaction.replace(R.id.tasklist_fragment_container, newFragment, TaskListFragment.TAG_TASKLIST_FRAGMENT);
|
|
|
|
|
|
|
|
transaction.commit();
|
|
|
|
|
|
|
|
runOnUiThread(new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
getFragmentManager().executePendingTransactions();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
// Don't worry about it
|
|
|
|
// Invalid
|
|
|
|
Timber.e(e, e.getMessage());
|
|
|
|
Timber.e(e, e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (component == null) {
|
|
|
|
@Override
|
|
|
|
component = TaskListFragment.class;
|
|
|
|
public void setupActivityFragment(TagData tagData) {
|
|
|
|
|
|
|
|
super.setupActivityFragment(tagData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fragmentLayout == LAYOUT_DOUBLE) {
|
|
|
|
|
|
|
|
View container = findViewById(R.id.taskedit_fragment_container);
|
|
|
|
|
|
|
|
if (container != null) {
|
|
|
|
|
|
|
|
container.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TaskListFragment newFragment;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
newFragment = (TaskListFragment) component.newInstance();
|
|
|
|
|
|
|
|
} catch (InstantiationException | IllegalAccessException e) {
|
|
|
|
|
|
|
|
Timber.e(e, e.getMessage());
|
|
|
|
|
|
|
|
newFragment = new TaskListFragment();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
|
|
|
args.putBundle(TaskListFragment.TOKEN_EXTRAS, extras);
|
|
|
|
|
|
|
|
newFragment.setArguments(args);
|
|
|
|
|
|
|
|
return newFragment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onPostResume() {
|
|
|
|
protected void onPostResume() {
|
|
|
|
super.onPostResume();
|
|
|
|
super.onPostResume();
|
|
|
|
|
|
|
|
|
|
|
|
if (!Flags.checkAndClear(Flags.TLA_DISMISSED_FROM_TASK_EDIT)) {
|
|
|
|
|
|
|
|
TaskEditFragment tea = getTaskEditFragment();
|
|
|
|
|
|
|
|
if (tea != null) {
|
|
|
|
|
|
|
|
onBackPressed();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (getIntent().hasExtra(TOKEN_SWITCH_TO_FILTER)) {
|
|
|
|
if (getIntent().hasExtra(TOKEN_SWITCH_TO_FILTER)) {
|
|
|
|
Filter newList = getIntent().getParcelableExtra(TOKEN_SWITCH_TO_FILTER);
|
|
|
|
Filter newList = getIntent().getParcelableExtra(TOKEN_SWITCH_TO_FILTER);
|
|
|
|
getIntent().removeExtra(TOKEN_SWITCH_TO_FILTER);
|
|
|
|
getIntent().removeExtra(TOKEN_SWITCH_TO_FILTER);
|
|
|
|
onFilterItemClicked(newList);
|
|
|
|
onFilterItemClicked(newList);
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// navigationDrawer.restoreLastSelected();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (getIntent().hasExtra(OPEN_TASK)) {
|
|
|
|
if (getIntent().hasExtra(OPEN_TASK)) {
|
|
|
|
@ -349,33 +435,90 @@ public class TaskListActivity extends AstridActivity implements OnFilterItemClic
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
TaskListFragment tlf = getTaskListFragment();
|
|
|
|
TaskListFragment tlf = getTaskListFragment();
|
|
|
|
if (tlf != null) {
|
|
|
|
if (tlf != null) {
|
|
|
|
tlf.quickAddBar.quickAddTask(); //$NON-NLS-1$
|
|
|
|
Task task = tlf.quickAddBar.quickAddTask("");//$NON-NLS-1$
|
|
|
|
|
|
|
|
onTaskListItemClicked(task.getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fragmentLayout == LAYOUT_SINGLE) {
|
|
|
|
|
|
|
|
getIntent().removeExtra(OPEN_TASK);
|
|
|
|
getIntent().removeExtra(OPEN_TASK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (getIntent().getBooleanExtra(TOKEN_CREATE_NEW_LIST, false)) {
|
|
|
|
if (getIntent().getBooleanExtra(TOKEN_CREATE_NEW_LIST, false)) {
|
|
|
|
newListFromLaunch();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void newListFromLaunch() {
|
|
|
|
|
|
|
|
Intent thisIntent = getIntent();
|
|
|
|
Intent thisIntent = getIntent();
|
|
|
|
Intent newTagIntent = new Intent(this, TagSettingsActivity.class);
|
|
|
|
Intent newTagIntent = new Intent(this, TagSettingsActivity.class);
|
|
|
|
newTagIntent.putExtra(TagSettingsActivity.TOKEN_AUTOPOPULATE_NAME, thisIntent.getStringExtra(TOKEN_CREATE_NEW_LIST_NAME));
|
|
|
|
newTagIntent.putExtra(TagSettingsActivity.TOKEN_AUTOPOPULATE_NAME, thisIntent.getStringExtra(TOKEN_CREATE_NEW_LIST_NAME));
|
|
|
|
thisIntent.removeExtra(TOKEN_CREATE_NEW_LIST_NAME);
|
|
|
|
thisIntent.removeExtra(TOKEN_CREATE_NEW_LIST_NAME);
|
|
|
|
startActivityForResult(newTagIntent, NavigationDrawerFragment.REQUEST_NEW_LIST);
|
|
|
|
startActivityForResult(newTagIntent, NavigationDrawerFragment.REQUEST_NEW_LIST);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onTaskListItemClicked(long taskId) {
|
|
|
|
public void onTaskListItemClicked(long taskId) {
|
|
|
|
if (fragmentLayout != LAYOUT_SINGLE) {
|
|
|
|
TaskEditFragment taskEditFragment = getTaskEditFragment();
|
|
|
|
getIntent().putExtra(OPEN_TASK, taskId);
|
|
|
|
|
|
|
|
|
|
|
|
if (taskEditFragment != null) {
|
|
|
|
|
|
|
|
taskEditFragment.onBackPressed();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Task task = loadItem(taskId);
|
|
|
|
|
|
|
|
if (task == null) {
|
|
|
|
|
|
|
|
Timber.e(new NullPointerException(), "Failed to load task id %s", taskId);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean isNewTask = task.getTitle().length() == 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String hideAlwaysTrigger = getString(R.string.TEA_ctrl_hide_section_pref);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
taskEditFragment = newTaskEditFragment(isNewTask, task);
|
|
|
|
|
|
|
|
List<TaskEditControlFragment> taskEditControlFragments = new ArrayList<>();
|
|
|
|
|
|
|
|
for (int i = 0 ; i < controlOrder.size() ; i++) {
|
|
|
|
|
|
|
|
String item = controlOrder.get(i);
|
|
|
|
|
|
|
|
if (item.equals(hideAlwaysTrigger)) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Integer resId = controlSetFragments.get(item);
|
|
|
|
|
|
|
|
if (resId == null) {
|
|
|
|
|
|
|
|
Timber.e("Unknown task edit control %s", item);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TaskEditControlFragment fragment = createFragment(resId);
|
|
|
|
|
|
|
|
fragment.initialize(isNewTask, task);
|
|
|
|
|
|
|
|
taskEditControlFragments.add(fragment);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
loadTaskEditFragment(false, taskEditFragment, taskEditControlFragments);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void registerFragment(int resId) {
|
|
|
|
|
|
|
|
controlSetFragments.put(getString(resId), resId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private TaskEditControlFragment createFragment(int fragmentId) {
|
|
|
|
|
|
|
|
switch (fragmentId) {
|
|
|
|
|
|
|
|
case R.string.TEA_ctrl_title_pref:
|
|
|
|
|
|
|
|
return new EditTitleControlSet();
|
|
|
|
|
|
|
|
case R.string.TEA_ctrl_when_pref:
|
|
|
|
|
|
|
|
return new DeadlineControlSet();
|
|
|
|
|
|
|
|
case R.string.TEA_ctrl_importance_pref:
|
|
|
|
|
|
|
|
return new PriorityControlSet();
|
|
|
|
|
|
|
|
case R.string.TEA_ctrl_notes_pref:
|
|
|
|
|
|
|
|
return new DescriptionControlSet();
|
|
|
|
|
|
|
|
case R.string.TEA_ctrl_gcal:
|
|
|
|
|
|
|
|
return new CalendarControlSet();
|
|
|
|
|
|
|
|
case R.string.TEA_ctrl_hide_until_pref:
|
|
|
|
|
|
|
|
return new HideUntilControlSet();
|
|
|
|
|
|
|
|
case R.string.TEA_ctrl_reminders_pref:
|
|
|
|
|
|
|
|
return new ReminderControlSet();
|
|
|
|
|
|
|
|
case R.string.TEA_ctrl_files_pref:
|
|
|
|
|
|
|
|
return new FilesControlSet();
|
|
|
|
|
|
|
|
case R.string.TEA_ctrl_timer_pref:
|
|
|
|
|
|
|
|
return new TimerControlSet();
|
|
|
|
|
|
|
|
case R.string.TEA_ctrl_lists_pref:
|
|
|
|
|
|
|
|
return new TagsControlSet();
|
|
|
|
|
|
|
|
case R.string.TEA_ctrl_repeat_pref:
|
|
|
|
|
|
|
|
return new RepeatControlSet();
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
throw new RuntimeException("Unsupported fragment");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
super.onTaskListItemClicked(taskId);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setListsTitle(String title) {
|
|
|
|
public void setListsTitle(String title) {
|
|
|
|
@ -393,19 +536,16 @@ public class TaskListActivity extends AstridActivity implements OnFilterItemClic
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// manage task edit visibility
|
|
|
|
if (getTaskEditFragment() != null) {
|
|
|
|
View taskeditFragmentContainer = findViewById(R.id.taskedit_fragment_container);
|
|
|
|
getTaskEditFragment().onBackPressed();
|
|
|
|
if(taskeditFragmentContainer != null && taskeditFragmentContainer.getVisibility() == View.VISIBLE) {
|
|
|
|
return;
|
|
|
|
Flags.set(Flags.TLA_DISMISSED_FROM_TASK_EDIT);
|
|
|
|
|
|
|
|
onPostResume();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
super.onBackPressed();
|
|
|
|
|
|
|
|
|
|
|
|
if (isFinishing()) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
super.onBackPressed();
|
|
|
|
public void finish() {
|
|
|
|
|
|
|
|
super.finish();
|
|
|
|
|
|
|
|
AndroidUtilities.callOverridePendingTransition(this, R.anim.slide_right_in, R.anim.slide_right_out);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@ -413,7 +553,13 @@ public class TaskListActivity extends AstridActivity implements OnFilterItemClic
|
|
|
|
Callback<String> quickAddTask = new Callback<String>() {
|
|
|
|
Callback<String> quickAddTask = new Callback<String>() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void apply(String title) {
|
|
|
|
public void apply(String title) {
|
|
|
|
getTaskListFragment().quickAddBar.quickAddTask(title);
|
|
|
|
TaskListFragment taskListFragment = getTaskListFragment();
|
|
|
|
|
|
|
|
Task task = taskListFragment.quickAddBar.quickAddTask(title);
|
|
|
|
|
|
|
|
taskCreator.addToCalendar(task);
|
|
|
|
|
|
|
|
onTaskListItemClicked(task.getId());
|
|
|
|
|
|
|
|
taskListFragment.loadTaskListContent();
|
|
|
|
|
|
|
|
taskListFragment.selectCustomId(task.getId());
|
|
|
|
|
|
|
|
taskListFragment.onTaskCreated(task.getId(), task.getUUID());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (voiceInputAssistant.handleActivityResult(requestCode, resultCode, data, quickAddTask)) {
|
|
|
|
if (voiceInputAssistant.handleActivityResult(requestCode, resultCode, data, quickAddTask)) {
|
|
|
|
@ -434,23 +580,6 @@ public class TaskListActivity extends AstridActivity implements OnFilterItemClic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
navigationDrawer.refresh();
|
|
|
|
navigationDrawer.refresh();
|
|
|
|
} else if (requestCode == TaskListFragment.ACTIVITY_EDIT_TASK && resultCode != Activity.RESULT_CANCELED) {
|
|
|
|
|
|
|
|
// Handle switch to assigned filter when it comes from TaskEditActivity finishing
|
|
|
|
|
|
|
|
// For cases when we're in a multi-frame layout, the TaskEditFragment will notify us here directly
|
|
|
|
|
|
|
|
TaskListFragment tlf = getTaskListFragment();
|
|
|
|
|
|
|
|
if (tlf != null) {
|
|
|
|
|
|
|
|
if (data != null) {
|
|
|
|
|
|
|
|
if (data.getBooleanExtra(TaskEditFragment.TOKEN_TAGS_CHANGED, false)) {
|
|
|
|
|
|
|
|
tagsChanged(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
tlf.refresh();
|
|
|
|
|
|
|
|
if (data != null) {
|
|
|
|
|
|
|
|
tlf.onTaskCreated(
|
|
|
|
|
|
|
|
data.getLongExtra(TaskEditFragment.TOKEN_ID, 0L),
|
|
|
|
|
|
|
|
data.getStringExtra(TaskEditFragment.TOKEN_UUID));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (requestCode == REQUEST_EDIT_TAG) {
|
|
|
|
} else if (requestCode == REQUEST_EDIT_TAG) {
|
|
|
|
if (resultCode == RESULT_OK) {
|
|
|
|
if (resultCode == RESULT_OK) {
|
|
|
|
String action = data.getAction();
|
|
|
|
String action = data.getAction();
|
|
|
|
@ -509,10 +638,18 @@ public class TaskListActivity extends AstridActivity implements OnFilterItemClic
|
|
|
|
getTaskListFragment().setUpTaskList();
|
|
|
|
getTaskListFragment().setUpTaskList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (requestCode == REQUEST_UPGRADE) {
|
|
|
|
|
|
|
|
if (resultCode == RESULT_OK) {
|
|
|
|
|
|
|
|
if (data != null && data.getBooleanExtra(UpgradeActivity.EXTRA_RESTART, false)) {
|
|
|
|
|
|
|
|
Timber.w("Upgrade requires restart");
|
|
|
|
|
|
|
|
finish();
|
|
|
|
|
|
|
|
startActivity(getIntent());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void tagsChanged() {
|
|
|
|
protected void tagsChanged() {
|
|
|
|
tagsChanged(false);
|
|
|
|
tagsChanged(false);
|
|
|
|
@ -579,10 +716,130 @@ public class TaskListActivity extends AstridActivity implements OnFilterItemClic
|
|
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
|
|
|
TaskEditFragment tef = getTaskEditFragment();
|
|
|
|
TaskEditFragment tef = getTaskEditFragment();
|
|
|
|
if (tef != null && tef.onKeyDown(keyCode)) {
|
|
|
|
if (tef != null) {
|
|
|
|
|
|
|
|
tef.onBackPressed();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return super.onKeyDown(keyCode, event);
|
|
|
|
return super.onKeyDown(keyCode, event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TaskListFragment getTaskListFragment() {
|
|
|
|
|
|
|
|
return (TaskListFragment) getFragmentManager()
|
|
|
|
|
|
|
|
.findFragmentByTag(TaskListFragment.TAG_TASKLIST_FRAGMENT);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TaskEditFragment getTaskEditFragment() {
|
|
|
|
|
|
|
|
return (TaskEditFragment) getFragmentManager()
|
|
|
|
|
|
|
|
.findFragmentByTag(TaskEditFragment.TAG_TASKEDIT_FRAGMENT);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void updateToolbar(int drawableResId, boolean showTitle) {
|
|
|
|
|
|
|
|
ActionBar supportActionBar = getSupportActionBar();
|
|
|
|
|
|
|
|
if (supportActionBar != null) {
|
|
|
|
|
|
|
|
supportActionBar.setDisplayHomeAsUpEnabled(true);
|
|
|
|
|
|
|
|
supportActionBar.setDisplayShowTitleEnabled(showTitle);
|
|
|
|
|
|
|
|
Drawable drawable = DrawableCompat.wrap(getResources().getDrawable(drawableResId));
|
|
|
|
|
|
|
|
DrawableCompat.setTint(drawable, getResources().getColor(android.R.color.white));
|
|
|
|
|
|
|
|
supportActionBar.setHomeAsUpIndicator(drawable);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected Bundle configureIntentAndExtrasWithFilter(Intent intent, Filter filter) {
|
|
|
|
|
|
|
|
if(filter instanceof FilterWithCustomIntent) {
|
|
|
|
|
|
|
|
int lastSelectedList = intent.getIntExtra(NavigationDrawerFragment.TOKEN_LAST_SELECTED, 0);
|
|
|
|
|
|
|
|
intent = ((FilterWithCustomIntent)filter).getCustomIntent();
|
|
|
|
|
|
|
|
intent.putExtra(NavigationDrawerFragment.TOKEN_LAST_SELECTED, lastSelectedList);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
intent.putExtra(TaskListFragment.TOKEN_FILTER, filter);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setIntent(intent);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bundle extras = intent.getExtras();
|
|
|
|
|
|
|
|
if (extras != null) {
|
|
|
|
|
|
|
|
extras = (Bundle) extras.clone();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return extras;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Loads action item from the given intent
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private Task loadItem(long taskId) {
|
|
|
|
|
|
|
|
Task model = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (taskId> -1L) {
|
|
|
|
|
|
|
|
model = taskService.fetchById(taskId, Task.PROPERTIES);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// not found by id or was never passed an id
|
|
|
|
|
|
|
|
if (model == null) {
|
|
|
|
|
|
|
|
Intent intent = getIntent();
|
|
|
|
|
|
|
|
String valuesAsString = intent.getStringExtra(TaskEditFragment.TOKEN_VALUES);
|
|
|
|
|
|
|
|
ContentValues values = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (valuesAsString != null) {
|
|
|
|
|
|
|
|
valuesAsString = PermaSql.replacePlaceholders(valuesAsString);
|
|
|
|
|
|
|
|
values = AndroidUtilities.contentValuesFromSerializedString(valuesAsString);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
// oops, can't serialize
|
|
|
|
|
|
|
|
Timber.e(e, e.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
model = taskService.createWithValues(values, null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (model.getTitle().length() == 0) {
|
|
|
|
|
|
|
|
// set deletion date until task gets a title
|
|
|
|
|
|
|
|
model.setDeletionDate(DateUtilities.now());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return model;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onPriorityChange(int priority) {
|
|
|
|
|
|
|
|
getTaskEditFragment().onPriorityChange(priority);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void repeatChanged(boolean repeat) {
|
|
|
|
|
|
|
|
getTaskEditFragment().onRepeatChanged(repeat);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public Task stopTimer() {
|
|
|
|
|
|
|
|
return getTaskEditFragment().stopTimer();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public Task startTimer() {
|
|
|
|
|
|
|
|
return getTaskEditFragment().startTimer();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isSinglePaneLayout() {
|
|
|
|
|
|
|
|
return !isDoublePaneLayout();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isDoublePaneLayout() {
|
|
|
|
|
|
|
|
return getResources().getBoolean(R.bool.two_pane_layout);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void taskEditFinished() {
|
|
|
|
|
|
|
|
getFragmentManager().popBackStack(TaskEditFragment.TAG_TASKEDIT_FRAGMENT, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
|
|
|
|
|
|
|
if (isSinglePaneLayout()) {
|
|
|
|
|
|
|
|
updateToolbar(R.drawable.ic_menu_24dp, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
hideKeyboard();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void hideKeyboard() {
|
|
|
|
|
|
|
|
View view = getCurrentFocus();
|
|
|
|
|
|
|
|
if (view != null) {
|
|
|
|
|
|
|
|
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
|
|
|
|
|
|
|
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|