croupier: Flutter changes to correspond with Go

Most of these are relatively minor. Many of the changes are in the
associated Go CL.

Added a place for avatars.
Upgraded Flutter to latest alpha (~1 day ago)

Change-Id: I4730ca7274cd8a93a725d1cdacd87e48931437fc
diff --git a/Makefile b/Makefile
index b2f8cfa..6944afb 100644
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@
 	# Location of mounttable on syncslides-alpha network.
 	MOUNTTABLE := /192.168.86.254:8101
 	# Name to mount under.
-	NAME := croupier
+	NAME := croupierAlex
 
 	APP_HOME_DIR = /data/data/org.chromium.mojo.shell/app_home
 	ANDROID_CREDS_DIR := /sdcard/v23creds
@@ -34,13 +34,15 @@
 	SYNCBASE_FLAGS += --logtostderr=true \
 		--root-dir=$(APP_HOME_DIR)/syncbase_data \
 		--v23.credentials=$(ANDROID_CREDS_DIR) \
-		--v23.namespace.root=$(MOUNTTABLE)
+		--v23.proxy=proxy
+
+	#--v23.namespace.root=$(MOUNTTABLE) \
 
 ifeq ($(ANDROID), 1)
 	# If ANDROID is set to 1 exactly, then treat it like the first device.
 	# TODO(alexfandrianto): If we can do a better job of this, we won't have to
 	# special-case the first device.
-	SYNCBASE_FLAGS += --name=$(NAME)
+	SYNCBASE_FLAGS += --name=$(MOUNTTABLE)/$(NAME)
 endif
 
 # If this is not the first mojo shell, then you must reuse the devservers
@@ -70,10 +72,10 @@
 # Runs a sky app.
 # $1 is location of flx file.
 define RUN_SKY_APP
-	pub run sky_tools -v --very-verbose run_mojo \
+	pub run flutter_tools -v --very-verbose run_mojo \
 	--app $1 \
 	$(MOJO_ANDROID_FLAGS) \
-	--mojo-path $(MOJO_DIR)/src/mojo/devtools/common/mojo_run \
+	--mojo-path $(MOJO_DIR)/src \
 	--checked \
 	--mojo-debug \
 	-- $(MOJO_SHELL_FLAGS) \
@@ -113,7 +115,7 @@
 build: croupier.flx
 
 croupier.flx: packages $(DART_LIB_FILES_ALL)
-	pub run sky_tools -v build --manifest manifest.yaml --output-file $@
+	pub run flutter_tools -v build --manifest manifest.yaml --output-file $@
 
 # Starts the app on the specified ANDROID device.
 # Don't forget to make creds first if they are not present.
diff --git a/images/avatars/Club.png b/images/avatars/Club.png
new file mode 100644
index 0000000..d09abc2
--- /dev/null
+++ b/images/avatars/Club.png
Binary files differ
diff --git a/images/avatars/Diamond.png b/images/avatars/Diamond.png
new file mode 100644
index 0000000..83733ff
--- /dev/null
+++ b/images/avatars/Diamond.png
Binary files differ
diff --git a/images/avatars/Heart.png b/images/avatars/Heart.png
new file mode 100644
index 0000000..2212ebb
--- /dev/null
+++ b/images/avatars/Heart.png
Binary files differ
diff --git a/images/avatars/Spade.png b/images/avatars/Spade.png
new file mode 100644
index 0000000..13358da
--- /dev/null
+++ b/images/avatars/Spade.png
Binary files differ
diff --git a/lib/components/croupier_profile.dart b/lib/components/croupier_profile.dart
index ff11876..cf3de40 100644
--- a/lib/components/croupier_profile.dart
+++ b/lib/components/croupier_profile.dart
@@ -15,6 +15,6 @@
         decoration:
             new BoxDecoration(backgroundColor: new Color(settings.color)),
         child: new Column(
-            [new NetworkImage(src: settings.avatar), new Text(settings.name)]));
+            [new NetworkImage(src: CroupierSettings.makeAvatarUrl(settings.avatar)), new Text(settings.name)]));
   }
 }
diff --git a/lib/components/croupier_settings.dart b/lib/components/croupier_settings.dart
index 73f6922..d34bc2e 100644
--- a/lib/components/croupier_settings.dart
+++ b/lib/components/croupier_settings.dart
@@ -61,7 +61,7 @@
   }
 
   Widget _makeImageButton(String url, NoArgCb cb) {
-    return new FlatButton(child: new NetworkImage(src: url), onPressed: cb);
+    return new FlatButton(child: new NetworkImage(src: CroupierSettings.makeAvatarUrl(url)), onPressed: cb);
   }
 
   Widget build(BuildContext context) {
@@ -70,7 +70,7 @@
     w.add(_makeButtonRow(
         colorKey, _makeColoredRectangle(config.settings.color, "", null)));
     w.add(_makeButtonRow(
-        avatarKey, new NetworkImage(src: config.settings.avatar)));
+        avatarKey, new NetworkImage(src: CroupierSettings.makeAvatarUrl(config.settings.avatar))));
 
     w.add(new FlatButton(child: new Text("Return"), onPressed: config.backCb));
     return new Column(w);
diff --git a/lib/logic/croupier_settings.dart b/lib/logic/croupier_settings.dart
index 27966a0..4c5501a 100644
--- a/lib/logic/croupier_settings.dart
+++ b/lib/logic/croupier_settings.dart
@@ -13,6 +13,8 @@
   String name;
   int color;
 
+  static String makeAvatarUrl(String key) => 'images/avatars/${key}';
+
   CroupierSettings.random() {
     _randomInitialization();
   }
@@ -82,10 +84,10 @@
 
 class RandomSettings {
   static final List avatars = [
-    'images/suits/Club.png',
-    'images/suits/Diamond.png',
-    'images/suits/Heart.png',
-    'images/suits/Spade.png'
+    'Club.png',
+    'Diamond.png',
+    'Heart.png',
+    'Spade.png'
   ];
   static final List names = [
     'Anne',
diff --git a/lib/logic/hearts/hearts_log.part.dart b/lib/logic/hearts/hearts_log.part.dart
index 769dd42..c6ef13e 100644
--- a/lib/logic/hearts/hearts_log.part.dart
+++ b/lib/logic/hearts/hearts_log.part.dart
@@ -10,13 +10,13 @@
 
   HeartsLog() {
     // TODO(alexfandrianto): The Game ID needs to be part of this constructor.
-    logWriter = new LogWriter(handleSyncUpdate, [0, 1, 2, 3]);
     seenKeys = new Set<String>();
   }
 
   @override
   void setGame(Game g) {
     this.game = g;
+    logWriter = new LogWriter(handleSyncUpdate, [0, 1, 2, 3]);
     logWriter.associatedUser = this.game.playerNumber;
     logWriter.logPrefix = "${game.gameID}/log";
   }
diff --git a/lib/logic/solitaire/solitaire_log.part.dart b/lib/logic/solitaire/solitaire_log.part.dart
index 10da814..7a1d3ce 100644
--- a/lib/logic/solitaire/solitaire_log.part.dart
+++ b/lib/logic/solitaire/solitaire_log.part.dart
@@ -10,13 +10,13 @@
 
   SolitaireLog() {
     // TODO(alexfandrianto): The Game ID needs to be part of this constructor.
-    logWriter = new LogWriter(handleSyncUpdate, [0]);
     seenKeys = new Set<String>();
   }
 
   @override
   void setGame(Game g) {
     this.game = g;
+    logWriter = new LogWriter(handleSyncUpdate, [0]);
     logWriter.associatedUser = this.game.playerNumber;
     logWriter.logPrefix = "${game.gameID}/log";
   }
diff --git a/lib/src/syncbase/log_writer.dart b/lib/src/syncbase/log_writer.dart
index ca6b0ee..e7f6b9f 100644
--- a/lib/src/syncbase/log_writer.dart
+++ b/lib/src/syncbase/log_writer.dart
@@ -103,6 +103,10 @@
       util.log('Watch Key: ${wc.rowKey}');
       util.log('Watch Value ${UTF8.decode(wc.valueBytes)}');
       String key = wc.rowKey.replaceFirst("${this.logPrefix}/", "");
+      if (key == wc.rowKey) {
+        print("Lacks prefix '${this.logPrefix}/', skipping...");
+        continue;
+      }
       String value;
       switch (wc.changeType) {
         case WatchChangeTypes.put:
diff --git a/lib/src/syncbase/util.dart b/lib/src/syncbase/util.dart
index a6ff117..2c6a506 100644
--- a/lib/src/syncbase/util.dart
+++ b/lib/src/syncbase/util.dart
@@ -13,7 +13,7 @@
 // proxy. Otherwise, it will be difficult for other users to run.
 // https://github.com/vanadium/issues/issues/782
 const mtAddr = '/192.168.86.254:8101';
-const sgPrefix = 'croupier/%%sync';
+const sgPrefix = 'croupierAlex/%%sync';
 const sgSuffix = 'discovery';
 const sgSuffixGame = 'gaming';
 
@@ -37,3 +37,4 @@
 String syncgamePrefix(int gameID) {
   return "${gameID}";
 }
+
diff --git a/manifest.yaml b/manifest.yaml
index ff79910..49f0273 100644
--- a/manifest.yaml
+++ b/manifest.yaml
@@ -214,3 +214,7 @@
   - images/suits/Diamond.png
   - images/suits/Heart.png
   - images/suits/Spade.png
+  - images/avatars/Club.png
+  - images/avatars/Diamond.png
+  - images/avatars/Heart.png
+  - images/avatars/Spade.png
\ No newline at end of file
diff --git a/pubspec.yaml b/pubspec.yaml
index 08e678e..2c3a1a6 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -4,7 +4,7 @@
   syncbase: ">=0.0.0 <0.1.0"
   flutter:
     path: ../../../../../flutter/packages/flutter
-  sky_tools:
+  flutter_tools:
     path: ../../../../../flutter/packages/flutter_tools
   test: any