TBR: java/projects/todos: Basic TODOs application
First commit for TODOs on Android.
- currently uses Firebase
Will make a matching interface between Firebase and Syncbase.
- RecyclerViews to show TodoLists and Tasks.
- Swipe to delete or mark as done.
- Dialogs to add/edit tasks and todo lists.
Change-Id: Ie77f3f24e74c9fa2bbeae310f6b4b8f7ab205838
diff --git a/projects/todos/app/.gitignore b/projects/todos/app/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/projects/todos/app/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/projects/todos/app/build.gradle b/projects/todos/app/build.gradle
new file mode 100644
index 0000000..698c363
--- /dev/null
+++ b/projects/todos/app/build.gradle
@@ -0,0 +1,34 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 23
+ buildToolsVersion "23.0.2"
+
+ defaultConfig {
+ applicationId "io.v.todos"
+ minSdkVersion 21
+ targetSdkVersion 23
+ versionCode 1
+ versionName "1.0"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+ packagingOptions {
+ exclude 'META-INF/LICENSE'
+ exclude 'META-INF/LICENSE-FIREBASE.txt'
+ exclude 'META-INF/NOTICE'
+ }
+}
+
+dependencies {
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+ testCompile 'junit:junit:4.12'
+ compile 'com.android.support:appcompat-v7:23.1.1'
+ compile 'com.android.support:design:23.1.1'
+ compile 'com.firebase:firebase-client-android:2.5.2+'
+ compile 'com.android.support:recyclerview-v7:+'
+}
diff --git a/projects/todos/app/proguard-rules.pro b/projects/todos/app/proguard-rules.pro
new file mode 100644
index 0000000..fd89494
--- /dev/null
+++ b/projects/todos/app/proguard-rules.pro
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /usr/local/google/home/alexfandrianto/Documents/veyron_root/environment/android/android-sdk-linux/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/projects/todos/app/src/androidTest/java/io/v/todos/ApplicationTest.java b/projects/todos/app/src/androidTest/java/io/v/todos/ApplicationTest.java
new file mode 100644
index 0000000..6b0e9f4
--- /dev/null
+++ b/projects/todos/app/src/androidTest/java/io/v/todos/ApplicationTest.java
@@ -0,0 +1,17 @@
+// Copyright 2016 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.todos;
+
+import android.app.Application;
+import android.test.ApplicationTestCase;
+
+/**
+ * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
+ */
+public class ApplicationTest extends ApplicationTestCase<Application> {
+ public ApplicationTest() {
+ super(Application.class);
+ }
+}
\ No newline at end of file
diff --git a/projects/todos/app/src/main/AndroidManifest.xml b/projects/todos/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..89aa1a7
--- /dev/null
+++ b/projects/todos/app/src/main/AndroidManifest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="io.v.todos">
+
+ <uses-permission android:name="android.permission.INTERNET" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@mipmap/vanadium_launcher"
+ android:label="@string/app_name"
+ android:supportsRtl="true"
+ android:theme="@style/AppTheme">
+ <activity
+ android:name="io.v.todos.MainActivity"
+ android:screenOrientation="portrait"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme.NoActionBar">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name="io.v.todos.TodoListActivity"
+ android:screenOrientation="portrait"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme.NoActionBar">
+ </activity>
+ </application>
+
+</manifest>
diff --git a/projects/todos/app/src/main/java/io/v/todos/DataList.java b/projects/todos/app/src/main/java/io/v/todos/DataList.java
new file mode 100644
index 0000000..b7e4845
--- /dev/null
+++ b/projects/todos/app/src/main/java/io/v/todos/DataList.java
@@ -0,0 +1,60 @@
+// Copyright 2016 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.todos;
+
+import java.util.ArrayList;
+
+/**
+ * DataList is an ArrayList with additional helper methods to keep the entries sorted.
+ * This list requires each entry to have a unique key.
+ *
+ * TODO(alexfandrianto): This should have tests.
+ *
+ * Created by alexfandrianto on 4/14/16.
+ */
+public class DataList<T extends KeyedData<T>> extends ArrayList<T> {
+ public void insertInOrder(T item) {
+ assert item.getKey() != null;
+ for (int i = 0; i < size(); i++) {
+ if (get(i).compareTo(item) > 0) {
+ add(i, item);
+ return;
+ }
+ }
+ add(item);
+ }
+
+ // We have to replace the old item while keeping sort order.
+ // It is easiest to remove and then insertInOrder.
+ public void updateInOrder(T item) {
+ assert item.getKey() != null;
+ removeByKey(item.getKey());
+ insertInOrder(item);
+ }
+
+ public void removeByKey(String key) {
+ int index = findIndexByKey(key);
+ if (index != -1) {
+ remove(index);
+ }
+ }
+
+ private int findIndexByKey(String key) {
+ for (int i = 0; i < size(); i++) {
+ T oldItem = get(i);
+ if (oldItem.getKey().equals(key)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public T findByKey(String key) {
+ int index = findIndexByKey(key);
+ return index == -1 ? null : get(index);
+ }
+
+
+}
diff --git a/projects/todos/app/src/main/java/io/v/todos/KeyedData.java b/projects/todos/app/src/main/java/io/v/todos/KeyedData.java
new file mode 100644
index 0000000..5dd3de8
--- /dev/null
+++ b/projects/todos/app/src/main/java/io/v/todos/KeyedData.java
@@ -0,0 +1,15 @@
+// Copyright 2016 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.todos;
+
+/**
+ * KeyedData represents data that has a key and is comparable.
+ * Most subclasses will use this key as part of their comparison function.
+ *
+ * Created by alexfandrianto on 4/14/16.
+ */
+public abstract class KeyedData<T> implements Comparable<T> {
+ public abstract String getKey();
+}
diff --git a/projects/todos/app/src/main/java/io/v/todos/MainActivity.java b/projects/todos/app/src/main/java/io/v/todos/MainActivity.java
new file mode 100644
index 0000000..09b4a50
--- /dev/null
+++ b/projects/todos/app/src/main/java/io/v/todos/MainActivity.java
@@ -0,0 +1,285 @@
+// Copyright 2016 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.todos;
+
+import android.app.Activity;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.os.Bundle;
+import android.support.v7.app.AlertDialog;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.helper.ItemTouchHelper;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.EditText;
+import android.widget.Toolbar;
+
+import com.firebase.client.ChildEventListener;
+import com.firebase.client.DataSnapshot;
+import com.firebase.client.Firebase;
+import com.firebase.client.FirebaseError;
+
+/**
+ * MainActivity for Vanadium TODOs
+ *
+ * This activity shows a list of todo lists.
+ * - Tap on a Todo List to launch its corresponding TodoListActivity.
+ * - Swipe Left on a Todo List to delete it.
+ * - Swipe Right in order to mark all of its Tasks as done.
+ */
+public class MainActivity extends Activity {
+ static final String FIREBASE_EXAMPLE_URL = "https://vivid-heat-7354.firebaseio.com/";
+ private Firebase myFirebaseRef;
+
+ // Snackoos are the code name for the list of todos.
+ // These todos are backed up at the SNACKOOS child of the Firebase URL.
+ // We use the snackoosList to track a custom sorted list of the stored values.
+ static final String INTENT_SNACKOO_KEY = "snackoo key";
+ static final String INTENT_SNACKOO_VALUE = "snackoo value";
+ static final String SNACKOOS = "snackoos (TodoList)";
+ private DataList<TodoList> snackoosList = new DataList<TodoList>();
+
+ // This adapter handle mirrors the firebase list values and generates the corresponding todo
+ // item View children for a list view.
+ private TodoListRecyclerAdapter adapter;
+
+ private ChildEventListener snackoosEventListener;
+
+ @Override
+ protected void onDestroy() {
+ myFirebaseRef.removeEventListener(snackoosEventListener);
+ super.onDestroy();
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setActionBar(toolbar);
+ getActionBar().setTitle(R.string.app_name);
+
+ // Set up the todo list adapter
+ final Activity self = this;
+ adapter = new TodoListRecyclerAdapter(snackoosList, new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ String fbKey = (String)view.getTag();
+
+ Intent intent = new Intent(self, TodoListActivity.class);
+ intent.putExtra(INTENT_SNACKOO_KEY, fbKey);
+ startActivity(intent);
+ }
+ });
+
+ RecyclerView recyclerView = (RecyclerView)findViewById(R.id.recycler);
+ recyclerView.setLayoutManager(new LinearLayoutManager(this));
+ recyclerView.setAdapter(adapter);
+
+ // TODO(alexfandrianto): Very much copy-pasted between MainActivity and TodoListActivity.
+ new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(
+ ItemTouchHelper.UP | ItemTouchHelper.DOWN,
+ ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
+ private Paint paint = new Paint();
+ private Bitmap deleteIcon = BitmapFactory.decodeResource(
+ getResources(), android.R.drawable.ic_input_delete);
+ private Bitmap doneIcon = BitmapFactory.decodeResource(
+ getResources(), android.R.drawable.checkbox_on_background);
+
+ @Override
+ public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
+ // TODO(alexfandrianto): Refactor further. Is there another way to do this?
+ if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
+ // Get RecyclerView item from the ViewHolder
+ View itemView = viewHolder.itemView;
+
+ if (dX > 0) {
+ /* Set your color for positive displacement */
+ paint.setColor(0xFF00FF00);
+
+ // Draw Rect with varying right side, equal to displacement dX
+ c.drawRect((float) itemView.getLeft(), (float) itemView.getTop(), dX,
+ (float) itemView.getBottom(), paint);
+
+ c.drawBitmap(doneIcon,
+ (float) itemView.getLeft() + 32,
+ (float) itemView.getTop() + ((float) itemView.getBottom() - (float) itemView.getTop() - doneIcon.getHeight())/2,
+ paint);
+ } else if (dX < 0) {
+ /* Set your color for negative displacement */
+ paint.setColor(0xFFFF0000);
+
+ // Draw Rect with varying left side, equal to the item's right side plus negative displacement dX
+ c.drawRect((float) itemView.getRight() + dX, (float) itemView.getTop(),
+ (float) itemView.getRight(), (float) itemView.getBottom(), paint);
+
+
+ //Set the image icon for Left swipe
+ c.drawBitmap(deleteIcon,
+ (float) itemView.getRight() - 32 - deleteIcon.getWidth(),
+ (float) itemView.getTop() + ((float) itemView.getBottom() - (float) itemView.getTop() - deleteIcon.getHeight())/2,
+ paint);
+ }
+
+ super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
+ }
+ }
+
+ @Override
+ public boolean onMove(final RecyclerView recyclerView,
+ final RecyclerView.ViewHolder viewHolder,
+ final RecyclerView.ViewHolder target) {
+
+
+ /*editListStructure(l -> l.add(target.getAdapterPosition(),
+ l.remove(viewHolder.getAdapterPosition())));*/
+
+ // TODO(alexfandrianto): Actually, I really doubt that we want to do this. It's super complex..
+ Log.d(SNACKOOS, "Moving is hard.");
+ return false;
+ }
+
+ @Override
+ public void onSwiped(final RecyclerView.ViewHolder viewHolder, final int direction) {
+ if (direction == ItemTouchHelper.RIGHT) {
+ Log.d(SNACKOOS, "Gonna mark all tasks as done");
+
+ // TODO(alexfandrianto): This doesn't do anything yet. Should mark all child Tasks as done.
+ adapter.notifyDataSetChanged();
+ } else if (direction == ItemTouchHelper.LEFT) {
+ Log.d(SNACKOOS, "Gonna delete this todo list");
+ deleteTodoItem((String)viewHolder.itemView.getTag());
+ }
+ }
+ }).attachToRecyclerView(recyclerView);
+
+ // Set up Firebase with the context and tell it to persist data locally even if we're offline.
+ Firebase.setAndroidContext(this);
+ Firebase.getDefaultConfig().setPersistenceEnabled(true);
+
+ // Prepare our Firebase Reference and the primary listener (SNACKOOS).
+ myFirebaseRef = new Firebase(FIREBASE_EXAMPLE_URL);
+ setUpSnackoos();
+ }
+
+ // Set the visibility based on what the adapter thinks is the visible item count.
+ private void setEmptyVisiblity() {
+ View v = findViewById(R.id.empty);
+ v.setVisibility(adapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
+ }
+
+ // Any time a child of SNACKOOS is added/changed/removed, we mirror the changes locally.
+ private void setUpSnackoos() {
+ snackoosEventListener = firebaseListReference().addChildEventListener(new ChildEventListener() {
+ @Override
+ public void onChildAdded(DataSnapshot dataSnapshot, String prevKey) {
+ String fbKey = dataSnapshot.getKey();
+ TodoList todoList = dataSnapshot.getValue(TodoList.class);
+ todoList.setKey(fbKey);
+
+ // Insert in order.
+ snackoosList.insertInOrder(todoList);
+
+ adapter.notifyDataSetChanged();
+
+ // TODO(alexfandrianto): In order to capture the computed values for this TodoList,
+ // we have to watch the Task's data.
+
+ setEmptyVisiblity();
+ }
+
+ @Override
+ public void onChildChanged(DataSnapshot dataSnapshot, String prevKey) {
+ String fbKey = dataSnapshot.getKey();
+ TodoList todoList = dataSnapshot.getValue(TodoList.class);
+ todoList.setKey(fbKey);
+
+ snackoosList.updateInOrder(todoList);
+ adapter.notifyDataSetChanged();
+ }
+
+ @Override
+ public void onChildRemoved(DataSnapshot dataSnapshot) {
+ String fbKey = dataSnapshot.getKey();
+ snackoosList.removeByKey(fbKey);
+ adapter.notifyDataSetChanged();
+
+ // TODO(alexfandrianto): Stop watching the Task data for this TodoList.
+
+ setEmptyVisiblity();
+ }
+
+ @Override
+ public void onChildMoved(DataSnapshot dataSnapshot, String prevKey) {
+
+ }
+
+ @Override
+ public void onCancelled(FirebaseError firebaseError) {
+
+ }
+ });
+ }
+
+ private Firebase firebaseListReference() {
+ return myFirebaseRef.child(SNACKOOS);
+ }
+ public void addTodoItem(String todo) {
+ firebaseListReference().push().setValue(new TodoList(todo));
+ }
+
+ public void deleteTodoItem(String fbKey) {
+ firebaseListReference().child(fbKey).removeValue();
+ }
+
+ public void addCallback(View view) {
+ final EditText todoItem = new EditText(this);
+
+ AlertDialog dialog = new AlertDialog.Builder(this)
+ .setTitle("New Todo")
+ .setView(todoItem)
+ .setPositiveButton("Add", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ addTodoItem(todoItem.getText().toString());
+ }
+ })
+ .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ }
+ }).show();
+ dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+ }
+
+ // The following methods are boilerplate for handling the Menu in the top right corner.
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+
+ //noinspection SimplifiableIfStatement
+ if (id == R.id.action_settings) {
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+}
diff --git a/projects/todos/app/src/main/java/io/v/todos/Task.java b/projects/todos/app/src/main/java/io/v/todos/Task.java
new file mode 100644
index 0000000..8bd42a2
--- /dev/null
+++ b/projects/todos/app/src/main/java/io/v/todos/Task.java
@@ -0,0 +1,81 @@
+// Copyright 2016 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.todos;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+/**
+ * Task is a Firebase-compatible class that tracks information regarding a particular task.
+ *
+ * Created by alexfandrianto on 4/11/16.
+ */
+@JsonIgnoreProperties({ "key" })
+public class Task extends KeyedData<Task> {
+ private String text;
+ private long addedAt;
+ private boolean done;
+
+ // Unserialized properties.
+ private String key; // Usually assigned for comparison/viewing.
+
+ // The default constructor is used by Firebase.
+ public Task() {}
+
+ // Use this constructor when creating a new Task for the first time.
+ public Task(String text) {
+ this.text = text;
+ this.addedAt = System.currentTimeMillis();
+ this.done = false;
+ }
+
+ public Task copy() {
+ Task t = new Task();
+ t.text = text;
+ t.addedAt = addedAt;
+ t.done = done;
+ t.key = key;
+ return t;
+ }
+
+ public String getText() {
+ return text;
+ }
+ public long getAddedAt() {
+ return addedAt;
+ }
+ public boolean getDone() {
+ return done;
+ }
+ public void setKey(String key) {
+ this.key = key;
+ }
+ public String getKey() {
+ return key;
+ }
+
+ public void setText(String newText) {
+ text = newText;
+ }
+ public void setDone(boolean newDone) {
+ done = newDone;
+ }
+
+ @Override
+ public int compareTo(Task other) {
+ if (done && !other.done) {
+ return 1;
+ } else if (!done && other.done) {
+ return -1;
+ }
+ if (key == null && other.key != null) {
+ return 1;
+ } else if (key != null && other.key == null) {
+ return -1;
+ } else if (key == null && other.key == null) {
+ return 0;
+ }
+ return key.compareTo(other.key);
+ }
+}
diff --git a/projects/todos/app/src/main/java/io/v/todos/TaskRecyclerAdapter.java b/projects/todos/app/src/main/java/io/v/todos/TaskRecyclerAdapter.java
new file mode 100644
index 0000000..fa181a7
--- /dev/null
+++ b/projects/todos/app/src/main/java/io/v/todos/TaskRecyclerAdapter.java
@@ -0,0 +1,61 @@
+// Copyright 2016 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.todos;
+
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import java.util.ArrayList;
+
+/**
+ * Created by alexfandrianto on 4/7/16.
+ */
+public class TaskRecyclerAdapter extends RecyclerView.Adapter<TaskViewHolder> {
+ private ArrayList<Task> backup;
+ private View.OnClickListener itemListener;
+ private boolean showDone = true;
+
+ private static final int RESOURCE_ID = R.layout.task_row;
+
+ public TaskRecyclerAdapter(ArrayList<Task> backup, View.OnClickListener itemListener) {
+ super();
+ this.backup = backup;
+ this.itemListener = itemListener;
+ }
+
+ @Override
+ public TaskViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ View view = LayoutInflater.from(parent.getContext())
+ .inflate(RESOURCE_ID, parent, false);
+ return new TaskViewHolder(view);
+ }
+
+ @Override
+ public void onBindViewHolder(TaskViewHolder holder, int position) {
+ Task task = backup.get(position);
+ holder.bindTask(task, itemListener);
+ }
+
+ @Override
+ public int getItemCount() {
+ return showDone ? backup.size() : nonDoneSize();
+ }
+
+ private int nonDoneSize() {
+ for (int i = 0; i < backup.size(); i++) {
+ if (backup.get(i).getDone()) {
+ return i;
+ }
+ }
+ return 0;
+ }
+
+ public void setShowDone(boolean showDone) {
+ this.showDone = showDone;
+ this.notifyDataSetChanged();
+ }
+}
\ No newline at end of file
diff --git a/projects/todos/app/src/main/java/io/v/todos/TaskViewHolder.java b/projects/todos/app/src/main/java/io/v/todos/TaskViewHolder.java
new file mode 100644
index 0000000..505d514
--- /dev/null
+++ b/projects/todos/app/src/main/java/io/v/todos/TaskViewHolder.java
@@ -0,0 +1,52 @@
+// Copyright 2016 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.todos;
+
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+/**
+ * Created by alexfandrianto on 4/12/16.
+ */
+public class TaskViewHolder extends RecyclerView.ViewHolder{
+ private View myView;
+ private boolean showDone = true;
+
+ public TaskViewHolder(View itemView) {
+ super(itemView);
+
+ myView = itemView;
+ }
+
+ public void bindTask(Task task, View.OnClickListener listener) {
+ // TODO(alexfandrianto): Now might be a good time to set data in myView.
+
+ final ImageView doneMark = (ImageView)myView.findViewById(R.id.task_done);
+ doneMark.setVisibility(task.getDone() ? View.VISIBLE : View.GONE);
+
+ final TextView name=(TextView)myView.findViewById(R.id.task_text);
+ name.setText(task.getText());
+
+ final TextView created=(TextView)myView.findViewById(R.id.task_time);
+ created.setText(computeCreated(task));
+
+ myView.setBackgroundColor(task.getDone() ? 0xFFCCCCCC : 0xFFFFFFFF);
+
+ myView.setTag(task.getKey());
+ myView.setOnClickListener(listener);
+
+ myView.setVisibility(!showDone && task.getDone() ? View.GONE : View.VISIBLE);
+ }
+
+ private String computeCreated(Task task) {
+ return "" + task.getAddedAt();
+ }
+
+ public void setShowDone(boolean showDone) {
+ this.showDone = showDone;
+ }
+}
diff --git a/projects/todos/app/src/main/java/io/v/todos/TodoList.java b/projects/todos/app/src/main/java/io/v/todos/TodoList.java
new file mode 100644
index 0000000..614b88b
--- /dev/null
+++ b/projects/todos/app/src/main/java/io/v/todos/TodoList.java
@@ -0,0 +1,62 @@
+// Copyright 2016 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.todos;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+/**
+ * TodoList is a Firebase-compatible class that tracks information regarding a particular todo list.
+ *
+ * Created by alexfandrianto on 4/11/16.
+ */
+@JsonIgnoreProperties({ "numCompleted", "numTasks", "done", "key" })
+public class TodoList extends KeyedData<TodoList> {
+ private String name;
+ private long updatedAt;
+
+ // Not serialized.
+ public int numCompleted = 0;
+ public int numTasks = 0;
+ private String key = null; // Usually assigned for comparison/viewing.
+ //public List<String> sharedWith ??
+
+ // The default constructor is used by Firebase.
+ public TodoList() {}
+
+ // Use this constructor when creating a new Task for the first time.
+ public TodoList(String name) {
+ this.name = name;
+ this.updatedAt = System.currentTimeMillis();
+ }
+
+ public String getName() {
+ return name;
+ }
+ public long getUpdatedAt() {
+ return updatedAt;
+ }
+
+ public boolean getDone() {
+ return numTasks > 0 && numCompleted == numTasks;
+ }
+ public void setKey(String key) {
+ this.key = key;
+ }
+ public String getKey() {
+ return key;
+ }
+
+ @Override
+ public int compareTo(TodoList other) {
+ if (key == null && other.key != null) {
+ return 1;
+ } else if (key != null && other.key == null) {
+ return -1;
+ } else if (key == null && other.key == null) {
+ return 0;
+ }
+ return key.compareTo(other.key);
+ }
+}
diff --git a/projects/todos/app/src/main/java/io/v/todos/TodoListActivity.java b/projects/todos/app/src/main/java/io/v/todos/TodoListActivity.java
new file mode 100644
index 0000000..89d5c83
--- /dev/null
+++ b/projects/todos/app/src/main/java/io/v/todos/TodoListActivity.java
@@ -0,0 +1,399 @@
+// Copyright 2016 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.todos;
+
+import android.app.Activity;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.os.Bundle;
+import android.support.v7.app.AlertDialog;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.helper.ItemTouchHelper;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.EditText;
+import android.widget.Toolbar;
+
+import com.firebase.client.ChildEventListener;
+import com.firebase.client.DataSnapshot;
+import com.firebase.client.Firebase;
+import com.firebase.client.FirebaseError;
+import com.firebase.client.ValueEventListener;
+
+/**
+ * TodoListActivity for Vanadium TODOs
+ *
+ * This activity shows a list of tasks.
+ * - Tap on a Task in order to edit it.
+ * - Swipe Left on a Task to delete it.
+ * - Swipe Right in order to mark the Task as done.
+ * - Select Edit from the menu to Edit the Todo List.
+ * - Toggle Show Done in the menu to show/hide completed Tasks.
+ *
+ * Created by alexfandrianto on 4/11/16.
+ */
+public class TodoListActivity extends Activity {
+ private Firebase myFirebaseRef;
+
+ private final static String SNACKOO_LISTS = "snackoo lists (Task)";
+ private String snackooKey;
+ private TodoList snackoo;
+ private DataList<Task> snackoosList = new DataList<Task>();
+ private boolean showDone = false; // TODO(alexfandrianto): Load from shared preferences...
+
+ // This adapter handle mirrors the firebase list values and generates the corresponding todo
+ // item View children for a list view.
+ private TaskRecyclerAdapter adapter;
+ private ValueEventListener snackooEventListener;
+ private ChildEventListener snackoosEventListener;
+
+ @Override
+ protected void onDestroy() {
+ myFirebaseRef.removeEventListener(snackooEventListener);
+ myFirebaseRef.removeEventListener(snackoosEventListener);
+ super.onDestroy();
+ }
+
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ Intent intent = getIntent();
+ snackooKey = intent.getStringExtra(MainActivity.INTENT_SNACKOO_KEY);
+
+ Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
+ setActionBar(toolbar);
+
+ // Set up the todo list adapter
+ final Activity self = this;
+ adapter = new TaskRecyclerAdapter(snackoosList, new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ String key = (String) view.getTag();
+
+ initiateTaskEdit(key);
+ }
+ });
+
+ RecyclerView recyclerView = (RecyclerView)findViewById(R.id.recycler);
+ recyclerView.setLayoutManager(new LinearLayoutManager(this));
+ recyclerView.setAdapter(adapter);
+
+ new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(
+ ItemTouchHelper.UP | ItemTouchHelper.DOWN,
+ ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
+
+ private Paint paint = new Paint();
+ private Bitmap deleteIcon = BitmapFactory.decodeResource(
+ getResources(), android.R.drawable.ic_input_delete);
+ private Bitmap doneIcon = BitmapFactory.decodeResource(
+ getResources(), android.R.drawable.checkbox_on_background);
+
+ @Override
+ public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
+ // TODO(alexfandrianto): Refactor further. Is there another way to do this?
+ if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
+ // Get RecyclerView item from the ViewHolder
+ View itemView = viewHolder.itemView;
+
+ if (dX > 0) {
+ /* Set your color for positive displacement */
+ paint.setColor(0xFF00FF00);
+
+ // Draw Rect with varying right side, equal to displacement dX
+ c.drawRect((float) itemView.getLeft(), (float) itemView.getTop(), dX,
+ (float) itemView.getBottom(), paint);
+
+ c.drawBitmap(doneIcon,
+ (float) itemView.getLeft() + 32,
+ (float) itemView.getTop() + ((float) itemView.getBottom() - (float) itemView.getTop() - doneIcon.getHeight())/2,
+ paint);
+ } else if (dX < 0) {
+ /* Set your color for negative displacement */
+ paint.setColor(0xFFFF0000);
+
+ // Draw Rect with varying left side, equal to the item's right side plus negative displacement dX
+ c.drawRect((float) itemView.getRight() + dX, (float) itemView.getTop(),
+ (float) itemView.getRight(), (float) itemView.getBottom(), paint);
+
+
+ //Set the image icon for Left swipe
+ c.drawBitmap(deleteIcon,
+ (float) itemView.getRight() - 32 - deleteIcon.getWidth(),
+ (float) itemView.getTop() + ((float) itemView.getBottom() - (float) itemView.getTop() - deleteIcon.getHeight())/2,
+ paint);
+ }
+
+ super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
+ }
+ }
+
+ @Override
+ public boolean onMove(final RecyclerView recyclerView,
+ final RecyclerView.ViewHolder viewHolder,
+ final RecyclerView.ViewHolder target) {
+
+
+ /*editListStructure(l -> l.add(target.getAdapterPosition(),
+ l.remove(viewHolder.getAdapterPosition())));*/
+
+ // TODO(alexfandrianto): Actually, I really doubt that we want to do this. It's super complex..
+ Log.d(SNACKOO_LISTS, "Moving is hard.");
+ return false;
+ }
+
+ @Override
+ public void onSwiped(final RecyclerView.ViewHolder viewHolder, final int direction) {
+ if (direction == ItemTouchHelper.RIGHT) {
+ Log.d(SNACKOO_LISTS, "Gonna mark all tasks as done");
+ markAsDone((String)viewHolder.itemView.getTag());
+ } else if (direction == ItemTouchHelper.LEFT) {
+ Log.d(SNACKOO_LISTS, "Gonna delete this todo list");
+ deleteTodoItem((String)viewHolder.itemView.getTag());
+ }
+ }
+ }).attachToRecyclerView(recyclerView);
+
+ // Set up Firebase with the context and tell it to persist data locally even if we're offline.
+ Firebase.setAndroidContext(this);
+ //Firebase.getDefaultConfig().setPersistenceEnabled(true);
+
+ // Prepare our Firebase Reference and the primary listener (SNACKOOS).
+ myFirebaseRef = new Firebase(MainActivity.FIREBASE_EXAMPLE_URL);
+ setUpSnackoo();
+ setUpSnackoos();
+ }
+
+ private Firebase firebaseListReference() {
+ return myFirebaseRef.child(MainActivity.SNACKOOS).child(snackooKey);
+ }
+
+ private Firebase firebaseTasksReference() {
+ return myFirebaseRef.child(SNACKOO_LISTS).child(snackooKey);
+ }
+
+ private void setUpSnackoo() {
+ snackooEventListener = firebaseListReference().addValueEventListener(new ValueEventListener() {
+ @Override
+ public void onDataChange(DataSnapshot dataSnapshot) {
+ snackoo = dataSnapshot.getValue(TodoList.class);
+ if (snackoo == null) {
+ // The list has been deleted. Get the heck out of here!
+ finish();
+ return;
+ }
+ getActionBar().setTitle(snackoo.getName());
+ }
+
+ @Override
+ public void onCancelled(FirebaseError firebaseError) {
+
+ }
+ });
+ }
+
+ // Set the visibility based on what the adapter thinks is the visible item count.
+ private void setEmptyVisiblity() {
+ View v = findViewById(R.id.empty);
+ v.setVisibility(adapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
+ }
+
+ // Any time a child of SNACKOOS is added/changed/removed, we mirror the changes locally.
+ private void setUpSnackoos() {
+ snackoosEventListener = firebaseTasksReference().addChildEventListener(new ChildEventListener() {
+ @Override
+ public void onChildAdded(DataSnapshot dataSnapshot, String prevKey) {
+ String fbKey = dataSnapshot.getKey();
+ Task task = dataSnapshot.getValue(Task.class);
+ task.setKey(fbKey);
+ snackoosList.insertInOrder(task);
+ adapter.notifyDataSetChanged();
+
+ setEmptyVisiblity();
+ }
+
+ @Override
+ public void onChildChanged(DataSnapshot dataSnapshot, String prevKey) {
+ String fbKey = dataSnapshot.getKey();
+ Task task = dataSnapshot.getValue(Task.class);
+ task.setKey(fbKey);
+ snackoosList.updateInOrder(task);
+ adapter.notifyDataSetChanged();
+ }
+
+ @Override
+ public void onChildRemoved(DataSnapshot dataSnapshot) {
+ String fbKey = dataSnapshot.getKey();
+ snackoosList.removeByKey(fbKey);
+ adapter.notifyDataSetChanged();
+
+ setEmptyVisiblity();
+ }
+
+ @Override
+ public void onChildMoved(DataSnapshot dataSnapshot, String prevKey) {
+
+ }
+
+ @Override
+ public void onCancelled(FirebaseError firebaseError) {
+
+ }
+ });
+ }
+
+ public void addTodoItem(String todo) {
+ // TODO(alexfandrianto): Turns out these are all batch changes that change the parents updatedAt
+ firebaseTasksReference().push().setValue(new Task(todo));
+ }
+
+ public void updateTodoItem(String fbKey, String todo) {
+ // TODO(alexfandrianto): Turns out these are all batch changes that change the parents updatedAt
+ Task task = snackoosList.findByKey(fbKey).copy();
+ task.setText(todo);
+ firebaseTasksReference().child(fbKey).setValue(task);
+ }
+ public void markAsDone(String fbKey) {
+ // TODO(alexfandrianto): Turns out these are all batch changes that change the parents updatedAt
+ Task task = snackoosList.findByKey(fbKey).copy();
+ task.setDone(!task.getDone());
+ firebaseTasksReference().child(fbKey).setValue(task);
+ }
+
+ public void deleteTodoItem(String fbKey) {
+ // TODO(alexfandrianto): Turns out these are all batch changes that change the parents updatedAt
+ firebaseTasksReference().child(fbKey).removeValue();
+ }
+
+ public void addCallback(View view) {
+ final EditText todoItem = new EditText(this);
+
+ AlertDialog dialog = new AlertDialog.Builder(this)
+ .setTitle("New Todo")
+ .setView(todoItem)
+ .setPositiveButton("Add", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ addTodoItem(todoItem.getText().toString());
+ }
+ })
+ .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ }
+ }).show();
+ dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+ }
+
+ private void initiateTaskEdit(final String fbKey) {
+ final EditText todoItem = new EditText(this);
+ todoItem.setText(snackoosList.findByKey(fbKey).getText());
+
+ AlertDialog dialog = new AlertDialog.Builder(this)
+ .setTitle("Update Task")
+ .setView(todoItem)
+ .setPositiveButton("Update", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ updateTodoItem(fbKey, todoItem.getText().toString());
+ }
+ })
+ .setNeutralButton("Delete", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ deleteTodoItem(fbKey);
+ }
+ })
+ .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ }
+ }).show();
+ dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+ }
+
+ private void initiateTodoListEdit() {
+ final EditText todoItem = new EditText(this);
+ todoItem.setText(snackoo.getName());
+
+ AlertDialog dialog = new AlertDialog.Builder(this)
+ .setTitle("Update Todo List")
+ .setView(todoItem)
+ .setPositiveButton("Update", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ updateTodoList(todoItem.getText().toString());
+ }
+ })
+ .setNeutralButton("Delete", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ deleteTodoList();
+ }
+ })
+ .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ }
+ }).show();
+ dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+ }
+
+
+ public void updateTodoList(String todo) {
+ firebaseListReference().setValue(new TodoList(todo));
+ }
+
+ public void deleteTodoList() {
+ firebaseListReference().removeValue();
+ }
+
+
+ // The following methods are boilerplate for handling the Menu in the top right corner.
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ Log.d(SNACKOO_LISTS, "Am I being called?");
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_task, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ Log.d(SNACKOO_LISTS, "Am I being called? 2");
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+
+ //noinspection SimplifiableIfStatement
+ switch (id) {
+ case R.id.show_done:
+ if(item.isChecked()){
+ item.setChecked(false);
+ adapter.setShowDone(false);
+ }else{
+ item.setChecked(true);
+ adapter.setShowDone(true);
+ }
+ adapter.notifyDataSetChanged();
+
+ // TODO(alexfandrianto): You may wish to save this data into SharedPreferences.
+ // You may also wish to save this to a different part of the space which is synced
+ // across your devices.
+
+ return true;
+ case R.id.action_settings:
+ return true;
+ case R.id.action_edit:
+ initiateTodoListEdit();
+ return true;
+ case R.id.action_share:
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+}
diff --git a/projects/todos/app/src/main/java/io/v/todos/TodoListRecyclerAdapter.java b/projects/todos/app/src/main/java/io/v/todos/TodoListRecyclerAdapter.java
new file mode 100644
index 0000000..6e5048b
--- /dev/null
+++ b/projects/todos/app/src/main/java/io/v/todos/TodoListRecyclerAdapter.java
@@ -0,0 +1,46 @@
+// Copyright 2016 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.todos;
+
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import java.util.ArrayList;
+
+/**
+ * Created by alexfandrianto on 4/7/16.
+ */
+public class TodoListRecyclerAdapter extends RecyclerView.Adapter<TodoListViewHolder> {
+ private ArrayList<TodoList> backup;
+ private View.OnClickListener itemListener;
+
+ private static final int RESOURCE_ID = R.layout.todo_list_row;
+
+ public TodoListRecyclerAdapter(ArrayList<TodoList> backup, View.OnClickListener itemListener) {
+ super();
+ this.backup = backup;
+ this.itemListener = itemListener;
+ }
+
+ @Override
+ public TodoListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ View view = LayoutInflater.from(parent.getContext())
+ .inflate(RESOURCE_ID, parent, false);
+ return new TodoListViewHolder(view);
+ }
+
+ @Override
+ public void onBindViewHolder(TodoListViewHolder holder, int position) {
+ TodoList todoList = backup.get(position);
+ holder.bindTodoList(todoList, itemListener);
+ }
+
+ @Override
+ public int getItemCount() {
+ return backup.size();
+ }
+}
diff --git a/projects/todos/app/src/main/java/io/v/todos/TodoListViewHolder.java b/projects/todos/app/src/main/java/io/v/todos/TodoListViewHolder.java
new file mode 100644
index 0000000..b754c52
--- /dev/null
+++ b/projects/todos/app/src/main/java/io/v/todos/TodoListViewHolder.java
@@ -0,0 +1,56 @@
+// Copyright 2016 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.todos;
+
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+import android.widget.TextView;
+
+/**
+ * Created by alexfandrianto on 4/12/16.
+ */
+public class TodoListViewHolder extends RecyclerView.ViewHolder {
+ private View myView;
+
+ public TodoListViewHolder(View itemView) {
+ super(itemView);
+
+ myView = itemView;
+ }
+
+ public void bindTodoList(TodoList todoList, View.OnClickListener listener) {
+ // TODO(alexfandrianto): Now might be a good time to set data in myView.
+
+ final TextView name=(TextView)myView.findViewById(R.id.todo_list_name);
+ name.setText(todoList.getName());
+
+ final TextView completedStatus=(TextView)myView.findViewById(R.id.todo_list_completed);
+ completedStatus.setText(computeCompleted(todoList));
+
+ final TextView timeAgo=(TextView)myView.findViewById(R.id.todo_list_time);
+ timeAgo.setText(computeTimeAgo(todoList));
+
+ myView.setBackgroundColor(todoList.getDone() ? 0xFFCCCCCC : 0xFFFFFFFF);
+
+ myView.setTag(todoList.getKey());
+ myView.setOnClickListener(listener);
+ }
+
+ private String computeTimeAgo(TodoList todoList) {
+ return "" + todoList.getUpdatedAt();
+ }
+
+ private String computeCompleted(TodoList todoList) {
+ if (todoList.getDone()) {
+ return "Done!";
+ } else if (todoList.numTasks == 0) {
+ return "Needs Tasks";
+ } else if (todoList.numCompleted == 0) {
+ return "Not Started";
+ } else {
+ return todoList.numCompleted + " of " + todoList.numTasks;
+ }
+ }
+}
diff --git a/projects/todos/app/src/main/res/layout/activity_main.xml b/projects/todos/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..8934c95
--- /dev/null
+++ b/projects/todos/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,26 @@
+<?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"
+ android:fitsSystemWindows="true"
+ tools:context="io.v.todos.MainActivity">
+
+ <android.support.design.widget.AppBarLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:theme="@style/AppTheme.AppBarOverlay">
+
+ <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>
+
+ <include layout="@layout/content_main" />
+
+</android.support.design.widget.CoordinatorLayout>
diff --git a/projects/todos/app/src/main/res/layout/content_main.xml b/projects/todos/app/src/main/res/layout/content_main.xml
new file mode 100644
index 0000000..94e4245
--- /dev/null
+++ b/projects/todos/app/src/main/res/layout/content_main.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout 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"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior"
+ tools:context="io.v.todos.MainActivity"
+ tools:showIn="@layout/activity_main">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+ <android.support.v7.widget.RecyclerView android:id="@+id/recycler"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_weight="1" />
+ <TextView android:id="@+id/empty"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#FF0000"
+ android:text="No data"/>
+ </LinearLayout>
+ <android.support.design.widget.FloatingActionButton
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentRight="true"
+ app:fabSize="normal"
+ android:src="@android:drawable/ic_input_add"
+ android:layout_margin="@dimen/fab_margin"
+ android:clickable="true"
+ android:onClick="addCallback"/>
+</RelativeLayout>
diff --git a/projects/todos/app/src/main/res/layout/task_row.xml b/projects/todos/app/src/main/res/layout/task_row.xml
new file mode 100644
index 0000000..a06e741
--- /dev/null
+++ b/projects/todos/app/src/main/res/layout/task_row.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/root"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:id="@+id/row">
+
+ <ImageView android:id="@+id/task_done"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@android:drawable/checkbox_on_background"
+ android:layout_gravity="center_vertical"
+ android:layout_margin="@dimen/fab_margin"
+ android:visibility="gone"/>
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_weight = "1"
+ android:layout_height="wrap_content">
+
+ <TextView android:id="@+id/task_text"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight = "1"
+ android:gravity="center_vertical"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentBottom="true"
+ android:textStyle="bold"
+ android:textSize="22sp"
+ android:textColor="#000000"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp" />
+
+ <TextView android:id="@+id/task_time"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight = "1"
+ android:gravity="center_vertical"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentBottom="true"
+ android:textStyle="bold"
+ android:textSize="22sp"
+ android:textColor="#000000"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp" />
+ </LinearLayout>
+ </LinearLayout>
+</RelativeLayout>
\ No newline at end of file
diff --git a/projects/todos/app/src/main/res/layout/todo_list_row.xml b/projects/todos/app/src/main/res/layout/todo_list_row.xml
new file mode 100644
index 0000000..04a4082
--- /dev/null
+++ b/projects/todos/app/src/main/res/layout/todo_list_row.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/root"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:id="@+id/row">
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <TextView android:id="@+id/todo_list_name"
+ android:layout_width="fill_parent"
+ android:layout_weight = "1"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentBottom="true"
+ android:textStyle="bold"
+ android:textSize="22dp"
+ android:textColor="#000000"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp" />
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight = "1">
+
+ <TextView android:id="@+id/todo_list_completed"
+ android:layout_width="wrap_content"
+ android:layout_weight = "1"
+ android:layout_height="fill_parent"
+ android:gravity="center_vertical"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentBottom="true"
+ android:textStyle="bold"
+ android:textSize="22dp"
+ android:textColor="#000000"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp" />
+
+ <TextView android:id="@+id/todo_list_time"
+ android:layout_width="wrap_content"
+ android:layout_weight = "1"
+ android:layout_height="fill_parent"
+ android:gravity="center_vertical"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentBottom="true"
+ android:textStyle="bold"
+ android:textSize="22dp"
+ android:textColor="#000000"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp" />
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+</RelativeLayout>
\ No newline at end of file
diff --git a/projects/todos/app/src/main/res/menu/menu_main.xml b/projects/todos/app/src/main/res/menu/menu_main.xml
new file mode 100644
index 0000000..bed03f0
--- /dev/null
+++ b/projects/todos/app/src/main/res/menu/menu_main.xml
@@ -0,0 +1,15 @@
+<menu 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"
+ tools:context="io.v.todos.MainActivity">
+ <item
+ android:id="@+id/action_settings"
+ android:orderInCategory="100"
+ android:title="@string/action_settings"
+ app:showAsAction="never" />
+ <item
+ android:id="@+id/action_debug"
+ android:orderInCategory="101"
+ android:title="@string/action_debug"
+ app:showAsAction="never" />
+</menu>
diff --git a/projects/todos/app/src/main/res/menu/menu_task.xml b/projects/todos/app/src/main/res/menu/menu_task.xml
new file mode 100644
index 0000000..6c19567
--- /dev/null
+++ b/projects/todos/app/src/main/res/menu/menu_task.xml
@@ -0,0 +1,26 @@
+<menu 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"
+ tools:context="io.v.todos.TodoListActivity">
+ <item
+ android:id="@+id/action_settings"
+ android:orderInCategory="100"
+ android:title="@string/action_settings"
+ app:showAsAction="never" />
+ <item
+ android:id="@+id/show_done"
+ android:orderInCategory="101"
+ android:checkable="true"
+ android:checked="true"
+ android:title="@string/show_done" />
+ <item
+ android:id="@+id/action_edit"
+ android:orderInCategory="102"
+ android:title="@string/action_edit"
+ app:showAsAction="never" />
+ <item
+ android:id="@+id/action_share"
+ android:orderInCategory="103"
+ android:title="@string/action_share"
+ app:showAsAction="never" />
+</menu>
diff --git a/projects/todos/app/src/main/res/mipmap-hdpi/ic_launcher.png b/projects/todos/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..cde69bc
--- /dev/null
+++ b/projects/todos/app/src/main/res/mipmap-hdpi/ic_launcher.png
Binary files differ
diff --git a/projects/todos/app/src/main/res/mipmap-hdpi/vanadium_launcher.png b/projects/todos/app/src/main/res/mipmap-hdpi/vanadium_launcher.png
new file mode 100644
index 0000000..9d5e0d6
--- /dev/null
+++ b/projects/todos/app/src/main/res/mipmap-hdpi/vanadium_launcher.png
Binary files differ
diff --git a/projects/todos/app/src/main/res/mipmap-mdpi/ic_launcher.png b/projects/todos/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..c133a0c
--- /dev/null
+++ b/projects/todos/app/src/main/res/mipmap-mdpi/ic_launcher.png
Binary files differ
diff --git a/projects/todos/app/src/main/res/mipmap-mdpi/vanadium_launcher.png b/projects/todos/app/src/main/res/mipmap-mdpi/vanadium_launcher.png
new file mode 100644
index 0000000..66f1514
--- /dev/null
+++ b/projects/todos/app/src/main/res/mipmap-mdpi/vanadium_launcher.png
Binary files differ
diff --git a/projects/todos/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/projects/todos/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..bfa42f0
--- /dev/null
+++ b/projects/todos/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Binary files differ
diff --git a/projects/todos/app/src/main/res/mipmap-xhdpi/vanadium_launcher.png b/projects/todos/app/src/main/res/mipmap-xhdpi/vanadium_launcher.png
new file mode 100644
index 0000000..9dfa8d7
--- /dev/null
+++ b/projects/todos/app/src/main/res/mipmap-xhdpi/vanadium_launcher.png
Binary files differ
diff --git a/projects/todos/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/projects/todos/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..324e72c
--- /dev/null
+++ b/projects/todos/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/projects/todos/app/src/main/res/mipmap-xxhdpi/vanadium_launcher.png b/projects/todos/app/src/main/res/mipmap-xxhdpi/vanadium_launcher.png
new file mode 100644
index 0000000..3c7d066
--- /dev/null
+++ b/projects/todos/app/src/main/res/mipmap-xxhdpi/vanadium_launcher.png
Binary files differ
diff --git a/projects/todos/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/projects/todos/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..aee44e1
--- /dev/null
+++ b/projects/todos/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Binary files differ
diff --git a/projects/todos/app/src/main/res/values-v21/styles.xml b/projects/todos/app/src/main/res/values-v21/styles.xml
new file mode 100644
index 0000000..251fb9f
--- /dev/null
+++ b/projects/todos/app/src/main/res/values-v21/styles.xml
@@ -0,0 +1,9 @@
+<resources>>
+
+ <style name="AppTheme.NoActionBar">
+ <item name="windowActionBar">false</item>
+ <item name="windowNoTitle">true</item>
+ <item name="android:windowDrawsSystemBarBackgrounds">true</item>
+ <item name="android:statusBarColor">@android:color/transparent</item>
+ </style>
+</resources>
diff --git a/projects/todos/app/src/main/res/values-w820dp/dimens.xml b/projects/todos/app/src/main/res/values-w820dp/dimens.xml
new file mode 100644
index 0000000..63fc816
--- /dev/null
+++ b/projects/todos/app/src/main/res/values-w820dp/dimens.xml
@@ -0,0 +1,6 @@
+<resources>
+ <!-- Example customization of dimensions originally defined in res/values/dimens.xml
+ (such as screen margins) for screens with more than 820dp of available width. This
+ would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
+ <dimen name="activity_horizontal_margin">64dp</dimen>
+</resources>
diff --git a/projects/todos/app/src/main/res/values/colors.xml b/projects/todos/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..3ab3e9c
--- /dev/null
+++ b/projects/todos/app/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <color name="colorPrimary">#3F51B5</color>
+ <color name="colorPrimaryDark">#303F9F</color>
+ <color name="colorAccent">#FF4081</color>
+</resources>
diff --git a/projects/todos/app/src/main/res/values/dimens.xml b/projects/todos/app/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..812cb7b
--- /dev/null
+++ b/projects/todos/app/src/main/res/values/dimens.xml
@@ -0,0 +1,6 @@
+<resources>
+ <!-- Default screen margins, per the Android Design guidelines. -->
+ <dimen name="activity_horizontal_margin">16dp</dimen>
+ <dimen name="activity_vertical_margin">16dp</dimen>
+ <dimen name="fab_margin">16dp</dimen>
+</resources>
diff --git a/projects/todos/app/src/main/res/values/strings.xml b/projects/todos/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..be63f07
--- /dev/null
+++ b/projects/todos/app/src/main/res/values/strings.xml
@@ -0,0 +1,10 @@
+<resources>
+ <string name="app_name">Vanadium Todos</string>
+ <string name="action_settings">Settings</string>
+ <string name="action_edit">Edit</string>
+ <string name="action_debug">Debug</string>
+ <string name="action_share">Share</string>
+ <string name="show_done">Show Done</string>
+ <string name="set_button">Set</string>
+ <string name="add_button">Add</string>
+</resources>
diff --git a/projects/todos/app/src/main/res/values/styles.xml b/projects/todos/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..545b9c6
--- /dev/null
+++ b/projects/todos/app/src/main/res/values/styles.xml
@@ -0,0 +1,20 @@
+<resources>
+
+ <!-- Base application theme. -->
+ <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+ <!-- Customize your theme here. -->
+ <item name="colorPrimary">@color/colorPrimary</item>
+ <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+ <item name="colorAccent">@color/colorAccent</item>
+ </style>
+
+ <style name="AppTheme.NoActionBar">
+ <item name="windowActionBar">false</item>
+ <item name="windowNoTitle">true</item>
+ </style>
+
+ <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
+
+ <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
+
+</resources>
diff --git a/projects/todos/app/src/test/java/io/v/firebaseexample/ExampleUnitTest.java b/projects/todos/app/src/test/java/io/v/firebaseexample/ExampleUnitTest.java
new file mode 100644
index 0000000..07340b3
--- /dev/null
+++ b/projects/todos/app/src/test/java/io/v/firebaseexample/ExampleUnitTest.java
@@ -0,0 +1,19 @@
+// Copyright 2016 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.todos;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * To work on unit tests, switch the Test Artifact in the Build Variants view.
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() throws Exception {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/projects/todos/build.gradle b/projects/todos/build.gradle
new file mode 100644
index 0000000..e0b366a
--- /dev/null
+++ b/projects/todos/build.gradle
@@ -0,0 +1,23 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ repositories {
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:1.5.0'
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ jcenter()
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/projects/todos/gradle.properties b/projects/todos/gradle.properties
new file mode 100644
index 0000000..1d3591c
--- /dev/null
+++ b/projects/todos/gradle.properties
@@ -0,0 +1,18 @@
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# Default value: -Xmx10248m -XX:MaxPermSize=256m
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
\ No newline at end of file
diff --git a/projects/todos/gradle/wrapper/gradle-wrapper.jar b/projects/todos/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..05ef575
--- /dev/null
+++ b/projects/todos/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/projects/todos/gradle/wrapper/gradle-wrapper.properties b/projects/todos/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..f23df6e
--- /dev/null
+++ b/projects/todos/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Oct 21 11:34:03 PDT 2015
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
diff --git a/projects/todos/gradlew b/projects/todos/gradlew
new file mode 100755
index 0000000..9d82f78
--- /dev/null
+++ b/projects/todos/gradlew
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/projects/todos/gradlew.bat b/projects/todos/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/projects/todos/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/projects/todos/settings.gradle b/projects/todos/settings.gradle
new file mode 100644
index 0000000..e7b4def
--- /dev/null
+++ b/projects/todos/settings.gradle
@@ -0,0 +1 @@
+include ':app'