From 0fb7e37f93b488325333da55f0bb771de1767313 Mon Sep 17 00:00:00 2001 From: bg45 Date: Thu, 16 Mar 2017 18:02:47 -0400 Subject: [PATCH] Due Dates fully functional Today list fully functional New and edit task dialog now goes full screen on smaller screens, stays as a pop-up on bigger ones New Alarm icon on expired tasks Better tasks layout Simpler new and edit task form layout: less labels, replaced radiogroup with slider,... --- .../donext/activities/MainActivity.java | 29 ++- .../adapters/TaskRecyclerViewAdapter.java | 28 ++- .../donext/database/TaskDataAccess.java | 24 +-- .../donext/fragments/TaskDialogFragment.java | 152 ++++++++++---- .../donext/fragments/TasksFragment.java | 58 ++++-- .../drawable/ic_access_alarm_black_24dp.xml | 9 + .../main/res/layout-large/activity_main.xml | 2 +- .../app/src/main/res/layout/activity_main.xml | 4 - .../res/layout/fragment_task_detailed.xml | 9 +- .../main/res/layout/fragment_task_form.xml | 188 +++++++++--------- .../main/res/layout/fragment_task_simple.xml | 12 +- .../src/main/res/layout/fragment_tasks.xml | 3 - .../app/src/main/res/menu/menu_new_task.xml | 14 ++ DoNExt/app/src/main/res/values-fr/strings.xml | 3 +- .../app/src/main/res/values-large/bools.xml | 4 + DoNExt/app/src/main/res/values/bools.xml | 4 + DoNExt/app/src/main/res/values/strings.xml | 3 +- 17 files changed, 347 insertions(+), 199 deletions(-) create mode 100644 DoNExt/app/src/main/res/drawable/ic_access_alarm_black_24dp.xml create mode 100644 DoNExt/app/src/main/res/menu/menu_new_task.xml create mode 100644 DoNExt/app/src/main/res/values-large/bools.xml create mode 100644 DoNExt/app/src/main/res/values/bools.xml diff --git a/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/activities/MainActivity.java b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/activities/MainActivity.java index 8664f4e..e230154 100644 --- a/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/activities/MainActivity.java +++ b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/activities/MainActivity.java @@ -11,6 +11,7 @@ import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.RecyclerView; @@ -27,7 +28,6 @@ import com.wismna.geoffroy.donext.adapters.SmartFragmentStatePagerAdapter; import com.wismna.geoffroy.donext.adapters.TaskRecyclerViewAdapter; import com.wismna.geoffroy.donext.dao.Task; import com.wismna.geoffroy.donext.dao.TaskList; -import com.wismna.geoffroy.donext.database.TaskDataAccess; import com.wismna.geoffroy.donext.database.TaskListDataAccess; import com.wismna.geoffroy.donext.fragments.TaskDialogFragment; import com.wismna.geoffroy.donext.fragments.TasksFragment; @@ -51,11 +51,13 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas private ViewPager mViewPager; private TabLayout tabLayout; private List taskLists; + private boolean mIsLargeLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + mIsLargeLayout = getResources().getBoolean(R.bool.large_layout); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); @@ -142,6 +144,7 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas @Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem item = menu.findItem(R.id.action_changeLayout); + if (item == null) return false; SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); String layoutType = sharedPref.getString("pref_conf_task_layout", "1"); switch (layoutType) { @@ -183,17 +186,28 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas /** Called when user clicks on the New Task floating button */ public void onNewTaskClick(View view) { int currentTabPosition = mViewPager.getCurrentItem(); - FragmentManager manager = getSupportFragmentManager(); TaskDialogFragment taskDialogFragment = TaskDialogFragment.newInstance(null, mSectionsPagerAdapter.getAllItems(), (TasksFragment) mSectionsPagerAdapter.getRegisteredFragment(currentTabPosition)); + FragmentManager fragmentManager = getSupportFragmentManager(); // Set current tab value to new task dialog Bundle args = new Bundle(); args.putInt("list", currentTabPosition); taskDialogFragment.setArguments(args); - taskDialogFragment.show(manager, "Create new task"); + if (mIsLargeLayout) + taskDialogFragment.show(fragmentManager, getString(R.string.action_new_task)); + else { + // The device is smaller, so show the fragment fullscreen + FragmentTransaction transaction = fragmentManager.beginTransaction(); + // For a little polish, specify a transition animation + transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); + // To make it fullscreen, use the 'content' root view as the container + // for the fragment, which is always the root view for the activity + transaction.replace(android.R.id.content, taskDialogFragment) + .addToBackStack(null).commit(); + } } /** Called when the user clicks on the Change Layout button */ @@ -270,11 +284,6 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas } if (!todayList.isVisible()) taskListDataAccess.updateVisibility(todayList.getId(), true); - // Mark all tasks with an earlier do date as done - try (TaskDataAccess taskDataAccess = new TaskDataAccess(this, TaskDataAccess.MODE.WRITE)) { - taskDataAccess.updateExpiredTasks( - Integer.valueOf(sharedPref.getString("pref_conf_today_action", "2")), todayList.getId()); - } } else { // Hide the today list if it exists if (todayList != null) { @@ -298,7 +307,9 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). - return TasksFragment.newInstance(taskLists.get(position).getId(), MainActivity.this); + TaskList taskList = taskLists.get(position); + return TasksFragment.newInstance(taskList.getId(), + taskList.getName().equals(getString(R.string.task_list_today)), MainActivity.this); } @Override diff --git a/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/adapters/TaskRecyclerViewAdapter.java b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/adapters/TaskRecyclerViewAdapter.java index 85caf52..67e8d65 100644 --- a/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/adapters/TaskRecyclerViewAdapter.java +++ b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/adapters/TaskRecyclerViewAdapter.java @@ -6,11 +6,14 @@ import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.TextView; import com.wismna.geoffroy.donext.R; import com.wismna.geoffroy.donext.dao.Task; +import org.joda.time.LocalDate; + import java.util.List; @@ -48,6 +51,8 @@ public class TaskRecyclerViewAdapter extends RecyclerView.Adapter priorities = new ArrayList<>(); public TaskDataAccess(Context context) { this(context, MODE.READ); } public TaskDataAccess(Context context, MODE writeMode) { dbHelper = new DatabaseHelper(context); - - priorities.add(context.getString(R.string.new_task_priority_low)); - priorities.add(context.getString(R.string.new_task_priority_normal)); - priorities.add(context.getString(R.string.new_task_priority_high)); - open(writeMode); } @@ -59,19 +50,16 @@ public class TaskDataAccess implements AutoCloseable { } /** Adds or update a task in the database */ - public Task createOrUpdateTask(long id, String name, String description, String priority, long taskList) { + public Task createOrUpdateTask(long id, String name, String description, int priority, long taskList) { return createOrUpdateTask(id, name, description, priority, taskList, LocalDate.now()); } - public Task createOrUpdateTask(long id, String name, String description, String priority, long taskList, LocalDate date) { + public Task createOrUpdateTask(long id, String name, String description, int priority, long taskList, LocalDate date) { ContentValues values = new ContentValues(); 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); - DateFormat sdf = SimpleDateFormat.getDateInstance(); - //SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-DD", Locale.US); - String dateString = sdf.format(date); - values.put(DatabaseHelper.TASKS_COLUMN_DUEDATE, dateString); + values.put(DatabaseHelper.TASKS_COLUMN_DUEDATE, date.toString()); long insertId; if (id == 0) insertId = database.insert(DatabaseHelper.TASKS_TABLE_NAME, null, values); @@ -98,8 +86,8 @@ public class TaskDataAccess implements AutoCloseable { ContentValues contentValues = new ContentValues(); contentValues.put(column, 1); return database.update(DatabaseHelper.TASKS_TABLE_NAME, contentValues, - DatabaseHelper.TASKS_COLUMN_DUEDATE + " < date('now','-1 day') " + - "AND " + DatabaseHelper.TASKS_COLUMN_LIST + " = " + taskListId, null); + DatabaseHelper.TASKS_COLUMN_DUEDATE + " <= date('now','-1 day')" + + " AND " + DatabaseHelper.TASKS_COLUMN_LIST + " = " + taskListId, null); } public List getAllTasks(long id) { diff --git a/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/fragments/TaskDialogFragment.java b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/fragments/TaskDialogFragment.java index 790887a..8184f4c 100644 --- a/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/fragments/TaskDialogFragment.java +++ b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/fragments/TaskDialogFragment.java @@ -1,19 +1,25 @@ package com.wismna.geoffroy.donext.fragments; -import android.app.AlertDialog; import android.app.Dialog; -import android.content.DialogInterface; import android.os.Bundle; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v4.app.DialogFragment; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; +import android.view.ViewGroup; +import android.view.Window; import android.widget.AdapterView; import android.widget.ArrayAdapter; -import android.widget.Button; import android.widget.DatePicker; import android.widget.EditText; -import android.widget.RadioGroup; +import android.widget.SeekBar; import android.widget.Spinner; import com.wismna.geoffroy.donext.R; @@ -59,17 +65,25 @@ public class TaskDialogFragment extends DialogFragment { return fragment; } + @Nullable @Override - @NonNull - public Dialog onCreateDialog(Bundle savedInstanceState) { - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - // Get the layout inflater - LayoutInflater inflater = getActivity().getLayoutInflater(); - View view = inflater.inflate(R.layout.fragment_task_form, null); + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_task_form, container, false); + Toolbar toolbar = (Toolbar) view.findViewById(R.id.new_task_toolbar); + + ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); + + ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setHomeButtonEnabled(true); + actionBar.setHomeAsUpIndicator(android.R.drawable.ic_menu_close_clear_cancel); + } + setHasOptionsMenu(true); // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout - builder.setView(view) + /*builder.setView(view) // Add action buttons .setPositiveButton(R.string.new_task_save, null) .setNegativeButton(R.string.new_task_cancel, new DialogInterface.OnClickListener() { @@ -78,15 +92,10 @@ public class TaskDialogFragment extends DialogFragment { // Canceled creation, nothing to do TaskDialogFragment.this.getDialog().cancel(); } - }); + });*/ // Get date picker final DatePicker dueDatePicker = (DatePicker) view.findViewById(R.id.new_task_due_date); - // Disallow past dates - dueDatePicker.setMinDate(LocalDate.now().toDate().getTime()); - // TODO: set task due date - LocalDate dueDate = task.getDueDate(); - dueDatePicker.updateDate(dueDate.getYear(), dueDate.getMonthOfYear(), dueDate.getDayOfMonth()); // Populate spinner with task lists Spinner spinner = (Spinner) view.findViewById(R.id.new_task_list); @@ -100,14 +109,17 @@ public class TaskDialogFragment extends DialogFragment { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { // Set due date - dueDatePicker.setEnabled(!taskLists.get(position).getName() - .equals(getString(R.string.task_list_today))); + boolean isRestricted = taskLists.get(position).getName() + .equals(getString(R.string.task_list_today)); + dueDatePicker.setEnabled(!isRestricted); + if (isRestricted) { + LocalDate today = LocalDate.now(); + dueDatePicker.updateDate(today.getYear(), today.getMonthOfYear() - 1, today.getDayOfMonth()); + } } @Override - public void onNothingSelected(AdapterView parent) { - - } + public void onNothingSelected(AdapterView parent) {} }); // Auto set list value to current tab @@ -117,42 +129,52 @@ public class TaskDialogFragment extends DialogFragment { // Set other properties if they exist if (task != null) { + toolbar.setTitle(R.string.action_edit_task); + EditText titleText = (EditText) view.findViewById(R.id.new_task_name); titleText.setText(task.getName()); EditText descText = (EditText) view.findViewById(R.id.new_task_description); descText.setText(task.getDescription()); - RadioGroup priorityGroup = (RadioGroup) view.findViewById(R.id.new_task_priority); - switch (task.getPriority()) { - case 0: - priorityGroup.check(R.id.new_task_priority_low); - break; - case 1: - priorityGroup.check(R.id.new_task_priority_normal); - break; - case 2: - priorityGroup.check(R.id.new_task_priority_high); - break; - } + SeekBar seekBar = (SeekBar) view.findViewById(R.id.new_task_priority); + seekBar.setProgress(task.getPriority()); - builder.setNeutralButton(R.string.new_task_delete, new DialogInterface.OnClickListener() { + // Set Due Date + LocalDate dueDate = task.getDueDate(); + dueDatePicker.updateDate(dueDate.getYear(), dueDate.getMonthOfYear() - 1, dueDate.getDayOfMonth()); + + // Add the Delete button +/* builder.setNeutralButton(R.string.new_task_delete, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mListener.onNewTaskDialogNeutralClick(TaskDialogFragment.this); } - }); - setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo_Light); + });*/ } - return builder.create(); + else { + toolbar.setTitle(R.string.action_new_task); + // Disallow past dates on new tasks + dueDatePicker.setMinDate(LocalDate.now().toDate().getTime()); + } + return view; + } + + @Override + @NonNull + public Dialog onCreateDialog(Bundle savedInstanceState) { + Dialog dialog = super.onCreateDialog(savedInstanceState); + dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); + return dialog; } @Override public void onStart() { super.onStart(); - final AlertDialog d = (AlertDialog) getDialog(); + final Dialog d = (Dialog) getDialog(); if(d != null) { - Button positiveButton = d.getButton(Dialog.BUTTON_POSITIVE); + //d.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + /*Button positiveButton = d.getButton(Dialog.BUTTON_POSITIVE); positiveButton.setOnClickListener(new View.OnClickListener() { @Override @@ -168,10 +190,58 @@ public class TaskDialogFragment extends DialogFragment { dismiss(); } } - }); + });*/ } } + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + //super.onCreateOptionsMenu(menu, inflater); + menu.clear(); + getActivity().getMenuInflater().inflate(R.menu.menu_new_task, menu); + } + + @Override + public void onPrepareOptionsMenu(Menu menu) { + if (task == null) { + menu.removeItem(R.id.menu_new_task_delete); + } + super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + + if (id == R.id.menu_new_task_save) { + EditText titleText = (EditText) getDialog().findViewById(R.id.new_task_name); + // handle confirmation button click hereEditText 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(); + } + return true; + } + else if (id == R.id.menu_new_task_delete) { + // handle confirmation button click here + mListener.onNewTaskDialogNeutralClick(TaskDialogFragment.this); + dismiss(); + return true; + } + else if (id == android.R.id.home) { + // handle close button click here + dismiss(); + return true; + } + dismiss(); + + return super.onOptionsItemSelected(item); + } + @Override public void onDestroyView() { Dialog dialog = getDialog(); diff --git a/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/fragments/TasksFragment.java b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/fragments/TasksFragment.java index b9fcd9a..082da55 100644 --- a/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/fragments/TasksFragment.java +++ b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/fragments/TasksFragment.java @@ -10,6 +10,7 @@ import android.support.design.widget.Snackbar; import android.support.v4.app.DialogFragment; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.helper.ItemTouchHelper; @@ -20,8 +21,7 @@ import android.view.ViewTreeObserver; import android.widget.CheckBox; import android.widget.DatePicker; import android.widget.EditText; -import android.widget.RadioButton; -import android.widget.RadioGroup; +import android.widget.SeekBar; import android.widget.Spinner; import android.widget.TextView; @@ -45,13 +45,16 @@ public class TasksFragment extends Fragment implements TaskDialogFragment.NewTaskListener, ConfirmDialogFragment.ConfirmDialogListener, TaskTouchHelper.TaskTouchHelperAdapter { + public interface TaskChangedAdapter { void onTaskListChanged(Task task, int tabPosition); } private static final String TASK_LIST_ID = "task_list_id"; + private static final String CLEAR_EXPIRED_TASKS = "clear_expired_tasks"; private long taskListId = -1; - //private TaskDataAccess taskDataAccess; + private boolean clearExpiredTasks = false; + private boolean mIsLargeLayout; private TaskRecyclerViewAdapter taskRecyclerViewAdapter; private View view; private RecyclerView recyclerView; @@ -65,10 +68,11 @@ public class TasksFragment extends Fragment implements public TasksFragment() { } - public static TasksFragment newInstance(long taskListId, TaskChangedAdapter taskChangedAdapter) { + public static TasksFragment newInstance(long taskListId, boolean clearExpiredTasks, TaskChangedAdapter taskChangedAdapter) { TasksFragment fragment = new TasksFragment(); Bundle args = new Bundle(); args.putLong(TASK_LIST_ID, taskListId); + args.putBoolean(CLEAR_EXPIRED_TASKS, clearExpiredTasks); fragment.setArguments(args); fragment.mAdapter = taskChangedAdapter; fragment.setRetainInstance(true); @@ -79,8 +83,10 @@ public class TasksFragment extends Fragment implements public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + mIsLargeLayout = getResources().getBoolean(R.bool.large_layout); if (getArguments() != null) { taskListId = getArguments().getLong(TASK_LIST_ID); + clearExpiredTasks = getArguments().getBoolean(CLEAR_EXPIRED_TASKS); } } @@ -90,13 +96,21 @@ public class TasksFragment extends Fragment implements view = inflater.inflate(R.layout.fragment_tasks, container, false); final Context context = view.getContext(); - // Set the Recycler view recyclerView = (RecyclerView) view.findViewById(R.id.task_list_view); recyclerView.setLayoutManager(new NoScrollingLayoutManager(context)); // Set RecyclerView Adapter SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext()); + + // Mark all tasks with an earlier do date as done + if (clearExpiredTasks) { + try (TaskDataAccess taskDataAccess = new TaskDataAccess(view.getContext(), TaskDataAccess.MODE.WRITE)) { + taskDataAccess.updateExpiredTasks( + Integer.valueOf(sharedPref.getString("pref_conf_today_action", "2")), taskListId); + } + } + // Get all tasks try (TaskDataAccess taskDataAccess = new TaskDataAccess(view.getContext())) { taskRecyclerViewAdapter = new TaskRecyclerViewAdapter( taskDataAccess.getAllTasks(taskListId), @@ -127,7 +141,21 @@ public class TasksFragment extends Fragment implements ((MainActivity.SectionsPagerAdapter) viewPager.getAdapter()).getAllItems(), TasksFragment.this); taskDialogFragment.setArguments(args); - taskDialogFragment.show(manager, getResources().getString(R.string.action_edit_task)); + + // Open the fragment as a dialog or as full-screen depending on screen size + FragmentManager fragmentManager = getFragmentManager(); + if (mIsLargeLayout) + taskDialogFragment.show(manager, getResources().getString(R.string.action_edit_task)); + else { + // The device is smaller, so show the fragment fullscreen + FragmentTransaction transaction = fragmentManager.beginTransaction(); + // For a little polish, specify a transition animation + transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); + // To make it fullscreen, use the 'content' root view as the container + // for the fragment, which is always the root view for the activity + transaction.replace(android.R.id.content, taskDialogFragment) + .addToBackStack(null).commit(); + } } }) ); @@ -300,8 +328,7 @@ public class TasksFragment extends Fragment implements Spinner listSpinner = (Spinner) dialogView.findViewById(R.id.new_task_list); EditText nameText = (EditText) dialogView.findViewById(R.id.new_task_name); EditText descText = (EditText) dialogView.findViewById(R.id.new_task_description); - RadioGroup priorityGroup = (RadioGroup) dialogView.findViewById(R.id.new_task_priority); - RadioButton priorityRadio = (RadioButton) dialogView.findViewById(priorityGroup.getCheckedRadioButtonId()); + SeekBar seekBar = (SeekBar) dialogView.findViewById(R.id.new_task_priority); DatePicker dueDatePicker = (DatePicker) dialogView.findViewById(R.id.new_task_due_date); TaskList taskList = (TaskList) listSpinner.getSelectedItem(); @@ -310,9 +337,9 @@ public class TasksFragment extends Fragment implements Task newTask = taskDataAccess.createOrUpdateTask(id, nameText.getText().toString(), descText.getText().toString(), - priorityRadio.getText().toString(), + seekBar.getProgress(), taskList.getId(), - new LocalDate(dueDatePicker.getYear(), dueDatePicker.getMonth(), dueDatePicker.getDayOfMonth())); + new LocalDate(dueDatePicker.getYear(), dueDatePicker.getMonth() + 1, dueDatePicker.getDayOfMonth())); Bundle args = dialog.getArguments(); // Should never happen because we will have to be on this tab to open the dialog @@ -320,8 +347,15 @@ public class TasksFragment extends Fragment implements // Add the task if (task == null) { - taskRecyclerViewAdapter.add(newTask, 0); - recyclerView.scrollToPosition(0); + // If the new task is added to another task list, update the tab + if (taskListId != taskList.getId()) { + mAdapter.onTaskListChanged(newTask, listSpinner.getSelectedItemPosition()); + } + // Otherwise add it to the current one + else { + taskRecyclerViewAdapter.add(newTask, 0); + recyclerView.scrollToPosition(0); + } } // Update the task else { diff --git a/DoNExt/app/src/main/res/drawable/ic_access_alarm_black_24dp.xml b/DoNExt/app/src/main/res/drawable/ic_access_alarm_black_24dp.xml new file mode 100644 index 0000000..934b067 --- /dev/null +++ b/DoNExt/app/src/main/res/drawable/ic_access_alarm_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/DoNExt/app/src/main/res/layout-large/activity_main.xml b/DoNExt/app/src/main/res/layout-large/activity_main.xml index a04e838..93275a7 100644 --- a/DoNExt/app/src/main/res/layout-large/activity_main.xml +++ b/DoNExt/app/src/main/res/layout-large/activity_main.xml @@ -35,7 +35,7 @@ diff --git a/DoNExt/app/src/main/res/layout/fragment_task_detailed.xml b/DoNExt/app/src/main/res/layout/fragment_task_detailed.xml index f439c65..a763a67 100644 --- a/DoNExt/app/src/main/res/layout/fragment_task_detailed.xml +++ b/DoNExt/app/src/main/res/layout/fragment_task_detailed.xml @@ -8,7 +8,7 @@ android:background="?android:attr/selectableItemBackground" > @@ -17,6 +17,13 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" /> + - - + + - - - - - + + + + + - - - - - - - + + + + - - + - - - - - - \ No newline at end of file + android:layout_height="wrap_content" + android:layout_below="@id/new_task_name" /> + + + + + + + \ No newline at end of file diff --git a/DoNExt/app/src/main/res/layout/fragment_task_simple.xml b/DoNExt/app/src/main/res/layout/fragment_task_simple.xml index ccf192e..a0335b7 100644 --- a/DoNExt/app/src/main/res/layout/fragment_task_simple.xml +++ b/DoNExt/app/src/main/res/layout/fragment_task_simple.xml @@ -6,8 +6,9 @@ android:background="?android:attr/selectableItemBackground" > + + + + + \ No newline at end of file diff --git a/DoNExt/app/src/main/res/values-fr/strings.xml b/DoNExt/app/src/main/res/values-fr/strings.xml index a77aada..096fbeb 100644 --- a/DoNExt/app/src/main/res/values-fr/strings.xml +++ b/DoNExt/app/src/main/res/values-fr/strings.xml @@ -1,7 +1,7 @@ DoNext - Version d\'Android: %s + Version d\'Android: %d Version de DoNext: %s À propos Changer l\'apparence @@ -66,4 +66,5 @@ Le nom \"Aujourd\'hui\" est réservé. Vous pouvez activer la liste Aujourd\'hui dans les paramètres. Action à entreprendre à la fin de la journée: Date de fin + Task is past due date \ No newline at end of file diff --git a/DoNExt/app/src/main/res/values-large/bools.xml b/DoNExt/app/src/main/res/values-large/bools.xml new file mode 100644 index 0000000..0e7909c --- /dev/null +++ b/DoNExt/app/src/main/res/values-large/bools.xml @@ -0,0 +1,4 @@ + + + true + \ No newline at end of file diff --git a/DoNExt/app/src/main/res/values/bools.xml b/DoNExt/app/src/main/res/values/bools.xml new file mode 100644 index 0000000..34c8ea4 --- /dev/null +++ b/DoNExt/app/src/main/res/values/bools.xml @@ -0,0 +1,4 @@ + + + false + \ No newline at end of file diff --git a/DoNExt/app/src/main/res/values/strings.xml b/DoNExt/app/src/main/res/values/strings.xml index f520888..589794f 100644 --- a/DoNExt/app/src/main/res/values/strings.xml +++ b/DoNExt/app/src/main/res/values/strings.xml @@ -75,7 +75,7 @@ DoNext version %s - Android version %s + Android version %d https://github.com/wismna Today list Enable Today list? @@ -84,4 +84,5 @@ Name \"Today\" is reserved. You may activate the Today list from the Settings. Action at the end of the day Due date + Task is past due date