Big change in the Today function: not a list anymore but a view, shown in the Toolbar
Layout enhancements (Coordinator Layout and Floating Action Button) in Tasks Fragment Code refactoring
7
DoNExt/.idea/dictionaries/bg45.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="bg45">
|
||||
<words>
|
||||
<w>geoffroy</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
</component>
|
2
DoNExt/.idea/misc.xml
generated
@@ -37,7 +37,7 @@
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
@@ -8,8 +8,8 @@ android {
|
||||
applicationId "com.wismna.geoffroy.donext"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 25
|
||||
versionCode 14
|
||||
versionName "1.3.0"
|
||||
versionCode 15
|
||||
versionName "1.4.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
@@ -21,7 +21,6 @@ android {
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:appcompat-v7:25.3.0'
|
||||
compile 'com.android.support:design:25.3.0'
|
||||
compile 'com.android.support:support-v4:25.3.0'
|
||||
@@ -29,4 +28,5 @@ dependencies {
|
||||
compile 'com.android.support:recyclerview-v7:25.3.0'
|
||||
compile 'com.google.android.gms:play-services-ads:10.2.0'
|
||||
compile 'net.danlew:android.joda:2.9.7'
|
||||
testCompile 'junit:junit:4.12'
|
||||
}
|
||||
|
@@ -1,26 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.wismna.geoffroy.donext">
|
||||
|
||||
<supports-screens
|
||||
android:largeScreens="true"
|
||||
android:smallScreens="true">
|
||||
</supports-screens>
|
||||
android:smallScreens="true" />
|
||||
|
||||
<application
|
||||
android:name=".DoNext"
|
||||
android:allowBackup="true"
|
||||
android:fullBackupContent="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:allowBackup="true"
|
||||
android:fullBackupContent="true">
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".activities.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateAlwaysHidden">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
@@ -48,5 +50,15 @@
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activities.MainActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activities.TodayActivity"
|
||||
android:label="@string/title_activity_today"
|
||||
android:parentActivityName=".activities.MainActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activities.MainActivity" />
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
</manifest>
|
@@ -6,7 +6,6 @@ import android.graphics.Point;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.TabLayout;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
@@ -69,9 +68,6 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas
|
||||
SharedPreferences sharedPref =
|
||||
PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
|
||||
|
||||
// Handle Today list
|
||||
handleTodayList(sharedPref);
|
||||
|
||||
// Access database to retrieve Tabs
|
||||
try (TaskListDataAccess taskListDataAccess = new TaskListDataAccess(this)) {
|
||||
taskLists = taskListDataAccess.getAllTaskLists();
|
||||
@@ -121,9 +117,6 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas
|
||||
}
|
||||
});
|
||||
}
|
||||
// Hide or show new task floating button
|
||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
fab.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,19 +136,24 @@ 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;
|
||||
// Handles layout change button
|
||||
MenuItem displayLayoutItem = menu.findItem(R.id.action_changeLayout);
|
||||
if (displayLayoutItem == null) return false;
|
||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
String layoutType = sharedPref.getString("pref_conf_task_layout", "1");
|
||||
switch (layoutType) {
|
||||
case "1" :
|
||||
item.setIcon(R.drawable.ic_list_white_24dp);
|
||||
displayLayoutItem.setIcon(R.drawable.ic_list_white_24dp);
|
||||
break;
|
||||
case "2" :
|
||||
item.setIcon(R.drawable.ic_view_list_white_24dp);
|
||||
displayLayoutItem.setIcon(R.drawable.ic_view_list_white_24dp);
|
||||
break;
|
||||
}
|
||||
|
||||
// Handles today list
|
||||
MenuItem todayListItem = menu.findItem(R.id.action_todayList);
|
||||
todayListItem.setVisible(sharedPref.getBoolean("pref_conf_today_enable", false));
|
||||
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@@ -191,9 +189,11 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas
|
||||
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
// Set current tab value to new task dialog
|
||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("list", currentTabPosition);
|
||||
args.putBoolean("layout", mIsLargeLayout);
|
||||
args.putBoolean("today", sharedPref.getBoolean("pref_conf_today_enable", false));
|
||||
taskDialogFragment.setArguments(args);
|
||||
|
||||
String title = getString(R.string.action_new_task);
|
||||
@@ -211,6 +211,12 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas
|
||||
}
|
||||
}
|
||||
|
||||
/** Called when the user clicks on the Today List button */
|
||||
public void showTodayList(MenuItem item) {
|
||||
Intent intent = new Intent(this, TodayActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
/** Called when the user clicks on the Change Layout button */
|
||||
public void changeLayout(MenuItem item) {
|
||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
@@ -273,27 +279,6 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas
|
||||
}
|
||||
}
|
||||
|
||||
private void handleTodayList(SharedPreferences sharedPref) {
|
||||
String todayListName = getString(R.string.task_list_today);
|
||||
try (TaskListDataAccess taskListDataAccess = new TaskListDataAccess(this, TaskListDataAccess.MODE.WRITE)) {
|
||||
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);
|
||||
} else {
|
||||
// Hide the today list if it exists
|
||||
if (todayList != null) {
|
||||
taskListDataAccess.updateVisibility(todayList.getId(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
|
||||
* one of the sections/tabs/pages.
|
||||
@@ -309,8 +294,7 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas
|
||||
// getItem is called to instantiate the fragment for the given page.
|
||||
// Return a PlaceholderFragment (defined as a static inner class below).
|
||||
TaskList taskList = taskLists.get(position);
|
||||
return TasksFragment.newInstance(taskList.getId(),
|
||||
taskList.getName().equals(getString(R.string.task_list_today)), MainActivity.this);
|
||||
return TasksFragment.newTaskListInstance(taskList.getId(), MainActivity.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -0,0 +1,31 @@
|
||||
package com.wismna.geoffroy.donext.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
|
||||
import com.wismna.geoffroy.donext.R;
|
||||
|
||||
public class TodayActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_today);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
// Get a support ActionBar corresponding to this toolbar
|
||||
ActionBar ab = getSupportActionBar();
|
||||
|
||||
if (ab != null) {
|
||||
// Enable the Up button
|
||||
ab.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void onNewTaskClick(View view) {
|
||||
}
|
||||
}
|
@@ -17,7 +17,6 @@ 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}.
|
||||
@@ -35,14 +34,11 @@ 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,
|
||||
String reservedTaskListName) {
|
||||
TaskListRecyclerViewAdapterListener listener) {
|
||||
mValues = items;
|
||||
mListener = listener;
|
||||
mReservedTaskListName = reservedTaskListName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,10 +66,8 @@ public class TaskListRecyclerViewAdapter extends RecyclerView.Adapter<TaskListRe
|
||||
}
|
||||
});
|
||||
|
||||
Boolean isReservedName = Objects.equals(holder.mItem.getName(), mReservedTaskListName);
|
||||
holder.mTaskNameView.setEnabled(!isReservedName);
|
||||
// Handle inline name change
|
||||
if (!isReservedName) holder.mTaskNameView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
holder.mTaskNameView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
EditText editText = (EditText) v;
|
||||
@@ -88,9 +82,8 @@ public class TaskListRecyclerViewAdapter extends RecyclerView.Adapter<TaskListRe
|
||||
}
|
||||
});
|
||||
|
||||
holder.mTaskDeleteButton.setEnabled(!isReservedName);
|
||||
// Handle click on delete button
|
||||
if (!isReservedName) holder.mTaskDeleteButton.setOnClickListener(new View.OnClickListener() {
|
||||
holder.mTaskDeleteButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// Disable the OnFocusChanged listener as it is now pointless and harmful
|
||||
|
@@ -17,6 +17,7 @@ public class Task {
|
||||
private long taskList;
|
||||
private String taskListName;
|
||||
private LocalDate dueDate;
|
||||
private LocalDate todayDate;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
@@ -103,6 +104,19 @@ public class Task {
|
||||
return dueDate;
|
||||
}
|
||||
|
||||
public void setTodayDate(String todayDate) {
|
||||
try {
|
||||
this.todayDate = LocalDate.parse(todayDate);
|
||||
}
|
||||
catch (Exception e){
|
||||
this.todayDate = null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isToday() {
|
||||
return todayDate!= null && todayDate.isEqual(LocalDate.now());
|
||||
}
|
||||
|
||||
// Will be used by the ArrayAdapter in the ListView
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@@ -9,7 +9,7 @@ import android.database.sqlite.SQLiteOpenHelper;
|
||||
* Database helper class that contains table and column names as well as handles database creation
|
||||
*/
|
||||
class DatabaseHelper extends SQLiteOpenHelper {
|
||||
private static final int DATABASE_VERSION = 3;
|
||||
private static final int DATABASE_VERSION = 4;
|
||||
private static final String DATABASE_NAME = "donext.db";
|
||||
static final String COLUMN_ID = "_id";
|
||||
static final String COLUMN_ORDER = "displayorder";
|
||||
@@ -35,6 +35,7 @@ class DatabaseHelper extends SQLiteOpenHelper {
|
||||
static final String TASKS_COLUMN_DELETED= "deleted";
|
||||
static final String TASKS_COLUMN_LIST = "list";
|
||||
static final String TASKS_COLUMN_DUEDATE = "duedate";
|
||||
static final String TASKS_COLUMN_TODAYDATE = "todaydate";
|
||||
private static final String TASKS_TABLE_CREATE =
|
||||
"CREATE TABLE " + TASKS_TABLE_NAME + " (" +
|
||||
COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
@@ -49,8 +50,14 @@ class DatabaseHelper extends SQLiteOpenHelper {
|
||||
"FOREIGN KEY(" + TASKS_COLUMN_LIST + ") REFERENCES " +
|
||||
TASKLIST_TABLE_NAME + "(" + COLUMN_ID + ")" +
|
||||
TASKS_COLUMN_DUEDATE + " DATE, " +
|
||||
TASKS_COLUMN_TODAYDATE + " DATE " +
|
||||
");";
|
||||
|
||||
static final String TASKS_VIEW_TODAY_NAME = "today";
|
||||
private static final String TASKS_VIEW_TODAY_CREATE =
|
||||
"CREATE VIEW IF NOT EXISTS " + TASKS_VIEW_TODAY_NAME + " AS" +
|
||||
" SELECT * FROM " + TASKS_TABLE_NAME +
|
||||
" WHERE " + TASKS_COLUMN_TODAYDATE + " = date('now')";
|
||||
DatabaseHelper(Context context) {
|
||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||
}
|
||||
@@ -59,21 +66,26 @@ class DatabaseHelper extends SQLiteOpenHelper {
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
db.execSQL(TASKLIST_TABLE_CREATE);
|
||||
db.execSQL(TASKS_TABLE_CREATE);
|
||||
db.execSQL(TASKS_VIEW_TODAY_CREATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
if (oldVersion == 1)
|
||||
{
|
||||
// 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");
|
||||
// Fall-through is intended
|
||||
switch (oldVersion) {
|
||||
case 1:
|
||||
// Add new Order column
|
||||
db.execSQL("ALTER TABLE " + TASKLIST_TABLE_NAME + " ADD COLUMN " + COLUMN_ORDER + " INTEGER");
|
||||
case 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");
|
||||
case 3:
|
||||
// Add new Today Date column
|
||||
db.execSQL("ALTER TABLE " + TASKS_TABLE_NAME + " ADD COLUMN " + TASKS_COLUMN_TODAYDATE + " DATE");
|
||||
// Create the Today view
|
||||
db.execSQL(TASKS_VIEW_TODAY_CREATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ public class TaskDataAccess implements AutoCloseable {
|
||||
DatabaseHelper.TASKS_COLUMN_DESC, DatabaseHelper.TASKS_COLUMN_PRIORITY,
|
||||
DatabaseHelper.TASKS_COLUMN_CYCLE, DatabaseHelper.TASKS_COLUMN_DONE,
|
||||
DatabaseHelper.TASKS_COLUMN_DELETED, DatabaseHelper.TASKS_COLUMN_LIST,
|
||||
DatabaseHelper.TASKS_COLUMN_DUEDATE};
|
||||
DatabaseHelper.TASKS_COLUMN_DUEDATE, DatabaseHelper.TASKS_COLUMN_TODAYDATE};
|
||||
|
||||
public TaskDataAccess(Context context) {
|
||||
this(context, MODE.READ);
|
||||
@@ -50,16 +50,15 @@ public class TaskDataAccess implements AutoCloseable {
|
||||
}
|
||||
|
||||
/** Adds or update a task in the database */
|
||||
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, int priority, long taskList, LocalDate date) {
|
||||
public Task createOrUpdateTask(long id, String name, String description, int priority,
|
||||
long taskList, LocalDate date, boolean isTodayList) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(DatabaseHelper.TASKS_COLUMN_NAME, name);
|
||||
values.put(DatabaseHelper.TASKS_COLUMN_DESC, description);
|
||||
values.put(DatabaseHelper.TASKS_COLUMN_PRIORITY, priority);
|
||||
values.put(DatabaseHelper.TASKS_COLUMN_LIST, taskList);
|
||||
values.put(DatabaseHelper.TASKS_COLUMN_DUEDATE, date.toString());
|
||||
values.put(DatabaseHelper.TASKS_COLUMN_TODAYDATE, isTodayList? LocalDate.now().toString() : "");
|
||||
long insertId;
|
||||
if (id == 0)
|
||||
insertId = database.insert(DatabaseHelper.TASKS_TABLE_NAME, null, values);
|
||||
@@ -76,6 +75,7 @@ public class TaskDataAccess implements AutoCloseable {
|
||||
return newTask;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int updateExpiredTasks(int action, long taskListId){
|
||||
String column = DatabaseHelper.TASKS_COLUMN_DELETED;
|
||||
if (action == 1)
|
||||
@@ -91,28 +91,22 @@ public class TaskDataAccess implements AutoCloseable {
|
||||
}
|
||||
|
||||
public List<Task> getAllTasks(long id) {
|
||||
List<Task> tasks = new ArrayList<>();
|
||||
|
||||
Cursor cursor = getAllTasksCursor(id);
|
||||
|
||||
cursor.moveToFirst();
|
||||
while (!cursor.isAfterLast()) {
|
||||
Task task = cursorToTask(cursor);
|
||||
tasks.add(task);
|
||||
cursor.moveToNext();
|
||||
}
|
||||
// make sure to close the cursor
|
||||
cursor.close();
|
||||
return tasks;
|
||||
}
|
||||
|
||||
private Cursor getAllTasksCursor(long id) {
|
||||
return database.query(DatabaseHelper.TASKS_TABLE_NAME, taskColumns,
|
||||
Cursor cursor = database.query(DatabaseHelper.TASKS_TABLE_NAME, taskColumns,
|
||||
DatabaseHelper.TASKS_COLUMN_LIST + " = " + id +
|
||||
" AND " + DatabaseHelper.TASKS_COLUMN_DONE + " = " + 0 +
|
||||
" AND " + DatabaseHelper.TASKS_COLUMN_DELETED + " = " + 0,
|
||||
" AND " + DatabaseHelper.TASKS_COLUMN_DONE + " = " + 0 +
|
||||
" AND " + DatabaseHelper.TASKS_COLUMN_DELETED + " = " + 0,
|
||||
null, null, null,
|
||||
DatabaseHelper.TASKS_COLUMN_CYCLE + ", " + DatabaseHelper.COLUMN_ID + " DESC");
|
||||
return getTasksFromCursor(cursor);
|
||||
}
|
||||
|
||||
public List<Task> getTodayTasks() {
|
||||
Cursor cursor = database.query(DatabaseHelper.TASKS_VIEW_TODAY_NAME, taskColumns,
|
||||
DatabaseHelper.TASKS_COLUMN_DONE + " = " + 0 +
|
||||
" AND " + DatabaseHelper.TASKS_COLUMN_DELETED + " = " + 0,
|
||||
null, null, null,
|
||||
DatabaseHelper.TASKS_COLUMN_CYCLE + ", " + DatabaseHelper.COLUMN_ID + " DESC");
|
||||
return getTasksFromCursor(cursor);
|
||||
}
|
||||
|
||||
public int setDone(long id) {
|
||||
@@ -147,6 +141,21 @@ public class TaskDataAccess implements AutoCloseable {
|
||||
task.setDeleted(cursor.getInt(6));
|
||||
task.setTaskList(cursor.getLong(7));
|
||||
task.setDueDate(cursor.getString(8));
|
||||
task.setTodayDate(cursor.getString(9));
|
||||
return task;
|
||||
}
|
||||
|
||||
private List<Task> getTasksFromCursor(Cursor cursor) {
|
||||
List<Task> tasks = new ArrayList<>();
|
||||
|
||||
cursor.moveToFirst();
|
||||
while (!cursor.isAfterLast()) {
|
||||
Task task = cursorToTask(cursor);
|
||||
tasks.add(task);
|
||||
cursor.moveToNext();
|
||||
}
|
||||
// make sure to close the cursor
|
||||
cursor.close();
|
||||
return tasks;
|
||||
}
|
||||
}
|
||||
|
@@ -18,13 +18,14 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.EditText;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.wismna.geoffroy.donext.R;
|
||||
import com.wismna.geoffroy.donext.dao.Task;
|
||||
@@ -210,28 +211,18 @@ public class TaskDialogFragment extends DialogFragment {
|
||||
// Specify the layout to use when the list of choices appears
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
spinner.setAdapter(adapter);
|
||||
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
// Set due date
|
||||
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) {}
|
||||
});
|
||||
|
||||
// Auto set list value to current tab
|
||||
Bundle args = getArguments();
|
||||
int id = args.getInt("list");
|
||||
spinner.setSelection(id);
|
||||
|
||||
CheckBox checkBox = (CheckBox) view.findViewById(R.id.new_task_today);
|
||||
TextView todayLabel = (TextView) view.findViewById(R.id.new_task_today_label);
|
||||
boolean isTodayActive = args.getBoolean("today");
|
||||
checkBox.setVisibility(isTodayActive ? View.VISIBLE : View.GONE);
|
||||
todayLabel.setVisibility(isTodayActive ? View.VISIBLE : View.GONE);
|
||||
|
||||
// Set other properties if they exist
|
||||
if (task != null) {
|
||||
|
||||
@@ -245,6 +236,8 @@ public class TaskDialogFragment extends DialogFragment {
|
||||
// Set Due Date
|
||||
LocalDate dueDate = task.getDueDate();
|
||||
dueDatePicker.updateDate(dueDate.getYear(), dueDate.getMonthOfYear() - 1, dueDate.getDayOfMonth());
|
||||
|
||||
checkBox.setChecked(task.isToday());
|
||||
}
|
||||
else {
|
||||
// Disallow past dates on new tasks
|
||||
|
@@ -70,10 +70,6 @@ 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);
|
||||
@@ -196,7 +192,7 @@ public class TaskListsFragment extends Fragment implements
|
||||
protected void onPostExecute(List<TaskList> taskLists) {
|
||||
super.onPostExecute(taskLists);
|
||||
taskListRecyclerViewAdapter =
|
||||
new TaskListRecyclerViewAdapter(taskLists, TaskListsFragment.this, getString(R.string.task_list_today));
|
||||
new TaskListRecyclerViewAdapter(taskLists, TaskListsFragment.this);
|
||||
|
||||
// Set the adapter
|
||||
Context context = mView.getContext();
|
||||
|
@@ -30,6 +30,7 @@ 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.helpers.TaskTouchHelper;
|
||||
import com.wismna.geoffroy.donext.listeners.RecyclerItemClickListener;
|
||||
import com.wismna.geoffroy.donext.widgets.DividerItemDecoration;
|
||||
@@ -37,6 +38,8 @@ import com.wismna.geoffroy.donext.widgets.NoScrollingLayoutManager;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A fragment representing a list of Items.
|
||||
*/
|
||||
@@ -50,10 +53,9 @@ public class TasksFragment extends Fragment implements
|
||||
}
|
||||
|
||||
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 boolean clearExpiredTasks = false;
|
||||
private boolean mIsLargeLayout;
|
||||
private boolean isTodayView = true;
|
||||
private TaskRecyclerViewAdapter taskRecyclerViewAdapter;
|
||||
private View view;
|
||||
private RecyclerView recyclerView;
|
||||
@@ -67,13 +69,13 @@ public class TasksFragment extends Fragment implements
|
||||
public TasksFragment() {
|
||||
}
|
||||
|
||||
public static TasksFragment newInstance(long taskListId, boolean clearExpiredTasks, TaskChangedAdapter taskChangedAdapter) {
|
||||
public static TasksFragment newTaskListInstance(long taskListId, 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.isTodayView = false;
|
||||
fragment.setRetainInstance(true);
|
||||
return fragment;
|
||||
}
|
||||
@@ -85,7 +87,6 @@ public class TasksFragment extends Fragment implements
|
||||
mIsLargeLayout = getResources().getBoolean(R.bool.large_layout);
|
||||
if (getArguments() != null) {
|
||||
taskListId = getArguments().getLong(TASK_LIST_ID);
|
||||
clearExpiredTasks = getArguments().getBoolean(CLEAR_EXPIRED_TASKS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,17 +103,10 @@ public class TasksFragment extends Fragment implements
|
||||
// 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),
|
||||
isTodayView? taskDataAccess.getTodayTasks() : taskDataAccess.getAllTasks(taskListId),
|
||||
Integer.valueOf(sharedPref.getString("pref_conf_task_layout", "1")));
|
||||
}
|
||||
recyclerView.setAdapter(taskRecyclerViewAdapter);
|
||||
@@ -127,19 +121,36 @@ public class TasksFragment extends Fragment implements
|
||||
new RecyclerItemClickListener(context, new RecyclerItemClickListener.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("position", position);
|
||||
args.putBoolean("layout", mIsLargeLayout);
|
||||
args.putBoolean("today", sharedPref.getBoolean("pref_conf_today_enable", false));
|
||||
|
||||
// Set current tab value to new task dialog
|
||||
ViewPager viewPager = (ViewPager) getActivity().findViewById(R.id.container);
|
||||
args.putInt("list", viewPager.getCurrentItem());
|
||||
List<TaskList> taskLists;
|
||||
Task task = taskRecyclerViewAdapter.getItem(position);
|
||||
if (viewPager != null) {
|
||||
taskLists = ((MainActivity.SectionsPagerAdapter) viewPager.getAdapter()).getAllItems();
|
||||
args.putInt("list", viewPager.getCurrentItem());
|
||||
}
|
||||
else {
|
||||
try (TaskListDataAccess taskListDataAccess = new TaskListDataAccess(getActivity())) {
|
||||
taskLists = taskListDataAccess.getAllTaskLists();
|
||||
}
|
||||
for (TaskList taskList :
|
||||
taskLists) {
|
||||
if (taskList.getId() == task.getTaskListId()) {
|
||||
args.putInt("list", taskLists.indexOf(taskList));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FragmentManager manager = getFragmentManager();
|
||||
TaskDialogFragment taskDialogFragment = TaskDialogFragment.newInstance(
|
||||
taskRecyclerViewAdapter.getItem(position),
|
||||
((MainActivity.SectionsPagerAdapter) viewPager.getAdapter()).getAllItems(),
|
||||
TasksFragment.this);
|
||||
task, taskLists, TasksFragment.this);
|
||||
taskDialogFragment.setArguments(args);
|
||||
|
||||
// Open the fragment as a dialog or as full-screen depending on screen size
|
||||
@@ -334,6 +345,7 @@ public class TasksFragment extends Fragment implements
|
||||
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();
|
||||
CheckBox todayList = (CheckBox) dialogView.findViewById(R.id.new_task_today);
|
||||
|
||||
// Add the task to the database
|
||||
try (TaskDataAccess taskDataAccess = new TaskDataAccess(view.getContext(), TaskDataAccess.MODE.WRITE)) {
|
||||
@@ -342,7 +354,8 @@ public class TasksFragment extends Fragment implements
|
||||
descText.getText().toString(),
|
||||
seekBar.getProgress(),
|
||||
taskList.getId(),
|
||||
new LocalDate(dueDatePicker.getYear(), dueDatePicker.getMonth() + 1, dueDatePicker.getDayOfMonth()));
|
||||
new LocalDate(dueDatePicker.getYear(), dueDatePicker.getMonth() + 1, dueDatePicker.getDayOfMonth()),
|
||||
todayList.isChecked());
|
||||
|
||||
Bundle args = dialog.getArguments();
|
||||
// Should never happen because we will have to be on this tab to open the dialog
|
||||
@@ -351,7 +364,7 @@ public class TasksFragment extends Fragment implements
|
||||
// Add the task
|
||||
if (task == null) {
|
||||
// If the new task is added to another task list, update the tab
|
||||
if (taskListId != taskList.getId()) {
|
||||
if (mAdapter != null && taskListId != taskList.getId()) {
|
||||
mAdapter.onTaskListChanged(newTask, listSpinner.getSelectedItemPosition());
|
||||
}
|
||||
// Otherwise add it to the current one
|
||||
@@ -364,7 +377,7 @@ public class TasksFragment extends Fragment implements
|
||||
else {
|
||||
int position = args.getInt("position");
|
||||
// Check if task list was changed
|
||||
if (task.getTaskListId() != taskList.getId())
|
||||
if (mAdapter != null && task.getTaskListId() != taskList.getId())
|
||||
{
|
||||
// Remove item from current tab
|
||||
taskRecyclerViewAdapter.remove(position);
|
||||
|
BIN
DoNExt/app/src/main/res/drawable-hdpi-v11/ic_stat_name.png
Normal file
After Width: | Height: | Size: 331 B |
BIN
DoNExt/app/src/main/res/drawable-hdpi-v9/ic_stat_name.png
Normal file
After Width: | Height: | Size: 392 B |
BIN
DoNExt/app/src/main/res/drawable-hdpi/ic_stat_name.png
Normal file
After Width: | Height: | Size: 961 B |
BIN
DoNExt/app/src/main/res/drawable-mdpi-v11/ic_stat_name.png
Normal file
After Width: | Height: | Size: 255 B |
BIN
DoNExt/app/src/main/res/drawable-mdpi-v9/ic_stat_name.png
Normal file
After Width: | Height: | Size: 304 B |
BIN
DoNExt/app/src/main/res/drawable-mdpi/ic_stat_name.png
Normal file
After Width: | Height: | Size: 643 B |
BIN
DoNExt/app/src/main/res/drawable-xhdpi-v11/ic_stat_name.png
Normal file
After Width: | Height: | Size: 351 B |
BIN
DoNExt/app/src/main/res/drawable-xhdpi-v9/ic_stat_name.png
Normal file
After Width: | Height: | Size: 496 B |
BIN
DoNExt/app/src/main/res/drawable-xhdpi/ic_stat_name.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
DoNExt/app/src/main/res/drawable-xxhdpi-v11/ic_stat_name.png
Normal file
After Width: | Height: | Size: 503 B |
BIN
DoNExt/app/src/main/res/drawable-xxhdpi-v9/ic_stat_name.png
Normal file
After Width: | Height: | Size: 620 B |
BIN
DoNExt/app/src/main/res/drawable-xxhdpi/ic_stat_name.png
Normal file
After Width: | Height: | Size: 437 B |
@@ -51,12 +51,4 @@
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:onClick="onNewTaskClick"
|
||||
android:src="@drawable/ic_add_white_24dp" />
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
31
DoNExt/app/src/main/res/layout/activity_today.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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"
|
||||
tools:context="com.wismna.geoffroy.donext.activities.TodayActivity">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/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>
|
||||
|
||||
<fragment
|
||||
android:name="com.wismna.geoffroy.donext.fragments.TasksFragment"
|
||||
android:id="@+id/fragment_task_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:layout="@layout/fragment_tasks" />
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
@@ -77,6 +77,20 @@
|
||||
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_today_label"
|
||||
android:text="@string/new_task_today"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_below="@id/new_task_priority" />
|
||||
<CheckBox
|
||||
android:id="@+id/new_task_today"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toEndOf="@id/new_task_today_label"
|
||||
android:layout_below="@id/new_task_priority" />
|
||||
<TextView
|
||||
android:id="@+id/new_task_due_date_label"
|
||||
android:text="@string/new_task_due_date"
|
||||
@@ -84,7 +98,7 @@
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_below="@id/new_task_priority" />
|
||||
android:layout_below="@id/new_task_today" />
|
||||
<DatePicker
|
||||
android:id="@+id/new_task_due_date"
|
||||
android:datePickerMode="spinner"
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.widget.RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<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"
|
||||
@@ -13,7 +13,7 @@
|
||||
android:id="@+id/total_task_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"/>
|
||||
android:layout_gravity="top|center"/>
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/task_list_view"
|
||||
android:layout_width="match_parent"
|
||||
@@ -62,6 +62,15 @@
|
||||
android:id="@+id/remaining_task_count"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_below="@id/task_list_view"/>
|
||||
</android.widget.RelativeLayout>
|
||||
android:layout_gravity="bottom|center"/>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:onClick="onNewTaskClick"
|
||||
android:src="@drawable/ic_add_white_24dp" />
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
@@ -6,4 +6,5 @@
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:layout_scrollFlags="enterAlways"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
|
@@ -8,6 +8,14 @@
|
||||
android:title="@string/action_new_task"
|
||||
android:onClick="openNewTaskDialog"
|
||||
app:showAsAction="never" />-->
|
||||
<item
|
||||
android:id="@+id/action_todayList"
|
||||
android:orderInCategory="15"
|
||||
android:title="@string/action_todayList"
|
||||
android:onClick="showTodayList"
|
||||
android:icon="@drawable/ic_stat_name"
|
||||
android:visible="false"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_changeLayout"
|
||||
android:orderInCategory="20"
|
||||
|
@@ -67,4 +67,7 @@
|
||||
<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>
|
||||
<string name="action_todayList">Vue Aujourd\'hui</string>
|
||||
<string name="title_activity_today">Aujourd\'hui</string>
|
||||
<string name="new_task_today">Ajouter la tâche à la vue Aujourd\'hui?</string>
|
||||
</resources>
|
@@ -85,4 +85,8 @@
|
||||
<string name="about_version_donext">DoNext 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="action_todayList">Today View</string>
|
||||
<string name="title_activity_today">Today</string>
|
||||
<string name="new_task_today">Add task to Today View?</string>
|
||||
<string name="title_activity_main2">Main2Activity</string>
|
||||
</resources>
|
||||
|