aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/me/texx/Texx/CameraActivity.kt
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/me/texx/Texx/CameraActivity.kt')
-rw-r--r--app/src/main/java/me/texx/Texx/CameraActivity.kt36
1 files changed, 32 insertions, 4 deletions
diff --git a/app/src/main/java/me/texx/Texx/CameraActivity.kt b/app/src/main/java/me/texx/Texx/CameraActivity.kt
index df03164..9186f28 100644
--- a/app/src/main/java/me/texx/Texx/CameraActivity.kt
+++ b/app/src/main/java/me/texx/Texx/CameraActivity.kt
@@ -1,15 +1,24 @@
package me.texx.Texx
+import android.graphics.BitmapFactory
+import android.graphics.Color.RED
+import android.graphics.PorterDuff
+import android.graphics.PorterDuffColorFilter
+import android.graphics.drawable.Drawable
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.Window
import android.view.WindowManager
import com.otaliastudios.cameraview.CameraListener
+import com.otaliastudios.cameraview.Gesture
+import com.otaliastudios.cameraview.GestureAction
+import com.otaliastudios.cameraview.SessionType
import daio.io.dresscode.dressCodeName
import daio.io.dresscode.matchDressCode
import kotlinx.android.synthetic.main.activity_camera.*
+import kotlinx.android.synthetic.main.activity_media_preview.*
import me.texx.Texx.util.ThemeUtil.getThemeName
-import org.jetbrains.anko.toast
+import org.jetbrains.anko.startActivity
class CameraActivity : AppCompatActivity() {
@@ -26,15 +35,34 @@ class CameraActivity : AppCompatActivity() {
}
private fun initCameraLayout() {
+ camera.mapGesture(Gesture.PINCH, GestureAction.ZOOM)
+ camera.mapGesture(Gesture.TAP, GestureAction.FOCUS_WITH_MARKER)
+ camera.mapGesture(Gesture.LONG_TAP, GestureAction.CAPTURE)
+ camera.mapGesture(Gesture.SCROLL_HORIZONTAL, GestureAction.EXPOSURE_CORRECTION)
+
camera.addCameraListener(object : CameraListener() {
- override fun onPictureTaken(jpeg: ByteArray?) {
- toast("Photo taken")
+ override fun onPictureTaken(jpeg: ByteArray) {
+ imagePreview.setImageBitmap(BitmapFactory.decodeByteArray(jpeg, 0, jpeg.size))
+ startActivity<MediaPreviewActivity>()
}
})
- photo_button.setOnClickListener {
+ camera_button.setOnClickListener {
camera.capturePicture()
}
+
+ camera_button.setOnLongClickListener {
+ if (camera.sessionType == SessionType.PICTURE) {
+ camera.sessionType = SessionType.VIDEO
+ val videoButtonDrawable: Drawable = this.resources.getDrawable(R.drawable.focus_marker_outline)
+ videoButtonDrawable.colorFilter = PorterDuffColorFilter(RED, PorterDuff.Mode.SRC_IN)
+ camera_button.setBackgroundDrawable(videoButtonDrawable)
+ } else {
+ camera.sessionType = SessionType.PICTURE
+ camera_button.setBackgroundDrawable(this.resources.getDrawable(R.drawable.focus_marker_outline))
+ }
+ true
+ }
}
override fun onResume() {