diff --git a/.repo/gh-join-spectrum.svg b/.repo/gh-join-spectrum.svg new file mode 100644 index 0000000000..97518944ca --- /dev/null +++ b/.repo/gh-join-spectrum.svg @@ -0,0 +1 @@ +Join Spectrum \ No newline at end of file diff --git a/.repo/gh-readme-alphaapps-logo.png b/.repo/gh-readme-alphaapps-logo.png new file mode 100644 index 0000000000..e1b08ca9b9 Binary files /dev/null and b/.repo/gh-readme-alphaapps-logo.png differ diff --git a/.repo/gh-readme-buddyworks.png b/.repo/gh-readme-buddyworks-logo.png similarity index 100% rename from .repo/gh-readme-buddyworks.png rename to .repo/gh-readme-buddyworks-logo.png diff --git a/.repo/gh-readme-expensify-logo.svg b/.repo/gh-readme-expensify-logo.svg new file mode 100644 index 0000000000..0ac06d2422 --- /dev/null +++ b/.repo/gh-readme-expensify-logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.repo/gh-readme-expensify.png b/.repo/gh-readme-expensify.png deleted file mode 100644 index 8f459bde5d..0000000000 Binary files a/.repo/gh-readme-expensify.png and /dev/null differ diff --git a/.repo/gh-readme-googleplay-demo-button.svg b/.repo/gh-readme-googleplay-demo-button.svg new file mode 100644 index 0000000000..ca72d7e747 --- /dev/null +++ b/.repo/gh-readme-googleplay-demo-button.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.repo/gh-readme-goosechase-logo.svg b/.repo/gh-readme-goosechase-logo.svg new file mode 100644 index 0000000000..55638fe90f --- /dev/null +++ b/.repo/gh-readme-goosechase-logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.repo/gh-readme-infitting-logo.svg b/.repo/gh-readme-infitting-logo.svg new file mode 100644 index 0000000000..278162e32e --- /dev/null +++ b/.repo/gh-readme-infitting-logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.repo/gh-readme-spectrum-button.svg b/.repo/gh-readme-spectrum-button.svg new file mode 100644 index 0000000000..2a6d277682 --- /dev/null +++ b/.repo/gh-readme-spectrum-button.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/README.md b/README.md index db57474878..5948f5ef43 100644 --- a/README.md +++ b/README.md @@ -1,88 +1,143 @@

- + CameraKit Header

- - CameraKit Header + + Google Play Link + + + Join Spectrum - Buddy.Works + Buddy.Works

-

- Join Slack - Code Climate - Code Climate -

- -# What is CameraKit? - -CameraKit takes one of the hardest Android APIs and makes it into a high level and easy to use library that solves all of your problems. +CameraKit helps you add reliable camera to your app quickly. Our open source camera platform provides consistent capture results, service that scales, and endless camera possibilities. -With CameraKit you are able to effortlessly do the following... +With CameraKit you are able to effortlessly do the following: - Image and video capture seamlessly working with the same preview session. - Automatic system permission handling. - Automatic preview scaling. -- Create a CameraView of any size (not just presets!). -- Automatic output cropping to match your CameraView bounds. + - Create a `CameraView` of any size (not just presets!). + - Automatic output cropping to match your `CameraView` bounds. - Multiple capture methods. - - METHOD_STANDARD: an image captured normally using the camera APIs. - - METHOD_STILL: a freeze frame of the CameraView preview (similar to SnapChat and Instagram) for devices with slower cameras. - - METHOD_SPEED: automatic capture method determination based on measured speed. + - `METHOD_STANDARD`: an image captured normally using the camera APIs. + - `METHOD_STILL`: a freeze frame of the `CameraView` preview (similar to SnapChat and Instagram) for devices with slower cameras. + - `METHOD_SPEED`: automatic capture method determination based on measured speed. - Built-in continuous focus. - Built-in tap to focus. - Built-in pinch to zoom. ## Sponsored By +Expensify +Buddy.Works - - -## Setup +## Trusted By +InFitting +GooseChase +Alpha Apps +Expensify -Add __CameraKit__ to the dependencies block in your `app` level `build.gradle`: +  -```groovy -implementation 'com.camerakit:camerakit:1.0.0-beta3.9' -``` +# Get The Most From CameraKit +There are currently two versions of CameraKit that we support, `v1.0.0-beta3.X` and `v0.13.X`. +If photo is your only need, try out the latest and greatest CameraKit features with `v1.0.0-beta3.11`. Our `beta3.11` release does not yet support video, but that feature is coming! + +In the meantime, if your application requires video we reccomend sticking with `v0.13.4`; the latest stable release with video implementation. -## Usage -To use CameraKit, simply add a `CameraKitView` to your layout: +| Use Case | Version | Notes | Documentation Link | +| --- | --- | --- | --- | +| Photo only | `v1.0.0-beta3.11` | The latest and greatest CameraKit has to offer. Video support coming soon! | [camerakit.io/docs/beta3.11](https://camerakit.io/docs?v=1.0.0-beta3.10) | +| Photo and Video | `v0.13.4` | Stable build with full photo and video support | [camerakit.io/docs/0.13.4](https://camerakit.io/docs?v=0.13.2) | -```xml + +## Documentation Site +Setup instructions for `1.0.0-beta3.11` are below. To see the full documentation head over to our website, [camerakit.io/docs](https://camerakit.io/docs). + + +## Setup +To include __CameraKit__ in your project, add the following to your `app` level `build.gradle`. +```java +dependencies { + implementation 'com.camerakit:camerakit:1.0.0-beta3.11' + implementation 'com.camerakit:jpegkit:0.1.0' + implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0' +} +``` +## Usage +Create a `CameraKitView` in your layout as follows: +``` + android:layout_height="wrap_content" + android:adjustViewBounds="true" + android:keepScreenOn="true" + app:camera_flash="auto" + app:camera_facing="back" + app:camera_focus="continuous" + app:camera_permissions="camera" /> ``` -Make sure you override `onResume` and `onPause` in your activity, and make pass-through calls CameraKit with `CameraKitView.onResume()` and `CameraKitView.onPause()`. - +Then create a new `CameraKitView` object in your `Activity` and override the following methods. ```java +private CameraKitView cameraKitView; + +@Override +protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + cameraKitView = findViewById(R.id.camera); +} + +@Override +protected void onStart() { + super.onStart(); + cameraKitView.onStart(); +} + @Override protected void onResume() { super.onResume(); - cameraView.onResume(); + cameraKitView.onResume(); } @Override protected void onPause() { - cameraView.onPause(); + cameraKitView.onPause(); super.onPause(); } -``` -## Detailed Documentation +@Override +protected void onStop() { + cameraKitView.onStop(); + super.onStop(); +} -To check out detailed docs, visit our [Documentation Website](https://docs.camerakit.website) +@Override +public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + cameraKitView.onRequestPermissionsResult(requestCode, permissions, grantResults); +} +``` +## ProGuard +If using ProGuard, add the following rules: +``` +-dontwarn com.google.android.gms.** +-keepclasseswithmembers class com.camerakit.preview.CameraSurfaceView { + native ; +} +``` ## License - -CameraKit is [MIT License](https://github.com/CameraKit/CameraKit-Android/blob/master/LICENSE) \ No newline at end of file +CameraKit is [MIT License](https://github.com/CameraKit/CameraKit-Android/blob/master/LICENSE) diff --git a/app/build.gradle b/app/build.gradle index a3278dd1ac..73b6ec3a5c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,5 +18,5 @@ dependencies { implementation project(':camerakit') implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.0' implementation 'androidx.appcompat:appcompat:1.0.2' - implementation 'com.google.android.material:material:1.1.0-alpha01' + implementation 'com.google.android.material:material:1.1.0-alpha02' } diff --git a/build.gradle b/build.gradle index b057f0c16b..ab0e48047a 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ buildscript { subprojects { project -> group = 'com.camerakit' - version = '1.0.0-beta3.10' + version = '1.0.0-beta3.11' repositories { google() diff --git a/camerakit/build.gradle b/camerakit/build.gradle index 2ea1c844d5..b37df37ee8 100644 --- a/camerakit/build.gradle +++ b/camerakit/build.gradle @@ -27,7 +27,7 @@ android { dependencies { api 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.0' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0' - api 'androidx.annotation:annotation:1.0.0' + api 'androidx.annotation:annotation:1.0.1' api 'com.camerakit:jpegkit:0.2.0-alpha1' testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:1.10.19' diff --git a/camerakit/src/main/java/com/camerakit/CameraKitView.java b/camerakit/src/main/java/com/camerakit/CameraKitView.java index b50706018d..4c7cfc78db 100644 --- a/camerakit/src/main/java/com/camerakit/CameraKitView.java +++ b/camerakit/src/main/java/com/camerakit/CameraKitView.java @@ -721,6 +721,22 @@ public void setFlash(@CameraKit.Flash int flash) { mCameraPreview.setFlash(cameraFlash); } + /** + * Determine if device is capable of flash + * @return boolean if device is capable of flash + */ + public boolean hasFlash() { + return mCameraPreview.hasFlash(); + } + + /** + * Get supported flash types on device + * @return array of supported flash types + */ + public CameraFlash[] getSupportedFlashTypes() { + return mCameraPreview.getSupportedFlashTypes(); + } + /** * @return one of {@link CameraKit.Flash}'s constants. * @see #setFlash(int) diff --git a/camerakit/src/main/java/com/camerakit/CameraPreview.kt b/camerakit/src/main/java/com/camerakit/CameraPreview.kt index 39fa856bac..3021e1716a 100644 --- a/camerakit/src/main/java/com/camerakit/CameraPreview.kt +++ b/camerakit/src/main/java/com/camerakit/CameraPreview.kt @@ -101,7 +101,7 @@ class CameraPreview : FrameLayout, CameraEvents { override fun onSurfaceReady(cameraSurfaceTexture: CameraSurfaceTexture) { surfaceTexture = cameraSurfaceTexture surfaceState = SurfaceState.SURFACE_AVAILABLE - if (lifecycleState == LifecycleState.RESUMED) { + if (lifecycleState == LifecycleState.STARTED || lifecycleState == LifecycleState.RESUMED) { resume() } } @@ -168,6 +168,17 @@ class CameraPreview : FrameLayout, CameraEvents { } } + fun hasFlash(): Boolean { + if (attributes?.flashes != null) { + return true + } + return false + } + + fun getSupportedFlashTypes(): Array? { + return attributes?.flashes + } + interface PhotoCallback { fun onCapture(jpeg: ByteArray) } diff --git a/camerakit/src/main/java/com/camerakit/preview/CameraSurfaceView.kt b/camerakit/src/main/java/com/camerakit/preview/CameraSurfaceView.kt index 8aea355e2e..ace91c76cd 100644 --- a/camerakit/src/main/java/com/camerakit/preview/CameraSurfaceView.kt +++ b/camerakit/src/main/java/com/camerakit/preview/CameraSurfaceView.kt @@ -3,6 +3,7 @@ package com.camerakit.preview import android.content.Context import android.opengl.GLES20.glGenTextures import android.opengl.GLSurfaceView +import android.os.Build import androidx.annotation.Keep import android.util.AttributeSet import javax.microedition.khronos.egl.EGLConfig @@ -106,6 +107,9 @@ class CameraSurfaceView : GLSurfaceView, GLSurfaceView.Renderer { companion object { init { + if (Build.VERSION.SDK_INT <= 17) { + System.loadLibrary("camerakit-core") + } System.loadLibrary("camerakit") }