diff --git a/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java b/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java index 3c4163e10..993467fb4 100755 --- a/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java +++ b/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java @@ -62,10 +62,11 @@ public final class TaskEditFragment extends InjectingFragment implements Toolbar void taskEditFinished(); } - public static TaskEditFragment newTaskEditFragment(boolean isNewTask, Task task) { + public static TaskEditFragment newTaskEditFragment(boolean isNewTask, Task task, int numFragments) { TaskEditFragment taskEditFragment = new TaskEditFragment(); taskEditFragment.isNewTask = isNewTask; taskEditFragment.model = task; + taskEditFragment.numFragments = numFragments; return taskEditFragment; } @@ -74,6 +75,7 @@ public final class TaskEditFragment extends InjectingFragment implements Toolbar private static final String EXTRA_TASK = "extra_task"; private static final String EXTRA_IS_NEW_TASK = "extra_is_new_task"; + private static final String EXTRA_NUM_FRAGMENTS = "extra_num_fragments"; @Inject TaskService taskService; @Inject UserActivityDao userActivityDao; @@ -88,12 +90,13 @@ public final class TaskEditFragment extends InjectingFragment implements Toolbar @BindView(R.id.toolbar) Toolbar toolbar; @BindView(R.id.comments) LinearLayout comments; + @BindView(R.id.control_sets) LinearLayout controlSets; // --- other instance variables /** true if editing started with a new task */ private boolean isNewTask = false; - + private int numFragments; /** task model */ Task model = null; @@ -119,6 +122,7 @@ public final class TaskEditFragment extends InjectingFragment implements Toolbar if (savedInstanceState != null) { model = savedInstanceState.getParcelable(EXTRA_TASK); isNewTask = savedInstanceState.getBoolean(EXTRA_IS_NEW_TASK); + numFragments = savedInstanceState.getInt(EXTRA_NUM_FRAGMENTS); } final boolean backButtonSavesTask = preferences.backButtonSavesTask(); @@ -148,8 +152,8 @@ public final class TaskEditFragment extends InjectingFragment implements Toolbar commentsController.initialize(model, comments); commentsController.reloadView(); - for (int i = 0 ; i < TaskEditControlSetFragmentManager.TASK_EDIT_CONTROL_FRAGMENT_ROWS.length - taskEditControlSetFragmentManager.getNumRows() ; i++) { - view.findViewById(TaskEditControlSetFragmentManager.TASK_EDIT_DIVIDER_ROWS[i]).setVisibility(View.GONE); + for (int i = numFragments - 2; i > 1 ; i--) { + controlSets.addView(inflater.inflate(R.layout.task_edit_row_divider, controlSets, false), i); } return view; @@ -303,6 +307,7 @@ public final class TaskEditFragment extends InjectingFragment implements Toolbar outState.putParcelable(EXTRA_TASK, model); outState.putBoolean(EXTRA_IS_NEW_TASK, isNewTask); + outState.putInt(EXTRA_NUM_FRAGMENTS, numFragments); } /* diff --git a/src/main/java/com/todoroo/astrid/activity/TaskListActivity.java b/src/main/java/com/todoroo/astrid/activity/TaskListActivity.java index 0d7c0893a..05fade935 100644 --- a/src/main/java/com/todoroo/astrid/activity/TaskListActivity.java +++ b/src/main/java/com/todoroo/astrid/activity/TaskListActivity.java @@ -305,10 +305,11 @@ public class TaskListActivity extends InjectingAppCompatActivity implements return; } boolean isNewTask = task.getTitle().length() == 0; + List controlFragments = taskEditControlSetFragmentManager.createNewFragments(isNewTask, task); loadTaskEditFragment( false, - newTaskEditFragment(isNewTask, task), - taskEditControlSetFragmentManager.createNewFragments(isNewTask, task)); + newTaskEditFragment(isNewTask, task, controlFragments.size()), + controlFragments); } @Override diff --git a/src/main/java/org/tasks/fragments/TaskEditControlSetFragmentManager.java b/src/main/java/org/tasks/fragments/TaskEditControlSetFragmentManager.java index 786c4d22a..7c4fbd462 100644 --- a/src/main/java/org/tasks/fragments/TaskEditControlSetFragmentManager.java +++ b/src/main/java/org/tasks/fragments/TaskEditControlSetFragmentManager.java @@ -51,19 +51,6 @@ public class TaskEditControlSetFragmentManager { R.id.row_10, }; - public static final int[] TASK_EDIT_DIVIDER_ROWS = new int[] { - R.id.row_divider_10, - R.id.row_divider_9, - R.id.row_divider_8, - R.id.row_divider_7, - R.id.row_divider_6, - R.id.row_divider_5, - R.id.row_divider_4, - R.id.row_divider_3, - R.id.row_divider_2, - R.id.row_divider_1 - }; - private static final int[] TASK_EDIT_CONTROL_SET_FRAGMENTS = new int[] { EditTitleControlSet.TAG, DeadlineControlSet.TAG, @@ -108,10 +95,6 @@ public class TaskEditControlSetFragmentManager { } } - public int getNumRows() { - return numRows; - } - public List createNewFragments(boolean isNewTask, Task task) { List taskEditControlFragments = new ArrayList<>(); for (int i = 0; i < numRows; i++) { diff --git a/src/main/res/layout/fragment_task_edit.xml b/src/main/res/layout/fragment_task_edit.xml index 118d72bff..915f0f9bc 100644 --- a/src/main/res/layout/fragment_task_edit.xml +++ b/src/main/res/layout/fragment_task_edit.xml @@ -20,6 +20,7 @@ android:overScrollMode="never"> - - - - - - - - - - - - - - - - - - - + +