From e03c25996424674a7015429022f850112d2d5aaf Mon Sep 17 00:00:00 2001 From: Yuichi Araki Date: Tue, 29 Mar 2016 10:49:48 +0900 Subject: [PATCH] Basic camera preview on Camera1 Change-Id: Iace32d2a230016229b60084bfe060c4ec7bca8b5 --- build.gradle | 2 +- demo/src/main/AndroidManifest.xml | 4 +- .../android/cameraview/demo/MainActivity.java | 19 ++ demo/src/main/res/values/styles.xml | 2 +- library/build.gradle | 5 + library/src/androidTest/AndroidManifest.xml | 23 +++ .../cameraview/CameraViewActivity.java | 47 +++++ .../android/cameraview/CameraViewTest.java | 79 ++++++-- .../android/cameraview/CameraViewImpl.java | 33 ++++ .../google/android/cameraview/Camera1.java | 181 ++++++++++++++++++ .../google/android/cameraview/CameraView.java | 35 ++++ .../main/res/layout/activity_camera_view.xml | 24 +++ library/src/main/res/layout/camera_view.xml | 21 ++ 13 files changed, 459 insertions(+), 16 deletions(-) create mode 100644 library/src/androidTest/AndroidManifest.xml create mode 100644 library/src/androidTest/java/com/google/android/cameraview/CameraViewActivity.java create mode 100644 library/src/main/base/com/google/android/cameraview/CameraViewImpl.java create mode 100644 library/src/main/camera1/com/google/android/cameraview/Camera1.java create mode 100644 library/src/main/res/layout/activity_camera_view.xml create mode 100644 library/src/main/res/layout/camera_view.xml diff --git a/build.gradle b/build.gradle index e293b0d3..db868459 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.0-alpha3' + classpath 'com.android.tools.build:gradle:2.1.0-alpha4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/demo/src/main/AndroidManifest.xml b/demo/src/main/AndroidManifest.xml index 912faf5d..59065aba 100644 --- a/demo/src/main/AndroidManifest.xml +++ b/demo/src/main/AndroidManifest.xml @@ -14,12 +14,14 @@ + + + android:theme="@style/Theme.Demo"> diff --git a/demo/src/main/java/com/google/android/cameraview/demo/MainActivity.java b/demo/src/main/java/com/google/android/cameraview/demo/MainActivity.java index 76be2b55..1dbcad50 100644 --- a/demo/src/main/java/com/google/android/cameraview/demo/MainActivity.java +++ b/demo/src/main/java/com/google/android/cameraview/demo/MainActivity.java @@ -16,15 +16,34 @@ package com.google.android.cameraview.demo; +import com.google.android.cameraview.CameraView; + import android.os.Bundle; import android.support.v7.app.AppCompatActivity; public class MainActivity extends AppCompatActivity { + private CameraView mCameraView; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + mCameraView = (CameraView) findViewById(R.id.camera); + } + + @Override + protected void onResume() { + super.onResume(); + mCameraView.onResume(); + mCameraView.startPreview(); + } + + @Override + protected void onPause() { + mCameraView.stopPreview(); + mCameraView.onPause(); + super.onPause(); } } diff --git a/demo/src/main/res/values/styles.xml b/demo/src/main/res/values/styles.xml index 39a975aa..e4ea791d 100644 --- a/demo/src/main/res/values/styles.xml +++ b/demo/src/main/res/values/styles.xml @@ -14,7 +14,7 @@ -