From 474d26e0c482148f9b9b5c2eb23cbac5d8145292 Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Wed, 2 Aug 2017 10:57:26 +0200 Subject: [PATCH] Demo app fixes --- README.md | 9 ++-- build.gradle | 9 +++- demo/src/main/AndroidManifest.xml | 2 + .../flurgle/camerakit/demo/MainActivity.java | 48 ++++++++++++------- demo/src/main/res/layout/activity_main.xml | 30 ++++++------ 5 files changed, 63 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 5ef75e5c..09ac8752 100644 --- a/README.md +++ b/README.md @@ -119,20 +119,23 @@ camera.captureImage(); TODO: test size and orientation stuff. -To capture video just call `CameraView.startRecordingVideo()` to start, and `CameraView.stopRecordingVideo()` to finish. Make sure you setup a `CameraListener` to handle the video callback. +To capture video just call `CameraView.startRecordingVideo(file)` to start, and `CameraView.stopRecordingVideo()` to finish. Make sure you setup a `CameraListener` to handle the video callback. ```java camera.setCameraListener(new CameraListener() { @Override public void onVideoTaken(File video) { - // The File parameter is an MP4 file. + // The File is the same you passed before. + // Now it holds a MP4 video. } }); -camera.startRecordingVideo(); +File file = ...; // Make sure you have permissions to write here. +camera.startRecordingVideo(file); camera.postDelayed(new Runnable() { @Override public void run() { + // This will trigger onVideoTaken(). camera.stopRecordingVideo(); } }, 2500); diff --git a/build.gradle b/build.gradle index 395f30b3..5a7fc30f 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.0' + classpath 'com.android.tools.build:gradle:2.3.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -19,6 +19,13 @@ allprojects { } } +ext { + compileSdkVersion = 25 + buildToolsVersion = "25.0.2" + minSdkVersion = 15 + targetSdkVersion = 25 +} + task clean(type: Delete) { delete rootProject.buildDir } diff --git a/demo/src/main/AndroidManifest.xml b/demo/src/main/AndroidManifest.xml index 976e1aa9..b61d7d6b 100644 --- a/demo/src/main/AndroidManifest.xml +++ b/demo/src/main/AndroidManifest.xml @@ -2,6 +2,8 @@ + + = 1) { updateCamera(true, false); } @@ -206,6 +221,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan RadioGroup.OnCheckedChangeListener widthModeChangedListener = new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { + if (mCapturing) return; widthUpdate.setEnabled(checkedId == R.id.widthCustom); widthUpdate.setAlpha(checkedId == R.id.widthCustom ? 1f : 0.3f); width.clearFocus(); @@ -218,6 +234,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan @OnClick(R.id.heightUpdate) void heightUpdateClicked() { + if (mCapturing) return; if (heightUpdate.getAlpha() >= 1) { updateCamera(false, true); } @@ -226,6 +243,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan RadioGroup.OnCheckedChangeListener heightModeChangedListener = new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { + if (mCapturing) return; heightUpdate.setEnabled(checkedId == R.id.heightCustom); heightUpdate.setAlpha(checkedId == R.id.heightCustom ? 1f : 0.3f); height.clearFocus(); @@ -237,6 +255,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan }; private void updateCamera(boolean updateWidth, boolean updateHeight) { + if (mCapturing) return; ViewGroup.LayoutParams cameraLayoutParams = camera.getLayoutParams(); int width = cameraLayoutParams.width; int height = cameraLayoutParams.height; @@ -290,7 +309,6 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan cameraLayoutParams.width = width; cameraLayoutParams.height = height; - camera.addOnLayoutChangeListener(this); camera.setLayoutParams(cameraLayoutParams); @@ -301,10 +319,8 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { mCameraWidth = right - left; mCameraHeight = bottom - top; - width.setText(String.valueOf(mCameraWidth)); height.setText(String.valueOf(mCameraHeight)); - camera.removeOnLayoutChangeListener(this); } diff --git a/demo/src/main/res/layout/activity_main.xml b/demo/src/main/res/layout/activity_main.xml index c18d3c42..c1964a4b 100644 --- a/demo/src/main/res/layout/activity_main.xml +++ b/demo/src/main/res/layout/activity_main.xml @@ -1,12 +1,13 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + android:id="@+id/activity_main" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@android:color/white" + android:descendantFocusability="beforeDescendants" + android:focusable="true" + android:focusableInTouchMode="true"> + app:cameraCropOutput="false" + app:cameraFacing="back" + app:cameraFlash="off" + app:cameraFocus="tapWithMarker" + app:cameraJpegQuality="100" + app:cameraSessionType="picture" /> @@ -62,8 +63,7 @@ android:layout_weight="1" android:backgroundTint="@color/colorPrimary" android:src="@drawable/ic_video" - android:tint="@android:color/white" - android:visibility="gone" /> + android:tint="@android:color/white" />