From 266795a39f11d58697a2e94e78ac13d79d6a9119 Mon Sep 17 00:00:00 2001 From: mar-v-in Date: Mon, 28 Sep 2015 18:27:29 +0200 Subject: [PATCH] Add and update APIs --- play-services-api/build.gradle | 33 +++-- play-services-api/gradle.properties | 6 +- .../android/gms/cast/ApplicationMetadata.java | 68 ++++++++++ .../google/android/gms/cast/CastDevice.java | 124 ++++++++++++++++++ .../android/gms/cast/LaunchOptions.java | 47 +++++++ .../android/gms/common/images/WebImage.java | 23 ++++ .../gms/maps/model/PolygonOptions.java | 120 ++++++++++++++++- 7 files changed, 407 insertions(+), 14 deletions(-) create mode 100644 play-services-api/src/main/java/com/google/android/gms/cast/ApplicationMetadata.java create mode 100644 play-services-api/src/main/java/com/google/android/gms/cast/CastDevice.java create mode 100644 play-services-api/src/main/java/com/google/android/gms/cast/LaunchOptions.java create mode 100644 play-services-api/src/main/java/com/google/android/gms/common/images/WebImage.java diff --git a/play-services-api/build.gradle b/play-services-api/build.gradle index f48d82b3..c5c36494 100644 --- a/play-services-api/build.gradle +++ b/play-services-api/build.gradle @@ -1,26 +1,43 @@ +/* + * Copyright 2013-2015 µg Project Team + * + * 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. + */ + buildscript { repositories { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'com.android.tools.build:gradle:1.3.0' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' } } apply plugin: 'com.android.library' -apply from: 'gradle-mvn-push.gradle' +apply plugin: 'com.github.dcendents.android-maven' group = 'org.microg' version = '1.0-SNAPSHOT' -dependencies { - compile project(':safe-parcel') -} - android { - compileSdkVersion 22 - buildToolsVersion "22.0.1" + compileSdkVersion 23 + buildToolsVersion "23.0.1" compileOptions { sourceCompatibility JavaVersion.VERSION_1_6 } } + +dependencies { + compile project(':safe-parcel') +} diff --git a/play-services-api/gradle.properties b/play-services-api/gradle.properties index 0859459b..263c3740 100644 --- a/play-services-api/gradle.properties +++ b/play-services-api/gradle.properties @@ -1,8 +1,4 @@ -GROUP=org.microg -POM_ARTIFACT_ID=play-services-api -VERSION_NAME=1.0-SNAPSHOT - -POM_NAME=µg GmsApi +POM_NAME=GmsApi POM_DESCRIPTION=Interfaces and objects for IPC between Play Services Library and Play Services Core POM_PACKAGING=aar diff --git a/play-services-api/src/main/java/com/google/android/gms/cast/ApplicationMetadata.java b/play-services-api/src/main/java/com/google/android/gms/cast/ApplicationMetadata.java new file mode 100644 index 00000000..46cf7751 --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/cast/ApplicationMetadata.java @@ -0,0 +1,68 @@ +/* + * Copyright 2013-2015 µg Project Team + * + * 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.google.android.gms.cast; + +import android.net.Uri; + +import com.google.android.gms.common.images.WebImage; + +import org.microg.gms.common.PublicApi; +import org.microg.safeparcel.AutoSafeParcelable; +import org.microg.safeparcel.SafeParceled; + +import java.util.List; + +@PublicApi +public class ApplicationMetadata extends AutoSafeParcelable { + + @SafeParceled(1) + private int versionCode = 1; + @SafeParceled(2) + private String applicationId; + @SafeParceled(3) + private String name; + @SafeParceled(value = 4, subClass = WebImage.class) + private List images; + @SafeParceled(value = 5, subClass = String.class) + private List namespaces; + @SafeParceled(6) + private String senderAppIdentifier; + @SafeParceled(7) + private Uri senderAppLaunchUri; + + public String getApplicationId() { + return applicationId; + } + + public List getImages() { + return images; + } + + public String getName() { + return name; + } + + public String getSenderAppIdentifier() { + return senderAppIdentifier; + } + + public boolean isNamespaceSupported(String namespace) { + return namespaces.contains(namespace); + } + + public static final Creator CREATOR = new AutoCreator(ApplicationMetadata.class); +} diff --git a/play-services-api/src/main/java/com/google/android/gms/cast/CastDevice.java b/play-services-api/src/main/java/com/google/android/gms/cast/CastDevice.java new file mode 100644 index 00000000..22ab65c8 --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/cast/CastDevice.java @@ -0,0 +1,124 @@ +/* + * Copyright 2013-2015 µg Project Team + * + * 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.google.android.gms.cast; + +import android.os.Bundle; +import android.text.TextUtils; + +import com.google.android.gms.common.images.WebImage; + +import org.microg.gms.common.PublicApi; +import org.microg.safeparcel.AutoSafeParcelable; +import org.microg.safeparcel.SafeParceled; + +import java.net.Inet4Address; +import java.util.ArrayList; +import java.util.List; + +@PublicApi +public class CastDevice extends AutoSafeParcelable { + private static final String EXTRA_CAST_DEVICE = "com.google.android.gms.cast.EXTRA_CAST_DEVICE"; + + public static final int CAPABILITY_VIDEO_OUT = 1; + public static final int CAPABILITY_VIDEO_IN = 2; + public static final int CAPABILITY_AUDIO_OUT = 4; + public static final int CAPABILITY_AUDIO_IN = 8; + + @SafeParceled(1) + private int versionCode; + + @SafeParceled(3) + private String addrString; + private Inet4Address addr; + + private String deviceId; + + private String deviceVersion; + + private String friendlyName; + + private int servicePort; + + @SafeParceled(value = 8, subClass = WebImage.class) + private ArrayList icons; + + public String getDeviceId() { + return deviceId; + } + + public String getDeviceVersion() { + return deviceVersion; + } + + public String getFriendlyName() { + return friendlyName; + } + + public static CastDevice getFromBundle(Bundle extras) { + if (extras == null) { + return null; + } + extras.setClassLoader(CastDevice.class.getClassLoader()); + return extras.getParcelable(EXTRA_CAST_DEVICE); + } + + public WebImage getIcon(int preferredWidth, int preferredHeight) { + return null; + } + + public List getIcons() { + return icons; + } + + public Inet4Address getIpAddress() { + return addr; + } + + public String getModelName() { + return null; + } + + public int getServicePort() { + return servicePort; + } + + public boolean hasCapabilities(int[] capabilities) { + return false; + } + + public boolean hasCapability(int capability) { + return false; + } + + public boolean hasIcons() { + return !icons.isEmpty(); + } + + public boolean isOnLocalNetwork() { + return false; + } + + public boolean isSameDevice(CastDevice castDevice) { + return TextUtils.equals(castDevice.deviceId, deviceId); + } + + public void putInBundle(Bundle bundle) { + bundle.putParcelable(EXTRA_CAST_DEVICE, this); + } + + public static Creator CREATOR = new AutoCreator(CastDevice.class); +} diff --git a/play-services-api/src/main/java/com/google/android/gms/cast/LaunchOptions.java b/play-services-api/src/main/java/com/google/android/gms/cast/LaunchOptions.java new file mode 100644 index 00000000..3a550360 --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/cast/LaunchOptions.java @@ -0,0 +1,47 @@ +/* + * Copyright 2013-2015 µg Project Team + * + * 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.google.android.gms.cast; + +import org.microg.safeparcel.AutoSafeParcelable; +import org.microg.safeparcel.SafeParceled; + +public class LaunchOptions extends AutoSafeParcelable { + @SafeParceled(1) + private int versionCode = 1; + @SafeParceled(2) + private boolean relaunchIfRunning; + @SafeParceled(3) + private String language; + + public String getLanguage() { + return language; + } + + public boolean getRelaunchIfRunning() { + return relaunchIfRunning; + } + + public void setLanguage(String language) { + this.language = language; + } + + public void setRelaunchIfRunning(boolean relaunchIfRunning) { + this.relaunchIfRunning = relaunchIfRunning; + } + + public static Creator CREATOR = new AutoCreator(LaunchOptions.class); +} diff --git a/play-services-api/src/main/java/com/google/android/gms/common/images/WebImage.java b/play-services-api/src/main/java/com/google/android/gms/common/images/WebImage.java new file mode 100644 index 00000000..58e29863 --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/common/images/WebImage.java @@ -0,0 +1,23 @@ +/* + * Copyright 2013-2015 µg Project Team + * + * 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.google.android.gms.common.images; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class WebImage extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator(WebImage.class); +} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/model/PolygonOptions.java b/play-services-api/src/main/java/com/google/android/gms/maps/model/PolygonOptions.java index 252a360f..a65e782d 100644 --- a/play-services-api/src/main/java/com/google/android/gms/maps/model/PolygonOptions.java +++ b/play-services-api/src/main/java/com/google/android/gms/maps/model/PolygonOptions.java @@ -16,17 +16,135 @@ package com.google.android.gms.maps.model; +import android.graphics.Color; + import org.microg.gms.common.PublicApi; import org.microg.safeparcel.AutoSafeParcelable; +import org.microg.safeparcel.SafeParceled; + +import java.util.ArrayList; +import java.util.List; /** * Defines options for a polygon. - * TODO + * TODO: Docs */ @PublicApi public class PolygonOptions extends AutoSafeParcelable { + @SafeParceled(1) + private int versionCode = 1; + @SafeParceled(value = 2, subClass = LatLng.class) + private List points = new ArrayList(); + @SafeParceled(value = 3, subClass = LatLng.class, useClassLoader = true) + private List> holes = new ArrayList>(); + @SafeParceled(4) + private float strokeWidth = 10; + @SafeParceled(5) + private int strokeColor = Color.BLACK; + @SafeParceled(6) + private int fillColor = Color.TRANSPARENT; + @SafeParceled(7) + private float zIndex = 0; + @SafeParceled(8) + private boolean visible = true; + @SafeParceled(9) + private boolean geodesic = false; + + /** + * Creates polygon options. + */ public PolygonOptions() { } + public PolygonOptions add(LatLng point) { + points.add(point); + return this; + } + + public PolygonOptions add(LatLng... points) { + for (LatLng point : points) { + this.points.add(point); + } + return this; + } + + public PolygonOptions add(Iterable points) { + for (LatLng point : points) { + this.points.add(point); + } + return this; + } + + public PolygonOptions addHole(Iterable points) { + ArrayList hole = new ArrayList(); + for (LatLng point : points) { + hole.add(point); + } + holes.add(hole); + return this; + } + + public PolygonOptions fillColor(int color) { + this.fillColor = color; + return this; + } + + public PolygonOptions geodesic(boolean geodesic) { + this.geodesic = geodesic; + return this; + } + + public int getFillColor() { + return fillColor; + } + + public List> getHoles() { + return holes; + } + + public List getPoints() { + return points; + } + + public int getStrokeColor() { + return strokeColor; + } + + public float getStrokeWidth() { + return strokeWidth; + } + + public float getZIndex() { + return zIndex; + } + + public boolean isGeodesic() { + return geodesic; + } + + public boolean isVisible() { + return visible; + } + + public PolygonOptions strokeColor(int color) { + this.strokeColor = color; + return this; + } + + public PolygonOptions strokeWidth(float width) { + this.strokeWidth = width; + return this; + } + + public PolygonOptions visible(boolean visible) { + this.visible = visible; + return this; + } + + public PolygonOptions zIndex(float zIndex) { + this.zIndex = zIndex; + return this; + } + public static Creator CREATOR = new AutoCreator(PolygonOptions.class); }