+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/build.gradle b/Week_09_Services_and_wearables/android-DataLayer-master/Application/build.gradle
new file mode 100644
index 0000000..82bcf89
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Application/build.gradle
@@ -0,0 +1,67 @@
+
+buildscript {
+ repositories {
+ jcenter()
+ }
+
+ dependencies {
+ classpath 'com.android.tools.build:gradle:2.3.3'
+ }
+}
+
+apply plugin: 'com.android.application'
+
+repositories {
+ jcenter()
+ maven {
+ url 'https://maven.google.com'
+ }
+}
+
+dependencies {
+ compile "com.android.support:support-v4:26.0.0"
+ compile "com.android.support:support-v13:26.0.0"
+ compile "com.android.support:cardview-v7:26.0.0"
+ compile "com.android.support:appcompat-v7:26.0.0"
+ compile 'com.google.android.gms:play-services-wearable:11.4.0'
+ compile 'com.android.support:support-v13:26.0.0'
+ wearApp project(':Wearable')
+}
+
+// The sample build uses multiple directories to
+// keep boilerplate and common code separate from
+// the main sample code.
+List dirs = [
+ 'main', // main sample code; look here for the interesting stuff.
+ 'common', // components that are reused by multiple samples
+ 'template'] // boilerplate code that is generated by the sample template process
+
+android {
+
+ compileSdkVersion 26
+
+ buildToolsVersion "26.0.1"
+
+ defaultConfig {
+ minSdkVersion 18
+ targetSdkVersion 25
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_7
+ targetCompatibility JavaVersion.VERSION_1_7
+ }
+
+ sourceSets {
+ main {
+ dirs.each { dir ->
+ java.srcDirs "src/${dir}/java"
+ res.srcDirs "src/${dir}/res"
+ }
+ }
+ androidTest.setRoot('tests')
+ androidTest.java.srcDirs = ['tests/src']
+
+ }
+
+}
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/AndroidManifest.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..ed1cec3
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/java/com/example/android/wearable/datalayer/MainActivity.java b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/java/com/example/android/wearable/datalayer/MainActivity.java
new file mode 100644
index 0000000..ca86d7a
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/java/com/example/android/wearable/datalayer/MainActivity.java
@@ -0,0 +1,459 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.wearable.datalayer;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentSender;
+import android.content.pm.PackageManager;
+import android.graphics.Bitmap;
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.provider.MediaStore;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import com.google.android.gms.common.ConnectionResult;
+import com.google.android.gms.common.api.GoogleApiClient;
+import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
+import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
+import com.google.android.gms.common.api.ResultCallback;
+import com.google.android.gms.wearable.Asset;
+import com.google.android.gms.wearable.CapabilityApi;
+import com.google.android.gms.wearable.CapabilityInfo;
+import com.google.android.gms.wearable.DataApi;
+import com.google.android.gms.wearable.DataApi.DataItemResult;
+import com.google.android.gms.wearable.DataEvent;
+import com.google.android.gms.wearable.DataEventBuffer;
+import com.google.android.gms.wearable.MessageApi;
+import com.google.android.gms.wearable.MessageApi.SendMessageResult;
+import com.google.android.gms.wearable.MessageEvent;
+import com.google.android.gms.wearable.Node;
+import com.google.android.gms.wearable.NodeApi;
+import com.google.android.gms.wearable.PutDataMapRequest;
+import com.google.android.gms.wearable.PutDataRequest;
+import com.google.android.gms.wearable.Wearable;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Receives its own events using a listener API designed for foreground activities. Updates a data
+ * item every second while it is open. Also allows user to take a photo and send that as an asset
+ * to the paired wearable.
+ */
+public class MainActivity extends Activity implements
+ CapabilityApi.CapabilityListener,
+ MessageApi.MessageListener,
+ DataApi.DataListener,
+ ConnectionCallbacks,
+ OnConnectionFailedListener {
+
+ private static final String TAG = "MainActivity";
+
+ //Request code for launching the Intent to resolve Google Play services errors.
+ private static final int REQUEST_RESOLVE_ERROR = 1000;
+
+ private static final int REQUEST_IMAGE_CAPTURE = 1;
+
+ private static final String START_ACTIVITY_PATH = "/start-activity";
+ private static final String COUNT_PATH = "/count";
+ private static final String IMAGE_PATH = "/image";
+ private static final String IMAGE_KEY = "photo";
+ private static final String COUNT_KEY = "count";
+
+ private GoogleApiClient mGoogleApiClient;
+ private boolean mResolvingError = false;
+ private boolean mCameraSupported = false;
+
+ private ListView mDataItemList;
+ private Button mSendPhotoBtn;
+ private ImageView mThumbView;
+ private Bitmap mImageBitmap;
+ private View mStartActivityBtn;
+
+ private DataItemAdapter mDataItemListAdapter;
+
+ // Send DataItems.
+ private ScheduledExecutorService mGeneratorExecutor;
+ private ScheduledFuture> mDataItemGeneratorFuture;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ LOGD(TAG, "onCreate");
+ mCameraSupported = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA);
+ setContentView(R.layout.main_activity);
+ setupViews();
+
+ // Stores DataItems received by the local broadcaster or from the paired watch.
+ mDataItemListAdapter = new DataItemAdapter(this, android.R.layout.simple_list_item_1);
+ mDataItemList.setAdapter(mDataItemListAdapter);
+
+ mGeneratorExecutor = new ScheduledThreadPoolExecutor(1);
+
+ mGoogleApiClient = new GoogleApiClient.Builder(this)
+ .addApi(Wearable.API)
+ .addConnectionCallbacks(this)
+ .addOnConnectionFailedListener(this)
+ .build();
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (!mResolvingError) {
+ mGoogleApiClient.connect();
+ }
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ mDataItemGeneratorFuture = mGeneratorExecutor.scheduleWithFixedDelay(
+ new DataItemGenerator(), 1, 5, TimeUnit.SECONDS);
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mDataItemGeneratorFuture.cancel(true /* mayInterruptIfRunning */);
+ }
+
+ @Override
+ protected void onStop() {
+ if (!mResolvingError && (mGoogleApiClient != null) && (mGoogleApiClient.isConnected())) {
+ Wearable.DataApi.removeListener(mGoogleApiClient, this);
+ Wearable.MessageApi.removeListener(mGoogleApiClient, this);
+ Wearable.CapabilityApi.removeListener(mGoogleApiClient, this);
+ mGoogleApiClient.disconnect();
+ }
+ super.onStop();
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
+ Bundle extras = data.getExtras();
+ mImageBitmap = (Bitmap) extras.get("data");
+ mThumbView.setImageBitmap(mImageBitmap);
+ }
+ }
+
+ @Override
+ public void onConnected(Bundle connectionHint) {
+ LOGD(TAG, "Google API Client was connected");
+ mResolvingError = false;
+ mStartActivityBtn.setEnabled(true);
+ mSendPhotoBtn.setEnabled(mCameraSupported);
+ Wearable.DataApi.addListener(mGoogleApiClient, this);
+ Wearable.MessageApi.addListener(mGoogleApiClient, this);
+ Wearable.CapabilityApi.addListener(
+ mGoogleApiClient, this, Uri.parse("wear://"), CapabilityApi.FILTER_REACHABLE);
+ }
+
+ @Override
+ public void onConnectionSuspended(int cause) {
+ LOGD(TAG, "Connection to Google API client was suspended");
+ mStartActivityBtn.setEnabled(false);
+ mSendPhotoBtn.setEnabled(false);
+ }
+
+ @Override
+ public void onConnectionFailed(ConnectionResult result) {
+ if (!mResolvingError) {
+
+ if (result.hasResolution()) {
+ try {
+ mResolvingError = true;
+ result.startResolutionForResult(this, REQUEST_RESOLVE_ERROR);
+ } catch (IntentSender.SendIntentException e) {
+ // There was an error with the resolution intent. Try again.
+ mGoogleApiClient.connect();
+ }
+ } else {
+ Log.e(TAG, "Connection to Google API client has failed");
+ mResolvingError = false;
+ mStartActivityBtn.setEnabled(false);
+ mSendPhotoBtn.setEnabled(false);
+ Wearable.DataApi.removeListener(mGoogleApiClient, this);
+ Wearable.MessageApi.removeListener(mGoogleApiClient, this);
+ Wearable.CapabilityApi.removeListener(mGoogleApiClient, this);
+ }
+ }
+ }
+
+ @Override
+ public void onDataChanged(DataEventBuffer dataEvents) {
+ LOGD(TAG, "onDataChanged: " + dataEvents);
+
+ for (DataEvent event : dataEvents) {
+ if (event.getType() == DataEvent.TYPE_CHANGED) {
+ mDataItemListAdapter.add(
+ new Event("DataItem Changed", event.getDataItem().toString()));
+ } else if (event.getType() == DataEvent.TYPE_DELETED) {
+ mDataItemListAdapter.add(
+ new Event("DataItem Deleted", event.getDataItem().toString()));
+ }
+ }
+ }
+
+ @Override
+ public void onMessageReceived(final MessageEvent messageEvent) {
+ LOGD(TAG, "onMessageReceived() A message from watch was received:"
+ + messageEvent.getRequestId() + " " + messageEvent.getPath());
+
+ mDataItemListAdapter.add(new Event("Message from watch", messageEvent.toString()));
+ }
+
+ @Override
+ public void onCapabilityChanged(final CapabilityInfo capabilityInfo) {
+ LOGD(TAG, "onCapabilityChanged: " + capabilityInfo);
+
+ mDataItemListAdapter.add(new Event("onCapabilityChanged", capabilityInfo.toString()));
+ }
+
+ /**
+ * Sets up UI components and their callback handlers.
+ */
+ private void setupViews() {
+ mSendPhotoBtn = (Button) findViewById(R.id.sendPhoto);
+ mThumbView = (ImageView) findViewById(R.id.imageView);
+ mDataItemList = (ListView) findViewById(R.id.data_item_list);
+ mStartActivityBtn = findViewById(R.id.start_wearable_activity);
+ }
+
+ public void onTakePhotoClick(View view) {
+ dispatchTakePictureIntent();
+ }
+
+ public void onSendPhotoClick(View view) {
+ if (null != mImageBitmap && mGoogleApiClient.isConnected()) {
+ sendPhoto(toAsset(mImageBitmap));
+ }
+ }
+
+ /**
+ * Sends an RPC to start a fullscreen Activity on the wearable.
+ */
+ public void onStartWearableActivityClick(View view) {
+ LOGD(TAG, "Generating RPC");
+
+ // Trigger an AsyncTask that will query for a list of connected nodes and send a
+ // "start-activity" message to each connected node.
+ new StartWearableActivityTask().execute();
+ }
+
+ private void sendStartActivityMessage(String node) {
+ Wearable.MessageApi.sendMessage(
+ mGoogleApiClient, node, START_ACTIVITY_PATH, new byte[0]).setResultCallback(
+ new ResultCallback() {
+ @Override
+ public void onResult(SendMessageResult sendMessageResult) {
+ if (!sendMessageResult.getStatus().isSuccess()) {
+ Log.e(TAG, "Failed to send message with status code: "
+ + sendMessageResult.getStatus().getStatusCode());
+ }
+ }
+ }
+ );
+ }
+
+ /**
+ * Dispatches an {@link android.content.Intent} to take a photo. Result will be returned back
+ * in onActivityResult().
+ */
+ private void dispatchTakePictureIntent() {
+ Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
+ if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
+ startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
+ }
+ }
+
+ /**
+ * Builds an {@link com.google.android.gms.wearable.Asset} from a bitmap. The image that we get
+ * back from the camera in "data" is a thumbnail size. Typically, your image should not exceed
+ * 320x320 and if you want to have zoom and parallax effect in your app, limit the size of your
+ * image to 640x400. Resize your image before transferring to your wearable device.
+ */
+ private static Asset toAsset(Bitmap bitmap) {
+ ByteArrayOutputStream byteStream = null;
+ try {
+ byteStream = new ByteArrayOutputStream();
+ bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteStream);
+ return Asset.createFromBytes(byteStream.toByteArray());
+ } finally {
+ if (null != byteStream) {
+ try {
+ byteStream.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ /**
+ * Sends the asset that was created from the photo we took by adding it to the Data Item store.
+ */
+ private void sendPhoto(Asset asset) {
+ PutDataMapRequest dataMap = PutDataMapRequest.create(IMAGE_PATH);
+ dataMap.getDataMap().putAsset(IMAGE_KEY, asset);
+ dataMap.getDataMap().putLong("time", new Date().getTime());
+ PutDataRequest request = dataMap.asPutDataRequest();
+ request.setUrgent();
+
+ Wearable.DataApi.putDataItem(mGoogleApiClient, request)
+ .setResultCallback(new ResultCallback() {
+ @Override
+ public void onResult(DataItemResult dataItemResult) {
+ LOGD(TAG, "Sending image was successful: " + dataItemResult.getStatus()
+ .isSuccess());
+ }
+ });
+ }
+
+ private Collection getNodes() {
+ HashSet results = new HashSet<>();
+ NodeApi.GetConnectedNodesResult nodes =
+ Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).await();
+
+ for (Node node : nodes.getNodes()) {
+ results.add(node.getId());
+ }
+
+ return results;
+ }
+
+ /**
+ * As simple wrapper around Log.d
+ */
+ private static void LOGD(final String tag, String message) {
+ if (Log.isLoggable(tag, Log.DEBUG)) {
+ Log.d(tag, message);
+ }
+ }
+
+ /**
+ * A View Adapter for presenting the Event objects in a list
+ */
+ private static class DataItemAdapter extends ArrayAdapter {
+
+ private final Context mContext;
+
+ public DataItemAdapter(Context context, int unusedResource) {
+ super(context, unusedResource);
+ mContext = context;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ ViewHolder holder;
+ if (convertView == null) {
+ holder = new ViewHolder();
+ LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ convertView = inflater.inflate(android.R.layout.two_line_list_item, null);
+ convertView.setTag(holder);
+ holder.text1 = (TextView) convertView.findViewById(android.R.id.text1);
+ holder.text2 = (TextView) convertView.findViewById(android.R.id.text2);
+ } else {
+ holder = (ViewHolder) convertView.getTag();
+ }
+ Event event = getItem(position);
+ holder.text1.setText(event.title);
+ holder.text2.setText(event.text);
+ return convertView;
+ }
+
+ private class ViewHolder {
+ TextView text1;
+ TextView text2;
+ }
+ }
+
+ private class Event {
+
+ String title;
+ String text;
+
+ public Event(String title, String text) {
+ this.title = title;
+ this.text = text;
+ }
+ }
+
+ private class StartWearableActivityTask extends AsyncTask {
+
+ @Override
+ protected Void doInBackground(Void... args) {
+ Collection nodes = getNodes();
+ for (String node : nodes) {
+ sendStartActivityMessage(node);
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Generates a DataItem based on an incrementing count.
+ */
+ private class DataItemGenerator implements Runnable {
+
+ private int count = 0;
+
+ @Override
+ public void run() {
+ PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(COUNT_PATH);
+ putDataMapRequest.getDataMap().putInt(COUNT_KEY, count++);
+
+ PutDataRequest request = putDataMapRequest.asPutDataRequest();
+ request.setUrgent();
+
+ LOGD(TAG, "Generating DataItem: " + request);
+ if (!mGoogleApiClient.isConnected()) {
+ return;
+ }
+ Wearable.DataApi.putDataItem(mGoogleApiClient, request)
+ .setResultCallback(new ResultCallback() {
+ @Override
+ public void onResult(DataItemResult dataItemResult) {
+ if (!dataItemResult.getStatus().isSuccess()) {
+ Log.e(TAG, "ERROR: failed to putDataItem, status code: "
+ + dataItemResult.getStatus().getStatusCode());
+ }
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-hdpi/ic_content_picture.png b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-hdpi/ic_content_picture.png
new file mode 100644
index 0000000..597997c
Binary files /dev/null and b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-hdpi/ic_content_picture.png differ
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-hdpi/ic_launcher.png b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..589f229
Binary files /dev/null and b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-hdpi/ic_launcher.png differ
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-hdpi/tile.9.png b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-hdpi/tile.9.png
new file mode 100644
index 0000000..1358628
Binary files /dev/null and b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-hdpi/tile.9.png differ
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-mdpi/ic_content_picture.png b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-mdpi/ic_content_picture.png
new file mode 100644
index 0000000..c23f4c0
Binary files /dev/null and b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-mdpi/ic_content_picture.png differ
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-mdpi/ic_launcher.png b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..77dd571
Binary files /dev/null and b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-mdpi/ic_launcher.png differ
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-xhdpi/ic_content_picture.png b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-xhdpi/ic_content_picture.png
new file mode 100644
index 0000000..289adf1
Binary files /dev/null and b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-xhdpi/ic_content_picture.png differ
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-xhdpi/ic_launcher.png b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..fe34ebe
Binary files /dev/null and b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-xxhdpi/ic_content_picture.png b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-xxhdpi/ic_content_picture.png
new file mode 100644
index 0000000..073ad55
Binary files /dev/null and b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-xxhdpi/ic_content_picture.png differ
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-xxhdpi/ic_launcher.png b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..ab80bcd
Binary files /dev/null and b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable-xxhdpi/ic_launcher.png differ
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable/divider.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable/divider.xml
new file mode 100644
index 0000000..95c4d33
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/drawable/divider.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/layout/main_activity.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/layout/main_activity.xml
new file mode 100644
index 0000000..0412023
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/layout/main_activity.xml
@@ -0,0 +1,86 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values-sw600dp/template-dimens.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values-sw600dp/template-dimens.xml
new file mode 100644
index 0000000..22074a2
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values-sw600dp/template-dimens.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+ @dimen/margin_huge
+ @dimen/margin_medium
+
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values-sw600dp/template-styles.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values-sw600dp/template-styles.xml
new file mode 100644
index 0000000..03d1974
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values-sw600dp/template-styles.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values-v11/template-styles.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values-v11/template-styles.xml
new file mode 100644
index 0000000..8c1ea66
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values-v11/template-styles.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values-v21/base-colors.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values-v21/base-colors.xml
new file mode 100644
index 0000000..8b6ec3f
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values-v21/base-colors.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values-v21/base-template-styles.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values-v21/base-template-styles.xml
new file mode 100644
index 0000000..c778e4f
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values-v21/base-template-styles.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values/base-strings.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values/base-strings.xml
new file mode 100644
index 0000000..d039ca8
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values/base-strings.xml
@@ -0,0 +1,31 @@
+
+
+
+
+ DataLayer
+
+
+
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values/strings.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values/strings.xml
new file mode 100644
index 0000000..9eba46c
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values/strings.xml
@@ -0,0 +1,22 @@
+
+
+
+
+ Start Wearable Activity
+ Start
+ Take a Photo
+ Send Photo
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values/style.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values/style.xml
new file mode 100644
index 0000000..81d6799
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values/style.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values/template-dimens.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values/template-dimens.xml
new file mode 100644
index 0000000..39e710b
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values/template-dimens.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+ 4dp
+ 8dp
+ 16dp
+ 32dp
+ 64dp
+
+
+
+ @dimen/margin_medium
+ @dimen/margin_medium
+
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values/template-styles.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values/template-styles.xml
new file mode 100644
index 0000000..6e7d593
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values/template-styles.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values/wear.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values/wear.xml
new file mode 100644
index 0000000..3220362
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Application/src/main/res/values/wear.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+ capability_1
+ capability_2
+
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/CONTRIB.md b/Week_09_Services_and_wearables/android-DataLayer-master/CONTRIB.md
new file mode 100644
index 0000000..14a4fcf
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/CONTRIB.md
@@ -0,0 +1,35 @@
+# How to become a contributor and submit your own code
+
+## Contributor License Agreements
+
+We'd love to accept your sample apps and patches! Before we can take them, we
+have to jump a couple of legal hurdles.
+
+Please fill out either the individual or corporate Contributor License Agreement (CLA).
+
+ * If you are an individual writing original source code and you're sure you
+ own the intellectual property, then you'll need to sign an [individual CLA]
+ (https://developers.google.com/open-source/cla/individual).
+ * If you work for a company that wants to allow you to contribute your work,
+ then you'll need to sign a [corporate CLA]
+ (https://developers.google.com/open-source/cla/corporate).
+
+Follow either of the two links above to access the appropriate CLA and
+instructions for how to sign and return it. Once we receive it, we'll be able to
+accept your pull requests.
+
+## Contributing A Patch
+
+1. Submit an issue describing your proposed change to the repo in question.
+1. The repo owner will respond to your issue promptly.
+1. If your proposed change is accepted, and you haven't already done so, sign a
+ Contributor License Agreement (see details above).
+1. Fork the desired repo, develop and test your code changes.
+1. Ensure that your code adheres to the existing style in the sample to which
+ you are contributing. Refer to the
+ [Android Code Style Guide]
+ (https://source.android.com/source/code-style.html) for the
+ recommended coding standards for this organization.
+1. Ensure that your code has an appropriate set of unit tests which all pass.
+1. Submit a pull request.
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/CONTRIBUTING.md b/Week_09_Services_and_wearables/android-DataLayer-master/CONTRIBUTING.md
new file mode 100644
index 0000000..faa8b5c
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/CONTRIBUTING.md
@@ -0,0 +1,35 @@
+# How to become a contributor and submit your own code
+
+## Contributor License Agreements
+
+We'd love to accept your sample apps and patches! Before we can take them, we
+have to jump a couple of legal hurdles.
+
+Please fill out either the individual or corporate Contributor License Agreement (CLA).
+
+ * If you are an individual writing original source code and you're sure you
+ own the intellectual property, then you'll need to sign an [individual CLA]
+ (https://cla.developers.google.com).
+ * If you work for a company that wants to allow you to contribute your work,
+ then you'll need to sign a [corporate CLA]
+ (https://cla.developers.google.com).
+
+Follow either of the two links above to access the appropriate CLA and
+instructions for how to sign and return it. Once we receive it, we'll be able to
+accept your pull requests.
+
+## Contributing A Patch
+
+1. Submit an issue describing your proposed change to the repo in question.
+1. The repo owner will respond to your issue promptly.
+1. If your proposed change is accepted, and you haven't already done so, sign a
+ Contributor License Agreement (see details above).
+1. Fork the desired repo, develop and test your code changes.
+1. Ensure that your code adheres to the existing style in the sample to which
+ you are contributing. Refer to the
+ [Android Code Style Guide]
+ (https://source.android.com/source/code-style.html) for the
+ recommended coding standards for this organization.
+1. Ensure that your code has an appropriate set of unit tests which all pass.
+1. Submit a pull request.
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/LICENSE b/Week_09_Services_and_wearables/android-DataLayer-master/LICENSE
new file mode 100644
index 0000000..4f22946
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/LICENSE
@@ -0,0 +1,647 @@
+Apache License
+--------------
+
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+All image and audio files (including *.png, *.jpg, *.svg, *.mp3, *.wav
+and *.ogg) are licensed under the CC-BY-NC license. All other files are
+licensed under the Apache 2 license.
+
+CC-BY-NC License
+----------------
+
+Attribution-NonCommercial-ShareAlike 4.0 International
+
+=======================================================================
+
+Creative Commons Corporation ("Creative Commons") is not a law firm and
+does not provide legal services or legal advice. Distribution of
+Creative Commons public licenses does not create a lawyer-client or
+other relationship. Creative Commons makes its licenses and related
+information available on an "as-is" basis. Creative Commons gives no
+warranties regarding its licenses, any material licensed under their
+terms and conditions, or any related information. Creative Commons
+disclaims all liability for damages resulting from their use to the
+fullest extent possible.
+
+Using Creative Commons Public Licenses
+
+Creative Commons public licenses provide a standard set of terms and
+conditions that creators and other rights holders may use to share
+original works of authorship and other material subject to copyright
+and certain other rights specified in the public license below. The
+following considerations are for informational purposes only, are not
+exhaustive, and do not form part of our licenses.
+
+ Considerations for licensors: Our public licenses are
+ intended for use by those authorized to give the public
+ permission to use material in ways otherwise restricted by
+ copyright and certain other rights. Our licenses are
+ irrevocable. Licensors should read and understand the terms
+ and conditions of the license they choose before applying it.
+ Licensors should also secure all rights necessary before
+ applying our licenses so that the public can reuse the
+ material as expected. Licensors should clearly mark any
+ material not subject to the license. This includes other CC-
+ licensed material, or material used under an exception or
+ limitation to copyright. More considerations for licensors:
+ wiki.creativecommons.org/Considerations_for_licensors
+
+ Considerations for the public: By using one of our public
+ licenses, a licensor grants the public permission to use the
+ licensed material under specified terms and conditions. If
+ the licensor's permission is not necessary for any reason--for
+ example, because of any applicable exception or limitation to
+ copyright--then that use is not regulated by the license. Our
+ licenses grant only permissions under copyright and certain
+ other rights that a licensor has authority to grant. Use of
+ the licensed material may still be restricted for other
+ reasons, including because others have copyright or other
+ rights in the material. A licensor may make special requests,
+ such as asking that all changes be marked or described.
+ Although not required by our licenses, you are encouraged to
+ respect those requests where reasonable. More_considerations
+ for the public:
+ wiki.creativecommons.org/Considerations_for_licensees
+
+=======================================================================
+
+Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
+Public License
+
+By exercising the Licensed Rights (defined below), You accept and agree
+to be bound by the terms and conditions of this Creative Commons
+Attribution-NonCommercial-ShareAlike 4.0 International Public License
+("Public License"). To the extent this Public License may be
+interpreted as a contract, You are granted the Licensed Rights in
+consideration of Your acceptance of these terms and conditions, and the
+Licensor grants You such rights in consideration of benefits the
+Licensor receives from making the Licensed Material available under
+these terms and conditions.
+
+
+Section 1 -- Definitions.
+
+ a. Adapted Material means material subject to Copyright and Similar
+ Rights that is derived from or based upon the Licensed Material
+ and in which the Licensed Material is translated, altered,
+ arranged, transformed, or otherwise modified in a manner requiring
+ permission under the Copyright and Similar Rights held by the
+ Licensor. For purposes of this Public License, where the Licensed
+ Material is a musical work, performance, or sound recording,
+ Adapted Material is always produced where the Licensed Material is
+ synched in timed relation with a moving image.
+
+ b. Adapter's License means the license You apply to Your Copyright
+ and Similar Rights in Your contributions to Adapted Material in
+ accordance with the terms and conditions of this Public License.
+
+ c. BY-NC-SA Compatible License means a license listed at
+ creativecommons.org/compatiblelicenses, approved by Creative
+ Commons as essentially the equivalent of this Public License.
+
+ d. Copyright and Similar Rights means copyright and/or similar rights
+ closely related to copyright including, without limitation,
+ performance, broadcast, sound recording, and Sui Generis Database
+ Rights, without regard to how the rights are labeled or
+ categorized. For purposes of this Public License, the rights
+ specified in Section 2(b)(1)-(2) are not Copyright and Similar
+ Rights.
+
+ e. Effective Technological Measures means those measures that, in the
+ absence of proper authority, may not be circumvented under laws
+ fulfilling obligations under Article 11 of the WIPO Copyright
+ Treaty adopted on December 20, 1996, and/or similar international
+ agreements.
+
+ f. Exceptions and Limitations means fair use, fair dealing, and/or
+ any other exception or limitation to Copyright and Similar Rights
+ that applies to Your use of the Licensed Material.
+
+ g. License Elements means the license attributes listed in the name
+ of a Creative Commons Public License. The License Elements of this
+ Public License are Attribution, NonCommercial, and ShareAlike.
+
+ h. Licensed Material means the artistic or literary work, database,
+ or other material to which the Licensor applied this Public
+ License.
+
+ i. Licensed Rights means the rights granted to You subject to the
+ terms and conditions of this Public License, which are limited to
+ all Copyright and Similar Rights that apply to Your use of the
+ Licensed Material and that the Licensor has authority to license.
+
+ j. Licensor means the individual(s) or entity(ies) granting rights
+ under this Public License.
+
+ k. NonCommercial means not primarily intended for or directed towards
+ commercial advantage or monetary compensation. For purposes of
+ this Public License, the exchange of the Licensed Material for
+ other material subject to Copyright and Similar Rights by digital
+ file-sharing or similar means is NonCommercial provided there is
+ no payment of monetary compensation in connection with the
+ exchange.
+
+ l. Share means to provide material to the public by any means or
+ process that requires permission under the Licensed Rights, such
+ as reproduction, public display, public performance, distribution,
+ dissemination, communication, or importation, and to make material
+ available to the public including in ways that members of the
+ public may access the material from a place and at a time
+ individually chosen by them.
+
+ m. Sui Generis Database Rights means rights other than copyright
+ resulting from Directive 96/9/EC of the European Parliament and of
+ the Council of 11 March 1996 on the legal protection of databases,
+ as amended and/or succeeded, as well as other essentially
+ equivalent rights anywhere in the world.
+
+ n. You means the individual or entity exercising the Licensed Rights
+ under this Public License. Your has a corresponding meaning.
+
+
+Section 2 -- Scope.
+
+ a. License grant.
+
+ 1. Subject to the terms and conditions of this Public License,
+ the Licensor hereby grants You a worldwide, royalty-free,
+ non-sublicensable, non-exclusive, irrevocable license to
+ exercise the Licensed Rights in the Licensed Material to:
+
+ a. reproduce and Share the Licensed Material, in whole or
+ in part, for NonCommercial purposes only; and
+
+ b. produce, reproduce, and Share Adapted Material for
+ NonCommercial purposes only.
+
+ 2. Exceptions and Limitations. For the avoidance of doubt, where
+ Exceptions and Limitations apply to Your use, this Public
+ License does not apply, and You do not need to comply with
+ its terms and conditions.
+
+ 3. Term. The term of this Public License is specified in Section
+ 6(a).
+
+ 4. Media and formats; technical modifications allowed. The
+ Licensor authorizes You to exercise the Licensed Rights in
+ all media and formats whether now known or hereafter created,
+ and to make technical modifications necessary to do so. The
+ Licensor waives and/or agrees not to assert any right or
+ authority to forbid You from making technical modifications
+ necessary to exercise the Licensed Rights, including
+ technical modifications necessary to circumvent Effective
+ Technological Measures. For purposes of this Public License,
+ simply making modifications authorized by this Section 2(a)
+ (4) never produces Adapted Material.
+
+ 5. Downstream recipients.
+
+ a. Offer from the Licensor -- Licensed Material. Every
+ recipient of the Licensed Material automatically
+ receives an offer from the Licensor to exercise the
+ Licensed Rights under the terms and conditions of this
+ Public License.
+
+ b. Additional offer from the Licensor -- Adapted Material.
+ Every recipient of Adapted Material from You
+ automatically receives an offer from the Licensor to
+ exercise the Licensed Rights in the Adapted Material
+ under the conditions of the Adapter's License You apply.
+
+ c. No downstream restrictions. You may not offer or impose
+ any additional or different terms or conditions on, or
+ apply any Effective Technological Measures to, the
+ Licensed Material if doing so restricts exercise of the
+ Licensed Rights by any recipient of the Licensed
+ Material.
+
+ 6. No endorsement. Nothing in this Public License constitutes or
+ may be construed as permission to assert or imply that You
+ are, or that Your use of the Licensed Material is, connected
+ with, or sponsored, endorsed, or granted official status by,
+ the Licensor or others designated to receive attribution as
+ provided in Section 3(a)(1)(A)(i).
+
+ b. Other rights.
+
+ 1. Moral rights, such as the right of integrity, are not
+ licensed under this Public License, nor are publicity,
+ privacy, and/or other similar personality rights; however, to
+ the extent possible, the Licensor waives and/or agrees not to
+ assert any such rights held by the Licensor to the limited
+ extent necessary to allow You to exercise the Licensed
+ Rights, but not otherwise.
+
+ 2. Patent and trademark rights are not licensed under this
+ Public License.
+
+ 3. To the extent possible, the Licensor waives any right to
+ collect royalties from You for the exercise of the Licensed
+ Rights, whether directly or through a collecting society
+ under any voluntary or waivable statutory or compulsory
+ licensing scheme. In all other cases the Licensor expressly
+ reserves any right to collect such royalties, including when
+ the Licensed Material is used other than for NonCommercial
+ purposes.
+
+
+Section 3 -- License Conditions.
+
+Your exercise of the Licensed Rights is expressly made subject to the
+following conditions.
+
+ a. Attribution.
+
+ 1. If You Share the Licensed Material (including in modified
+ form), You must:
+
+ a. retain the following if it is supplied by the Licensor
+ with the Licensed Material:
+
+ i. identification of the creator(s) of the Licensed
+ Material and any others designated to receive
+ attribution, in any reasonable manner requested by
+ the Licensor (including by pseudonym if
+ designated);
+
+ ii. a copyright notice;
+
+ iii. a notice that refers to this Public License;
+
+ iv. a notice that refers to the disclaimer of
+ warranties;
+
+ v. a URI or hyperlink to the Licensed Material to the
+ extent reasonably practicable;
+
+ b. indicate if You modified the Licensed Material and
+ retain an indication of any previous modifications; and
+
+ c. indicate the Licensed Material is licensed under this
+ Public License, and include the text of, or the URI or
+ hyperlink to, this Public License.
+
+ 2. You may satisfy the conditions in Section 3(a)(1) in any
+ reasonable manner based on the medium, means, and context in
+ which You Share the Licensed Material. For example, it may be
+ reasonable to satisfy the conditions by providing a URI or
+ hyperlink to a resource that includes the required
+ information.
+ 3. If requested by the Licensor, You must remove any of the
+ information required by Section 3(a)(1)(A) to the extent
+ reasonably practicable.
+
+ b. ShareAlike.
+
+ In addition to the conditions in Section 3(a), if You Share
+ Adapted Material You produce, the following conditions also apply.
+
+ 1. The Adapter's License You apply must be a Creative Commons
+ license with the same License Elements, this version or
+ later, or a BY-NC-SA Compatible License.
+
+ 2. You must include the text of, or the URI or hyperlink to, the
+ Adapter's License You apply. You may satisfy this condition
+ in any reasonable manner based on the medium, means, and
+ context in which You Share Adapted Material.
+
+ 3. You may not offer or impose any additional or different terms
+ or conditions on, or apply any Effective Technological
+ Measures to, Adapted Material that restrict exercise of the
+ rights granted under the Adapter's License You apply.
+
+
+Section 4 -- Sui Generis Database Rights.
+
+Where the Licensed Rights include Sui Generis Database Rights that
+apply to Your use of the Licensed Material:
+
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right
+ to extract, reuse, reproduce, and Share all or a substantial
+ portion of the contents of the database for NonCommercial purposes
+ only;
+
+ b. if You include all or a substantial portion of the database
+ contents in a database in which You have Sui Generis Database
+ Rights, then the database in which You have Sui Generis Database
+ Rights (but not its individual contents) is Adapted Material,
+ including for purposes of Section 3(b); and
+
+ c. You must comply with the conditions in Section 3(a) if You Share
+ all or a substantial portion of the contents of the database.
+
+For the avoidance of doubt, this Section 4 supplements and does not
+replace Your obligations under this Public License where the Licensed
+Rights include other Copyright and Similar Rights.
+
+
+Section 5 -- Disclaimer of Warranties and Limitation of Liability.
+
+ a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
+ EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
+ AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
+ ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
+ IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
+ WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
+ ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
+ KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
+ ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
+
+ b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
+ TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
+ NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
+ COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
+ USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
+ ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
+ DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
+ IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
+
+ c. The disclaimer of warranties and limitation of liability provided
+ above shall be interpreted in a manner that, to the extent
+ possible, most closely approximates an absolute disclaimer and
+ waiver of all liability.
+
+
+Section 6 -- Term and Termination.
+
+ a. This Public License applies for the term of the Copyright and
+ Similar Rights licensed here. However, if You fail to comply with
+ this Public License, then Your rights under this Public License
+ terminate automatically.
+
+ b. Where Your right to use the Licensed Material has terminated under
+ Section 6(a), it reinstates:
+
+ 1. automatically as of the date the violation is cured, provided
+ it is cured within 30 days of Your discovery of the
+ violation; or
+
+ 2. upon express reinstatement by the Licensor.
+
+ For the avoidance of doubt, this Section 6(b) does not affect any
+ right the Licensor may have to seek remedies for Your violations
+ of this Public License.
+
+ c. For the avoidance of doubt, the Licensor may also offer the
+ Licensed Material under separate terms or conditions or stop
+ distributing the Licensed Material at any time; however, doing so
+ will not terminate this Public License.
+
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
+ License.
+
+
+Section 7 -- Other Terms and Conditions.
+
+ a. The Licensor shall not be bound by any additional or different
+ terms or conditions communicated by You unless expressly agreed.
+
+ b. Any arrangements, understandings, or agreements regarding the
+ Licensed Material not stated herein are separate from and
+ independent of the terms and conditions of this Public License.
+
+
+Section 8 -- Interpretation.
+
+ a. For the avoidance of doubt, this Public License does not, and
+ shall not be interpreted to, reduce, limit, restrict, or impose
+ conditions on any use of the Licensed Material that could lawfully
+ be made without permission under this Public License.
+
+ b. To the extent possible, if any provision of this Public License is
+ deemed unenforceable, it shall be automatically reformed to the
+ minimum extent necessary to make it enforceable. If the provision
+ cannot be reformed, it shall be severed from this Public License
+ without affecting the enforceability of the remaining terms and
+ conditions.
+
+ c. No term or condition of this Public License will be waived and no
+ failure to comply consented to unless expressly agreed to by the
+ Licensor.
+
+ d. Nothing in this Public License constitutes or may be interpreted
+ as a limitation upon, or waiver of, any privileges and immunities
+ that apply to the Licensor or You, including from the legal
+ processes of any jurisdiction or authority.
+
+=======================================================================
+
+Creative Commons is not a party to its public licenses.
+Notwithstanding, Creative Commons may elect to apply one of its public
+licenses to material it publishes and in those instances will be
+considered the "Licensor." Except for the limited purpose of indicating
+that material is shared under a Creative Commons public license or as
+otherwise permitted by the Creative Commons policies published at
+creativecommons.org/policies, Creative Commons does not authorize the
+use of the trademark "Creative Commons" or any other trademark or logo
+of Creative Commons without its prior written consent including,
+without limitation, in connection with any unauthorized modifications
+to any of its public licenses or any other arrangements,
+understandings, or agreements concerning use of licensed material. For
+the avoidance of doubt, this paragraph does not form part of the public
+licenses.
+
+Creative Commons may be contacted at creativecommons.org.
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/README.md b/Week_09_Services_and_wearables/android-DataLayer-master/README.md
new file mode 100644
index 0000000..f13caff
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/README.md
@@ -0,0 +1,75 @@
+
+Android DataLayer Sample
+===================================
+
+This sample demonstrates how to work with a WearableListenerService,
+to produce and consume DataEvents and effectively work with the DataLayer.
+
+Introduction
+------------
+
+This sample demonstrates how to make a handheld and an Android Wear device communicate
+using the [DataApi][2].
+It does this by sending a picture between connected devices.
+
+An Activity is being used for both the connected devices which implement their parts of
+the required interfaces.
+
+It showcases how to use an [WearableListenerService][1] to consume DataEvents
+as well as implementations for various required listeners when using the [DataApi][2],
+[MessageApi][3] and [NodeApi][4].
+
+[1]: https://developer.android.com/reference/com/google/android/gms/wearable/WearableListenerService.html
+[2]: https://developer.android.com/reference/com/google/android/gms/wearable/DataApi.html
+[3]: https://developer.android.com/reference/com/google/android/gms/wearable/MessageApi.html
+[4]: https://developer.android.com/reference/com/google/android/gms/wearable/NodeApi.html
+
+Pre-requisites
+--------------
+
+- Android SDK 26
+- Android Build Tools v26.0.1
+- Android Support Repository
+
+Screenshots
+-------------
+
+
+
+Getting Started
+---------------
+
+This sample uses the Gradle build system. To build this project, use the
+"gradlew build" command or use "Import Project" in Android Studio.
+
+Support
+-------
+
+- Google+ Community: https://plus.google.com/communities/105153134372062985968
+- Stack Overflow: http://stackoverflow.com/questions/tagged/android
+
+If you've found an error in this sample, please file an issue:
+https://github.com/googlesamples/android-DataLayer
+
+Patches are encouraged, and may be submitted by forking this project and
+submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
+
+License
+-------
+
+Copyright 2017 The Android Open Source Project, Inc.
+
+Licensed to the Apache Software Foundation (ASF) under one or more contributor
+license agreements. See the NOTICE file distributed with this work for
+additional information regarding copyright ownership. The ASF licenses this
+file to you under the Apache License, Version 2.0 (the "License"); you may not
+use this file except in compliance with the License. You may obtain a copy of
+the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+License for the specific language governing permissions and limitations under
+the License.
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/build.gradle b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/build.gradle
new file mode 100644
index 0000000..b9ed618
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/build.gradle
@@ -0,0 +1,77 @@
+
+buildscript {
+ repositories {
+ jcenter()
+ }
+
+ dependencies {
+ classpath 'com.android.tools.build:gradle:2.3.3'
+ }
+}
+
+apply plugin: 'com.android.application'
+
+repositories {
+ jcenter()
+ maven {
+ url 'https://maven.google.com'
+ }
+}
+
+
+
+dependencies {
+
+
+
+ compile 'com.google.android.gms:play-services-wearable:11.4.0'
+ compile 'com.android.support:support-v13:26.0.0'
+
+ provided 'com.google.android.wearable:wearable:2.0.5'
+
+ compile 'com.google.android.support:wearable:2.0.5'
+
+}
+
+// The sample build uses multiple directories to
+// keep boilerplate and common code separate from
+// the main sample code.
+List dirs = [
+ 'main', // main sample code; look here for the interesting stuff.
+ 'common', // components that are reused by multiple samples
+ 'template'] // boilerplate code that is generated by the sample template process
+
+android {
+
+ compileSdkVersion 26
+
+ buildToolsVersion "26.0.1"
+
+ defaultConfig {
+ versionCode 1
+ versionName "1.0"
+
+ minSdkVersion 18
+
+ targetSdkVersion 25
+
+
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_7
+ targetCompatibility JavaVersion.VERSION_1_7
+ }
+
+ sourceSets {
+ main {
+ dirs.each { dir ->
+ java.srcDirs "src/${dir}/java"
+ res.srcDirs "src/${dir}/res"
+ }
+ }
+ androidTest.setRoot('tests')
+ androidTest.java.srcDirs = ['tests/src']
+
+ }
+}
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/AndroidManifest.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..2bc5f4c
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/AndroidManifest.xml
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/java/com/example/android/wearable/datalayer/DataLayerListenerService.java b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/java/com/example/android/wearable/datalayer/DataLayerListenerService.java
new file mode 100644
index 0000000..020cd15
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/java/com/example/android/wearable/datalayer/DataLayerListenerService.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.wearable.datalayer;
+
+import android.content.Intent;
+import android.net.Uri;
+import android.util.Log;
+
+import com.google.android.gms.common.ConnectionResult;
+import com.google.android.gms.common.api.GoogleApiClient;
+import com.google.android.gms.wearable.DataEvent;
+import com.google.android.gms.wearable.DataEventBuffer;
+import com.google.android.gms.wearable.MessageEvent;
+import com.google.android.gms.wearable.Wearable;
+import com.google.android.gms.wearable.WearableListenerService;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Listens to DataItems and Messages from the local node.
+ */
+public class DataLayerListenerService extends WearableListenerService {
+
+ private static final String TAG = "DataLayerService";
+
+ private static final String START_ACTIVITY_PATH = "/start-activity";
+ private static final String DATA_ITEM_RECEIVED_PATH = "/data-item-received";
+ public static final String COUNT_PATH = "/count";
+ public static final String IMAGE_PATH = "/image";
+ public static final String IMAGE_KEY = "photo";
+ GoogleApiClient mGoogleApiClient;
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ mGoogleApiClient = new GoogleApiClient.Builder(this)
+ .addApi(Wearable.API)
+ .build();
+ mGoogleApiClient.connect();
+ }
+
+ @Override
+ public void onDataChanged(DataEventBuffer dataEvents) {
+ LOGD(TAG, "onDataChanged: " + dataEvents);
+ if (!mGoogleApiClient.isConnected() || !mGoogleApiClient.isConnecting()) {
+ ConnectionResult connectionResult = mGoogleApiClient
+ .blockingConnect(30, TimeUnit.SECONDS);
+ if (!connectionResult.isSuccess()) {
+ Log.e(TAG, "DataLayerListenerService failed to connect to GoogleApiClient, "
+ + "error code: " + connectionResult.getErrorCode());
+ return;
+ }
+ }
+
+ // Loop through the events and send a message back to the node that created the data item.
+ for (DataEvent event : dataEvents) {
+ Uri uri = event.getDataItem().getUri();
+ String path = uri.getPath();
+ if (COUNT_PATH.equals(path)) {
+ // Get the node id of the node that created the data item from the host portion of
+ // the uri.
+ String nodeId = uri.getHost();
+ // Set the data of the message to be the bytes of the Uri.
+ byte[] payload = uri.toString().getBytes();
+
+ // Send the rpc
+ Wearable.MessageApi.sendMessage(mGoogleApiClient, nodeId, DATA_ITEM_RECEIVED_PATH,
+ payload);
+ }
+ }
+ }
+
+ @Override
+ public void onMessageReceived(MessageEvent messageEvent) {
+ LOGD(TAG, "onMessageReceived: " + messageEvent);
+
+ // Check to see if the message is to start an activity
+ if (messageEvent.getPath().equals(START_ACTIVITY_PATH)) {
+ Intent startIntent = new Intent(this, MainActivity.class);
+ startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ startActivity(startIntent);
+ }
+ }
+
+ public static void LOGD(final String tag, String message) {
+ if (Log.isLoggable(tag, Log.DEBUG)) {
+ Log.d(tag, message);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/java/com/example/android/wearable/datalayer/MainActivity.java b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/java/com/example/android/wearable/datalayer/MainActivity.java
new file mode 100644
index 0000000..402912f
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/java/com/example/android/wearable/datalayer/MainActivity.java
@@ -0,0 +1,346 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.wearable.datalayer;
+
+import static com.example.android.wearable.datalayer.DataLayerListenerService.LOGD;
+
+import android.app.Activity;
+import android.app.Fragment;
+import android.app.FragmentManager;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.support.wearable.view.DotsPageIndicator;
+import android.support.wearable.view.FragmentGridPagerAdapter;
+import android.support.wearable.view.GridViewPager;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.Toast;
+
+import com.example.android.wearable.datalayer.fragments.AssetFragment;
+import com.example.android.wearable.datalayer.fragments.DataFragment;
+import com.example.android.wearable.datalayer.fragments.DiscoveryFragment;
+import com.google.android.gms.common.ConnectionResult;
+import com.google.android.gms.common.api.GoogleApiClient;
+import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
+import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
+import com.google.android.gms.common.api.PendingResult;
+import com.google.android.gms.common.api.ResultCallback;
+import com.google.android.gms.wearable.Asset;
+import com.google.android.gms.wearable.CapabilityApi;
+import com.google.android.gms.wearable.CapabilityInfo;
+import com.google.android.gms.wearable.DataApi;
+import com.google.android.gms.wearable.DataEvent;
+import com.google.android.gms.wearable.DataEventBuffer;
+import com.google.android.gms.wearable.DataMapItem;
+import com.google.android.gms.wearable.MessageApi;
+import com.google.android.gms.wearable.MessageEvent;
+import com.google.android.gms.wearable.Node;
+import com.google.android.gms.wearable.Wearable;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * The main activity with a view pager, containing three pages:
+ *
+ *
+ * Page 1: shows a list of DataItems received from the phone application
+ *
+ *
+ * Page 2: shows the photo that is sent from the phone application
+ *
+ *
+ * Page 3: includes two buttons to show the connected phone and watch devices
+ *
+ *
+ */
+public class MainActivity extends Activity implements
+ ConnectionCallbacks,
+ OnConnectionFailedListener,
+ DataApi.DataListener,
+ MessageApi.MessageListener,
+ CapabilityApi.CapabilityListener {
+
+ private static final String TAG = "MainActivity";
+ private static final String CAPABILITY_1_NAME = "capability_1";
+ private static final String CAPABILITY_2_NAME = "capability_2";
+
+ private GoogleApiClient mGoogleApiClient;
+ private GridViewPager mPager;
+ private DataFragment mDataFragment;
+ private AssetFragment mAssetFragment;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main_activity);
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+ setupViews();
+ mGoogleApiClient = new GoogleApiClient.Builder(this)
+ .addApi(Wearable.API)
+ .addConnectionCallbacks(this)
+ .addOnConnectionFailedListener(this)
+ .build();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ mGoogleApiClient.connect();
+ }
+
+ @Override
+ protected void onPause() {
+ if ((mGoogleApiClient != null) && mGoogleApiClient.isConnected()) {
+ Wearable.DataApi.removeListener(mGoogleApiClient, this);
+ Wearable.MessageApi.removeListener(mGoogleApiClient, this);
+ Wearable.CapabilityApi.removeListener(mGoogleApiClient, this);
+ mGoogleApiClient.disconnect();
+ }
+
+ super.onPause();
+ }
+
+ @Override
+ public void onConnected(Bundle connectionHint) {
+ LOGD(TAG, "onConnected(): Successfully connected to Google API client");
+ Wearable.DataApi.addListener(mGoogleApiClient, this);
+ Wearable.MessageApi.addListener(mGoogleApiClient, this);
+ Wearable.CapabilityApi.addListener(
+ mGoogleApiClient, this, Uri.parse("wear://"), CapabilityApi.FILTER_REACHABLE);
+ }
+
+ @Override
+ public void onConnectionSuspended(int cause) {
+ LOGD(TAG, "onConnectionSuspended(): Connection to Google API client was suspended");
+ }
+
+ @Override
+ public void onConnectionFailed(ConnectionResult result) {
+ Log.e(TAG, "onConnectionFailed(): Failed to connect, with result: " + result);
+ }
+
+ @Override
+ public void onDataChanged(DataEventBuffer dataEvents) {
+ LOGD(TAG, "onDataChanged(): " + dataEvents);
+
+ for (DataEvent event : dataEvents) {
+ if (event.getType() == DataEvent.TYPE_CHANGED) {
+ String path = event.getDataItem().getUri().getPath();
+ if (DataLayerListenerService.IMAGE_PATH.equals(path)) {
+ DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem());
+ Asset photoAsset = dataMapItem.getDataMap()
+ .getAsset(DataLayerListenerService.IMAGE_KEY);
+ // Loads image on background thread.
+ new LoadBitmapAsyncTask().execute(photoAsset);
+
+ } else if (DataLayerListenerService.COUNT_PATH.equals(path)) {
+ LOGD(TAG, "Data Changed for COUNT_PATH");
+ mDataFragment.appendItem("DataItem Changed", event.getDataItem().toString());
+ } else {
+ LOGD(TAG, "Unrecognized path: " + path);
+ }
+
+ } else if (event.getType() == DataEvent.TYPE_DELETED) {
+ mDataFragment.appendItem("DataItem Deleted", event.getDataItem().toString());
+ } else {
+ mDataFragment.appendItem("Unknown data event type", "Type = " + event.getType());
+ }
+ }
+ }
+
+ public void onClicked(View view) {
+ switch (view.getId()) {
+ case R.id.capability_2_btn:
+ showNodes(CAPABILITY_2_NAME);
+ break;
+ case R.id.capabilities_1_and_2_btn:
+ showNodes(CAPABILITY_1_NAME, CAPABILITY_2_NAME);
+ break;
+ default:
+ Log.e(TAG, "Unknown click event registered");
+ }
+ }
+
+ /**
+ * Find the connected nodes that provide at least one of the given capabilities
+ */
+ private void showNodes(final String... capabilityNames) {
+
+ PendingResult pendingCapabilityResult =
+ Wearable.CapabilityApi.getAllCapabilities(
+ mGoogleApiClient,
+ CapabilityApi.FILTER_REACHABLE);
+
+ pendingCapabilityResult.setResultCallback(
+ new ResultCallback() {
+ @Override
+ public void onResult(
+ CapabilityApi.GetAllCapabilitiesResult getAllCapabilitiesResult) {
+
+ if (!getAllCapabilitiesResult.getStatus().isSuccess()) {
+ Log.e(TAG, "Failed to get capabilities");
+ return;
+ }
+
+ Map capabilitiesMap =
+ getAllCapabilitiesResult.getAllCapabilities();
+ Set nodes = new HashSet<>();
+
+ if (capabilitiesMap.isEmpty()) {
+ showDiscoveredNodes(nodes);
+ return;
+ }
+ for (String capabilityName : capabilityNames) {
+ CapabilityInfo capabilityInfo = capabilitiesMap.get(capabilityName);
+ if (capabilityInfo != null) {
+ nodes.addAll(capabilityInfo.getNodes());
+ }
+ }
+ showDiscoveredNodes(nodes);
+ }
+
+ private void showDiscoveredNodes(Set nodes) {
+ List nodesList = new ArrayList<>();
+ for (Node node : nodes) {
+ nodesList.add(node.getDisplayName());
+ }
+ LOGD(TAG, "Connected Nodes: " + (nodesList.isEmpty()
+ ? "No connected device was found for the given capabilities"
+ : TextUtils.join(",", nodesList)));
+ String msg;
+ if (!nodesList.isEmpty()) {
+ msg = getString(R.string.connected_nodes,
+ TextUtils.join(", ", nodesList));
+ } else {
+ msg = getString(R.string.no_device);
+ }
+ Toast.makeText(MainActivity.this, msg, Toast.LENGTH_LONG).show();
+ }
+ });
+ }
+
+ @Override
+ public void onMessageReceived(MessageEvent event) {
+ LOGD(TAG, "onMessageReceived: " + event);
+ mDataFragment.appendItem("Message", event.toString());
+ }
+
+ @Override
+ public void onCapabilityChanged(CapabilityInfo capabilityInfo) {
+ LOGD(TAG, "onCapabilityChanged: " + capabilityInfo);
+ mDataFragment.appendItem("onCapabilityChanged", capabilityInfo.toString());
+ }
+
+ private void setupViews() {
+ mPager = (GridViewPager) findViewById(R.id.pager);
+ mPager.setOffscreenPageCount(2);
+ DotsPageIndicator dotsPageIndicator = (DotsPageIndicator) findViewById(R.id.page_indicator);
+ dotsPageIndicator.setDotSpacing((int) getResources().getDimension(R.dimen.dots_spacing));
+ dotsPageIndicator.setPager(mPager);
+ mDataFragment = new DataFragment();
+ mAssetFragment = new AssetFragment();
+ DiscoveryFragment discoveryFragment = new DiscoveryFragment();
+ List pages = new ArrayList<>();
+ pages.add(mDataFragment);
+ pages.add(mAssetFragment);
+ pages.add(discoveryFragment);
+ final MyPagerAdapter adapter = new MyPagerAdapter(getFragmentManager(), pages);
+ mPager.setAdapter(adapter);
+ }
+
+ /**
+ * Switches to the page {@code index}. The first page has index 0.
+ */
+ private void moveToPage(int index) {
+ mPager.setCurrentItem(0, index, true);
+ }
+
+ private class MyPagerAdapter extends FragmentGridPagerAdapter {
+
+ private List mFragments;
+
+ public MyPagerAdapter(FragmentManager fm, List fragments) {
+ super(fm);
+ mFragments = fragments;
+ }
+
+ @Override
+ public int getRowCount() {
+ return 1;
+ }
+
+ @Override
+ public int getColumnCount(int row) {
+ return mFragments == null ? 0 : mFragments.size();
+ }
+
+ @Override
+ public Fragment getFragment(int row, int column) {
+ return mFragments.get(column);
+ }
+
+ }
+
+ /*
+ * Extracts {@link android.graphics.Bitmap} data from the
+ * {@link com.google.android.gms.wearable.Asset}
+ */
+ private class LoadBitmapAsyncTask extends AsyncTask {
+
+ @Override
+ protected Bitmap doInBackground(Asset... params) {
+
+ if (params.length > 0) {
+
+ Asset asset = params[0];
+
+ InputStream assetInputStream = Wearable.DataApi.getFdForAsset(
+ mGoogleApiClient, asset).await().getInputStream();
+
+ if (assetInputStream == null) {
+ Log.w(TAG, "Requested an unknown Asset.");
+ return null;
+ }
+ return BitmapFactory.decodeStream(assetInputStream);
+
+ } else {
+ Log.e(TAG, "Asset must be non-null");
+ return null;
+ }
+ }
+
+ @Override
+ protected void onPostExecute(Bitmap bitmap) {
+
+ if (bitmap != null) {
+ LOGD(TAG, "Setting background image on second page..");
+ moveToPage(1);
+ mAssetFragment.setBackgroundImage(bitmap);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/java/com/example/android/wearable/datalayer/fragments/AssetFragment.java b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/java/com/example/android/wearable/datalayer/fragments/AssetFragment.java
new file mode 100644
index 0000000..879c2a7
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/java/com/example/android/wearable/datalayer/fragments/AssetFragment.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.wearable.datalayer.fragments;
+
+import android.app.Fragment;
+import android.graphics.Bitmap;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+
+import com.example.android.wearable.datalayer.R;
+
+/**
+ * A simple fragment that shows a (photo) asset received from the phone.
+ */
+public class AssetFragment extends Fragment {
+
+ private ImageView mPhoto;
+
+ @Nullable
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.asset_fragment, container, false);
+ mPhoto = (ImageView) view.findViewById(R.id.photo);
+ return view;
+ }
+
+ public void setBackgroundImage(Bitmap bitmap) {
+ mPhoto.setImageBitmap(bitmap);
+ }
+}
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/java/com/example/android/wearable/datalayer/fragments/DataFragment.java b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/java/com/example/android/wearable/datalayer/fragments/DataFragment.java
new file mode 100644
index 0000000..f111e7d
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/java/com/example/android/wearable/datalayer/fragments/DataFragment.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.wearable.datalayer.fragments;
+
+import android.app.Fragment;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import com.example.android.wearable.datalayer.R;
+
+/**
+ * A fragment that shows a list of DataItems received from the phone
+ */
+public class DataFragment extends Fragment {
+
+ private DataItemAdapter mDataItemListAdapter;
+ private TextView mIntroText;
+ private boolean mInitialized;
+
+ @Nullable
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.data_fragment, container, false);
+ ListView dataItemList = (ListView) view.findViewById(R.id.dataItem_list);
+ mIntroText = (TextView) view.findViewById(R.id.intro);
+ mDataItemListAdapter = new DataItemAdapter(getActivity(),
+ android.R.layout.simple_list_item_1);
+ dataItemList.setAdapter(mDataItemListAdapter);
+ mInitialized = true;
+ return view;
+ }
+
+ public void appendItem(String title, String text) {
+ if (!mInitialized) {
+ return;
+ }
+ mIntroText.setVisibility(View.INVISIBLE);
+ mDataItemListAdapter.add(new Event(title, text));
+ }
+
+ private static class DataItemAdapter extends ArrayAdapter {
+
+ private final Context mContext;
+
+ public DataItemAdapter(Context context, int unusedResource) {
+ super(context, unusedResource);
+ mContext = context;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ ViewHolder holder;
+ if (convertView == null) {
+ holder = new ViewHolder();
+ LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ convertView = inflater.inflate(android.R.layout.two_line_list_item, null);
+ convertView.setTag(holder);
+ holder.text1 = (TextView) convertView.findViewById(android.R.id.text1);
+ holder.text2 = (TextView) convertView.findViewById(android.R.id.text2);
+ } else {
+ holder = (ViewHolder) convertView.getTag();
+ }
+ Event event = getItem(position);
+ holder.text1.setText(event.title);
+ holder.text2.setText(event.text);
+ return convertView;
+ }
+
+ private class ViewHolder {
+
+ TextView text1;
+ TextView text2;
+ }
+ }
+
+ private class Event {
+
+ String title;
+ String text;
+
+ public Event(String title, String text) {
+ this.title = title;
+ this.text = text;
+ }
+ }
+}
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/java/com/example/android/wearable/datalayer/fragments/DiscoveryFragment.java b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/java/com/example/android/wearable/datalayer/fragments/DiscoveryFragment.java
new file mode 100644
index 0000000..90b4b06
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/java/com/example/android/wearable/datalayer/fragments/DiscoveryFragment.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.wearable.datalayer.fragments;
+
+import android.app.Fragment;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.example.android.wearable.datalayer.R;
+
+/**
+ * A simple fragment with two buttons to show connected phones and watches
+ */
+public class DiscoveryFragment extends Fragment {
+
+ @Nullable
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.discovery_fragment, container, false);
+ }
+}
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/drawable-hdpi/ic_launcher.png b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..589f229
Binary files /dev/null and b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/drawable-hdpi/ic_launcher.png differ
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/drawable-mdpi/ic_launcher.png b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..77dd571
Binary files /dev/null and b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/drawable-mdpi/ic_launcher.png differ
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/drawable-nodpi/photo_placeholder.png b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/drawable-nodpi/photo_placeholder.png
new file mode 100644
index 0000000..d794731
Binary files /dev/null and b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/drawable-nodpi/photo_placeholder.png differ
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/drawable-xhdpi/ic_launcher.png b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..fe34ebe
Binary files /dev/null and b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/drawable-xxhdpi/ic_launcher.png b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..ab80bcd
Binary files /dev/null and b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/drawable-xxhdpi/ic_launcher.png differ
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/drawable/rounded_background.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/drawable/rounded_background.xml
new file mode 100644
index 0000000..226c174
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/drawable/rounded_background.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/layout/asset_fragment.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/layout/asset_fragment.xml
new file mode 100644
index 0000000..3c5f7b1
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/layout/asset_fragment.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/layout/data_fragment.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/layout/data_fragment.xml
new file mode 100644
index 0000000..efbbe9c
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/layout/data_fragment.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/layout/discovery_fragment.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/layout/discovery_fragment.xml
new file mode 100644
index 0000000..5cd247c
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/layout/discovery_fragment.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/layout/main_activity.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/layout/main_activity.xml
new file mode 100644
index 0000000..4608e4b
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/layout/main_activity.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/values/dimens.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..f24f84d
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/values/dimens.xml
@@ -0,0 +1,19 @@
+
+
+
+
+ 15dp
+
\ No newline at end of file
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/values/strings.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/values/strings.xml
new file mode 100644
index 0000000..3dc0a88
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/values/strings.xml
@@ -0,0 +1,24 @@
+
+
+
+
+ Data Layer Sample Wearable App
+ Waiting for data to arrive\u2026
+ Capability 2
+ Capabilities 1 and 2
+ No device provides the requested capabilities
+ Nodes: %1$s
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/values/wear.xml b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/values/wear.xml
new file mode 100644
index 0000000..41dc3bb
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/Wearable/src/main/res/values/wear.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+ capability_1
+
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/build.gradle b/Week_09_Services_and_wearables/android-DataLayer-master/build.gradle
new file mode 100644
index 0000000..5cf5d3d
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/build.gradle
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/gradle/wrapper/gradle-wrapper.jar b/Week_09_Services_and_wearables/android-DataLayer-master/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
Binary files /dev/null and b/Week_09_Services_and_wearables/android-DataLayer-master/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/gradle/wrapper/gradle-wrapper.properties b/Week_09_Services_and_wearables/android-DataLayer-master/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..f6f95d8
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Tue Apr 12 16:28:18 PDT 2016
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip
\ No newline at end of file
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/gradlew b/Week_09_Services_and_wearables/android-DataLayer-master/gradlew
new file mode 100644
index 0000000..91a7e26
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/gradlew
@@ -0,0 +1,164 @@
+#!/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
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# 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\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+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"`
+
+ # 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/Week_09_Services_and_wearables/android-DataLayer-master/gradlew.bat b/Week_09_Services_and_wearables/android-DataLayer-master/gradlew.bat
new file mode 100644
index 0000000..8a0b282
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/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/Week_09_Services_and_wearables/android-DataLayer-master/screenshots/phone_image.png b/Week_09_Services_and_wearables/android-DataLayer-master/screenshots/phone_image.png
new file mode 100644
index 0000000..e045b65
Binary files /dev/null and b/Week_09_Services_and_wearables/android-DataLayer-master/screenshots/phone_image.png differ
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/screenshots/wearable_background_image.png b/Week_09_Services_and_wearables/android-DataLayer-master/screenshots/wearable_background_image.png
new file mode 100644
index 0000000..7826180
Binary files /dev/null and b/Week_09_Services_and_wearables/android-DataLayer-master/screenshots/wearable_background_image.png differ
diff --git a/Week_09_Services_and_wearables/android-DataLayer-master/settings.gradle b/Week_09_Services_and_wearables/android-DataLayer-master/settings.gradle
new file mode 100644
index 0000000..f35b8cc
--- /dev/null
+++ b/Week_09_Services_and_wearables/android-DataLayer-master/settings.gradle
@@ -0,0 +1,2 @@
+
+include ':Application', ':Wearable'