From f0ffb21ef567a27a5cd982f5c753c077d55ca537 Mon Sep 17 00:00:00 2001 From: Jan-Felix Schmakeit Date: Mon, 6 Jul 2015 11:00:26 +1000 Subject: [PATCH] Add Ambient mode support to AndroidWearMap sample. Change-Id: I7bfdfdff6855234d81a1518ce5c10901d16cfa85 --- AndroidWearMap/README.md | 4 +- AndroidWearMap/Wearable/build.gradle | 11 ++++-- .../Wearable/src/main/AndroidManifest.xml | 16 ++------ .../example/androidwearmap/MainActivity.java | 38 ++++++++++++++++--- .../src/main/res/layout/activity_main.xml | 32 ++++++++-------- AndroidWearMap/build.gradle | 2 +- 6 files changed, 64 insertions(+), 39 deletions(-) diff --git a/AndroidWearMap/README.md b/AndroidWearMap/README.md index 51e1cff33..15a7f502a 100644 --- a/AndroidWearMap/README.md +++ b/AndroidWearMap/README.md @@ -3,12 +3,12 @@ Android Wear Maps Sample This sample uses the [Google Maps Android API v2](https://developers.google.com/maps/documentation/android/) to display a map on Android Wear. It shows the basic setup required for a -gradle-based Android Studio project. +gradle-based Android Studio project that [supports ambient mode](https://developer.android.com/training/wearables/apps/always-on.html). Pre-requisites -------------- -- Android SDK v21 +- Android SDK v22 - Latest Android Build Tools - Android Support Repository - Android Wear emulator or device diff --git a/AndroidWearMap/Wearable/build.gradle b/AndroidWearMap/Wearable/build.gradle index 0361f1c2e..622ad8dda 100644 --- a/AndroidWearMap/Wearable/build.gradle +++ b/AndroidWearMap/Wearable/build.gradle @@ -40,10 +40,15 @@ repositories { jcenter() } - dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.google.android.support:wearable:1.1.0' - compile 'com.google.android.gms:play-services:7.8.0' + // Required for DismissOverlayView to exit full screen wearable app. + compile 'com.google.android.support:wearable:1.2.0' + + // Required to support ambient mode. + provided 'com.google.android.wearable:wearable:1.0.0' + + // Include the Google Maps Android API from Google Play Services. + compile 'com.google.android.gms:play-services-maps:8.1.0' } diff --git a/AndroidWearMap/Wearable/src/main/AndroidManifest.xml b/AndroidWearMap/Wearable/src/main/AndroidManifest.xml index c08598c91..a9b90e25c 100644 --- a/AndroidWearMap/Wearable/src/main/AndroidManifest.xml +++ b/AndroidWearMap/Wearable/src/main/AndroidManifest.xml @@ -21,14 +21,8 @@ - - - - - - + + - - + + - + + android:id="@+id/map_container" + android:layout_width="match_parent" + android:layout_height="match_parent"> + android:id="@+id/map" + android:name="com.google.android.gms.maps.MapFragment" + android:layout_width="match_parent" + android:layout_height="match_parent" + map:ambientEnabled="true" /> + android:id="@+id/dismiss_overlay" + android:layout_width="match_parent" + android:layout_height="match_parent" /> \ No newline at end of file diff --git a/AndroidWearMap/build.gradle b/AndroidWearMap/build.gradle index 5fa424a98..702559461 100644 --- a/AndroidWearMap/build.gradle +++ b/AndroidWearMap/build.gradle @@ -21,7 +21,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.0.0' + classpath 'com.android.tools.build:gradle:1.3.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files