summaryrefslogtreecommitdiff
path: root/prebuilts/gradle/BasicMediaDecoder
diff options
context:
space:
mode:
authorTrevor Johns <trevorjohns@google.com>2016-06-15 10:56:34 -0700
committerTrevor Johns <trevorjohns@google.com>2016-06-15 11:23:05 -0700
commit8ef75db005ad4c69bfb25a6510873181c06980a3 (patch)
tree18949b40f8c9390284995045608b6597244a0e6b /prebuilts/gradle/BasicMediaDecoder
parentb6e44500104da45c00848b4a30e980c9a98da441 (diff)
downloadbuild-8ef75db005ad4c69bfb25a6510873181c06980a3.tar.gz
developers/samples/android: f9872ded3bb6cd3c01ab0881a58764f5171b4c64 developers/build: 23e77f8a040c0b35531a68e776363f32fa7feeeb Change-Id: I3f61cc23f90d2fd778d62d88cd3df6ea0842da8e
Diffstat (limited to 'prebuilts/gradle/BasicMediaDecoder')
-rw-r--r--prebuilts/gradle/BasicMediaDecoder/Application/build.gradle11
-rw-r--r--prebuilts/gradle/BasicMediaDecoder/Application/src/main/java/com/example/android/common/media/CameraHelper.java38
-rw-r--r--prebuilts/gradle/BasicMediaDecoder/README.md6
-rw-r--r--prebuilts/gradle/BasicMediaDecoder/gradle/wrapper/gradle-wrapper.properties2
4 files changed, 33 insertions, 24 deletions
diff --git a/prebuilts/gradle/BasicMediaDecoder/Application/build.gradle b/prebuilts/gradle/BasicMediaDecoder/Application/build.gradle
index 766dcc8d..c1290074 100644
--- a/prebuilts/gradle/BasicMediaDecoder/Application/build.gradle
+++ b/prebuilts/gradle/BasicMediaDecoder/Application/build.gradle
@@ -5,7 +5,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:1.2.3'
+ classpath 'com.android.tools.build:gradle:2.1.2'
}
}
@@ -16,9 +16,10 @@ repositories {
}
dependencies {
- compile "com.android.support:support-v4:23.1.0"
- compile "com.android.support:support-v13:23.1.0"
- compile "com.android.support:cardview-v7:23.1.0"
+ compile "com.android.support:support-v4:24.0.0-beta1"
+ compile "com.android.support:support-v13:24.0.0-beta1"
+ compile "com.android.support:cardview-v7:24.0.0-beta1"
+ compile "com.android.support:appcompat-v7:24.0.0-beta1"
}
// The sample build uses multiple directories to
@@ -31,7 +32,7 @@ List<String> dirs = [
android {
compileSdkVersion 23
- buildToolsVersion "23.0.2"
+ buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 17
diff --git a/prebuilts/gradle/BasicMediaDecoder/Application/src/main/java/com/example/android/common/media/CameraHelper.java b/prebuilts/gradle/BasicMediaDecoder/Application/src/main/java/com/example/android/common/media/CameraHelper.java
index 1fa84167..b578767d 100644
--- a/prebuilts/gradle/BasicMediaDecoder/Application/src/main/java/com/example/android/common/media/CameraHelper.java
+++ b/prebuilts/gradle/BasicMediaDecoder/Application/src/main/java/com/example/android/common/media/CameraHelper.java
@@ -36,49 +36,57 @@ public class CameraHelper {
public static final int MEDIA_TYPE_VIDEO = 2;
/**
- * Iterate over supported camera preview sizes to see which one best fits the
+ * Iterate over supported camera video sizes to see which one best fits the
* dimensions of the given view while maintaining the aspect ratio. If none can,
* be lenient with the aspect ratio.
*
- * @param sizes Supported camera preview sizes.
- * @param w The width of the view.
- * @param h The height of the view.
- * @return Best match camera preview size to fit in the view.
+ * @param supportedVideoSizes Supported camera video sizes.
+ * @param previewSizes Supported camera preview sizes.
+ * @param w The width of the view.
+ * @param h The height of the view.
+ * @return Best match camera video size to fit in the view.
*/
- public static Camera.Size getOptimalPreviewSize(List<Camera.Size> sizes, int w, int h) {
+ public static Camera.Size getOptimalVideoSize(List<Camera.Size> supportedVideoSizes,
+ List<Camera.Size> previewSizes, int w, int h) {
// Use a very small tolerance because we want an exact match.
final double ASPECT_TOLERANCE = 0.1;
double targetRatio = (double) w / h;
- if (sizes == null)
- return null;
+ // Supported video sizes list might be null, it means that we are allowed to use the preview
+ // sizes
+ List<Camera.Size> videoSizes;
+ if (supportedVideoSizes != null) {
+ videoSizes = supportedVideoSizes;
+ } else {
+ videoSizes = previewSizes;
+ }
Camera.Size optimalSize = null;
- // Start with max value and refine as we iterate over available preview sizes. This is the
+ // Start with max value and refine as we iterate over available video sizes. This is the
// minimum difference between view and camera height.
double minDiff = Double.MAX_VALUE;
// Target view height
int targetHeight = h;
- // Try to find a preview size that matches aspect ratio and the target view size.
+ // Try to find a video size that matches aspect ratio and the target view size.
// Iterate over all available sizes and pick the largest size that can fit in the view and
// still maintain the aspect ratio.
- for (Camera.Size size : sizes) {
+ for (Camera.Size size : videoSizes) {
double ratio = (double) size.width / size.height;
if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE)
continue;
- if (Math.abs(size.height - targetHeight) < minDiff) {
+ if (Math.abs(size.height - targetHeight) < minDiff && previewSizes.contains(size)) {
optimalSize = size;
minDiff = Math.abs(size.height - targetHeight);
}
}
- // Cannot find preview size that matches the aspect ratio, ignore the requirement
+ // Cannot find video size that matches the aspect ratio, ignore the requirement
if (optimalSize == null) {
minDiff = Double.MAX_VALUE;
- for (Camera.Size size : sizes) {
- if (Math.abs(size.height - targetHeight) < minDiff) {
+ for (Camera.Size size : videoSizes) {
+ if (Math.abs(size.height - targetHeight) < minDiff && previewSizes.contains(size)) {
optimalSize = size;
minDiff = Math.abs(size.height - targetHeight);
}
diff --git a/prebuilts/gradle/BasicMediaDecoder/README.md b/prebuilts/gradle/BasicMediaDecoder/README.md
index aa55c57c..ce631f0a 100644
--- a/prebuilts/gradle/BasicMediaDecoder/README.md
+++ b/prebuilts/gradle/BasicMediaDecoder/README.md
@@ -54,8 +54,8 @@ MediaExtractor instance.
Pre-requisites
--------------
-- Android SDK v23
-- Android Build Tools v23.0.2
+- Android SDK 23
+- Android Build Tools v23.0.3
- Android Support Repository
Screenshots
@@ -84,7 +84,7 @@ submitting a pull request through GitHub. Please see CONTRIBUTING.md for more de
License
-------
-Copyright 2014 The Android Open Source Project, Inc.
+Copyright 2016 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
diff --git a/prebuilts/gradle/BasicMediaDecoder/gradle/wrapper/gradle-wrapper.properties b/prebuilts/gradle/BasicMediaDecoder/gradle/wrapper/gradle-wrapper.properties
index 07fc193f..d5705170 100644
--- a/prebuilts/gradle/BasicMediaDecoder/gradle/wrapper/gradle-wrapper.properties
+++ b/prebuilts/gradle/BasicMediaDecoder/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip