mirror of
https://github.com/wismna/DoNext.git
synced 2025-10-03 07:30:13 -04:00
New Today list via settings
Code cleanup WIP Today tasks
This commit is contained in:
@@ -8,8 +8,8 @@ android {
|
||||
applicationId "com.wismna.geoffroy.donext"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 25
|
||||
versionCode 13
|
||||
versionName "1.2.0"
|
||||
versionCode 14
|
||||
versionName "1.3.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
@@ -63,10 +63,16 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas
|
||||
// primary sections of the activity.
|
||||
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||
|
||||
SharedPreferences sharedPref =
|
||||
PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
|
||||
|
||||
// Access database to retrieve Tabs
|
||||
TaskListDataAccess taskListDataAccess = new TaskListDataAccess(this);
|
||||
taskListDataAccess.open();
|
||||
|
||||
// Handle Today list
|
||||
handleTodayList(sharedPref, taskListDataAccess);
|
||||
|
||||
taskLists = taskListDataAccess.getAllTaskLists();
|
||||
mSectionsPagerAdapter.notifyDataSetChanged();
|
||||
taskListDataAccess.close();
|
||||
@@ -81,8 +87,6 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas
|
||||
mViewPager = (ViewPager) findViewById(R.id.container);
|
||||
mViewPager.setAdapter(mSectionsPagerAdapter);
|
||||
// Open last opened tab
|
||||
SharedPreferences sharedPref =
|
||||
PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
|
||||
mViewPager.setCurrentItem(sharedPref.getInt("last_opened_tab", 0));
|
||||
|
||||
View tabs = findViewById(R.id.tabs);
|
||||
@@ -256,6 +260,25 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas
|
||||
}
|
||||
}
|
||||
|
||||
private void handleTodayList(SharedPreferences sharedPref, TaskListDataAccess taskListDataAccess) {
|
||||
String todayListName = getString(R.string.task_list_today);
|
||||
TaskList todayList = taskListDataAccess.getTaskListByName(todayListName);
|
||||
if (sharedPref.getBoolean("pref_conf_today_enable", false)) {
|
||||
// Get or create the Today list
|
||||
if (todayList == null) {
|
||||
// TODO: set order correctly
|
||||
todayList = taskListDataAccess.createTaskList(todayListName, 0);
|
||||
}
|
||||
if (!todayList.isVisible()) taskListDataAccess.updateVisibility(todayList.getId(), true);
|
||||
// Mark all tasks with an earlier do date as done
|
||||
}
|
||||
else {
|
||||
if (todayList != null){
|
||||
taskListDataAccess.updateVisibility(todayList.getId(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
|
||||
* one of the sections/tabs/pages.
|
||||
|
@@ -17,6 +17,7 @@ import com.wismna.geoffroy.donext.helpers.TaskListTouchHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* {@link RecyclerView.Adapter} that can display a {@link TaskList}.
|
||||
@@ -34,10 +35,14 @@ public class TaskListRecyclerViewAdapter extends RecyclerView.Adapter<TaskListRe
|
||||
|
||||
private final List<TaskList> mValues;
|
||||
private TaskListRecyclerViewAdapterListener mListener;
|
||||
private String mReservedTaskListName;
|
||||
|
||||
public TaskListRecyclerViewAdapter(List<TaskList> items, TaskListRecyclerViewAdapterListener listener) {
|
||||
public TaskListRecyclerViewAdapter(List<TaskList> items,
|
||||
TaskListRecyclerViewAdapterListener listener,
|
||||
String reservedTaskListName) {
|
||||
mValues = items;
|
||||
mListener = listener;
|
||||
mReservedTaskListName = reservedTaskListName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,6 +58,7 @@ public class TaskListRecyclerViewAdapter extends RecyclerView.Adapter<TaskListRe
|
||||
holder.mTaskCountView.setText(String.valueOf(mValues.get(position).getTaskCount()));
|
||||
holder.mTaskNameView.setText(mValues.get(position).getName());
|
||||
|
||||
|
||||
holder.handleView.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
@@ -64,8 +70,10 @@ public class TaskListRecyclerViewAdapter extends RecyclerView.Adapter<TaskListRe
|
||||
}
|
||||
});
|
||||
|
||||
Boolean isReservedName = Objects.equals(holder.mItem.getName(), mReservedTaskListName);
|
||||
holder.mTaskNameView.setEnabled(!isReservedName);
|
||||
// Handle inline name change
|
||||
holder.mTaskNameView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
if (!isReservedName) holder.mTaskNameView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
EditText editText = (EditText) v;
|
||||
@@ -80,8 +88,9 @@ public class TaskListRecyclerViewAdapter extends RecyclerView.Adapter<TaskListRe
|
||||
}
|
||||
});
|
||||
|
||||
holder.mTaskDeleteButton.setEnabled(!isReservedName);
|
||||
// Handle click on delete button
|
||||
holder.mTaskDeleteButton.setOnClickListener(new View.OnClickListener() {
|
||||
if (!isReservedName) holder.mTaskDeleteButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// Disable the OnFocusChanged listener as it is now pointless and harmful
|
||||
@@ -134,15 +143,15 @@ public class TaskListRecyclerViewAdapter extends RecyclerView.Adapter<TaskListRe
|
||||
return true;
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public final View mView;
|
||||
public final ImageView handleView;
|
||||
public final TextView mTaskCountView;
|
||||
public final TextView mTaskNameView;
|
||||
public final Button mTaskDeleteButton;
|
||||
public TaskList mItem;
|
||||
class ViewHolder extends RecyclerView.ViewHolder {
|
||||
final View mView;
|
||||
final ImageView handleView;
|
||||
final TextView mTaskCountView;
|
||||
final TextView mTaskNameView;
|
||||
final Button mTaskDeleteButton;
|
||||
TaskList mItem;
|
||||
|
||||
public ViewHolder(View view) {
|
||||
ViewHolder(View view) {
|
||||
super(view);
|
||||
mView = view;
|
||||
handleView = (ImageView) itemView.findViewById(R.id.handle);
|
||||
|
@@ -1,5 +1,8 @@
|
||||
package com.wismna.geoffroy.donext.dao;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
/**
|
||||
* Created by geoffroy on 15-11-25.
|
||||
* Data access object class that represents a Task
|
||||
@@ -14,6 +17,7 @@ public class Task {
|
||||
private int deleted;
|
||||
private long taskList;
|
||||
private String taskListName;
|
||||
private Date dueDate;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
@@ -87,6 +91,14 @@ public class Task {
|
||||
this.taskListName = taskListName;
|
||||
}
|
||||
|
||||
public void setDueDate(String dueDate) {
|
||||
this.dueDate = Date.valueOf(dueDate);
|
||||
}
|
||||
|
||||
public Date getDueDate() {
|
||||
return dueDate;
|
||||
}
|
||||
|
||||
// Will be used by the ArrayAdapter in the ListView
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@@ -9,6 +9,7 @@ public class TaskList {
|
||||
private String name;
|
||||
private long taskCount;
|
||||
private int order;
|
||||
private Boolean visible;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
@@ -42,8 +43,15 @@ public class TaskList {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public void setVisible(int visible) {
|
||||
this.visible = visible != 0;
|
||||
}
|
||||
public Boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -8,43 +8,48 @@ import android.database.sqlite.SQLiteOpenHelper;
|
||||
* Created by geoffroy on 15-11-25.
|
||||
* Database helper class that contains table and column names as well as handles database creation
|
||||
*/
|
||||
public class DatabaseHelper extends SQLiteOpenHelper {
|
||||
private static final int DATABASE_VERSION = 2;
|
||||
class DatabaseHelper extends SQLiteOpenHelper {
|
||||
private static final int DATABASE_VERSION = 3;
|
||||
private static final String DATABASE_NAME = "donext.db";
|
||||
public static final String COLUMN_ID = "_id";
|
||||
public static final String COLUMN_ORDER = "displayorder";
|
||||
static final String COLUMN_ID = "_id";
|
||||
static final String COLUMN_ORDER = "displayorder";
|
||||
|
||||
public static final String TASKLIST_TABLE_NAME = "tasklist";
|
||||
public static final String TASKLIST_COLUMN_NAME = "name";
|
||||
public static final String TASKLIST_COLUMN_TASK_COUNT = "taskcount";
|
||||
static final String TASKLIST_TABLE_NAME = "tasklist";
|
||||
static final String TASKLIST_COLUMN_NAME = "name";
|
||||
static final String TASKLIST_COLUMN_TASK_COUNT = "taskcount";
|
||||
static final String TASKLIST_COLUMN_VISIBLE = "visible";
|
||||
private static final String TASKLIST_TABLE_CREATE =
|
||||
"CREATE TABLE " + TASKLIST_TABLE_NAME + " (" +
|
||||
COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
TASKLIST_COLUMN_NAME + " TEXT NOT NULL, " +
|
||||
COLUMN_ORDER + " INTEGER);";
|
||||
"CREATE TABLE " + TASKLIST_TABLE_NAME + " (" +
|
||||
COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
TASKLIST_COLUMN_NAME + " TEXT NOT NULL, " +
|
||||
COLUMN_ORDER + " INTEGER, " +
|
||||
TASKLIST_COLUMN_VISIBLE + " INTEGER DEFAULT 1" +
|
||||
");";
|
||||
|
||||
public static final String TASKS_TABLE_NAME = "tasks";
|
||||
public static final String TASKS_COLUMN_NAME = "name";
|
||||
public static final String TASKS_COLUMN_DESC = "description";
|
||||
public static final String TASKS_COLUMN_CYCLE = "cycle";
|
||||
public static final String TASKS_COLUMN_PRIORITY = "priority";
|
||||
public static final String TASKS_COLUMN_DONE = "done";
|
||||
public static final String TASKS_COLUMN_DELETED= "deleted";
|
||||
public static final String TASKS_COLUMN_LIST = "list";
|
||||
static final String TASKS_TABLE_NAME = "tasks";
|
||||
static final String TASKS_COLUMN_NAME = "name";
|
||||
static final String TASKS_COLUMN_DESC = "description";
|
||||
static final String TASKS_COLUMN_CYCLE = "cycle";
|
||||
static final String TASKS_COLUMN_PRIORITY = "priority";
|
||||
static final String TASKS_COLUMN_DONE = "done";
|
||||
static final String TASKS_COLUMN_DELETED= "deleted";
|
||||
static final String TASKS_COLUMN_LIST = "list";
|
||||
static final String TASKS_COLUMN_DUEDATE = "duedate";
|
||||
private static final String TASKS_TABLE_CREATE =
|
||||
"CREATE TABLE " + TASKS_TABLE_NAME + " (" +
|
||||
COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
TASKS_COLUMN_NAME + " TEXT NOT NULL, " +
|
||||
TASKS_COLUMN_DESC + " TEXT, " +
|
||||
TASKS_COLUMN_PRIORITY + " INTEGER, " +
|
||||
TASKS_COLUMN_CYCLE + " INTEGER DEFAULT 0, " +
|
||||
TASKS_COLUMN_DONE + " INTEGER DEFAULT 0, " +
|
||||
TASKS_COLUMN_DELETED + " INTEGER DEFAULT 0, " +
|
||||
COLUMN_ORDER + " INTEGER, " +
|
||||
TASKS_COLUMN_LIST + " INTEGER NOT NULL, " +
|
||||
"FOREIGN KEY(" + TASKS_COLUMN_LIST + ") REFERENCES " +
|
||||
TASKLIST_TABLE_NAME + "(" + COLUMN_ID + ")" +
|
||||
");";
|
||||
"CREATE TABLE " + TASKS_TABLE_NAME + " (" +
|
||||
COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
TASKS_COLUMN_NAME + " TEXT NOT NULL, " +
|
||||
TASKS_COLUMN_DESC + " TEXT, " +
|
||||
TASKS_COLUMN_PRIORITY + " INTEGER, " +
|
||||
TASKS_COLUMN_CYCLE + " INTEGER DEFAULT 0, " +
|
||||
TASKS_COLUMN_DONE + " INTEGER DEFAULT 0, " +
|
||||
TASKS_COLUMN_DELETED + " INTEGER DEFAULT 0, " +
|
||||
COLUMN_ORDER + " INTEGER, " +
|
||||
TASKS_COLUMN_LIST + " INTEGER NOT NULL, " +
|
||||
"FOREIGN KEY(" + TASKS_COLUMN_LIST + ") REFERENCES " +
|
||||
TASKLIST_TABLE_NAME + "(" + COLUMN_ID + ")" +
|
||||
TASKS_COLUMN_DUEDATE + " DATE, " +
|
||||
");";
|
||||
|
||||
DatabaseHelper(Context context) {
|
||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||
@@ -63,5 +68,12 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||
// Add new Order column
|
||||
db.execSQL("ALTER TABLE " + TASKLIST_TABLE_NAME + " ADD COLUMN " + COLUMN_ORDER + " INTEGER");
|
||||
}
|
||||
if (oldVersion == 2)
|
||||
{
|
||||
// Add new Visible column
|
||||
db.execSQL("ALTER TABLE " + TASKLIST_TABLE_NAME + " ADD COLUMN " + TASKLIST_COLUMN_VISIBLE + " INTEGER DEFAULT 1");
|
||||
// Add new Due Date column
|
||||
db.execSQL("ALTER TABLE " + TASKS_TABLE_NAME + " ADD COLUMN " + TASKS_COLUMN_DUEDATE + " DATE");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,9 @@ import android.database.sqlite.SQLiteDatabase;
|
||||
import com.wismna.geoffroy.donext.R;
|
||||
import com.wismna.geoffroy.donext.dao.Task;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -55,11 +58,17 @@ 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) {
|
||||
return createOrUpdateTask(id, name, description, priority, taskList, new Date());
|
||||
}
|
||||
public Task createOrUpdateTask(long id, String name, String description, String priority, long taskList, Date 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_LIST, taskList);
|
||||
DateFormat sdf = SimpleDateFormat.getDateInstance();
|
||||
String dateString = sdf.format(date);
|
||||
values.put(DatabaseHelper.TASKS_COLUMN_DUEDATE, dateString);
|
||||
long insertId;
|
||||
if (id == 0)
|
||||
insertId = database.insert(DatabaseHelper.TASKS_TABLE_NAME, null, values);
|
||||
@@ -92,7 +101,7 @@ public class TaskDataAccess implements AutoCloseable {
|
||||
return tasks;
|
||||
}
|
||||
|
||||
public Cursor getAllTasksCursor(long id) {
|
||||
private Cursor getAllTasksCursor(long id) {
|
||||
return database.query(DatabaseHelper.TASKS_TABLE_NAME, taskColumns,
|
||||
DatabaseHelper.TASKS_COLUMN_LIST + " = " + id +
|
||||
" AND " + DatabaseHelper.TASKS_COLUMN_DONE + " = " + 0 +
|
||||
@@ -102,22 +111,23 @@ public class TaskDataAccess implements AutoCloseable {
|
||||
}
|
||||
|
||||
public int setDone(long id) {
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put(DatabaseHelper.TASKS_COLUMN_DONE, 1);
|
||||
return database.update(DatabaseHelper.TASKS_TABLE_NAME, contentValues, DatabaseHelper.COLUMN_ID + " = " + id, null);
|
||||
return update(id, DatabaseHelper.TASKS_COLUMN_DONE, 1);
|
||||
}
|
||||
|
||||
public int increaseCycle(int newCycle, long id) {
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put(DatabaseHelper.TASKS_COLUMN_CYCLE, newCycle);
|
||||
return database.update(DatabaseHelper.TASKS_TABLE_NAME, contentValues, DatabaseHelper.COLUMN_ID + " = " + id, null);
|
||||
return update(id, DatabaseHelper.TASKS_COLUMN_CYCLE, newCycle);
|
||||
}
|
||||
|
||||
public int deleteTask(long id) {
|
||||
/*database.delete(DatabaseHelper.TASKS_TABLE_NAME,
|
||||
DatabaseHelper.COLUMN_ID + " = " + taskId, null);*/
|
||||
return update(id, DatabaseHelper.TASKS_COLUMN_DELETED, 1);
|
||||
}
|
||||
|
||||
private int update(long id, String column, Object value) {
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put(DatabaseHelper.TASKS_COLUMN_DELETED, 1);
|
||||
if (value instanceof Integer)
|
||||
contentValues.put(column, (int) value);
|
||||
return database.update(DatabaseHelper.TASKS_TABLE_NAME, contentValues, DatabaseHelper.COLUMN_ID + " = " + id, null);
|
||||
}
|
||||
|
||||
@@ -131,6 +141,7 @@ public class TaskDataAccess implements AutoCloseable {
|
||||
task.setDone(cursor.getInt(5));
|
||||
task.setDeleted(cursor.getInt(6));
|
||||
task.setTaskList(cursor.getLong(7));
|
||||
task.setDueDate(cursor.getString(8));
|
||||
return task;
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,8 @@ public class TaskListDataAccess {
|
||||
private SQLiteDatabase database;
|
||||
private DatabaseHelper dbHelper;
|
||||
private String[] taskListColumns =
|
||||
{DatabaseHelper.COLUMN_ID, DatabaseHelper.TASKLIST_COLUMN_NAME, DatabaseHelper.COLUMN_ORDER};
|
||||
{DatabaseHelper.COLUMN_ID, DatabaseHelper.TASKLIST_COLUMN_NAME,
|
||||
DatabaseHelper.COLUMN_ORDER, DatabaseHelper.TASKLIST_COLUMN_VISIBLE};
|
||||
|
||||
public TaskListDataAccess(Context context) {
|
||||
dbHelper = new DatabaseHelper(context);
|
||||
@@ -35,9 +36,14 @@ public class TaskListDataAccess {
|
||||
}
|
||||
|
||||
public TaskList createTaskList(String name, int order) {
|
||||
return createTaskList(name, order, true);
|
||||
}
|
||||
|
||||
public TaskList createTaskList(String name, int order, Boolean visible) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(DatabaseHelper.TASKLIST_COLUMN_NAME, name);
|
||||
values.put(DatabaseHelper.COLUMN_ORDER, order);
|
||||
values.put(DatabaseHelper.TASKLIST_COLUMN_VISIBLE, visible ? 1 : 0);
|
||||
long insertId = database.insert(DatabaseHelper.TASKLIST_TABLE_NAME, null,
|
||||
values);
|
||||
Cursor cursor = database.query(DatabaseHelper.TASKLIST_TABLE_NAME,
|
||||
@@ -59,22 +65,32 @@ public class TaskListDataAccess {
|
||||
}
|
||||
|
||||
public void updateOrder(long id, int order) {
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put(DatabaseHelper.COLUMN_ORDER, order);
|
||||
database.update(DatabaseHelper.TASKLIST_TABLE_NAME, contentValues, DatabaseHelper.COLUMN_ID + " = " + id, null);
|
||||
update(id, DatabaseHelper.COLUMN_ORDER, order);
|
||||
}
|
||||
|
||||
public void updateName(long id, String name) {
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put(DatabaseHelper.TASKLIST_COLUMN_NAME, name);
|
||||
database.update(DatabaseHelper.TASKLIST_TABLE_NAME, contentValues, DatabaseHelper.COLUMN_ID + " = " + id, null);
|
||||
update(id, DatabaseHelper.TASKLIST_COLUMN_NAME, name);
|
||||
}
|
||||
|
||||
public void updateVisibility(long id, boolean visible){
|
||||
update(id, DatabaseHelper.TASKLIST_COLUMN_VISIBLE, visible ? 1 : 0);
|
||||
}
|
||||
|
||||
public TaskList getTaskListByName(String name) {
|
||||
Cursor cursor = getTaskListByNameCursor(name);
|
||||
TaskList taskList = null;
|
||||
if (cursor.getCount() > 0) {
|
||||
cursor.moveToFirst();
|
||||
taskList = cursorToTaskList(cursor);
|
||||
cursor.close();
|
||||
}
|
||||
return taskList;
|
||||
}
|
||||
|
||||
public List<TaskList> getAllTaskLists() {
|
||||
List<TaskList> taskLists = new ArrayList<>();
|
||||
|
||||
Cursor cursor = getAllTaskListsCursor();
|
||||
|
||||
cursor.moveToFirst();
|
||||
while (!cursor.isAfterLast()) {
|
||||
TaskList taskList = cursorToTaskList(cursor);
|
||||
@@ -86,13 +102,28 @@ public class TaskListDataAccess {
|
||||
return taskLists;
|
||||
}
|
||||
|
||||
public Cursor getAllTaskListsCursor() {
|
||||
private void update(long id, String column, Object value)
|
||||
{
|
||||
ContentValues contentValues = new ContentValues();
|
||||
if (value instanceof String)
|
||||
contentValues.put(column, (String) value);
|
||||
if (value instanceof Integer)
|
||||
contentValues.put(column, (int) value);
|
||||
database.update(DatabaseHelper.TASKLIST_TABLE_NAME, contentValues, DatabaseHelper.COLUMN_ID + " = " + id, null);
|
||||
}
|
||||
|
||||
private Cursor getTaskListByNameCursor(String name) {
|
||||
return database.query(true, DatabaseHelper.TASKLIST_TABLE_NAME, taskListColumns,
|
||||
DatabaseHelper.TASKLIST_COLUMN_NAME + " = '" + name + "'", null, null, null, null, null);
|
||||
}
|
||||
private Cursor getAllTaskListsCursor() {
|
||||
return database.rawQuery("SELECT *," +
|
||||
" (SELECT COUNT(*) " +
|
||||
" FROM " + DatabaseHelper.TASKS_TABLE_NAME +
|
||||
" WHERE " + DatabaseHelper.TASKS_TABLE_NAME + "." + DatabaseHelper.TASKS_COLUMN_LIST + " = " +
|
||||
DatabaseHelper.TASKLIST_TABLE_NAME + "." + DatabaseHelper.COLUMN_ID + ") AS " + DatabaseHelper.TASKLIST_COLUMN_TASK_COUNT +
|
||||
" FROM " + DatabaseHelper.TASKLIST_TABLE_NAME +
|
||||
" WHERE " + DatabaseHelper.TASKLIST_COLUMN_VISIBLE + " = " + 1 +
|
||||
" ORDER BY " + DatabaseHelper.COLUMN_ORDER + " ASC ",
|
||||
null);
|
||||
}
|
||||
@@ -102,8 +133,11 @@ public class TaskListDataAccess {
|
||||
taskList.setId(cursor.getLong(0));
|
||||
taskList.setName(cursor.getString(1));
|
||||
taskList.setOrder(cursor.getInt(2));
|
||||
if (cursor.getColumnCount() == 4)
|
||||
taskList.setTaskCount(cursor.getLong(3));
|
||||
taskList.setVisible(cursor.getInt(3));
|
||||
// Get "false" count column if it exists
|
||||
if (cursor.getColumnCount() == 5)
|
||||
taskList.setTaskCount(cursor.getLong(4));
|
||||
return taskList;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -70,6 +70,10 @@ public class TaskListsFragment extends Fragment implements
|
||||
editText.setError(getResources().getString(R.string.task_list_new_list_error));
|
||||
return;
|
||||
}
|
||||
else if (text.matches(getString(R.string.task_list_today))) {
|
||||
editText.setError(getResources().getString(R.string.task_list_today_list_error));
|
||||
return;
|
||||
}
|
||||
int position = taskListRecyclerViewAdapter.getItemCount();
|
||||
|
||||
TaskList taskList = taskListDataAccess.createTaskList(text, position);
|
||||
@@ -101,7 +105,7 @@ public class TaskListsFragment extends Fragment implements
|
||||
LinearLayout layout = (LinearLayout) view.findViewById(R.id.new_task_list_layout);
|
||||
int taskListCount = taskListRecyclerViewAdapter.getItemCount();
|
||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
String maxTaskListsString = sharedPref.getString("pref_conf_max_lists", "3");
|
||||
String maxTaskListsString = sharedPref.getString("pref_conf_max_lists", "5");
|
||||
int maxTaskLists = Integer.valueOf(maxTaskListsString);
|
||||
if (taskListCount >= maxTaskLists) layout.setVisibility(View.GONE);
|
||||
else layout.setVisibility(View.VISIBLE);
|
||||
@@ -192,7 +196,7 @@ public class TaskListsFragment extends Fragment implements
|
||||
protected void onPostExecute(List<TaskList> taskLists) {
|
||||
super.onPostExecute(taskLists);
|
||||
taskListRecyclerViewAdapter =
|
||||
new TaskListRecyclerViewAdapter(taskLists, TaskListsFragment.this);
|
||||
new TaskListRecyclerViewAdapter(taskLists, TaskListsFragment.this, getString(R.string.task_list_today));
|
||||
|
||||
// Set the adapter
|
||||
Context context = mView.getContext();
|
||||
|
7
DoNExt/app/src/main/res/values-fr/arrays.xml
Normal file
7
DoNExt/app/src/main/res/values-fr/arrays.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="settings_today_actions">
|
||||
<item>Terminé</item>
|
||||
<item>Supprimé</item>
|
||||
</string-array>
|
||||
</resources>
|
@@ -63,4 +63,10 @@
|
||||
<string name="task_total">%1$d tâche%2$s</string>
|
||||
<string name="task_total_cycles">%1$d cycle%2$s</string>
|
||||
<string name="title_activity_task_list">TaskListActivity</string>
|
||||
<string name="settings_today_title">Liste Aujourd\'hui</string>
|
||||
<string name="settings_today_enable">Activer la liste Aujourd\'hui?</string>
|
||||
<string name="settings_today_desc">La liste Aujourd\'hui est une liste spéciale, dans laquelle les tâches n\'existent que pour la journée en cours. Chaque jour, cette liste est réinitialisée.</string>
|
||||
<string name="task_list_today">Aujourd\'hui</string>
|
||||
<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>
|
||||
</resources>
|
28
DoNExt/app/src/main/res/values/arrays.xml
Normal file
28
DoNExt/app/src/main/res/values/arrays.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="settings_max_lists_number" translatable="false">
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
<item>6</item>
|
||||
<item>7</item>
|
||||
</string-array>
|
||||
<string-array name="settings_task_layouts">
|
||||
<item>Simple</item>
|
||||
<item>Detailed</item>
|
||||
</string-array>
|
||||
<string-array name="settings_task_layout_values" translatable="false">
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
<string-array name="settings_today_actions">
|
||||
<item>Done</item>
|
||||
<item>Delete</item>
|
||||
</string-array>
|
||||
<string-array name="settings_today_action_values" translatable="false">
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
</resources>
|
@@ -69,28 +69,18 @@
|
||||
<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" translatable="false">
|
||||
<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" translatable="false">
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
<item>6</item>
|
||||
<item>7</item>
|
||||
</string-array>
|
||||
<string name="title_activity_task_list">TaskListActivity</string>
|
||||
|
||||
<!-- 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_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>
|
||||
<string name="settings_today_desc">The Today list is a special kind of list, in which tasks only exist for the current day. Each day, the list is reset.</string>
|
||||
<string name="task_list_today">Today</string>
|
||||
<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>
|
||||
</resources>
|
||||
|
@@ -35,5 +35,22 @@
|
||||
android:entryValues="@array/settings_max_lists_number"
|
||||
android:summary="%s"
|
||||
android:defaultValue="5" />
|
||||
<PreferenceScreen
|
||||
android:title="@string/settings_today_title">
|
||||
<PreferenceCategory
|
||||
android:title="@string/settings_today_title" />
|
||||
<SwitchPreference
|
||||
android:key="pref_conf_today_enable"
|
||||
android:title="@string/settings_today_enable"
|
||||
android:summary="@string/settings_today_desc"/>
|
||||
<ListPreference
|
||||
android:key="pref_conf_today_action"
|
||||
android:title="@string/settings_today_action_title"
|
||||
android:dialogTitle="@string/settings_today_title"
|
||||
android:entries="@array/settings_today_actions"
|
||||
android:entryValues="@array/settings_today_action_values"
|
||||
android:summary="%s"
|
||||
android:defaultValue="0" />
|
||||
</PreferenceScreen>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
Reference in New Issue
Block a user