mirror of
https://github.com/wismna/DoNext.git
synced 2025-10-03 15:40:14 -04:00
New categories in Settings
New type of task layout without description and with bigger title Old layout is now called Detailed Possibility to choose layout in Settings Task list delete confirmation checkbox "never ask again" implemented and present in Settings Divider between tasks Design changes (different colors on Swipe) Data validation on new task and new task list Correction of database open bug in Task List fragment
This commit is contained in:
@@ -8,8 +8,8 @@ android {
|
||||
applicationId "com.wismna.geoffroy.donext"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 23
|
||||
versionCode 3
|
||||
versionName "0.3"
|
||||
versionCode 5
|
||||
versionName "0.5"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
@@ -17,29 +17,41 @@ import java.util.List;
|
||||
/**
|
||||
* {@link RecyclerView.Adapter} that can display a {@link Task}.
|
||||
*/
|
||||
public class TaskRecyclerViewAdapter extends RecyclerView.Adapter<TaskRecyclerViewAdapter.ViewHolder> {
|
||||
public class TaskRecyclerViewAdapter extends RecyclerView.Adapter<TaskRecyclerViewAdapter.SimpleViewHolder> {
|
||||
|
||||
private final List<Task> mValues;
|
||||
private int viewType;
|
||||
|
||||
public TaskRecyclerViewAdapter(List<Task> items) {
|
||||
public TaskRecyclerViewAdapter(List<Task> items, int viewType) {
|
||||
mValues = items;
|
||||
this.viewType = viewType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.fragment_task, parent, false);
|
||||
|
||||
return new ViewHolder(view);
|
||||
public SimpleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view;
|
||||
switch (viewType)
|
||||
{
|
||||
case 1:
|
||||
view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.fragment_task_simple, parent, false);
|
||||
return new SimpleViewHolder(view);
|
||||
case 2:
|
||||
view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.fragment_task_detailed, parent, false);
|
||||
return new DetailedViewHolder(view);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final ViewHolder holder, int position) {
|
||||
public void onBindViewHolder(final SimpleViewHolder holder, int position) {
|
||||
holder.mItem = mValues.get(position);
|
||||
holder.mIdView.setText(String.valueOf(holder.mItem.getId()));
|
||||
holder.mCycleView.setText(String.valueOf(holder.mItem.getCycle()));
|
||||
holder.mTitleView.setText(holder.mItem.getName());
|
||||
holder.mDescriptionView.setText(holder.mItem.getDescription());
|
||||
if (holder instanceof DetailedViewHolder)
|
||||
((DetailedViewHolder)holder).mDescriptionView.setText(holder.mItem.getDescription());
|
||||
int priority = holder.mItem.getPriority();
|
||||
|
||||
// Reset task rendering
|
||||
@@ -67,6 +79,11 @@ public class TaskRecyclerViewAdapter extends RecyclerView.Adapter<TaskRecyclerVi
|
||||
return getItem(position).getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return viewType;
|
||||
}
|
||||
|
||||
public void add(Task item, int position) {
|
||||
mValues.add(position, item);
|
||||
notifyItemInserted(position);
|
||||
@@ -83,25 +100,47 @@ public class TaskRecyclerViewAdapter extends RecyclerView.Adapter<TaskRecyclerVi
|
||||
notifyItemChanged(position);
|
||||
}
|
||||
|
||||
public int getCycleCount() {
|
||||
int count = 0;
|
||||
for (Task task: mValues) {
|
||||
count += task.getCycle();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public Task getItem(int position) {
|
||||
return mValues.get(position);
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public class SimpleViewHolder extends RecyclerView.ViewHolder {
|
||||
public final View mView;
|
||||
public final TextView mIdView;
|
||||
public final TextView mCycleView;
|
||||
public final TextView mTitleView;
|
||||
public final TextView mDescriptionView;
|
||||
public Task mItem;
|
||||
|
||||
public ViewHolder(View view) {
|
||||
public SimpleViewHolder(View view) {
|
||||
super(view);
|
||||
mView = view;
|
||||
|
||||
mIdView = (TextView) view.findViewById(R.id.task_id);
|
||||
mCycleView = (TextView) view.findViewById(R.id.task_cycle);
|
||||
mTitleView = (TextView) view.findViewById(R.id.task_name);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " '" + mTitleView.getText() + "'";
|
||||
}
|
||||
}
|
||||
|
||||
public class DetailedViewHolder extends SimpleViewHolder {
|
||||
public final TextView mDescriptionView;
|
||||
|
||||
public DetailedViewHolder(View view) {
|
||||
super(view);
|
||||
mDescriptionView = (TextView) view.findViewById(R.id.task_description);
|
||||
}
|
||||
|
||||
|
@@ -48,7 +48,6 @@ public class TaskDataAccess {
|
||||
values.put(DatabaseHelper.TASKS_COLUMN_NAME, name);
|
||||
values.put(DatabaseHelper.TASKS_COLUMN_DESC, description);
|
||||
values.put(DatabaseHelper.TASKS_COLUMN_PRIORITY, priorities.indexOf(priority));
|
||||
//values.put(DatabaseHelper.TASKS_COLUMN_PRIORITY, priority);
|
||||
values.put(DatabaseHelper.TASKS_COLUMN_LIST, taskList);
|
||||
long insertId;
|
||||
if (id == 0)
|
||||
@@ -87,33 +86,6 @@ public class TaskDataAccess {
|
||||
return tasks;
|
||||
}
|
||||
|
||||
public int getTaskCount(long id) {
|
||||
int taskCount;
|
||||
Cursor cursor = database.rawQuery(
|
||||
"SELECT COUNT(*) " +
|
||||
" FROM " + DatabaseHelper.TASKS_TABLE_NAME +
|
||||
" WHERE " + DatabaseHelper.TASKS_COLUMN_LIST + " = " + id +
|
||||
" AND " + DatabaseHelper.TASKS_COLUMN_DONE + " = " + 0 +
|
||||
" AND " + DatabaseHelper.TASKS_COLUMN_DELETED + " = " + 0, null);
|
||||
cursor.moveToFirst();
|
||||
taskCount = cursor.getInt(0);
|
||||
cursor.close();
|
||||
return taskCount;
|
||||
}
|
||||
public int getTotalCycles(long id) {
|
||||
int totalCycles;
|
||||
Cursor cursor = database.rawQuery(
|
||||
"SELECT SUM(" + DatabaseHelper.TASKS_COLUMN_CYCLE + ") " +
|
||||
" FROM " + DatabaseHelper.TASKS_TABLE_NAME +
|
||||
" WHERE " + DatabaseHelper.TASKS_COLUMN_LIST + " = " + id +
|
||||
" AND " + DatabaseHelper.TASKS_COLUMN_DONE + " = " + 0 +
|
||||
" AND " + DatabaseHelper.TASKS_COLUMN_DELETED + " = " + 0, null);
|
||||
cursor.moveToFirst();
|
||||
totalCycles = cursor.getInt(0);
|
||||
cursor.close();
|
||||
return totalCycles;
|
||||
}
|
||||
|
||||
public Cursor getAllTasksCursor(long id) {
|
||||
return database.query(DatabaseHelper.TASKS_TABLE_NAME, taskColumns,
|
||||
DatabaseHelper.TASKS_COLUMN_LIST + " = " + id +
|
||||
|
@@ -87,8 +87,6 @@ public class TaskListDataAccess {
|
||||
}
|
||||
|
||||
public Cursor getAllTaskListsCursor() {
|
||||
//return database.query(DatabaseHelper.TASKLIST_TABLE_NAME,
|
||||
// taskListColumns, null, null, null, null, null);
|
||||
return database.rawQuery("SELECT *," +
|
||||
" (SELECT COUNT(*) " +
|
||||
" FROM " + DatabaseHelper.TASKS_TABLE_NAME +
|
||||
|
@@ -9,6 +9,7 @@ import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.Spinner;
|
||||
@@ -59,19 +60,13 @@ public class TaskDialogFragment extends DialogFragment {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
// Get the layout inflater
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.fragment_task_details, null);
|
||||
View view = inflater.inflate(R.layout.fragment_task_form, null);
|
||||
|
||||
// Inflate and set the layout for the dialog
|
||||
// Pass null as the parent view because its going in the dialog layout
|
||||
builder.setView(view)
|
||||
// Add action buttons
|
||||
.setPositiveButton(R.string.new_task_save, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
// Send the positive button event back to the host activity
|
||||
mListener.onNewTaskDialogPositiveClick(TaskDialogFragment.this);
|
||||
}
|
||||
})
|
||||
.setPositiveButton(R.string.new_task_save, null)
|
||||
.setNegativeButton(R.string.new_task_cancel, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
// Send the negative button event back to the host activity
|
||||
@@ -123,4 +118,31 @@ public class TaskDialogFragment extends DialogFragment {
|
||||
}
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
final AlertDialog d = (AlertDialog) getDialog();
|
||||
if(d != null)
|
||||
{
|
||||
Button positiveButton = d.getButton(Dialog.BUTTON_POSITIVE);
|
||||
positiveButton.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
EditText titleText = (EditText) d.findViewById(R.id.new_task_name);
|
||||
if (titleText.getText().toString().matches(""))
|
||||
titleText.setError(getResources().getString(R.string.new_task_name_error));
|
||||
else
|
||||
{
|
||||
// Send the positive button event back to the host activity
|
||||
mListener.onNewTaskDialogPositiveClick(TaskDialogFragment.this);
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
@@ -47,6 +48,7 @@ public class TaskListsFragment extends Fragment implements
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
taskListDataAccess = new TaskListDataAccess(getContext());
|
||||
taskListDataAccess.open();
|
||||
new GetTaskListsTask().execute(taskListDataAccess);
|
||||
}
|
||||
|
||||
@@ -62,10 +64,12 @@ public class TaskListsFragment extends Fragment implements
|
||||
public void onClick(View v) {
|
||||
EditText editText = (EditText) mView.findViewById(R.id.new_task_list_name);
|
||||
String text = editText.getText().toString();
|
||||
if (text.matches("")) return;
|
||||
if (text.matches("")) {
|
||||
editText.setError(getResources().getString(R.string.task_list_new_list_error));
|
||||
return;
|
||||
}
|
||||
int position = taskListRecyclerViewAdapter.getItemCount();
|
||||
|
||||
taskListDataAccess.open();
|
||||
TaskList taskList = taskListDataAccess.createTaskList(text, position);
|
||||
taskListRecyclerViewAdapter.add(taskList, position);
|
||||
|
||||
@@ -106,6 +110,9 @@ public class TaskListsFragment extends Fragment implements
|
||||
|
||||
@Override
|
||||
public void onClickDeleteButton(int position, long id) {
|
||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
|
||||
if(sharedPref.getBoolean("pref_conf_tasklist_del", true)) {
|
||||
String title = getResources().getString(R.string.task_list_confirmation_delete);
|
||||
ConfirmDialogFragment confirmDialogFragment =
|
||||
ConfirmDialogFragment.newInstance(title, this);
|
||||
@@ -115,6 +122,27 @@ public class TaskListsFragment extends Fragment implements
|
||||
confirmDialogFragment.setArguments(args);
|
||||
confirmDialogFragment.show(getFragmentManager(), title);
|
||||
}
|
||||
else deleteTaskList(position, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfirmDialogClick(DialogFragment dialog, ConfirmDialogFragment.ButtonEvent event) {
|
||||
// Handle never ask again checkbox
|
||||
CheckBox neverAskAgainCheckBox = (CheckBox) dialog.getDialog().findViewById(R.id.task_confirmation_never);
|
||||
if (neverAskAgainCheckBox.isChecked()) {
|
||||
|
||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
SharedPreferences.Editor editor = sharedPref.edit();
|
||||
|
||||
editor.putBoolean("pref_conf_tasklist_del", false);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
if (event == ConfirmDialogFragment.ButtonEvent.NO) return;
|
||||
|
||||
Bundle args = dialog.getArguments();
|
||||
deleteTaskList(args.getInt("ItemPosition"), args.getLong("ItemId"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemMove(long fromTaskId, long toTaskId, int fromPosition, int toPosition) {
|
||||
@@ -122,13 +150,8 @@ public class TaskListsFragment extends Fragment implements
|
||||
taskListDataAccess.updateOrder(toTaskId, fromPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfirmDialogClick(DialogFragment dialog, ConfirmDialogFragment.ButtonEvent event) {
|
||||
if (event == ConfirmDialogFragment.ButtonEvent.NO) return;
|
||||
|
||||
Bundle args = dialog.getArguments();
|
||||
int position = args.getInt("ItemPosition");
|
||||
long id = args.getLong("ItemId");
|
||||
private void deleteTaskList(int position, long id)
|
||||
{
|
||||
taskListRecyclerViewAdapter.remove(position);
|
||||
taskListDataAccess.deleteTaskList(id);
|
||||
toggleVisibleCreateNewTaskListLayout(mView);
|
||||
@@ -138,10 +161,7 @@ public class TaskListsFragment extends Fragment implements
|
||||
@Override
|
||||
protected List<TaskList> doInBackground(TaskListDataAccess... params) {
|
||||
TaskListDataAccess taskListDataAccess = params[0];
|
||||
taskListDataAccess.open();
|
||||
List<TaskList> taskLists = taskListDataAccess.getAllTaskLists();
|
||||
taskListDataAccess.close();
|
||||
return taskLists;
|
||||
return taskListDataAccess.getAllTaskLists();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -31,6 +31,7 @@ import com.wismna.geoffroy.donext.dao.TaskList;
|
||||
import com.wismna.geoffroy.donext.database.TaskDataAccess;
|
||||
import com.wismna.geoffroy.donext.helpers.TaskTouchHelper;
|
||||
import com.wismna.geoffroy.donext.listeners.RecyclerItemClickListener;
|
||||
import com.wismna.geoffroy.donext.widgets.DividerItemDecoration;
|
||||
import com.wismna.geoffroy.donext.widgets.NoScrollingLayoutManager;
|
||||
|
||||
/**
|
||||
@@ -83,20 +84,20 @@ public class TasksFragment extends Fragment implements
|
||||
view = inflater.inflate(R.layout.fragment_tasks, container, false);
|
||||
final Context context = view.getContext();
|
||||
|
||||
taskDataAccess = new TaskDataAccess(view.getContext());
|
||||
taskDataAccess.open();
|
||||
|
||||
// Set the Recycler view
|
||||
recyclerView = (RecyclerView) view.findViewById(R.id.task_list_view);
|
||||
recyclerView.setLayoutManager(new NoScrollingLayoutManager(context));
|
||||
|
||||
taskDataAccess = new TaskDataAccess(view.getContext());
|
||||
taskDataAccess.open();
|
||||
|
||||
// Set RecyclerView Adapter
|
||||
taskRecyclerViewAdapter = new TaskRecyclerViewAdapter(taskDataAccess.getAllTasks(taskListId));
|
||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
taskRecyclerViewAdapter = new TaskRecyclerViewAdapter(
|
||||
taskDataAccess.getAllTasks(taskListId),
|
||||
Integer.valueOf(sharedPref.getString("pref_conf_task_layout", "1")));
|
||||
recyclerView.setAdapter(taskRecyclerViewAdapter);
|
||||
|
||||
// Set total cycles
|
||||
UpdateCycleCount();
|
||||
|
||||
// Set ItemTouch helper in RecyclerView to handle swipe move on elements
|
||||
ItemTouchHelper.Callback callback = new TaskTouchHelper(this);
|
||||
ItemTouchHelper helper = new ItemTouchHelper(callback);
|
||||
@@ -125,18 +126,37 @@ public class TasksFragment extends Fragment implements
|
||||
})
|
||||
);
|
||||
|
||||
// Set total count
|
||||
UpdateTaskCount();
|
||||
|
||||
// Handle updating remaining task count in a listener to be sure that the layout is available
|
||||
// Handle updating total counts in a listener to be sure that the layout is available
|
||||
recyclerView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
UpdateRemainingTaskCount();
|
||||
recyclerView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
// Update total cycle count
|
||||
int totalCycles = taskRecyclerViewAdapter.getCycleCount();
|
||||
if (totalCycles != 0) {
|
||||
TextView totalCyclesView = (TextView) view.findViewById(R.id.total_task_cycles);
|
||||
totalCyclesView.setText(String.valueOf(totalCycles + " cycles"));
|
||||
}
|
||||
|
||||
// Update total tasks
|
||||
int totalTasks = taskRecyclerViewAdapter.getItemCount();
|
||||
TextView totalTasksView = (TextView) view.findViewById(R.id.total_task_count);
|
||||
if (totalTasks == 0) totalTasksView.setText(getResources().getText(R.string.task_no_tasks));
|
||||
else totalTasksView.setText(String.valueOf(totalTasks + " task" + (totalTasks > 1 ? "s" : "")));
|
||||
|
||||
// Update remaining tasks
|
||||
TextView remainingTasksView = (TextView) view.findViewById(R.id.remaining_task_count);
|
||||
NoScrollingLayoutManager layoutManager = (NoScrollingLayoutManager) recyclerView.getLayoutManager();
|
||||
int remainingTaskCount = totalTasks - layoutManager.findLastVisibleItemPosition() - 1;
|
||||
if (remainingTaskCount == 0) remainingTasksView.setText("");
|
||||
else remainingTasksView.setText(String.valueOf(
|
||||
remainingTaskCount + " more task" + (remainingTaskCount > 1 ? "s" : "")));
|
||||
|
||||
//recyclerView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
recyclerView.addItemDecoration(new DividerItemDecoration(getActivity()));
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -152,31 +172,6 @@ public class TasksFragment extends Fragment implements
|
||||
taskDataAccess.open();
|
||||
}
|
||||
|
||||
private void UpdateCycleCount() {
|
||||
int totalCycles = taskDataAccess.getTotalCycles(taskListId);
|
||||
if (totalCycles == 0) return;
|
||||
TextView totalCyclesView = (TextView) view.findViewById(R.id.total_task_cycles);
|
||||
totalCyclesView.setText(String.valueOf(totalCycles + " cycles"));
|
||||
}
|
||||
|
||||
private void UpdateTaskCount() {
|
||||
int totalTasks = taskRecyclerViewAdapter.getItemCount();
|
||||
TextView totalTasksView = (TextView) view.findViewById(R.id.total_task_count);
|
||||
if (totalTasks == 0) totalTasksView.setText(getResources().getText(R.string.task_no_tasks));
|
||||
else totalTasksView.setText(String.valueOf(totalTasks + " tasks"));
|
||||
}
|
||||
|
||||
private void UpdateRemainingTaskCount() {
|
||||
TextView remainingTasksView = (TextView) view.findViewById(R.id.remaining_task_count);
|
||||
NoScrollingLayoutManager layoutManager = (NoScrollingLayoutManager) recyclerView.getLayoutManager();
|
||||
int remainingTaskCount = taskRecyclerViewAdapter.getItemCount() - layoutManager.findLastVisibleItemPosition() - 1;
|
||||
if (remainingTaskCount == 0)
|
||||
remainingTasksView.setText("");
|
||||
else
|
||||
remainingTasksView.setText(String.valueOf(
|
||||
remainingTaskCount + " more task" + (remainingTaskCount > 1 ? "s" : "")));
|
||||
}
|
||||
|
||||
/** Performs an action on a task: done, next or delete */
|
||||
public void PerformTaskAction(final int itemPosition, final int direction) {
|
||||
final long itemId = taskRecyclerViewAdapter.getItemId(itemPosition);
|
||||
@@ -207,8 +202,7 @@ public class TasksFragment extends Fragment implements
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// Undo adapter changes
|
||||
switch (direction)
|
||||
{
|
||||
switch (direction) {
|
||||
// Nothing special to do for done
|
||||
case ItemTouchHelper.LEFT:
|
||||
break;
|
||||
@@ -249,10 +243,7 @@ public class TasksFragment extends Fragment implements
|
||||
taskDataAccess.deleteTask(itemId);
|
||||
}
|
||||
|
||||
UpdateCycleCount();
|
||||
|
||||
UpdateTaskCount();
|
||||
UpdateRemainingTaskCount();
|
||||
//UpdateCycleCount();
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
@@ -315,7 +306,6 @@ public class TasksFragment extends Fragment implements
|
||||
priorityRadio.getText().toString(),
|
||||
taskList.getId());
|
||||
|
||||
|
||||
Bundle args = dialog.getArguments();
|
||||
// Should never happen because we will have to be on this tab to open the dialog
|
||||
if (taskRecyclerViewAdapter == null) return;
|
||||
@@ -324,9 +314,6 @@ public class TasksFragment extends Fragment implements
|
||||
if (task == null) {
|
||||
taskRecyclerViewAdapter.add(newTask, 0);
|
||||
recyclerView.scrollToPosition(0);
|
||||
|
||||
// Update the task count
|
||||
UpdateTaskCount();
|
||||
}
|
||||
// Update the task
|
||||
else {
|
||||
@@ -336,13 +323,12 @@ public class TasksFragment extends Fragment implements
|
||||
{
|
||||
// Remove item from current tab
|
||||
taskRecyclerViewAdapter.remove(position);
|
||||
//UpdateCycleCount();
|
||||
|
||||
// Add it to the corresponding tab provided it is already instanciated
|
||||
mAdapter.onTaskListChanged(newTask, listSpinner.getSelectedItemPosition());
|
||||
} else taskRecyclerViewAdapter.update(newTask, position);
|
||||
}
|
||||
|
||||
UpdateRemainingTaskCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.wismna.geoffroy.donext.helpers;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||
@@ -50,27 +49,27 @@ public class TaskTouchHelper extends ItemTouchHelper.SimpleCallback {
|
||||
View itemView = viewHolder.itemView;
|
||||
|
||||
Paint p = new Paint();
|
||||
p.setARGB(255, 222, 222, 222);
|
||||
if (dX > 0) {
|
||||
/* Set your color for positive displacement */
|
||||
p.setARGB(255, 204, 229, 255);
|
||||
// Set your color for positive displacement
|
||||
//p.setARGB(255, 204, 229, 255);
|
||||
|
||||
// Draw Rect with varying right side, equal to displacement dX
|
||||
c.drawRect((float) itemView.getLeft(), (float) itemView.getTop(), dX,
|
||||
(float) itemView.getBottom(), p);
|
||||
} else {
|
||||
/* Set your color for negative displacement */
|
||||
p.setARGB(255, 204, 255, 229);
|
||||
// Set your color for negative displacement
|
||||
//p.setARGB(255, 204, 255, 229);
|
||||
|
||||
// Draw Rect with varying left side, equal to the item's right side plus negative displacement dX
|
||||
c.drawRect((float) itemView.getRight() + dX, (float) itemView.getTop(),
|
||||
(float) itemView.getRight(), (float) itemView.getBottom(), p);
|
||||
}
|
||||
|
||||
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
/*@Override
|
||||
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
|
||||
if (actionState != ItemTouchHelper.ACTION_STATE_IDLE)
|
||||
{
|
||||
@@ -86,5 +85,5 @@ public class TaskTouchHelper extends ItemTouchHelper.SimpleCallback {
|
||||
|
||||
viewHolder.itemView.setAlpha(1.0f);
|
||||
viewHolder.itemView.setBackgroundColor(0);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
@@ -0,0 +1,54 @@
|
||||
package com.wismna.geoffroy.donext.widgets;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* Created by geoffroy on 16-01-11.
|
||||
* Displays dividers between RecyclerView items
|
||||
*/
|
||||
public class DividerItemDecoration extends RecyclerView.ItemDecoration {
|
||||
|
||||
private static final int[] ATTRS = new int[]{android.R.attr.listDivider};
|
||||
|
||||
private Drawable mDivider;
|
||||
|
||||
/**
|
||||
* Default divider will be used
|
||||
*/
|
||||
public DividerItemDecoration(Context context) {
|
||||
final TypedArray styledAttributes = context.obtainStyledAttributes(ATTRS);
|
||||
mDivider = styledAttributes.getDrawable(0);
|
||||
styledAttributes.recycle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom divider will be used
|
||||
*/
|
||||
/*public DividerItemDecoration(Context context, int resId) {
|
||||
mDivider = ContextCompat.getDrawable(context, resId);
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
|
||||
int left = parent.getPaddingLeft();
|
||||
int right = parent.getWidth() - parent.getPaddingRight();
|
||||
|
||||
int childCount = parent.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View child = parent.getChildAt(i);
|
||||
|
||||
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
|
||||
|
||||
int top = child.getBottom() + params.bottomMargin;
|
||||
int bottom = top + mDivider.getIntrinsicHeight();
|
||||
|
||||
mDivider.setBounds(left, top, right, bottom);
|
||||
mDivider.draw(c);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@android:color/darker_gray" android:state_pressed="false" android:state_selected="true" />
|
||||
<item android:drawable="@android:color/holo_red_light" android:state_selected="true" />
|
||||
<item android:drawable="@android:color/holo_red_light" android:state_pressed="true" />
|
||||
<item android:drawable="@android:color/white" android:state_selected="false" />
|
||||
</selector>
|
@@ -7,8 +7,8 @@
|
||||
android:id="@+id/task_confirmation_never"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginLeft="@dimen/text_margin"
|
||||
android:layout_marginStart="@dimen/text_margin"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="@string/task_confirmation_never_button" />
|
||||
</LinearLayout>
|
@@ -2,7 +2,10 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="70dp"
|
||||
android:orientation="horizontal" >
|
||||
android:paddingTop="5dp"
|
||||
android:orientation="horizontal"
|
||||
android:focusable="true"
|
||||
android:background="?android:attr/selectableItemBackground" >
|
||||
<TextView
|
||||
android:id="@+id/task_cycle"
|
||||
android:layout_width="56dp"
|
@@ -3,7 +3,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:padding="16dp"
|
||||
android:padding="@dimen/text_margin"
|
||||
android:orientation="vertical"
|
||||
tools:context=".activities.MainActivity">
|
||||
<TextView
|
||||
@@ -24,7 +24,8 @@
|
||||
<EditText
|
||||
android:id="@+id/new_task_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/new_task_name_hint" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -34,6 +35,8 @@
|
||||
android:id="@+id/new_task_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/new_task_description_hint"
|
||||
android:gravity="top|start"
|
||||
android:lines="3"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
24
DoNExt/app/src/main/res/layout/fragment_task_simple.xml
Normal file
24
DoNExt/app/src/main/res/layout/fragment_task_simple.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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="70dp"
|
||||
android:orientation="horizontal"
|
||||
android:background="?android:attr/selectableItemBackground" >
|
||||
<TextView
|
||||
android:id="@+id/task_cycle"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10dp"
|
||||
android:textAppearance="?attr/textAppearanceListItem" />
|
||||
<TextView
|
||||
android:id="@+id/task_id"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
<TextView
|
||||
android:id="@+id/task_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?attr/textAppearanceListItem"
|
||||
android:textSize="25sp"/>
|
||||
</LinearLayout>
|
@@ -21,13 +21,13 @@
|
||||
android:name="com.wismna.geoffroy.donext.activities.TaskFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginLeft="@dimen/text_margin"
|
||||
android:layout_marginRight="@dimen/text_margin"
|
||||
android:layout_below="@id/total_task_cycles"
|
||||
app:layoutManager="LinearLayoutManager"
|
||||
app:layout_heightPercent="90%"
|
||||
tools:context=".fragments.TasksFragment"
|
||||
tools:listitem="@layout/fragment_task" />
|
||||
tools:listitem="@layout/fragment_task_detailed" />
|
||||
<TextView
|
||||
android:id="@+id/remaining_task_count"
|
||||
android:layout_width="150dp"
|
||||
|
@@ -11,14 +11,17 @@
|
||||
<!-- Strings related to Task List edition -->
|
||||
<string name="task_list_new_list_hint">New list name</string>
|
||||
<string name="task_list_new_list_create">Create</string>
|
||||
<string name="task_list_new_list_error">List name cannot be blank</string>
|
||||
<string name="task_list_delete">Delete</string>
|
||||
<string name="task_list_confirmation_delete">Delete task list?</string>
|
||||
|
||||
|
||||
<!-- Strings related to new task dialog -->
|
||||
<string name="new_task_list">List</string>
|
||||
<string name="new_task_name">Name</string>
|
||||
<string name="new_task_name_hint">New task name</string>
|
||||
<string name="new_task_name_error">Task name cannot be blank</string>
|
||||
<string name="new_task_description">Description</string>
|
||||
<string name="new_task_description_hint">Optional task description</string>
|
||||
<string name="new_task_priority">Priority</string>
|
||||
<string name="new_task_priority_low">Low</string>
|
||||
<string name="new_task_priority_normal">Normal</string>
|
||||
@@ -43,10 +46,21 @@
|
||||
<string name="task_confirmation_never_button">Never ask again</string>
|
||||
|
||||
<!-- Strings related to Settings -->
|
||||
<string name="settings_category_tasks">Tasks</string>
|
||||
<string name="settings_category_tasklists">Task lists</string>
|
||||
<string name="settings_confirm_message">Mark task as</string>
|
||||
<string name="settings_confirm_donext">Confirm on next?</string>
|
||||
<string name="settings_confirm_markdone">Confirm on done?</string>
|
||||
<string name="settings_confirm_delete">Confirm on delete?</string>
|
||||
<string name="settings_task_layout">Task layout:</string>
|
||||
<string-array name="settings_task_layouts">
|
||||
<item>Simple</item>
|
||||
<item>Detailed</item>
|
||||
</string-array>
|
||||
<string-array name="settings_task_layout_values">
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
<string name="settings_max_lists_label">Maximum number of lists:</string>
|
||||
<string-array name="settings_max_lists_number">
|
||||
<item>1</item>
|
||||
|
@@ -1,17 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<CheckBoxPreference
|
||||
<PreferenceCategory android:title="@string/settings_category_tasks" >
|
||||
<SwitchPreference
|
||||
android:key="pref_conf_next"
|
||||
android:title="@string/settings_confirm_donext"
|
||||
android:defaultValue="true" />
|
||||
<CheckBoxPreference
|
||||
<SwitchPreference
|
||||
android:key="pref_conf_done"
|
||||
android:title="@string/settings_confirm_markdone"
|
||||
android:defaultValue="true" />
|
||||
<CheckBoxPreference
|
||||
<SwitchPreference
|
||||
android:key="pref_conf_del"
|
||||
android:title="@string/settings_confirm_delete"
|
||||
android:defaultValue="true" />
|
||||
<ListPreference
|
||||
android:key="pref_conf_task_layout"
|
||||
android:title="@string/settings_task_layout"
|
||||
android:dialogTitle="@string/settings_max_lists_label"
|
||||
android:entries="@array/settings_task_layouts"
|
||||
android:entryValues="@array/settings_task_layout_values"
|
||||
android:summary="%s"
|
||||
android:defaultValue="1" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/settings_category_tasklists">
|
||||
<SwitchPreference
|
||||
android:key="pref_conf_tasklist_del"
|
||||
android:title="@string/settings_confirm_delete"
|
||||
android:defaultValue="true" />
|
||||
<ListPreference
|
||||
android:key="pref_conf_max_lists"
|
||||
android:title="@string/settings_max_lists_label"
|
||||
@@ -20,4 +35,5 @@
|
||||
android:entryValues="@array/settings_max_lists_number"
|
||||
android:summary="%s"
|
||||
android:defaultValue="3" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
Reference in New Issue
Block a user