Fixed a bug with ShareLinkActivity not working with swipe between lists

pull/14/head
Sam Bosley 13 years ago
parent 8564e37b40
commit e5d30775a1

@ -10,6 +10,7 @@ import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.ui.QuickAddBar;
/** /**
* @author joshuagross * @author joshuagross
@ -44,21 +45,18 @@ public final class ShareLinkActivity extends TaskListActivity {
@Override @Override
protected void onPostResume() { protected void onPostResume() {
super.onPostResume(); super.onPostResume();
TaskListFragment tlf = getTaskListFragment();
if (tlf == null) {
return; // Uh ohs!
}
if (!handled) { if (!handled) {
Intent callerIntent = getIntent(); Intent callerIntent = getIntent();
Task task = tlf.quickAddBar.quickAddTask(subject, false); Task task = QuickAddBar.basicQuickAddTask(subject);
if (task != null) {
task.setValue(Task.NOTES, callerIntent.getStringExtra(Intent.EXTRA_TEXT)); task.setValue(Task.NOTES, callerIntent.getStringExtra(Intent.EXTRA_TEXT));
taskService.save(task); taskService.save(task);
handled = true; handled = true;
onTaskListItemClicked(task.getId()); onTaskListItemClicked(task.getId());
} }
} }
}
@Override @Override
protected void onSaveInstanceState(Bundle outState) { protected void onSaveInstanceState(Bundle outState) {

@ -23,6 +23,7 @@ import android.widget.TextView.OnEditorActionListener;
import com.timsu.astrid.R; import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService; import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.andlib.utility.DialogUtilities;
@ -35,6 +36,7 @@ import com.todoroo.astrid.activity.TaskEditFragment;
import com.todoroo.astrid.activity.TaskListActivity; import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.activity.TaskListFragment; import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.activity.TaskListFragment.OnTaskListItemClickedListener; import com.todoroo.astrid.activity.TaskListFragment.OnTaskListItemClickedListener;
import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.data.SyncFlags; import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.TagData;
@ -290,17 +292,7 @@ public class QuickAddBar extends LinearLayout {
resetControlSets(); resetControlSets();
boolean gcalCreateEventEnabled = Preferences.getStringValue(R.string.gcal_p_default) != null addToCalendar(task, title, taskService);
&& !Preferences.getStringValue(R.string.gcal_p_default).equals(
"-1");
if (!TextUtils.isEmpty(title) && gcalCreateEventEnabled && TextUtils.isEmpty(task.getValue(Task.CALENDAR_URI))) {
Uri calendarUri = GCalHelper.createTaskEvent(task,
activity.getContentResolver(), new ContentValues());
task.setValue(Task.CALENDAR_URI, calendarUri.toString());
task.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
task.putTransitory(SyncFlags.GTASKS_SUPPRESS_SYNC, true);
taskService.save(task);
}
if(!TextUtils.isEmpty(title)) if(!TextUtils.isEmpty(title))
fragment.showTaskEditHelpPopover(); fragment.showTaskEditHelpPopover();
@ -332,6 +324,40 @@ public class QuickAddBar extends LinearLayout {
} }
} }
private static void addToCalendar(Task task, String title, TaskService taskService) {
boolean gcalCreateEventEnabled = Preferences.getStringValue(R.string.gcal_p_default) != null
&& !Preferences.getStringValue(R.string.gcal_p_default).equals("-1"); //$NON-NLS-1$
if (!TextUtils.isEmpty(title) && gcalCreateEventEnabled && TextUtils.isEmpty(task.getValue(Task.CALENDAR_URI))) {
Uri calendarUri = GCalHelper.createTaskEvent(task,
ContextManager.getContext().getContentResolver(), new ContentValues());
task.setValue(Task.CALENDAR_URI, calendarUri.toString());
task.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
task.putTransitory(SyncFlags.GTASKS_SUPPRESS_SYNC, true);
taskService.save(task);
}
}
/**
* Static method to quickly add tasks without all the control set nonsense.
* Used from the share link activity.
* @param title
* @return
*/
public static Task basicQuickAddTask(String title) {
if (TextUtils.isEmpty(title))
return null;
TaskService taskService = PluginServices.getTaskService();
MetadataService metadataService = PluginServices.getMetadataService();
title = title.trim();
Task task = TaskService.createWithValues(null, title, taskService, metadataService);
addToCalendar(task, title, taskService);
return task;
}
private static void showAlertForMarkupTask(AstridActivity activity, Task task, String originalText) { private static void showAlertForMarkupTask(AstridActivity activity, Task task, String originalText) {
DateChangedAlerts.showQuickAddMarkupDialog(activity, task, originalText); DateChangedAlerts.showQuickAddMarkupDialog(activity, task, originalText);
} }

Loading…
Cancel
Save