diff --git a/DoNExt/app/src/main/AndroidManifest.xml b/DoNExt/app/src/main/AndroidManifest.xml
index d57f787..d3c026f 100644
--- a/DoNExt/app/src/main/AndroidManifest.xml
+++ b/DoNExt/app/src/main/AndroidManifest.xml
@@ -20,8 +20,15 @@
+ android:label="@string/settings_activity_title"
+ android:parentActivityName=".MainActivity">
+
+
+
diff --git a/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/DatabaseHelper.java b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/DatabaseHelper.java
new file mode 100644
index 0000000..35ffd03
--- /dev/null
+++ b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/DatabaseHelper.java
@@ -0,0 +1,58 @@
+package com.wismna.geoffroy.donext;
+
+import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+
+/**
+ * Created by geoffroy on 15-11-25.
+ */
+public class DatabaseHelper extends SQLiteOpenHelper {
+ private static final int DATABASE_VERSION = 1;
+ private static final String DATABASE_NAME = "donext.db";
+ public static final String COLUMN_ID = "_id";
+
+ public static final String TASKLIST_TABLE_NAME = "tasklist";
+ public static final String TASKLIST_COLUMN_NAME = "name";
+ private static final String TASKLIST_TABLE_CREATE =
+ "CREATE TABLE " + TASKLIST_TABLE_NAME + " (" +
+ COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
+ TASKLIST_COLUMN_NAME + " TEXT NOT NULL);";
+
+ 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";
+ 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_CYCLE + " INTEGER NOT NULL, " +
+ TASKS_COLUMN_DONE + " INTEGER, " +
+ TASKS_COLUMN_DELETED + " INTEGER, " +
+ TASKS_COLUMN_PRIORITY + " INTEGER, " +
+ TASKS_COLUMN_LIST + " INTEGER NOT NULL, " +
+ "FOREIGN KEY(" + TASKS_COLUMN_LIST + ") REFERENCES " +
+ TASKLIST_TABLE_NAME + "(" + COLUMN_ID + ")" +
+ ");";
+
+ DatabaseHelper(Context context) {
+ super(context, DATABASE_NAME, null, DATABASE_VERSION);
+ }
+
+ @Override
+ public void onCreate(SQLiteDatabase db) {
+ db.execSQL(TASKLIST_TABLE_CREATE);
+ db.execSQL(TASKS_TABLE_CREATE);
+ }
+
+ @Override
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+
+ }
+}
diff --git a/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/MainActivity.java b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/MainActivity.java
index 9c73f38..e2fc2da 100644
--- a/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/MainActivity.java
+++ b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/MainActivity.java
@@ -69,6 +69,11 @@ public class MainActivity extends AppCompatActivity {
Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
}
+ /** Called when the user clicks the Edit Lists button */
+ public void openTaskLists(MenuItem menuItem) {
+ Intent intent = new Intent(this, TaskListActivity.class);
+ startActivity(intent);
+ }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
diff --git a/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/Task.java b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/Task.java
new file mode 100644
index 0000000..cc9b5dc
--- /dev/null
+++ b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/Task.java
@@ -0,0 +1,76 @@
+package com.wismna.geoffroy.donext;
+
+/**
+ * Created by geoffroy on 15-11-25.
+ */
+public class Task {
+ private long id;
+ private String name;
+ private String description;
+ private int cycle;
+ private boolean deleted;
+ private long taskList;
+ private String taskListName;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String comment) {
+ this.name = comment;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public int getCycle() {
+ return cycle;
+ }
+
+ public void setCycle(int cycle) {
+ this.cycle = cycle;
+ }
+
+ public boolean isDeleted() {
+ return deleted;
+ }
+
+ public void setDeleted(boolean deleted) {
+ this.deleted = deleted;
+ }
+
+ public long getTaskList() {
+ return taskList;
+ }
+
+ public void setTaskList(long taskList) {
+ this.taskList = taskList;
+ }
+
+ public String getTaskListName() {
+ return taskListName;
+ }
+
+ public void setTaskListName(String taskListName) {
+ this.taskListName = taskListName;
+ }
+
+ // Will be used by the ArrayAdapter in the ListView
+ @Override
+ public String toString() {
+ return name;
+ }
+}
diff --git a/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/TaskList.java b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/TaskList.java
new file mode 100644
index 0000000..6d48db1
--- /dev/null
+++ b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/TaskList.java
@@ -0,0 +1,31 @@
+package com.wismna.geoffroy.donext;
+
+/**
+ * Created by geoffroy on 15-11-25.
+ */
+public class TaskList {
+ private long id;
+ private String name;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String comment) {
+ this.name = comment;
+ }
+
+ // Will be used by the ArrayAdapter in the ListView
+ @Override
+ public String toString() {
+ return name;
+ }
+}
diff --git a/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/TaskListActivity.java b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/TaskListActivity.java
new file mode 100644
index 0000000..757d226
--- /dev/null
+++ b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/TaskListActivity.java
@@ -0,0 +1,74 @@
+package com.wismna.geoffroy.donext;
+
+import android.app.ListActivity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.ListView;
+
+public class TaskListActivity extends ListActivity {
+ private TasksDataAccess dataAccess;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_task_list);
+
+ ListView listView = (ListView) findViewById(android.R.id.list);
+ dataAccess = new TasksDataAccess(this);
+ dataAccess.open();
+
+ //List values = dataAccess.getAllTaskLists();
+
+ // use the SimpleCursorAdapter to show the
+ // elements in a ListView
+ /*ArrayAdapter adapter = new ArrayAdapter(this,
+ android.R.layout.simple_list_item_1, values);
+ setListAdapter(adapter);*/
+
+ TaskListCursorAdapter adapter = new TaskListCursorAdapter(
+ this, R.layout.item_task_list, dataAccess.getAllTaskListsCursor(), 0);
+ listView.setAdapter(adapter);
+ }
+
+ // Will be called when the create Task List button is clicked
+ public void onCreateTaskList(View view) {
+ @SuppressWarnings("unchecked")
+ //ArrayAdapter adapter = (ArrayAdapter) getListAdapter();
+ TaskListCursorAdapter adapter = (TaskListCursorAdapter) getListAdapter();
+ TaskList taskList;
+
+ EditText editText = (EditText) findViewById(R.id.new_task_list_name);
+ // save the new comment to the database
+ taskList = dataAccess.createTaskList(editText.getText().toString());
+ //adapter.add(taskList);
+
+ adapter.notifyDataSetChanged();
+ }
+
+ public void onDeleteTaskList(View view) {
+ @SuppressWarnings("unchecked")
+ //ArrayAdapter adapter = (ArrayAdapter) getListAdapter();
+ TaskListCursorAdapter adapter = (TaskListCursorAdapter) getListAdapter();
+ TaskList taskList;
+
+ if (adapter.getCount() > 0) {
+ taskList = (TaskList) getListAdapter().getItem(0);
+ dataAccess.deleteTaskList(taskList);
+ //adapter.remove(taskList);
+ }
+ adapter.notifyDataSetChanged();
+ }
+
+ @Override
+ protected void onResume() {
+ dataAccess.open();
+ super.onResume();
+ }
+
+ @Override
+ protected void onPause() {
+ dataAccess.close();
+ super.onPause();
+ }
+}
diff --git a/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/TaskListCursorAdapter.java b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/TaskListCursorAdapter.java
new file mode 100644
index 0000000..7b8b119
--- /dev/null
+++ b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/TaskListCursorAdapter.java
@@ -0,0 +1,41 @@
+package com.wismna.geoffroy.donext;
+
+import android.content.Context;
+import android.database.Cursor;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ResourceCursorAdapter;
+import android.widget.TextView;
+
+/**
+ * Created by geoffroy on 15-11-25.
+ */
+public class TaskListCursorAdapter extends ResourceCursorAdapter {
+ public TaskListCursorAdapter(Context context, int layout, Cursor cursor, int flags) {
+ super(context, layout, cursor, flags);
+ }
+
+ // The newView method is used to inflate a new view and return it,
+ // you don't bind any data to the view at this point.
+ @Override
+ public View newView(Context context, Cursor cursor, ViewGroup parent) {
+ return LayoutInflater.from(context).inflate(R.layout.item_task_list, parent, false);
+ }
+
+ // The bindView method is used to bind all data to a given view
+ // such as setting the text on a TextView.
+ @Override
+ public void bindView(View view, Context context, Cursor cursor) {
+ // Find fields to populate in inflated template
+ TextView taskListCount = (TextView) view.findViewById(R.id.task_list_count);
+ TextView taskListName = (TextView) view.findViewById(R.id.task_list_name);
+ // Extract properties from cursor
+ String name = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseHelper.TASKLIST_COLUMN_NAME));
+ // TODO: Update the count when tasks are implemented
+ int count = 0;
+ // Populate fields with extracted properties
+ taskListCount.setText(String.valueOf(count));
+ taskListName.setText(name);
+ }
+}
diff --git a/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/TasksDataAccess.java b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/TasksDataAccess.java
new file mode 100644
index 0000000..47e89ce
--- /dev/null
+++ b/DoNExt/app/src/main/java/com/wismna/geoffroy/donext/TasksDataAccess.java
@@ -0,0 +1,81 @@
+package com.wismna.geoffroy.donext;
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.database.SQLException;
+import android.database.sqlite.SQLiteDatabase;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by geoffroy on 15-11-25.
+ */
+public class TasksDataAccess {
+ // Database fields
+ private SQLiteDatabase database;
+ private DatabaseHelper dbHelper;
+ private String[] taskListColumns = {DatabaseHelper.COLUMN_ID, DatabaseHelper.TASKLIST_COLUMN_NAME};
+
+ public TasksDataAccess(Context context) {
+ dbHelper = new DatabaseHelper(context);
+ }
+
+ public void open() throws SQLException {
+ database = dbHelper.getWritableDatabase();
+ }
+
+ public void close() {
+ dbHelper.close();
+ }
+
+ public TaskList createTaskList(String name) {
+ ContentValues values = new ContentValues();
+ values.put(DatabaseHelper.TASKLIST_COLUMN_NAME, name);
+ long insertId = database.insert(DatabaseHelper.TASKLIST_TABLE_NAME, null,
+ values);
+ Cursor cursor = database.query(DatabaseHelper.TASKLIST_TABLE_NAME,
+ taskListColumns, DatabaseHelper.COLUMN_ID + " = " + insertId, null,
+ null, null, null);
+ cursor.moveToFirst();
+ TaskList newTaskList = cursorToTaskList(cursor);
+ cursor.close();
+ return newTaskList;
+ }
+
+ public void deleteTaskList(TaskList comment) {
+ long id = comment.getId();
+ System.out.println("Comment deleted with id: " + id);
+ database.delete(DatabaseHelper.TASKLIST_TABLE_NAME, DatabaseHelper.COLUMN_ID
+ + " = " + id, null);
+ }
+
+ public List getAllTaskLists() {
+ List taskLists = new ArrayList();
+
+ Cursor cursor = getAllTaskListsCursor();
+
+ cursor.moveToFirst();
+ while (!cursor.isAfterLast()) {
+ TaskList taskList = cursorToTaskList(cursor);
+ taskLists.add(taskList);
+ cursor.moveToNext();
+ }
+ // make sure to close the cursor
+ cursor.close();
+ return taskLists;
+ }
+
+ public Cursor getAllTaskListsCursor() {
+ return database.query(DatabaseHelper.TASKLIST_TABLE_NAME,
+ taskListColumns, null, null, null, null, null);
+ }
+
+ private TaskList cursorToTaskList(Cursor cursor) {
+ TaskList taskList = new TaskList();
+ taskList.setId(cursor.getLong(0));
+ taskList.setName(cursor.getString(1));
+ return taskList;
+ }
+}
diff --git a/DoNExt/app/src/main/res/layout/activity_task_list.xml b/DoNExt/app/src/main/res/layout/activity_task_list.xml
new file mode 100644
index 0000000..812246a
--- /dev/null
+++ b/DoNExt/app/src/main/res/layout/activity_task_list.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
diff --git a/DoNExt/app/src/main/res/layout/item_task_list.xml b/DoNExt/app/src/main/res/layout/item_task_list.xml
new file mode 100644
index 0000000..403f097
--- /dev/null
+++ b/DoNExt/app/src/main/res/layout/item_task_list.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DoNExt/app/src/main/res/menu/menu_main.xml b/DoNExt/app/src/main/res/menu/menu_main.xml
index e89c74a..5a4758c 100644
--- a/DoNExt/app/src/main/res/menu/menu_main.xml
+++ b/DoNExt/app/src/main/res/menu/menu_main.xml
@@ -8,14 +8,15 @@
android:title="@string/action_settings"
android:onClick="openSettings"
app:showAsAction="never" />
-
+
diff --git a/DoNExt/app/src/main/res/values/strings.xml b/DoNExt/app/src/main/res/values/strings.xml
index 6fd3117..8faa981 100644
--- a/DoNExt/app/src/main/res/values/strings.xml
+++ b/DoNExt/app/src/main/res/values/strings.xml
@@ -1,10 +1,18 @@
+
DoNExt
Settings
New list
Edit lists
+ About
Hello World from section: %1$d
- Settings
+ Settings
+ List edition
+
+
+ New list name
+ Create
+ Delete
Confirm on DoNext?
@@ -20,4 +28,5 @@
- 6
- 7
+ TaskListActivity