Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ buildscript {
ext.versions = [
goldeneye: '1.1.2',
google : '28.0.0',
kotlin : '1.3.10'
kotlin : '1.3.61'
]

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.17"
Expand Down
1 change: 1 addition & 0 deletions example/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application android:allowBackup="true"
android:icon="@drawable/ic_logo"
Expand Down
41 changes: 35 additions & 6 deletions example/src/main/java/co/infinum/example/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ package co.infinum.example

import android.Manifest
import android.annotation.SuppressLint
import android.content.ContentValues
import android.content.Context
import android.content.pm.PackageManager
import android.graphics.Bitmap
import android.graphics.SurfaceTexture
import android.media.MediaPlayer
import android.net.Uri
import android.os.Bundle
import android.os.Environment
import android.os.Handler
import android.os.Looper
import android.provider.MediaStore
import android.provider.MediaStore.MediaColumns
import android.support.v4.app.ActivityCompat
import android.support.v7.app.AlertDialog
import android.support.v7.app.AppCompatActivity
Expand All @@ -18,13 +24,17 @@ import android.util.Log
import android.view.Surface
import android.view.TextureView
import android.view.View
import android.widget.Toast
import co.infinum.goldeneye.GoldenEye
import co.infinum.goldeneye.InitCallback
import co.infinum.goldeneye.Logger
import co.infinum.goldeneye.config.CameraConfig
import co.infinum.goldeneye.config.CameraInfo
import kotlinx.android.synthetic.main.activity_main.*
import java.io.File
import java.io.File.separator
import java.io.FileOutputStream
import java.io.OutputStream
import java.util.concurrent.Executors
import kotlin.math.min

Expand Down Expand Up @@ -62,7 +72,8 @@ class MainActivity : AppCompatActivity() {
setContentView(R.layout.activity_main)
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
initGoldenEye()
videoFile = File.createTempFile("vid", "")
videoFile = File.createTempFile("vid", ".mp4",
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES))
initListeners()
}

Expand All @@ -80,6 +91,7 @@ class MainActivity : AppCompatActivity() {
goldenEye.takePicture(
onPictureTaken = { bitmap ->
if (bitmap.width <= 4096 && bitmap.height <= 4096) {
saveImage(bitmap, "MyExperience" + java.util.Calendar.getInstance(), this)
displayPicture(bitmap)
} else {
reducePictureSize(bitmap)
Expand Down Expand Up @@ -136,6 +148,7 @@ class MainActivity : AppCompatActivity() {
private fun initGoldenEye() {
goldenEye = GoldenEye.Builder(this)
.setLogger(logger)
.withAdvancedFeatures()
.setOnZoomChangedCallback { zoomView.text = "Zoom: ${it.toPercentage()}" }
.build()
}
Expand Down Expand Up @@ -201,11 +214,11 @@ class MainActivity : AppCompatActivity() {
} else {
AlertDialog.Builder(this)
.setTitle("GoldenEye")
.setMessage("Smartass Detected!")
.setPositiveButton("I am smartass") { _, _ ->
throw SmartassException
.setMessage("Permission needed to access app features")
.setPositiveButton("Deny") { _, _ ->
throw NoPermissionException
}
.setNegativeButton("Sorry") { _, _ ->
.setNegativeButton("Allow") { _, _ ->
openCamera(goldenEye.availableCameras[0])
}
.setCancelable(false)
Expand Down Expand Up @@ -234,6 +247,7 @@ class MainActivity : AppCompatActivity() {
MediaPlayer().apply {
setSurface(Surface(previewVideoView.surfaceTexture))
setDataSource(videoFile.absolutePath)
Toast.makeText(baseContext, videoFile.absolutePath, Toast.LENGTH_LONG).show()
setOnCompletionListener {
mainHandler.postDelayed({
previewVideoContainer.visibility = View.GONE
Expand All @@ -258,4 +272,19 @@ class MainActivity : AppCompatActivity() {
}
}

object SmartassException : Throwable()
// Method to save an image to gallery and return uri
private fun saveImage(bitmap:Bitmap, title:String, context:Context):Uri{

// Save image to gallery
val savedImageURL = MediaStore.Images.Media.insertImage(
context.contentResolver,
bitmap,
title,
"Image of $title"
)

// Parse the gallery image url to uri
return Uri.parse(savedImageURL)
}

object NoPermissionException : Throwable()
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ internal abstract class BaseAdvancedFeatureConfig<T : Any>(
}
}

override var antibandingMode = AntibandingMode.UNKNOWN
override var antibandingMode = AntibandingMode.OFF
get() = when {
field != AntibandingMode.UNKNOWN -> field
supportedAntibandingModes.contains(AntibandingMode.AUTO) -> AntibandingMode.AUTO
field != AntibandingMode.OFF -> field
supportedAntibandingModes.contains(AntibandingMode.OFF) -> AntibandingMode.OFF
else -> AntibandingMode.UNKNOWN
}
set(value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ interface VideoConfig {
* Defines the quality of recorded video.
*
* Default value is the first supported of [VideoQuality.RESOLUTION_2160P],
* [VideoQuality.RESOLUTION_1080P], [VideoQuality.RESOLUTION_720P], [VideoQuality.HIGH],
* [VideoQuality.RESOLUTION_1080P], [VideoQuality.RESOLUTION_720P], [VideoQuality.RESOLUTION_480P],
* [VideoQuality.RESOLUTION_QVGA], [VideoQuality.HIGH],
* [VideoQuality.LOW]. If none is supported, [VideoQuality.UNKNOWN] is used.
*
* @see VideoQuality
Expand Down Expand Up @@ -45,12 +46,14 @@ internal abstract class BaseVideoConfig<T : Any>(

lateinit var characteristics: T

override var videoQuality = VideoQuality.UNKNOWN
override var videoQuality = VideoQuality.RESOLUTION_QVGA
get() = when {
field != VideoQuality.UNKNOWN -> field
supportedVideoQualities.contains(VideoQuality.RESOLUTION_2160P) -> VideoQuality.RESOLUTION_2160P
supportedVideoQualities.contains(VideoQuality.RESOLUTION_1080P) -> VideoQuality.RESOLUTION_1080P
supportedVideoQualities.contains(VideoQuality.RESOLUTION_720P) -> VideoQuality.RESOLUTION_720P
supportedVideoQualities.contains(VideoQuality.RESOLUTION_480P) -> VideoQuality.RESOLUTION_480P
supportedVideoQualities.contains(VideoQuality.RESOLUTION_QVGA) -> VideoQuality.RESOLUTION_QVGA
supportedVideoQualities.contains(VideoQuality.HIGH) -> VideoQuality.HIGH
supportedVideoQualities.contains(VideoQuality.LOW) -> VideoQuality.LOW
else -> VideoQuality.UNKNOWN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ enum class VideoQuality(
* @see CamcorderProfile.QUALITY_HIGH
*/
HIGH(CamcorderProfile.QUALITY_HIGH),
/**
* @see CamcorderProfile.QUALITY_480P
*/
RESOLUTION_480P(CamcorderProfile.QUALITY_480P),
/**
* @see CamcorderProfile.QUALITY_QVGA
*/
RESOLUTION_QVGA(CamcorderProfile.QUALITY_QVGA),
/**
* @see CamcorderProfile.QUALITY_720P
*/
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Sep 25 13:16:57 CEST 2018
#Mon Jan 20 12:02:21 IST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip