Skip to content

Commit

Permalink
Always replace task details fragments instead of updating them. #624
Browse files Browse the repository at this point in the history
Potential fix for the mysterious bugs on certain emulators.

Fix task list item selection highlight issue by changing the twopane flag from being a TaskListFragment extra to just being read from the bool resource.

Fix issue on small tablet, rotating to portrait not opening up task again.

Fix issue when deleting a task and rotating.

Fix the case when selected item is deleted by swiping it out in two pane mode.

Fix the case when previously select task was shown incorrectly.

Fix crash related to color when a new task is created with the editor.

Compare task uri in ViewTaskFragment.Callback#onTaskDeleted() as well just to be sure. Rename callback methods, move implementations next to each other.

Speculative fix for the crash when a task was deleted.
  • Loading branch information
Gabor Keszthelyi authored and dmfs committed Sep 26, 2018
1 parent 139fa2a commit de1ffe6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 3 additions & 1 deletion opentasks/src/main/java/org/dmfs/tasks/EditTaskFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public class EditTaskFragment extends SupportFragment implements LoaderManager.L
public static final String PREFERENCE_LAST_LIST = "pref_last_list_used_for_new_event";
public static final String PREFERENCE_LAST_ACCOUNT_TYPE = "pref_last_account_type_used_for_new_event";

public static final String KEY_NEW_TASK = "new_event";

/**
* A set of values that may affect the recurrence set of a task. If one of these values changes we have to submit all of them.
*/
Expand Down Expand Up @@ -784,7 +786,7 @@ public void saveAndExit()

mTaskUri = mValues.persist(activity);

activity.setResult(Activity.RESULT_OK, new Intent().setData(mTaskUri));
activity.setResult(Activity.RESULT_OK, new Intent().setData(mTaskUri).putExtra(KEY_NEW_TASK, isNewTask));
Toast.makeText(activity, R.string.activity_edit_task_task_saved, Toast.LENGTH_SHORT).show();
activity.finish();
if (isNewTask)
Expand Down
9 changes: 4 additions & 5 deletions opentasks/src/main/java/org/dmfs/tasks/TaskListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -489,18 +489,17 @@ private void updateTitle(int pageId)
private void resolveIntentAction(Intent intent)
{
// check which task should be selected
if (intent.hasExtra(EXTRA_DISPLAY_TASK))
if (intent.getBooleanExtra(EXTRA_DISPLAY_TASK, false))

{
mShouldSwitchToDetail = true;
mSelectedTaskUri = intent.getData();
}

if (intent != null && intent.hasExtra(EXTRA_DISPLAY_TASK) && intent.getBooleanExtra(EXTRA_FORCE_LIST_SELECTION, true) && mTwoPane)
if (intent.getBooleanExtra(EXTRA_DISPLAY_TASK, false) && intent.getBooleanExtra(EXTRA_FORCE_LIST_SELECTION, true) && mTwoPane)
{
mShouldSwitchToDetail = true;
Uri newSelection = intent.getData();
mSelectedTaskUriOnLaunch = newSelection;
mSelectedTaskUriOnLaunch = intent.getData();
mShouldSelectTaskListItem = true;
if (mPagerAdapter != null)
{
Expand All @@ -522,7 +521,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent intent)
{
// Use the same flow to display the new task as if it was opened from the widget
Intent displayIntent = new Intent(this, TaskListActivity.class);
displayIntent.putExtra(TaskListActivity.EXTRA_DISPLAY_TASK, true);
displayIntent.putExtra(TaskListActivity.EXTRA_DISPLAY_TASK, !intent.getBooleanExtra(EditTaskFragment.KEY_NEW_TASK, false));
displayIntent.putExtra(TaskListActivity.EXTRA_FORCE_LIST_SELECTION, true);
Uri newTaskUri = intent.getData();
displayIntent.setData(newTaskUri);
Expand Down

0 comments on commit de1ffe6

Please sign in to comment.