Skip to content

Commit 2997b7d

Browse files
tjohnsandroid-build-merger
authored andcommitted
Update prebuilts for mnc-docs am: 7e9f067
am: a466e36 Change-Id: If3c83372af2090dfb93574d33d14ddace6228447
2 parents b5dfaab + a466e36 commit 2997b7d

File tree

72 files changed

+2031
-678
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2031
-678
lines changed

samples/browseable/AgendaData/Application/src/com.example.android.wearable.agendadata/MainActivity.java

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
import com.google.android.gms.wearable.DataApi;
4242
import com.google.android.gms.wearable.DataItem;
4343
import com.google.android.gms.wearable.DataItemBuffer;
44-
import com.google.android.gms.wearable.Node;
45-
import com.google.android.gms.wearable.NodeApi;
4644
import com.google.android.gms.wearable.Wearable;
4745

4846
/**
@@ -51,7 +49,6 @@
5149
* permissions as well.
5250
*/
5351
public class MainActivity extends AppCompatActivity implements
54-
NodeApi.NodeListener,
5552
ConnectionCallbacks,
5653
OnConnectionFailedListener,
5754
ActivityCompat.OnRequestPermissionsResultCallback {
@@ -66,11 +63,11 @@ public class MainActivity extends AppCompatActivity implements
6663
private GoogleApiClient mGoogleApiClient;
6764
private boolean mResolvingError = false;
6865

69-
private TextView mLogTextView;
70-
ScrollView mScroller;
71-
7266
private View mLayout;
7367

68+
private TextView mLogTextView;
69+
private ScrollView mScroller;
70+
7471
@Override
7572
protected void onCreate(Bundle savedInstanceState) {
7673
super.onCreate(savedInstanceState);
@@ -98,10 +95,10 @@ protected void onStart() {
9895

9996
@Override
10097
protected void onStop() {
101-
if (mGoogleApiClient.isConnected()) {
102-
Wearable.NodeApi.removeListener(mGoogleApiClient, this);
98+
if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
99+
mGoogleApiClient.disconnect();
103100
}
104-
mGoogleApiClient.disconnect();
101+
105102
super.onStop();
106103
}
107104

@@ -132,10 +129,6 @@ public void onGetEventsClicked(View view) {
132129

133130
}
134131

135-
private void pushCalendarToWear() {
136-
startService(new Intent(this, CalendarQueryService.class));
137-
}
138-
139132
/*
140133
* Requests Calendar and Contact permissions.
141134
* If the permission has been denied previously, a SnackBar will prompt the user to grant the
@@ -190,7 +183,9 @@ public void onClick(View view) {
190183
// END_INCLUDE(calendar_and_contact_permissions_request)
191184
}
192185

193-
186+
private void pushCalendarToWear() {
187+
startService(new Intent(this, CalendarQueryService.class));
188+
}
194189

195190
public void onDeleteEventsClicked(View view) {
196191
if (mGoogleApiClient.isConnected()) {
@@ -245,38 +240,27 @@ public void onResult(DataApi.DeleteDataItemsResult deleteResult) {
245240
}
246241
}
247242

248-
@Override
249-
public void onPeerConnected(Node peer) {
250-
appendLog("Device connected");
251-
}
252-
253-
@Override
254-
public void onPeerDisconnected(Node peer) {
255-
appendLog("Device disconnected");
256-
}
257-
258243
@Override
259244
public void onConnected(Bundle connectionHint) {
260245
if (Log.isLoggable(TAG, Log.DEBUG)) {
261246
Log.d(TAG, "Connected to Google Api Service.");
262247
}
263248
mResolvingError = false;
264-
Wearable.NodeApi.addListener(mGoogleApiClient, this);
265249
}
266250

267251
@Override
268252
public void onConnectionSuspended(int cause) {
269-
// Ignore
253+
if (Log.isLoggable(TAG, Log.DEBUG)) {
254+
Log.d(TAG, "onConnectionSuspended(): Cause id: " + cause);
255+
}
270256
}
271257

272258
@Override
273259
public void onConnectionFailed(ConnectionResult result) {
274260
if (Log.isLoggable(TAG, Log.DEBUG)) {
275261
Log.d(TAG, "Disconnected from Google Api Service");
276262
}
277-
if (null != Wearable.NodeApi) {
278-
Wearable.NodeApi.removeListener(mGoogleApiClient, this);
279-
}
263+
280264
if (mResolvingError) {
281265
// Already attempting to resolve an error.
282266
return;
@@ -359,4 +343,4 @@ public void run() {
359343
}
360344
});
361345
}
362-
}
346+
}

samples/browseable/AgendaData/Wearable/AndroidManifest.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
package="com.example.android.wearable.agendadata" >
1919

2020
<uses-sdk android:minSdkVersion="20"
21-
android:targetSdkVersion="22" />
21+
android:targetSdkVersion="23" />
2222

2323
<uses-feature android:name="android.hardware.type.watch" />
2424

@@ -34,7 +34,8 @@
3434
<service
3535
android:name="com.example.android.wearable.agendadata.HomeListenerService" >
3636
<intent-filter>
37-
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
37+
<action android:name="com.google.android.gms.wearable.DATA_CHANGED" />
38+
<data android:scheme="wear" android:host="*" android:pathPrefix="/"/>
3839
</intent-filter>
3940
</service>
4041

samples/browseable/AgendaData/Wearable/src/com.example.android.wearable.agendadata/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ private Constants() {
3232
public static final String PROFILE_PIC = "profile_pic";
3333

3434
public static final String EXTRA_SILENT = "silent";
35-
}
35+
}

samples/browseable/AgendaData/Wearable/src/com.example.android.wearable.agendadata/DeleteService.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616

1717
package com.example.android.wearable.agendadata;
1818

19-
import static com.example.android.wearable.agendadata.Constants.TAG;
20-
import static com.example.android.wearable.agendadata.Constants.EXTRA_SILENT;
21-
2219
import android.app.IntentService;
2320
import android.content.Intent;
2421
import android.net.Uri;
2522
import android.os.Bundle;
2623
import android.support.wearable.activity.ConfirmationActivity;
2724
import android.util.Log;
2825

26+
import static com.example.android.wearable.agendadata.Constants.TAG;
27+
import static com.example.android.wearable.agendadata.Constants.EXTRA_SILENT;
28+
2929
import com.google.android.gms.common.ConnectionResult;
3030
import com.google.android.gms.common.api.GoogleApiClient;
3131
import com.google.android.gms.wearable.DataApi;
@@ -105,14 +105,23 @@ private void startConfirmationActivity(int animationType, String message) {
105105

106106
@Override
107107
public void onConnected(Bundle connectionHint) {
108+
if (Log.isLoggable(TAG, Log.DEBUG)) {
109+
Log.d(TAG, "onConnected: " + connectionHint);
110+
}
108111
}
109112

110113
@Override
111114
public void onConnectionSuspended(int cause) {
115+
if (Log.isLoggable(TAG, Log.DEBUG)) {
116+
Log.d(TAG, "onConnectionSuspended: " + cause);
117+
}
112118
}
113119

114120
@Override
115121
public void onConnectionFailed(ConnectionResult result) {
122+
if (Log.isLoggable(TAG, Log.DEBUG)) {
123+
Log.d(TAG, "onConnectionFailed: " + result);
124+
}
116125
}
117126

118127
}

samples/browseable/AgendaData/Wearable/src/com.example.android.wearable.agendadata/HomeListenerService.java

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@
1616

1717
package com.example.android.wearable.agendadata;
1818

19-
import static com.example.android.wearable.agendadata.Constants.TAG;
20-
import static com.example.android.wearable.agendadata.Constants.EXTRA_SILENT;
21-
22-
import static com.example.android.wearable.agendadata.Constants.ALL_DAY;
23-
import static com.example.android.wearable.agendadata.Constants.BEGIN;
24-
import static com.example.android.wearable.agendadata.Constants.DESCRIPTION;
25-
import static com.example.android.wearable.agendadata.Constants.END;
26-
import static com.example.android.wearable.agendadata.Constants.PROFILE_PIC;
27-
import static com.example.android.wearable.agendadata.Constants.TITLE;
28-
2919
import android.app.Notification;
3020
import android.app.NotificationManager;
3121
import android.app.PendingIntent;
@@ -37,6 +27,15 @@
3727
import android.text.format.DateFormat;
3828
import android.util.Log;
3929

30+
import static com.example.android.wearable.agendadata.Constants.ALL_DAY;
31+
import static com.example.android.wearable.agendadata.Constants.BEGIN;
32+
import static com.example.android.wearable.agendadata.Constants.DESCRIPTION;
33+
import static com.example.android.wearable.agendadata.Constants.EXTRA_SILENT;
34+
import static com.example.android.wearable.agendadata.Constants.END;
35+
import static com.example.android.wearable.agendadata.Constants.PROFILE_PIC;
36+
import static com.example.android.wearable.agendadata.Constants.TAG;
37+
import static com.example.android.wearable.agendadata.Constants.TITLE;
38+
4039
import com.google.android.gms.common.api.GoogleApiClient;
4140
import com.google.android.gms.wearable.Asset;
4241
import com.google.android.gms.wearable.DataApi;
@@ -45,7 +44,6 @@
4544
import com.google.android.gms.wearable.DataItem;
4645
import com.google.android.gms.wearable.DataMap;
4746
import com.google.android.gms.wearable.DataMapItem;
48-
import com.google.android.gms.wearable.MessageEvent;
4947
import com.google.android.gms.wearable.Wearable;
5048
import com.google.android.gms.wearable.WearableListenerService;
5149

@@ -63,12 +61,22 @@ public class HomeListenerService extends WearableListenerService {
6361
private static int sNotificationId = 1;
6462
private GoogleApiClient mGoogleApiClient;
6563

64+
@Override
65+
public void onCreate() {
66+
super.onCreate();
67+
mGoogleApiClient = new GoogleApiClient.Builder(this.getApplicationContext())
68+
.addApi(Wearable.API)
69+
.build();
70+
mGoogleApiClient.connect();
71+
}
72+
6673
@Override
6774
public void onDataChanged(DataEventBuffer dataEvents) {
6875
if (Log.isLoggable(TAG, Log.DEBUG)) {
6976
Log.d(TAG, "onDataChanged: " + dataEvents + " for " + getPackageName());
7077
}
7178
for (DataEvent event : dataEvents) {
79+
7280
if (event.getType() == DataEvent.TYPE_DELETED) {
7381
deleteDataItem(event.getDataItem());
7482
} else if (event.getType() == DataEvent.TYPE_CHANGED) {
@@ -77,13 +85,17 @@ public void onDataChanged(DataEventBuffer dataEvents) {
7785
}
7886
}
7987

80-
@Override
81-
public void onCreate() {
82-
super.onCreate();
83-
mGoogleApiClient = new GoogleApiClient.Builder(this.getApplicationContext())
84-
.addApi(Wearable.API)
85-
.build();
86-
mGoogleApiClient.connect();
88+
/**
89+
* Deletes the calendar card associated with the data item.
90+
*/
91+
private void deleteDataItem(DataItem dataItem) {
92+
if (Log.isLoggable(TAG, Log.VERBOSE)) {
93+
Log.v(TAG, "onDataItemDeleted:DataItem=" + dataItem.getUri());
94+
}
95+
Integer notificationId = sNotificationIdByDataItemUri.remove(dataItem.getUri());
96+
if (notificationId != null) {
97+
((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).cancel(notificationId);
98+
}
8799
}
88100

89101
/**
@@ -154,26 +166,4 @@ private void updateNotificationForDataItem(DataItem dataItem) {
154166

155167
sNotificationIdByDataItemUri.put(dataItem.getUri(), sNotificationId++);
156168
}
157-
158-
/**
159-
* Deletes the calendar card associated with the data item.
160-
*/
161-
private void deleteDataItem(DataItem dataItem) {
162-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
163-
Log.v(TAG, "onDataItemDeleted:DataItem=" + dataItem.getUri());
164-
}
165-
Integer notificationId = sNotificationIdByDataItemUri.remove(dataItem.getUri());
166-
if (notificationId != null) {
167-
((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).cancel(notificationId);
168-
}
169-
}
170-
171-
@Override
172-
public void onMessageReceived(MessageEvent messageEvent) {
173-
if (Log.isLoggable(TAG, Log.DEBUG)) {
174-
Log.d(TAG, "onMessageReceived: " + messageEvent.getPath()
175-
+ " " + messageEvent.getData() + " for " + getPackageName());
176-
}
177-
}
178-
179169
}

samples/browseable/BasicMediaDecoder/src/com.example.android.common.media/CameraHelper.java

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,49 +36,57 @@ public class CameraHelper {
3636
public static final int MEDIA_TYPE_VIDEO = 2;
3737

3838
/**
39-
* Iterate over supported camera preview sizes to see which one best fits the
39+
* Iterate over supported camera video sizes to see which one best fits the
4040
* dimensions of the given view while maintaining the aspect ratio. If none can,
4141
* be lenient with the aspect ratio.
4242
*
43-
* @param sizes Supported camera preview sizes.
44-
* @param w The width of the view.
45-
* @param h The height of the view.
46-
* @return Best match camera preview size to fit in the view.
43+
* @param supportedVideoSizes Supported camera video sizes.
44+
* @param previewSizes Supported camera preview sizes.
45+
* @param w The width of the view.
46+
* @param h The height of the view.
47+
* @return Best match camera video size to fit in the view.
4748
*/
48-
public static Camera.Size getOptimalPreviewSize(List<Camera.Size> sizes, int w, int h) {
49+
public static Camera.Size getOptimalVideoSize(List<Camera.Size> supportedVideoSizes,
50+
List<Camera.Size> previewSizes, int w, int h) {
4951
// Use a very small tolerance because we want an exact match.
5052
final double ASPECT_TOLERANCE = 0.1;
5153
double targetRatio = (double) w / h;
52-
if (sizes == null)
53-
return null;
5454

55+
// Supported video sizes list might be null, it means that we are allowed to use the preview
56+
// sizes
57+
List<Camera.Size> videoSizes;
58+
if (supportedVideoSizes != null) {
59+
videoSizes = supportedVideoSizes;
60+
} else {
61+
videoSizes = previewSizes;
62+
}
5563
Camera.Size optimalSize = null;
5664

57-
// Start with max value and refine as we iterate over available preview sizes. This is the
65+
// Start with max value and refine as we iterate over available video sizes. This is the
5866
// minimum difference between view and camera height.
5967
double minDiff = Double.MAX_VALUE;
6068

6169
// Target view height
6270
int targetHeight = h;
6371

64-
// Try to find a preview size that matches aspect ratio and the target view size.
72+
// Try to find a video size that matches aspect ratio and the target view size.
6573
// Iterate over all available sizes and pick the largest size that can fit in the view and
6674
// still maintain the aspect ratio.
67-
for (Camera.Size size : sizes) {
75+
for (Camera.Size size : videoSizes) {
6876
double ratio = (double) size.width / size.height;
6977
if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE)
7078
continue;
71-
if (Math.abs(size.height - targetHeight) < minDiff) {
79+
if (Math.abs(size.height - targetHeight) < minDiff && previewSizes.contains(size)) {
7280
optimalSize = size;
7381
minDiff = Math.abs(size.height - targetHeight);
7482
}
7583
}
7684

77-
// Cannot find preview size that matches the aspect ratio, ignore the requirement
85+
// Cannot find video size that matches the aspect ratio, ignore the requirement
7886
if (optimalSize == null) {
7987
minDiff = Double.MAX_VALUE;
80-
for (Camera.Size size : sizes) {
81-
if (Math.abs(size.height - targetHeight) < minDiff) {
88+
for (Camera.Size size : videoSizes) {
89+
if (Math.abs(size.height - targetHeight) < minDiff && previewSizes.contains(size)) {
8290
optimalSize = size;
8391
minDiff = Math.abs(size.height - targetHeight);
8492
}

0 commit comments

Comments
 (0)