diff options
author | Marvin Borner | 2018-08-31 02:03:59 +0200 |
---|---|---|
committer | Marvin Borner | 2018-08-31 02:03:59 +0200 |
commit | df994e4fe077dc643658dbd4c65845b0e086fc8a (patch) | |
tree | 448e7f4265a50cd12c8689e33ca01c4afa2bbc2f /app | |
parent | e9dcc2b88ec1cb4a09e5f82e6aa91ad46ca13037 (diff) |
Added video button and began preview after image
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/AndroidManifest.xml | 5 | ||||
-rw-r--r-- | app/src/main/java/me/texx/Texx/CameraActivity.kt | 36 | ||||
-rw-r--r-- | app/src/main/java/me/texx/Texx/MediaPreviewActivity.kt | 22 | ||||
-rw-r--r-- | app/src/main/res/layout/activity_camera.xml | 2 | ||||
-rw-r--r-- | app/src/main/res/layout/activity_media_preview.xml | 15 |
5 files changed, 74 insertions, 6 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b27c25b..1e82523 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -4,6 +4,8 @@ package="me.texx.Texx"> <!-- To auto-complete the email text field in the login form with the user's emails --> + <uses-permission android:name="android.permission.RECORD_AUDIO" /> + <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.READ_PROFILE" /> <uses-permission android:name="android.permission.READ_CONTACTS" /> @@ -39,7 +41,8 @@ android:name="android.support.PARENT_ACTIVITY" android:value="me.texx.Texx.MainActivity" /> </activity> - <activity android:name=".CameraActivity"></activity> + <activity android:name=".CameraActivity" /> + <activity android:name=".MediaPreviewActivity"></activity> </application> </manifest>
\ No newline at end of file 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() { diff --git a/app/src/main/java/me/texx/Texx/MediaPreviewActivity.kt b/app/src/main/java/me/texx/Texx/MediaPreviewActivity.kt new file mode 100644 index 0000000..cdc5c71 --- /dev/null +++ b/app/src/main/java/me/texx/Texx/MediaPreviewActivity.kt @@ -0,0 +1,22 @@ +package me.texx.Texx + +import android.os.Bundle +import android.support.v7.app.AppCompatActivity +import android.view.Window +import android.view.WindowManager +import daio.io.dresscode.dressCodeName +import daio.io.dresscode.matchDressCode +import me.texx.Texx.util.ThemeUtil.getThemeName + +class MediaPreviewActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + matchDressCode() + super.onCreate(savedInstanceState) + dressCodeName = getThemeName(this) + requestWindowFeature(Window.FEATURE_NO_TITLE) + window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, + WindowManager.LayoutParams.FLAG_FULLSCREEN) + setContentView(R.layout.activity_camera) + } +} diff --git a/app/src/main/res/layout/activity_camera.xml b/app/src/main/res/layout/activity_camera.xml index 527db7c..d9b7a35 100644 --- a/app/src/main/res/layout/activity_camera.xml +++ b/app/src/main/res/layout/activity_camera.xml @@ -7,7 +7,7 @@ tools:context=".CameraActivity"> <Button - android:id="@+id/photo_button" + android:id="@+id/camera_button" android:layout_width="100dp" android:layout_height="100dp" android:layout_marginBottom="48dp" diff --git a/app/src/main/res/layout/activity_media_preview.xml b/app/src/main/res/layout/activity_media_preview.xml new file mode 100644 index 0000000..4996725 --- /dev/null +++ b/app/src/main/res/layout/activity_media_preview.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".MediaPreviewActivity"> + + <ImageView + android:id="@+id/imagePreview" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:contentDescription="Kwel image" + app:srcCompat="@drawable/ic_camera_black_24dp" /> +</android.support.constraint.ConstraintLayout>
\ No newline at end of file |