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,...
This commit is contained in:
bg45
2017-03-16 18:02:47 -04:00
parent 9e90715e65
commit 0fb7e37f93
17 changed files with 347 additions and 199 deletions

View File

@@ -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<TaskList> 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

View File

@@ -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<TaskRecyclerVi
public void onBindViewHolder(final SimpleViewHolder holder, int position) {
holder.mItem = mValues.get(position);
holder.mIdView.setText(String.valueOf(holder.mItem.getId()));
if(holder.mItem.getDueDate().isBefore(LocalDate.now()))
holder.mAlarmView.setImageResource(R.drawable.ic_access_alarm_black_24dp);
holder.mCycleView.setText(String.valueOf(holder.mItem.getCycle()));
holder.mTitleView.setText(holder.mItem.getName());
if (holder instanceof DetailedViewHolder)
@@ -112,21 +117,22 @@ public class TaskRecyclerViewAdapter extends RecyclerView.Adapter<TaskRecyclerVi
}
public class SimpleViewHolder extends RecyclerView.ViewHolder {
public final View mView;
public final TextView mIdView;
public final TextView mCycleView;
public final TextView mTitleView;
public Task mItem;
class SimpleViewHolder extends RecyclerView.ViewHolder {
final View mView;
final TextView mIdView;
final ImageView mAlarmView;
final TextView mCycleView;
final TextView mTitleView;
Task mItem;
public SimpleViewHolder(View view) {
SimpleViewHolder(View view) {
super(view);
mView = view;
mIdView = (TextView) view.findViewById(R.id.task_id);
mAlarmView = (ImageView) view.findViewById(R.id.task_alarm);
mCycleView = (TextView) view.findViewById(R.id.task_cycle);
mTitleView = (TextView) view.findViewById(R.id.task_name);
}
@Override
@@ -135,10 +141,10 @@ public class TaskRecyclerViewAdapter extends RecyclerView.Adapter<TaskRecyclerVi
}
}
public class DetailedViewHolder extends SimpleViewHolder {
public final TextView mDescriptionView;
private class DetailedViewHolder extends SimpleViewHolder {
private final TextView mDescriptionView;
public DetailedViewHolder(View view) {
private DetailedViewHolder(View view) {
super(view);
mDescriptionView = (TextView) view.findViewById(R.id.task_description);
}

View File

@@ -6,13 +6,10 @@ import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import com.wismna.geoffroy.donext.R;
import com.wismna.geoffroy.donext.dao.Task;
import org.joda.time.LocalDate;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
@@ -34,18 +31,12 @@ public class TaskDataAccess implements AutoCloseable {
DatabaseHelper.TASKS_COLUMN_CYCLE, DatabaseHelper.TASKS_COLUMN_DONE,
DatabaseHelper.TASKS_COLUMN_DELETED, DatabaseHelper.TASKS_COLUMN_LIST,
DatabaseHelper.TASKS_COLUMN_DUEDATE};
private List<String> 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<Task> getAllTasks(long id) {

View File

@@ -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();

View File

@@ -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 {

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M22,5.72l-4.6,-3.86 -1.29,1.53 4.6,3.86L22,5.72zM7.88,3.39L6.6,1.86 2,5.71l1.29,1.53 4.59,-3.85zM12.5,8L11,8v6l4.75,2.85 0.75,-1.23 -4,-2.37L12.5,8zM12,4c-4.97,0 -9,4.03 -9,9s4.02,9 9,9c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9zM12,20c-3.87,0 -7,-3.13 -7,-7s3.13,-7 7,-7 7,3.13 7,7 -3.13,7 -7,7z"/>
</vector>

View File

@@ -35,7 +35,7 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="80dp"
android:layout_marginTop="?attr/actionBarSize"
android:orientation="horizontal">
<android.widget.ListView
android:id="@+id/tabs"

View File

@@ -30,7 +30,6 @@
android:id="@+id/left_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:contentDescription="@string/tab_left_arrow"
@@ -39,7 +38,6 @@
android:id="@+id/right_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:contentDescription="@string/tab_right_arrow"
@@ -48,9 +46,7 @@
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/left_arrow"
android:layout_toEndOf="@+id/left_arrow"
android:layout_toLeftOf="@+id/right_arrow"
android:layout_toStartOf="@+id/right_arrow"
app:tabMode="scrollable" />
</RelativeLayout>

View File

@@ -8,7 +8,7 @@
android:background="?android:attr/selectableItemBackground" >
<TextView
android:id="@+id/task_cycle"
android:layout_width="56dp"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:textAppearance="?attr/textAppearanceListItem" />
@@ -17,6 +17,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
<ImageView
android:id="@+id/task_alarm"
android:layout_width="24dp"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:layout_marginEnd="5dp"
android:contentDescription="@string/task_alarm"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="?listPreferredItemHeight"

View File

@@ -1,106 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/text_margin"
android:orientation="vertical"
tools:context=".activities.MainActivity">
<TextView
android:id="@+id/new_task_list_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/new_task_list"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Spinner
android:id="@+id/new_task_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginStart="5dp"
android:layout_toEndOf="@id/new_task_list_label">
</Spinner>
<TextView
android:id="@+id/new_task_name_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/new_task_name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_below="@id/new_task_list_label"/>
<EditText
android:id="@+id/new_task_name"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/new_task_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
</android.support.design.widget.AppBarLayout>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:background="@android:color/background_light">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/new_task_name_hint"
android:maxLines="1"
android:inputType="text"
android:layout_below="@id/new_task_name_label"/>
<TextView
android:id="@+id/new_task_description_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/new_task_description"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_below="@id/new_task_name" />
<EditText
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"
android:layout_below="@id/new_task_description_label" />
<TextView
android:id="@+id/new_task_priority_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/new_task_priority"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_below="@id/new_task_description" />
<RadioGroup
android:id="@+id/new_task_priority"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_below="@id/new_task_priority_label" >
<RadioButton
android:id="@+id/new_task_priority_low"
android:text="@string/new_task_priority_low"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</RadioButton>
<RadioButton
android:id="@+id/new_task_priority_normal"
android:text="@string/new_task_priority_normal"
android:padding="@dimen/text_margin"
android:orientation="vertical"
tools:context=".activities.MainActivity">
<TextView
android:id="@+id/new_task_list_label"
android:text="@string/new_task_list"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_marginTop="3dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Spinner
android:id="@+id/new_task_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_toEndOf="@id/new_task_list_label">
</Spinner>
<EditText
android:id="@+id/new_task_name"
android:hint="@string/new_task_name_hint"
android:maxLines="1"
android:inputType="text"
android:textSize="30sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true">
</RadioButton>
<RadioButton
android:id="@+id/new_task_priority_high"
android:text="@string/new_task_priority_high"
android:layout_below="@id/new_task_list"/>
<EditText
android:id="@+id/new_task_description"
android:hint="@string/new_task_description_hint"
android:gravity="top|start"
android:lines="3"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</RadioButton>
</RadioGroup>
<TextView
android:id="@+id/new_task_due_date_label"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="@string/new_task_due_date"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_toEndOf="@id/new_task_priority"
android:layout_below="@id/new_task_description" />
<DatePicker
android:id="@+id/new_task_due_date"
android:calendarViewShown="true"
android:spinnersShown="false"
android:layout_width="800dp"
android:layout_height="800dp"
android:layout_toEndOf="@id/new_task_priority"
android:layout_below="@id/new_task_due_date_label" />
</RelativeLayout>
</ScrollView>
android:layout_height="wrap_content"
android:layout_below="@id/new_task_name" />
<TextView
android:id="@+id/new_task_priority_label"
android:text="@string/new_task_priority"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_below="@id/new_task_description" />
<SeekBar
android:id="@+id/new_task_priority"
android:max="2"
android:progress="1"
android:layout_width="300dp"
android:layout_height="30dp"
android:layout_toEndOf="@id/new_task_priority_label"
android:layout_below="@id/new_task_description" />
<TextView
android:id="@+id/new_task_due_date_label"
android:text="@string/new_task_due_date"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@id/new_task_priority" />
<DatePicker
android:id="@+id/new_task_due_date"
android:datePickerMode="spinner"
android:calendarViewShown="false"
android:spinnersShown="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/new_task_due_date_label" />
</RelativeLayout>
</ScrollView>
</android.support.design.widget.CoordinatorLayout>

View File

@@ -6,8 +6,9 @@
android:background="?android:attr/selectableItemBackground" >
<TextView
android:id="@+id/task_cycle"
android:layout_width="56dp"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:paddingTop="10dp"
android:textAppearance="?attr/textAppearanceListItem" />
<TextView
@@ -15,8 +16,17 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
<ImageView
android:id="@+id/task_alarm"
android:layout_width="24dp"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:layout_marginEnd="5dp"
android:layout_marginTop="10dp"
android:contentDescription="@string/task_alarm"/>
<TextView
android:id="@+id/task_name"
android:layout_marginTop="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?attr/textAppearanceListItem"

View File

@@ -9,7 +9,6 @@
android:id="@+id/total_task_cycles"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<TextView
android:id="@+id/total_task_count"
@@ -41,7 +40,6 @@
android:id="@+id/task_background_done"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:text="@string/task_confirmation_done_button"
@@ -53,7 +51,6 @@
android:id="@+id/task_background_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:text="@string/task_confirmation_next_button"

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/menu_new_task_save"
android:orderInCategory="100"
android:title="@string/new_task_save"
app:showAsAction="always"/>
<item
android:id="@+id/menu_new_task_delete"
android:orderInCategory="50"
android:title="@string/new_task_delete"
app:showAsAction="ifRoom"/>
</menu>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">DoNext</string>
<string name="about_version_android">Version d\'Android: %s</string>
<string name="about_version_android">Version d\'Android: %d</string>
<string name="about_version_donext">Version de DoNext: %s</string>
<string name="action_about">À propos</string>
<string name="action_changeLayout">Changer l\'apparence</string>
@@ -66,4 +66,5 @@
<string name="task_list_today_list_error">Le nom \"Aujourd\'hui\" est réservé. Vous pouvez activer la liste Aujourd\'hui dans les paramètres.</string>
<string name="settings_today_action_title">Action à entreprendre à la fin de la journée:</string>
<string name="new_task_due_date">Date de fin</string>
<string name="task_alarm">Task is past due date</string>
</resources>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="large_layout">true</bool>
</resources>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="large_layout">false</bool>
</resources>

View File

@@ -75,7 +75,7 @@
<!-- Strings related to About -->
<string name="about_version_donext">DoNext version %s</string>
<string name="about_version_android">Android version %s</string>
<string name="about_version_android">Android version %d</string>
<string name="about_link" translatable="false">https://github.com/wismna</string>
<string name="settings_today_title">Today list</string>
<string name="settings_today_enable">Enable Today list?</string>
@@ -84,4 +84,5 @@
<string name="task_list_today_list_error">Name \"Today\" is reserved. You may activate the Today list from the Settings.</string>
<string name="settings_today_action_title">Action at the end of the day</string>
<string name="new_task_due_date">Due date</string>
<string name="task_alarm">Task is past due date</string>
</resources>