Response to API usability study 2016.02.23

Making HelloBaku examples clearer. We now use a single data binding and
show an example of a write to Syncbase in response to a button
press. We've also renamed and commented on things that were unclear.

Change-Id: Idfaf063a3e21e00638cc5205ab2dc07e9be330b1
diff --git a/examples/hellobaku/android/app/build.gradle b/examples/hellobaku/android/app/build.gradle
index 0669b78..fbd75ee 100644
--- a/examples/hellobaku/android/app/build.gradle
+++ b/examples/hellobaku/android/app/build.gradle
@@ -1,10 +1,15 @@
 apply plugin: 'android-sdk-manager'
 apply plugin: 'com.android.application'
+apply plugin: 'me.tatarka.retrolambda'
 
 android {
     compileSdkVersion 23
     buildToolsVersion "23.0.1"
 
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
+    }
     defaultConfig {
         applicationId "io.v.baku.hellobaku"
         minSdkVersion 21
diff --git a/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivity.java b/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivity.java
index 7c12d40..84026f7 100644
--- a/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivity.java
+++ b/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivity.java
@@ -5,6 +5,7 @@
 package io.v.baku.hellobaku;
 
 import android.os.Bundle;
+import android.widget.EditText;
 
 import io.v.baku.toolkit.BakuActivity;
 
@@ -14,8 +15,16 @@
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_hello);
 
-        binder().key("text")
-                .bindTo(R.id.textView)
-                .bindTo(R.id.editText);
+        // Binds the Syncbase row named "message" to displayTextView
+        binder().key("message")
+                .bindTo(R.id.displayTextView);
+
+        final EditText txtInput = (EditText) findViewById(R.id.inputEditText);
+        findViewById(R.id.actionButton).setOnClickListener(bn -> {
+            // Writes the text of inputEditText to the Syncbase row named "message"
+            getSyncbaseTable().put("message", txtInput.getText().toString());
+
+            txtInput.setText("");
+        });
     }
 }
diff --git a/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivityALaCarte.java b/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivityALaCarte.java
index 1dd1a0b..28085d5 100644
--- a/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivityALaCarte.java
+++ b/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivityALaCarte.java
@@ -6,12 +6,15 @@
 
 import android.app.Activity;
 import android.os.Bundle;
+import android.widget.EditText;
 
+import io.v.baku.toolkit.ErrorReporters;
 import io.v.baku.toolkit.VAndroidContextMixin;
 import io.v.baku.toolkit.VAndroidContextTrait;
 import io.v.baku.toolkit.bind.SyncbaseBinding;
 import io.v.rx.syncbase.RxAndroidSyncbase;
 import io.v.rx.syncbase.RxDb;
+import io.v.rx.syncbase.RxTable;
 import io.v.rx.syncbase.UserSyncgroup;
 import rx.Subscription;
 
@@ -28,20 +31,32 @@
                 VAndroidContextMixin.withDefaults(this, savedInstanceState);
 
         mSb = new RxAndroidSyncbase(vActivity);
-        final RxDb db = mSb.rxApp("app").rxDb("db");
+        // Operate on Syncbase io.v.baku.hellobaku/db/t
+        final RxDb db = mSb.rxApp(getPackageName()).rxDb("db");
+        final RxTable t = db.rxTable("t");
 
-        // We want these data bindings to share the lifecycle of the Activity from onCreate to
-        // onDestroy, so keep track of their CompositeSubscription and unsubscribe in onDestroy.
+        // We want this data binding to share the lifecycle of the Activity from onCreate to
+        // onDestroy, so keep track of its Subscription and unsubscribe in onDestroy.
         mActivityDataBindings = SyncbaseBinding.builder()
                 .activity(vActivity)
                 .rxTable(db.rxTable("t"))
 
-                .key("text")
-                .bindTo(R.id.textView)
-                .bindTo(R.id.editText)
+                // Binds the Syncbase row named "message" to displayTextView
+                .key("message")
+                .bindTo(R.id.displayTextView)
 
                 .getAllBindings();
 
+        final EditText txtInput = (EditText) findViewById(R.id.inputEditText);
+        findViewById(R.id.actionButton).setOnClickListener(bn -> {
+            // Writes the text of inputEditText to the Syncbase row named "message"
+            t.put("message", txtInput.getText().toString())
+                    // Report any error. Normally BakuActivityMixin does this for you.
+                    .subscribe(x -> {}, ErrorReporters.getDefaultSyncErrorReporter(vActivity));
+
+            txtInput.setText("");
+        });
+
         UserSyncgroup.builder()
                 .activity(vActivity)
                 .db(db)
diff --git a/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivityComposition.java b/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivityComposition.java
index 6aa337a..93612eb 100644
--- a/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivityComposition.java
+++ b/examples/hellobaku/android/app/src/main/java/io/v/baku/hellobaku/HelloActivityComposition.java
@@ -6,6 +6,7 @@
 
 import android.app.Activity;
 import android.os.Bundle;
+import android.widget.EditText;
 
 import io.v.baku.toolkit.BakuActivityMixin;
 import io.v.baku.toolkit.BakuActivityTrait;
@@ -20,9 +21,17 @@
 
         mBaku = new BakuActivityMixin<>(this, savedInstanceState);
 
-        mBaku.binder().key("text")
-                .bindTo(R.id.textView)
-                .bindTo(R.id.editText);
+        // Binds the Syncbase row named "message" to displayTextView
+        mBaku.binder().key("message")
+                .bindTo(R.id.displayTextView);
+
+        final EditText txtInput = (EditText) findViewById(R.id.inputEditText);
+        findViewById(R.id.actionButton).setOnClickListener(bn -> {
+            // Writes the text of inputEditText to the Syncbase row named "message"
+            mBaku.getSyncbaseTable().put("message", txtInput.getText().toString());
+
+            txtInput.setText("");
+        });
     }
 
     @Override
diff --git a/examples/hellobaku/android/app/src/main/res/layout/activity_hello.xml b/examples/hellobaku/android/app/src/main/res/layout/activity_hello.xml
index 051ce5c..193ffa2 100644
--- a/examples/hellobaku/android/app/src/main/res/layout/activity_hello.xml
+++ b/examples/hellobaku/android/app/src/main/res/layout/activity_hello.xml
@@ -9,7 +9,7 @@
     tools:context=".HelloActivity">
 
     <TextView
-        android:id="@+id/textView"
+        android:id="@+id/displayTextView"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignParentEnd="true"
@@ -17,10 +17,18 @@
         android:layout_alignParentTop="true" />
 
     <EditText
-        android:id="@+id/editText"
+        android:id="@+id/inputEditText"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_alignEnd="@+id/textView"
         android:layout_alignParentStart="true"
-        android:layout_below="@+id/textView" />
+        android:layout_below="@+id/displayTextView"
+        android:layout_toStartOf="@+id/actionButton" />
+
+    <Button
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/bn_text"
+        android:id="@+id/actionButton"
+        android:layout_below="@+id/displayTextView"
+        android:layout_alignEnd="@+id/displayTextView" />
 </RelativeLayout>
diff --git a/examples/hellobaku/android/app/src/main/res/values/strings.xml b/examples/hellobaku/android/app/src/main/res/values/strings.xml
index b3c397f..ca2df86 100644
--- a/examples/hellobaku/android/app/src/main/res/values/strings.xml
+++ b/examples/hellobaku/android/app/src/main/res/values/strings.xml
@@ -2,4 +2,5 @@
     <string name="app_name">Hello Baku</string>
     <string name="comp_label">Hello Baku - Composition</string>
     <string name="alacarte_label">Hello Baku - À la Carte</string>
+    <string name="bn_text">Write</string>
 </resources>
diff --git a/examples/hellobaku/android/build.gradle b/examples/hellobaku/android/build.gradle
index 15c2350..4c4d164 100644
--- a/examples/hellobaku/android/build.gradle
+++ b/examples/hellobaku/android/build.gradle
@@ -7,7 +7,8 @@
     dependencies {
         classpath (
                 'com.android.tools.build:gradle:1.5.0',
-                'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
+                'com.jakewharton.sdkmanager:gradle-plugin:0.12.0',
+                'me.tatarka:gradle-retrolambda:3.2.4'
         )
 
         // NOTE: Do not place your application dependencies here; they belong