Convert comment bar to task edit control fragment

pull/384/head
Alex Baker 9 years ago
parent 9e83129915
commit a12aa40895

@ -57,8 +57,6 @@ public class GtasksTaskListUpdaterTest extends DatabaseTestCase {
public void disabled_testMetadataParentComputation() {
Task[] tasks = givenTasksABCDE();
whenCalculatingOrder();
thenExpectMetadataParent(tasks[0], null);
thenExpectMetadataParent(tasks[1], tasks[0]);
thenExpectMetadataParent(tasks[2], tasks[0]);
@ -69,8 +67,6 @@ public class GtasksTaskListUpdaterTest extends DatabaseTestCase {
public void disabled_testMetadataOrderComputation() {
Task[] tasks = givenTasksABCDE();
whenCalculatingOrder();
thenExpectMetadataIndentAndOrder(tasks[0], 0, 0);
thenExpectMetadataIndentAndOrder(tasks[1], 1, 1);
thenExpectMetadataIndentAndOrder(tasks[2], 2, 1);
@ -82,7 +78,6 @@ public class GtasksTaskListUpdaterTest extends DatabaseTestCase {
givenTasksABCDE();
Task newTask = createTask("F", VALUE_UNSET, 0);
whenCalculatingOrder();
thenExpectMetadataIndentAndOrder(newTask, 5, 0);
}
@ -149,12 +144,6 @@ public class GtasksTaskListUpdaterTest extends DatabaseTestCase {
}
}
private void whenCalculatingOrder() {
for(GtasksList list : gtasksListService.getLists())
gtasksTaskListUpdater.correctMetadataForList(list.getRemoteId());
}
/**
* A
* B

@ -273,7 +273,6 @@ public class GtasksTaskMovingTest extends DatabaseTestCase {
D = createTask("D", 3, 2);
E = createTask("E", 4, 0);
F = createTask("F", 5, 0);
gtasksTaskListUpdater.correctMetadataForList("1");
}
private Task createTask(String title, long order, int indent) {

@ -21,15 +21,16 @@ import android.widget.LinearLayout;
import com.google.common.base.Strings;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.UserActivity;
import org.json.JSONObject;
import org.tasks.R;
import org.tasks.activities.CameraActivity;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.injection.InjectingFragment;
import org.tasks.preferences.Device;
import org.tasks.preferences.Preferences;
import org.tasks.ui.TaskEditControlFragment;
import java.util.ArrayList;
import java.util.List;
@ -45,7 +46,9 @@ import butterknife.OnTextChanged;
import static org.tasks.files.FileHelper.getPathFromUri;
import static org.tasks.files.ImageHelper.sampleBitmap;
public class CommentBarFragment extends InjectingFragment {
public class CommentBarFragment extends TaskEditControlFragment {
public static final int TAG = R.string.TEA_ctrl_comments;
public interface CommentBarFragmentCallback {
void addComment(String message, String actionCode, String picture);
@ -56,7 +59,9 @@ public class CommentBarFragment extends InjectingFragment {
}
private static final int REQUEST_CODE_CAMERA = 60;
private static final String TOKEN_PICTURE_IN_PROGRESS = "picture_in_progress"; //$NON-NLS-1$
private static final String EXTRA_TEXT = "extra_text";
private static final String EXTRA_PICTURE = "extra_picture";
private final int cameraButton = R.drawable.ic_camera_alt_white_24dp;
@ -83,15 +88,16 @@ public class CommentBarFragment extends InjectingFragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_comment_bar, container, false);
View view = inflater.inflate(getLayout(), container, false);
ButterKnife.bind(this, view);
if (savedInstanceState != null) {
String uri = savedInstanceState.getString(TOKEN_PICTURE_IN_PROGRESS);
String uri = savedInstanceState.getString(EXTRA_PICTURE);
if (uri != null) {
pendingCommentPicture = Uri.parse(uri);
setPictureButtonToPendingPicture();
}
commentField.setText(savedInstanceState.getString(EXTRA_TEXT));
}
commentField.setHorizontallyScrolling(false);
@ -104,6 +110,31 @@ public class CommentBarFragment extends InjectingFragment {
return view;
}
@Override
protected int getLayout() {
return R.layout.fragment_comment_bar;
}
@Override
protected int getIcon() {
return 0;
}
@Override
public int controlId() {
return TAG;
}
@Override
public void initialize(boolean isNewTask, Task task) {
}
@Override
public void apply(Task task) {
}
@OnTextChanged(R.id.commentField)
void onTextChanged(CharSequence s) {
commentButton.setVisibility(pendingCommentPicture == null && Strings.isNullOrEmpty(s.toString())
@ -132,8 +163,9 @@ public class CommentBarFragment extends InjectingFragment {
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(EXTRA_TEXT, commentField.getText().toString());
if (pendingCommentPicture != null) {
outState.putString(TOKEN_PICTURE_IN_PROGRESS, pendingCommentPicture.toString());
outState.putString(EXTRA_PICTURE, pendingCommentPicture.toString());
}
}

@ -2,6 +2,7 @@ package org.tasks.fragments;
import android.app.Activity;
import android.app.FragmentManager;
import android.view.ContextMenu;
import com.todoroo.astrid.activity.BeastModePreferences;
import com.todoroo.astrid.data.Task;
@ -36,6 +37,8 @@ import timber.log.Timber;
public class TaskEditControlSetFragmentManager {
public static final int[] TASK_EDIT_CONTROL_FRAGMENT_ROWS = new int[] {
R.id.row_title,
R.id.comment_bar,
R.id.row_1,
R.id.row_2,
R.id.row_3,
@ -46,7 +49,6 @@ public class TaskEditControlSetFragmentManager {
R.id.row_8,
R.id.row_9,
R.id.row_10,
R.id.row_11,
};
private static final int[] TASK_EDIT_CONTROL_SET_FRAGMENTS = new int[] {
@ -60,7 +62,8 @@ public class TaskEditControlSetFragmentManager {
FilesControlSet.TAG,
TimerControlSet.TAG,
TagsControlSet.TAG,
RepeatControlSet.TAG
RepeatControlSet.TAG,
CommentBarFragment.TAG
};
static {
@ -78,6 +81,7 @@ public class TaskEditControlSetFragmentManager {
public TaskEditControlSetFragmentManager(Activity activity, Preferences preferences) {
displayOrder = BeastModePreferences.constructOrderedControlList(preferences, activity);
displayOrder.add(0, activity.getString(EditTitleControlSet.TAG));
displayOrder.add(1, activity.getString(CommentBarFragment.TAG));
fragmentManager = activity.getFragmentManager();
hideAlwaysTrigger = activity.getString(R.string.TEA_ctrl_hide_section_pref);
@ -149,6 +153,8 @@ public class TaskEditControlSetFragmentManager {
return new TagsControlSet();
case RepeatControlSet.TAG:
return new RepeatControlSet();
case CommentBarFragment.TAG:
return new CommentBarFragment();
default:
throw new RuntimeException("Unsupported fragment");
}

@ -26,6 +26,11 @@
android:gravity="center_horizontal"
android:orientation="vertical">
<FrameLayout
android:id="@+id/row_title"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@+id/row_1"
android:layout_width="match_parent"
@ -76,11 +81,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@+id/row_11"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/comments"
android:layout_width="match_parent"
@ -95,8 +95,7 @@
android:layout_height="1px"
android:background="?attr/asToolbarSeparator" />
<fragment
android:name="org.tasks.fragments.CommentBarFragment"
<FrameLayout
android:id="@+id/comment_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

@ -228,6 +228,7 @@
<string name="TEA_ctrl_hide_section_pref">TEA_ctrl_hide_section_pref</string>
<string name="TEA_ctrl_reminders_pref">TEA_ctrl_reminders_pref</string>
<string name="TEA_ctrl_timer_pref">TEA_ctrl_timer_pref</string>
<string name="TEA_ctrl_comments">TEA_ctrl_comments</string>
<string name="TEA_ctrl_gcal">TEA_ctrl_gcal</string>
<string name="sync_gtasks">sync_gtasks</string>
<string name="p_rmd_notif_actions_enabled">p_rmd_notif_actions_enabled</string>

Loading…
Cancel
Save