From 11b32f038486390d91aafb56c6204666267db89f Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Mon, 23 Jun 2014 14:46:11 -0700 Subject: [PATCH] Clean up samples (gradle files and Compat stuff in wearable code). - Remove -v13 and -v4 dependencies on wearable side - Verify phone is set to compile on API 19 and wearable on 20 - Replace NotificationCompat in wearable side since it uses API 20 - Move ElizaChat code to Application directory Bug: 15809453 Change-Id: Ib75e7894505f82e5b4d8591b4dfa91a3de8e0329 --- .../AgendaData/Application/build.gradle | 6 +-- .../Application/src/main/AndroidManifest.xml | 2 - .../wearable/AgendaData/Wearable/build.gradle | 3 +- .../Wearable/src/main/AndroidManifest.xml | 2 - .../DataLayer/Application/build.gradle | 4 +- .../Application/src/main/AndroidManifest.xml | 1 - .../wearable/DataLayer/Wearable/build.gradle | 9 ++-- .../Wearable/src/main/AndroidManifest.xml | 2 - .../Application/build.gradle | 6 +-- .../Application/src/main/AndroidManifest.xml | 2 - .../DelayedConfirmation/Wearable/build.gradle | 3 +- .../delayedconfirmation/MainActivity.java | 11 ++-- .../ElizaChat/Application/build.gradle | 24 +++++++++ .../{ => Application}/proguard-rules.txt | 4 +- .../ElizaChat/Application/project.properties | 14 ++++++ .../src/main/AndroidManifest.xml | 2 - .../wearable/elizachat/ElizaResponder.java | 0 .../wearable/elizachat/MainActivity.java | 3 -- .../wearable/elizachat/ResponderService.java | 2 +- .../main/res/drawable-hdpi/ic_full_reply.png | Bin .../main/res/drawable-mdpi/ic_full_reply.png | Bin .../src/main/res/drawable-nodpi/bg_eliza.png | Bin .../main/res/drawable-xhdpi/ic_full_reply.png | Bin .../src/main/res/layout/activity_main.xml | 0 .../src/main/res/menu/main.xml | 0 .../src/main/res/mipmap-hdpi/ic_app_eliza.png | Bin .../src/main/res/mipmap-mdpi/ic_app_eliza.png | Bin .../main/res/mipmap-xhdpi/ic_app_eliza.png | Bin .../main/res/mipmap-xxhdpi/ic_app_eliza.png | Bin .../main/res/mipmap-xxxhdpi/ic_app_eliza.png | Bin .../src/main/res/values/dimens.xml | 0 .../src/main/res/values/strings.xml | 0 .../src/main/res/values/styles.xml | 0 samples/wearable/ElizaChat/build.gradle | 27 ---------- samples/wearable/ElizaChat/settings.gradle | 1 + .../EmbeddedApp/Application/build.gradle | 2 +- .../FindMyPhone/Application/build.gradle | 6 +-- .../Application/src/main/AndroidManifest.xml | 2 - .../FindMyPhone/Wearable/build.gradle | 3 +- .../Wearable/src/main/AndroidManifest.xml | 1 - samples/wearable/FindMyPhone/build.gradle | 2 - .../wearable/Flashlight/Wearable/build.gradle | 1 - .../Wearable/src/main/AndroidManifest.xml | 2 - samples/wearable/Flashlight/build.gradle | 2 - .../Geofencing/Application/build.gradle | 6 +-- .../Application/src/main/AndroidManifest.xml | 2 - .../wearable/Geofencing/Wearable/build.gradle | 3 +- .../Wearable/src/main/AndroidManifest.xml | 2 - .../GridViewPager/Wearable/build.gradle | 1 - .../Wearable/src/main/AndroidManifest.xml | 8 +-- .../JumpingJack/Wearable/build.gradle | 3 +- samples/wearable/JumpingJack/build.gradle | 2 - .../Notifications/Application/build.gradle | 4 +- .../Application/src/main/AndroidManifest.xml | 2 - .../Notifications/Wearable/build.gradle | 1 - .../Wearable/src/main/AndroidManifest.xml | 2 - .../wearable/notifications/MainActivity.java | 5 +- .../wearable/Quiz/Application/build.gradle | 4 +- .../Application/src/main/AndroidManifest.xml | 2 - samples/wearable/Quiz/Wearable/build.gradle | 3 +- .../Wearable/src/main/AndroidManifest.xml | 4 -- samples/wearable/Quiz/build.gradle | 2 - .../RecipeAssistant/Application/build.gradle | 2 +- .../Application/src/main/AndroidManifest.xml | 6 +-- samples/wearable/RecipeAssistant/build.gradle | 2 - .../SkeletonWearableApp/Wearable/build.gradle | 1 - .../Application/build.gradle | 2 +- samples/wearable/Timer/Wearable/build.gradle | 2 - .../Wearable/src/main/AndroidManifest.xml | 9 +--- .../wearable/timer/SetTimerActivity.java | 47 +++--------------- .../timer/TimerNotificationService.java | 32 +++--------- samples/wearable/Timer/build.gradle | 2 - .../WatchViewStub/Wearable/build.gradle | 1 - .../Wearable/src/main/AndroidManifest.xml | 2 - 74 files changed, 97 insertions(+), 216 deletions(-) create mode 100644 samples/wearable/ElizaChat/Application/build.gradle rename samples/wearable/ElizaChat/{ => Application}/proguard-rules.txt (86%) create mode 100644 samples/wearable/ElizaChat/Application/project.properties rename samples/wearable/ElizaChat/{ => Application}/src/main/AndroidManifest.xml (93%) rename samples/wearable/ElizaChat/{ => Application}/src/main/java/com/example/android/wearable/elizachat/ElizaResponder.java (100%) rename samples/wearable/ElizaChat/{ => Application}/src/main/java/com/example/android/wearable/elizachat/MainActivity.java (96%) rename samples/wearable/ElizaChat/{ => Application}/src/main/java/com/example/android/wearable/elizachat/ResponderService.java (99%) rename samples/wearable/ElizaChat/{ => Application}/src/main/res/drawable-hdpi/ic_full_reply.png (100%) rename samples/wearable/ElizaChat/{ => Application}/src/main/res/drawable-mdpi/ic_full_reply.png (100%) rename samples/wearable/ElizaChat/{ => Application}/src/main/res/drawable-nodpi/bg_eliza.png (100%) rename samples/wearable/ElizaChat/{ => Application}/src/main/res/drawable-xhdpi/ic_full_reply.png (100%) rename samples/wearable/ElizaChat/{ => Application}/src/main/res/layout/activity_main.xml (100%) rename samples/wearable/ElizaChat/{ => Application}/src/main/res/menu/main.xml (100%) rename samples/wearable/ElizaChat/{ => Application}/src/main/res/mipmap-hdpi/ic_app_eliza.png (100%) rename samples/wearable/ElizaChat/{ => Application}/src/main/res/mipmap-mdpi/ic_app_eliza.png (100%) rename samples/wearable/ElizaChat/{ => Application}/src/main/res/mipmap-xhdpi/ic_app_eliza.png (100%) rename samples/wearable/ElizaChat/{ => Application}/src/main/res/mipmap-xxhdpi/ic_app_eliza.png (100%) rename samples/wearable/ElizaChat/{ => Application}/src/main/res/mipmap-xxxhdpi/ic_app_eliza.png (100%) rename samples/wearable/ElizaChat/{ => Application}/src/main/res/values/dimens.xml (100%) rename samples/wearable/ElizaChat/{ => Application}/src/main/res/values/strings.xml (100%) rename samples/wearable/ElizaChat/{ => Application}/src/main/res/values/styles.xml (100%) create mode 100644 samples/wearable/ElizaChat/settings.gradle diff --git a/samples/wearable/AgendaData/Application/build.gradle b/samples/wearable/AgendaData/Application/build.gradle index 9c68a1864..19aeb471b 100644 --- a/samples/wearable/AgendaData/Application/build.gradle +++ b/samples/wearable/AgendaData/Application/build.gradle @@ -1,12 +1,12 @@ apply plugin: 'android' android { - compileSdkVersion 20 + compileSdkVersion 18 buildToolsVersion '20' defaultConfig { minSdkVersion 18 - targetSdkVersion 20 + targetSdkVersion 19 versionCode 1 versionName "1.0" } @@ -23,4 +23,4 @@ dependencies { compile 'com.google.android.gms:play-services:5.0.+@aar' compile "com.android.support:support-v4:20.0.+" wearApp project(':Wearable') -} \ No newline at end of file +} diff --git a/samples/wearable/AgendaData/Application/src/main/AndroidManifest.xml b/samples/wearable/AgendaData/Application/src/main/AndroidManifest.xml index d96efd8d5..7f070ffd0 100644 --- a/samples/wearable/AgendaData/Application/src/main/AndroidManifest.xml +++ b/samples/wearable/AgendaData/Application/src/main/AndroidManifest.xml @@ -2,8 +2,6 @@ - - diff --git a/samples/wearable/AgendaData/Wearable/build.gradle b/samples/wearable/AgendaData/Wearable/build.gradle index a1921f0d5..0e23b4d56 100644 --- a/samples/wearable/AgendaData/Wearable/build.gradle +++ b/samples/wearable/AgendaData/Wearable/build.gradle @@ -20,7 +20,6 @@ android { } dependencies { - compile 'com.google.android.gms:play-services:5.+@aar' - compile "com.android.support:support-v4:20.0.+" + compile 'com.google.android.gms:play-services-wearable:+' compile "com.google.android.support:wearable:1.0.+" } \ No newline at end of file diff --git a/samples/wearable/AgendaData/Wearable/src/main/AndroidManifest.xml b/samples/wearable/AgendaData/Wearable/src/main/AndroidManifest.xml index f986b3aa3..2bb042ddc 100644 --- a/samples/wearable/AgendaData/Wearable/src/main/AndroidManifest.xml +++ b/samples/wearable/AgendaData/Wearable/src/main/AndroidManifest.xml @@ -2,8 +2,6 @@ - - - - - - - - - - - - - - - - - - - - + package="com.example.android.wearable.gridviewpager" > - - - - - - - - - - + package="com.example.android.wearable.recipeassistant" > - - - - + android:theme="@android:style/Theme.DeviceDefault.Light" + android:allowBackup="true"> diff --git a/samples/wearable/Timer/Wearable/src/main/java/com/example/android/wearable/timer/SetTimerActivity.java b/samples/wearable/Timer/Wearable/src/main/java/com/example/android/wearable/timer/SetTimerActivity.java index 92dbfc043..2d0ec2f85 100644 --- a/samples/wearable/Timer/Wearable/src/main/java/com/example/android/wearable/timer/SetTimerActivity.java +++ b/samples/wearable/Timer/Wearable/src/main/java/com/example/android/wearable/timer/SetTimerActivity.java @@ -19,14 +19,13 @@ package com.example.android.wearable.timer; import android.app.Activity; import android.app.AlarmManager; import android.app.Notification; +import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; import android.provider.AlarmClock; -import android.support.v4.app.NotificationCompat; -import android.support.v4.app.NotificationManagerCompat; import android.util.Log; import android.view.View; import android.widget.AdapterView; @@ -35,21 +34,15 @@ import android.widget.ListView; import com.example.android.wearable.timer.util.Constants; import com.example.android.wearable.timer.util.TimerFormat; -import com.google.android.gms.common.ConnectionResult; -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.wearable.Wearable; /** This class sets a timer. */ -public class SetTimerActivity extends Activity - implements AdapterView.OnItemClickListener, GoogleApiClient.ConnectionCallbacks, - GoogleApiClient.OnConnectionFailedListener { +public class SetTimerActivity extends Activity implements AdapterView.OnItemClickListener { public static final int NUMBER_OF_TIMES = 10; public static final String TAG = "SetTimerActivity"; private ListViewItem[] mTimeOptions = new ListViewItem[NUMBER_OF_TIMES]; private ListView mListView; - private GoogleApiClient mGoogleApiClient; @Override @@ -82,24 +75,6 @@ public class SetTimerActivity extends Activity android.R.layout.simple_list_item_1, mTimeOptions); mListView.setAdapter(arrayAdapter); mListView.setOnItemClickListener(this); - - mGoogleApiClient = new GoogleApiClient.Builder(this) - .addApi(Wearable.API) - .addConnectionCallbacks(this) - .addOnConnectionFailedListener(this) - .build(); - } - - @Override - protected void onStart() { - super.onStart(); - mGoogleApiClient.connect(); - } - - @Override - protected void onStop() { - super.onStop(); - mGoogleApiClient.disconnect(); } /** @@ -107,7 +82,8 @@ public class SetTimerActivity extends Activity * milliseconds. */ private void setupTimer(long duration) { - NotificationManagerCompat notifyMgr = NotificationManagerCompat.from(this); + NotificationManager notifyMgr = + ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)); // Delete dataItem and cancel a potential old countdown. cancelCountdown(notifyMgr); @@ -165,7 +141,7 @@ public class SetTimerActivity extends Activity .getService(this, 0, deleteIntent, PendingIntent.FLAG_UPDATE_CURRENT); // Create countdown notification using a chronometer style. - return new NotificationCompat.Builder(this) + return new Notification.Builder(this) .setSmallIcon(R.drawable.ic_cc_alarm) .setContentTitle(getString(R.string.timer_time_left)) .setContentText(TimerFormat.getTimeString(duration)) @@ -185,7 +161,7 @@ public class SetTimerActivity extends Activity * * @param notifyMgr the notification manager. */ - private void cancelCountdown(NotificationManagerCompat notifyMgr) { + private void cancelCountdown(NotificationManager notifyMgr) { notifyMgr.cancel(Constants.NOTIFICATION_TIMER_EXPIRED); } @@ -208,15 +184,4 @@ public class SetTimerActivity extends Activity } } - @Override - public void onConnected(Bundle connectionHint) { - } - - @Override - public void onConnectionSuspended(int cause) { - } - - @Override - public void onConnectionFailed(ConnectionResult result) { - } } diff --git a/samples/wearable/Timer/Wearable/src/main/java/com/example/android/wearable/timer/TimerNotificationService.java b/samples/wearable/Timer/Wearable/src/main/java/com/example/android/wearable/timer/TimerNotificationService.java index 344d84c0c..11437e67c 100644 --- a/samples/wearable/Timer/Wearable/src/main/java/com/example/android/wearable/timer/TimerNotificationService.java +++ b/samples/wearable/Timer/Wearable/src/main/java/com/example/android/wearable/timer/TimerNotificationService.java @@ -19,27 +19,18 @@ package com.example.android.wearable.timer; import android.app.AlarmManager; import android.app.IntentService; import android.app.Notification; +import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; -import android.os.Bundle; -import android.support.v4.app.NotificationCompat; -import android.support.v4.app.NotificationManagerCompat; import android.util.Log; import com.example.android.wearable.timer.util.Constants; -import com.google.android.gms.common.ConnectionResult; -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.wearable.Wearable; - -import java.util.concurrent.TimeUnit; /** * Service class that manages notifications of the timer. */ -public class TimerNotificationService extends IntentService - implements GoogleApiClient.ConnectionCallbacks, - GoogleApiClient.OnConnectionFailedListener { +public class TimerNotificationService extends IntentService { public static final String TAG = "TimerNotificationSvc"; @@ -94,7 +85,8 @@ public class TimerNotificationService extends IntentService } private void cancelCountdownNotification() { - NotificationManagerCompat notifyMgr = NotificationManagerCompat.from(this); + NotificationManager notifyMgr = + ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)); notifyMgr.cancel(Constants.NOTIFICATION_TIMER_COUNTDOWN); } @@ -109,8 +101,9 @@ public class TimerNotificationService extends IntentService .getService(this, 0, restartIntent, PendingIntent.FLAG_UPDATE_CURRENT); // Create notification that timer has expired. - NotificationManagerCompat notifyMgr = NotificationManagerCompat.from(this); - Notification notif = new NotificationCompat.Builder(this) + NotificationManager notifyMgr = + ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)); + Notification notif = new Notification.Builder(this) .setSmallIcon(R.drawable.ic_cc_alarm) .setContentTitle(getString(R.string.timer_done)) .setContentText(getString(R.string.timer_done)) @@ -123,15 +116,4 @@ public class TimerNotificationService extends IntentService notifyMgr.notify(Constants.NOTIFICATION_TIMER_EXPIRED, notif); } - @Override - public void onConnected(Bundle connectionHint) { - } - - @Override - public void onConnectionSuspended(int cause) { - } - - @Override - public void onConnectionFailed(ConnectionResult result) { - } } diff --git a/samples/wearable/Timer/build.gradle b/samples/wearable/Timer/build.gradle index e33f14283..8bd4ffc49 100644 --- a/samples/wearable/Timer/build.gradle +++ b/samples/wearable/Timer/build.gradle @@ -1,5 +1,3 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - buildscript { repositories { mavenCentral() diff --git a/samples/wearable/WatchViewStub/Wearable/build.gradle b/samples/wearable/WatchViewStub/Wearable/build.gradle index 2a520308a..b9450ca9a 100644 --- a/samples/wearable/WatchViewStub/Wearable/build.gradle +++ b/samples/wearable/WatchViewStub/Wearable/build.gradle @@ -20,6 +20,5 @@ android { } dependencies { - compile "com.android.support:support-v13:20.0.+" compile "com.google.android.support:wearable:1.0.+" } diff --git a/samples/wearable/WatchViewStub/Wearable/src/main/AndroidManifest.xml b/samples/wearable/WatchViewStub/Wearable/src/main/AndroidManifest.xml index 21925469e..ea6d7b225 100644 --- a/samples/wearable/WatchViewStub/Wearable/src/main/AndroidManifest.xml +++ b/samples/wearable/WatchViewStub/Wearable/src/main/AndroidManifest.xml @@ -2,8 +2,6 @@ - -