Fixed bugs in widget not using customExtras

pull/14/head
Sam Bosley 14 years ago
parent 9fd8cab63e
commit a2153ea237

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="67"
android:id="@+id/tasklist_fragment_container">
<fragment
android:name="com.todoroo.astrid.activity.TaskListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="tasklist_fragment">
<!-- Preview: layout=@layout/task_list_activity -->
</fragment>
</FrameLayout>
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="#000000"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="33"
android:id="@+id/taskedit_fragment_container">
<fragment
android:name="com.todoroo.astrid.activity.TaskEditFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="taskedit_fragment">
<!-- Preview: layout=@layout/task_edit_activity -->
</fragment>
</FrameLayout>
</LinearLayout>

@ -18,10 +18,7 @@ public class TaskEditActivity extends AstridActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
ThemeService.applyTheme(this); ThemeService.applyTheme(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (AndroidUtilities.isTabletSized(this)) setContentView(R.layout.task_edit_wrapper_activity);
setContentView(R.layout.task_edit_wrapper_activity_3pane);
else
setContentView(R.layout.task_edit_wrapper_activity);
ActionBar actionBar = getSupportActionBar(); ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true);

@ -402,8 +402,12 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
onTaskListItemClicked(id); onTaskListItemClicked(id);
} else { } else {
TaskListFragment tlf = getTaskListFragment(); TaskListFragment tlf = getTaskListFragment();
if (tlf != null) if (tlf != null) {
tlf.quickAddBar.quickAddTask("", true); //$NON-NLS-1$ System.err.println("Adding task");
Task result = tlf.quickAddBar.quickAddTask("", true); //$NON-NLS-1$
if (result != null)
onTaskListItemClicked(result.getId());
}
} }
getIntent().removeExtra(OPEN_TASK); getIntent().removeExtra(OPEN_TASK);
} }

@ -315,7 +315,7 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
// We have a menu item to show in action bar. // We have a menu item to show in action bar.
setHasOptionsMenu(true); setHasOptionsMenu(true);
System.err.println("Initializing fragment");
syncActionHelper = new SyncActionHelper(getActivity(), this); syncActionHelper = new SyncActionHelper(getActivity(), this);
setUpUiComponents(); setUpUiComponents();
initializeData(); initializeData();
@ -368,6 +368,7 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
protected void initializeData() { protected void initializeData() {
if (extras != null && extras.containsKey(TOKEN_FILTER)) { if (extras != null && extras.containsKey(TOKEN_FILTER)) {
filter = extras.getParcelable(TOKEN_FILTER); filter = extras.getParcelable(TOKEN_FILTER);
System.err.println("Filter on init: " + filter);
extras.remove(TOKEN_FILTER); // Otherwise writing this filter to parcel gives infinite recursion extras.remove(TOKEN_FILTER); // Otherwise writing this filter to parcel gives infinite recursion
} else { } else {
filter = CoreFilterExposer.buildInboxFilter(getResources()); filter = CoreFilterExposer.buildInboxFilter(getResources());

@ -285,6 +285,10 @@ public class QuickAddBar extends LinearLayout {
peopleControl.saveSharingSettings(null); peopleControl.saveSharingSettings(null);
} }
System.err.println("Fragment: " + fragment);
if (fragment != null)
System.err.println("Filter: " + fragment.getFilter());
TaskService.createWithValues(task, fragment.getFilter().valuesForNewTasks, title, TaskService.createWithValues(task, fragment.getFilter().valuesForNewTasks, title,
taskService, metadataService); taskService, metadataService);

@ -227,6 +227,10 @@ public class TasksWidget extends AppWidgetProvider {
} else { } else {
listIntent.setAction("L" + widgetId); listIntent.setAction("L" + widgetId);
} }
if (filter instanceof FilterWithCustomIntent) {
listIntent.putExtras(((FilterWithCustomIntent) filter).customExtras);
}
PendingIntent pListIntent = PendingIntent.getActivity(context, widgetId, PendingIntent pListIntent = PendingIntent.getActivity(context, widgetId,
listIntent, PendingIntent.FLAG_CANCEL_CURRENT); listIntent, PendingIntent.FLAG_CANCEL_CURRENT);
if (pListIntent != null) if (pListIntent != null)
@ -235,8 +239,10 @@ public class TasksWidget extends AppWidgetProvider {
Intent editIntent; Intent editIntent;
boolean tablet = AndroidUtilities.isTabletSized(context); boolean tablet = AndroidUtilities.isTabletSized(context);
if (tablet) if (tablet) {
editIntent = new Intent(context, TaskListActivity.class); editIntent = new Intent(context, TaskListActivity.class);
editIntent.putExtra(TaskListActivity.OPEN_TASK, 0L);
}
else else
editIntent = new Intent(context, TaskEditActivity.class); editIntent = new Intent(context, TaskEditActivity.class);
@ -244,11 +250,17 @@ public class TasksWidget extends AppWidgetProvider {
editIntent.putExtra(TaskEditFragment.OVERRIDE_FINISH_ANIM, false); editIntent.putExtra(TaskEditFragment.OVERRIDE_FINISH_ANIM, false);
if(filter != null) { if(filter != null) {
editIntent.putExtra(TaskListFragment.TOKEN_FILTER, filter); editIntent.putExtra(TaskListFragment.TOKEN_FILTER, filter);
if (filter.valuesForNewTasks != null && tablet) { if (tablet) {
String values = AndroidUtilities.contentValuesToSerializedString(filter.valuesForNewTasks); if (filter.valuesForNewTasks != null) {
values = PermaSql.replacePlaceholders(values); String values = AndroidUtilities.contentValuesToSerializedString(filter.valuesForNewTasks);
editIntent.putExtra(TaskEditFragment.TOKEN_VALUES, values); values = PermaSql.replacePlaceholders(values);
editIntent.setAction("E" + widgetId + values); editIntent.putExtra(TaskEditFragment.TOKEN_VALUES, values);
editIntent.setAction("E" + widgetId + values);
}
if (filter instanceof FilterWithCustomIntent) {
Bundle customExtras = ((FilterWithCustomIntent) filter).customExtras;
editIntent.putExtras(customExtras);
}
} }
} else { } else {
editIntent.setAction("E" + widgetId); editIntent.setAction("E" + widgetId);

Loading…
Cancel
Save