Change due date by clicking on date in task list

pull/996/head
Alex Baker 5 years ago
parent 05cf6b8b12
commit 58ecc7e9ab

@ -89,6 +89,8 @@ import org.tasks.data.CaldavCalendar;
import org.tasks.data.CaldavDao;
import org.tasks.data.Place;
import org.tasks.data.TagDataDao;
import org.tasks.data.TaskContainer;
import org.tasks.dialogs.DateTimePicker;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.dialogs.SortDialog;
import org.tasks.etesync.EteSyncCalendarSettingsActivity;
@ -128,9 +130,11 @@ public final class TaskListFragment extends InjectingFragment
private static final String EXTRA_FILTER = "extra_filter";
private static final String FRAG_TAG_REMOTE_LIST_PICKER = "frag_tag_remote_list_picker";
private static final String FRAG_TAG_SORT_DIALOG = "frag_tag_sort_dialog";
private static final String FRAG_TAG_DATE_TIME_PICKER = "frag_tag_date_time_picker";
private static final int REQUEST_LIST_SETTINGS = 10101;
private static final int REQUEST_MOVE_TASKS = 10103;
private static final int REQUEST_TAG_TASKS = 10106;
private static final int REQUEST_DUE_DATE = 10107;
private static final int SEARCH_DEBOUNCE_TIMEOUT = 300;
private final RefreshReceiver refreshReceiver = new RefreshReceiver();
@ -634,6 +638,15 @@ public final class TaskListFragment extends InjectingFragment
finishActionMode();
}
break;
case REQUEST_DUE_DATE:
if (resultCode == RESULT_OK) {
long taskId = data.getLongExtra(DateTimePicker.EXTRA_TASK, 0L);
Task task = taskDao.fetch(taskId);
long dueDate = data.getLongExtra(DateTimePicker.EXTRA_TIMESTAMP, 0L);
task.setDueDateAdjustingHideUntil(dueDate);
taskDao.save(task);
}
break;
default:
super.onActivityResult(requestCode, resultCode, data);
}
@ -756,6 +769,11 @@ public final class TaskListFragment extends InjectingFragment
}
}
public void showDateTimePicker(TaskContainer task) {
DateTimePicker.Companion.newDateTimePicker(this, REQUEST_DUE_DATE, task.getId(), task.getDueDate())
.show(getParentFragmentManager(), FRAG_TAG_DATE_TIME_PICKER);
}
public interface TaskListFragmentCallbackHandler {
void onTaskListItemClicked(Task task);

@ -2,19 +2,14 @@ package org.tasks.dialogs
import android.app.Activity
import android.app.Activity.RESULT_OK
import android.app.Dialog
import android.content.Intent
import android.os.Bundle
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.fragment.app.Fragment
import butterknife.ButterKnife
import butterknife.OnClick
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.todoroo.andlib.utility.AndroidUtilities
import com.todoroo.andlib.utility.AndroidUtilities.atLeastMarshmallow
import com.todoroo.andlib.utility.DateUtilities
@ -50,14 +45,16 @@ class DateTimePicker : InjectingBottomSheetDialogFragment() {
companion object {
const val EXTRA_TIMESTAMP = "extra_timestamp"
const val EXTRA_TASK = "extra_task"
private const val EXTRA_SELECTED = "extra_selected"
private const val REQUEST_TIME = 10101
private const val REQUEST_DATE = 10102
private const val FRAG_TAG_TIME_PICKER = "frag_tag_time_picker"
private const val FRAG_TAG_DATE_PICKER = "frag_tag_date_picker"
fun newDateTimePicker(target: Fragment, rc: Int, current: Long): DateTimePicker {
fun newDateTimePicker(target: Fragment, rc: Int, task: Long, current: Long): DateTimePicker {
val bundle = Bundle()
bundle.putLong(EXTRA_TASK, task)
bundle.putLong(EXTRA_TIMESTAMP, current)
val fragment = DateTimePicker()
fragment.arguments = bundle
@ -201,7 +198,10 @@ class DateTimePicker : InjectingBottomSheetDialogFragment() {
private fun returnDate(date: Long? = selected?.millis) {
selected = if (date == null || date <= 0) null else DateTime(date)
targetFragment?.onActivityResult(targetRequestCode, RESULT_OK, Intent().putExtra(EXTRA_TIMESTAMP, selected?.millis ?: 0))
val intent = Intent()
intent.putExtra(EXTRA_TIMESTAMP, selected?.millis ?: 0)
intent.putExtra(EXTRA_TASK, arguments?.getLong(EXTRA_TASK) ?: 0)
targetFragment?.onActivityResult(targetRequestCode, RESULT_OK, intent)
dismiss()
}

@ -1,20 +1,25 @@
package org.tasks.tasklist;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.ListUpdateCallback;
import androidx.recyclerview.widget.RecyclerView;
import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.adapter.TaskAdapter;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.dao.TaskDao;
import java.util.List;
import org.tasks.data.TaskContainer;
import org.tasks.dialogs.DateTimePicker;
import org.tasks.intents.TaskIntents;
import org.tasks.tasklist.ViewHolder.ViewHolderCallbacks;
import java.util.List;
public abstract class TaskListRecyclerAdapter extends RecyclerView.Adapter<ViewHolder>
implements ViewHolderCallbacks, ListUpdateCallback {
@ -89,6 +94,11 @@ public abstract class TaskListRecyclerAdapter extends RecyclerView.Adapter<ViewH
return true;
}
@Override
public void onChangeDueDate(TaskContainer task) {
taskList.showDateTimePicker(task);
}
protected abstract boolean dragAndDropEnabled();
@Override

@ -25,6 +25,7 @@ import com.todoroo.astrid.ui.CheckableImageView;
import java.util.List;
import org.tasks.R;
import org.tasks.data.TaskContainer;
import org.tasks.dialogs.DateTimePicker;
import org.tasks.dialogs.Linkify;
import org.tasks.locale.Locale;
import org.tasks.preferences.Preferences;
@ -121,8 +122,8 @@ public class ViewHolder extends RecyclerView.ViewHolder {
description.setEllipsize(null);
}
setTopPadding(rowPadding, nameView, completeBox);
setBottomPadding(rowPadding, completeBox);
setTopPadding(rowPadding, nameView, completeBox, dueDate);
setBottomPadding(rowPadding, completeBox, dueDate);
nameView.setTextSize(fontSize);
description.setTextSize(fontSize);
@ -308,6 +309,11 @@ public class ViewHolder extends RecyclerView.ViewHolder {
setupTitleAndCheckbox();
}
@OnClick(R.id.due_date)
void changeDueDate() {
callback.onChangeDueDate(task);
}
public int getIndent() {
return indent;
}
@ -345,5 +351,7 @@ public class ViewHolder extends RecyclerView.ViewHolder {
void toggleSubtasks(TaskContainer task, boolean collapsed);
boolean onLongPress(ViewHolder viewHolder);
void onChangeDueDate(TaskContainer task);
}
}

@ -75,7 +75,7 @@ public class DeadlineControlSet extends TaskEditControlFragment {
boolean showDateTimePicker() {
Fragment fragment = getParentFragmentManager().findFragmentByTag(FRAG_TAG_DATE_PICKER);
if (fragment == null) {
DateTimePicker.Companion.newDateTimePicker(this, REQUEST_DATE, getDueDateTime())
DateTimePicker.Companion.newDateTimePicker(this, REQUEST_DATE, 0, getDueDateTime())
.show(getParentFragmentManager(), FRAG_TAG_DATE_PICKER);
}
return true;

@ -23,6 +23,7 @@
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/title"
android:layout_alignParentEnd="true"
android:background="?attr/selectableItemBackgroundBorderless"
android:paddingStart="0dp"
android:paddingEnd="@dimen/keyline_first"
android:ellipsize="end"

Loading…
Cancel
Save