aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMarvin Borner2018-09-01 02:34:08 +0200
committerMarvin Borner2018-09-01 02:34:08 +0200
commit2295bd4f8f4a1d565e69ab5931ae2f0108d24407 (patch)
treefe575cedac90778bbdfff80ce0cbb0043880ac2f
parent02534de25c78ccb01b8fb8752483bca37e72d935 (diff)
Added drawing tool and color selection seekbar
-rw-r--r--app/build.gradle2
-rw-r--r--app/src/main/AndroidManifest.xml2
-rw-r--r--app/src/main/java/me/texx/Texx/CameraActivity.kt2
-rw-r--r--app/src/main/java/me/texx/Texx/MediaPreviewActivity.kt34
-rw-r--r--app/src/main/java/me/texx/Texx/PhotoEditorActivity.kt69
-rw-r--r--app/src/main/res/drawable/ic_mode_edit_black_24dp.xml9
-rw-r--r--app/src/main/res/layout/activity_photo_editor.xml58
7 files changed, 140 insertions, 36 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 3fb7432..37d058f 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -29,6 +29,8 @@ dependencies {
implementation 'com.kazakago.cryptore:cryptore:1.3.0'
implementation 'com.github.kittinunf.fuel:fuel-android:1.6.0'
implementation 'com.github.Daio-io:dresscode:v0.0.2'
+ implementation 'com.github.rtugeek:colorseekbar:1.7.2'
+ implementation 'ja.burhanrashid52:photoeditor:0.3.3'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.anko:anko-commons:0.10.5"
implementation "org.jetbrains.anko:anko-design:0.10.5"
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f92d495..927f6b1 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -44,7 +44,7 @@
android:value="me.texx.Texx.MainActivity" />
</activity>
<activity android:name=".CameraActivity" />
- <activity android:name=".MediaPreviewActivity"></activity>
+ <activity android:name=".PhotoEditorActivity"></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 2cb67c2..ed50f25 100644
--- a/app/src/main/java/me/texx/Texx/CameraActivity.kt
+++ b/app/src/main/java/me/texx/Texx/CameraActivity.kt
@@ -65,7 +65,7 @@ class CameraActivity : AppCompatActivity() {
override fun onPictureTaken(jpeg: ByteArray?) {
val file: File? = createFile()
writeFile(BitmapFactory.decodeByteArray(jpeg, 0, jpeg!!.size), file)
- startActivity(intentFor<MediaPreviewActivity>("filepath" to file.toString()))
+ startActivity(intentFor<PhotoEditorActivity>("filepath" to file.toString()))
}
})
diff --git a/app/src/main/java/me/texx/Texx/MediaPreviewActivity.kt b/app/src/main/java/me/texx/Texx/MediaPreviewActivity.kt
deleted file mode 100644
index b0ebaa7..0000000
--- a/app/src/main/java/me/texx/Texx/MediaPreviewActivity.kt
+++ /dev/null
@@ -1,34 +0,0 @@
-package me.texx.Texx
-
-import android.net.Uri
-import android.os.Bundle
-import android.support.v7.app.AppCompatActivity
-import android.view.Window
-import android.view.WindowManager
-import android.widget.ImageView
-import daio.io.dresscode.dressCodeName
-import daio.io.dresscode.matchDressCode
-import me.texx.Texx.util.ThemeUtil.getThemeName
-
-/**
- * Activity which will be shown after you've taken a picture
- * Previews the taken picture and posts it if you want
- */
-class MediaPreviewActivity : AppCompatActivity() {
- /**
- * Set initial configuration
- */
- 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_media_preview)
-
- val filepath = intent.getStringExtra("filepath")
- val imageView = findViewById<ImageView>(R.id.imagePreview)
- imageView.setImageURI(Uri.parse(filepath))
- }
-}
diff --git a/app/src/main/java/me/texx/Texx/PhotoEditorActivity.kt b/app/src/main/java/me/texx/Texx/PhotoEditorActivity.kt
new file mode 100644
index 0000000..dd537a7
--- /dev/null
+++ b/app/src/main/java/me/texx/Texx/PhotoEditorActivity.kt
@@ -0,0 +1,69 @@
+package me.texx.Texx
+
+import android.net.Uri
+import android.os.Bundle
+import android.support.v7.app.AppCompatActivity
+import android.view.View
+import android.view.Window
+import android.view.WindowManager
+import daio.io.dresscode.dressCodeName
+import daio.io.dresscode.matchDressCode
+import ja.burhanrashid52.photoeditor.PhotoEditor
+import ja.burhanrashid52.photoeditor.PhotoEditorView
+import kotlinx.android.synthetic.main.activity_photo_editor.*
+import me.texx.Texx.util.ThemeUtil.getThemeName
+
+/**
+ * Activity which will be shown after you've taken a picture
+ * Previews the taken picture and posts it if you want
+ */
+class PhotoEditorActivity : AppCompatActivity() {
+ /**
+ * Set initial configuration
+ */
+ 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_photo_editor)
+
+ initPhotoEditor()
+ }
+
+ private fun initPhotoEditor() {
+ val filepath = intent.getStringExtra("filepath")
+ val imageEditorView = findViewById<PhotoEditorView>(R.id.imageEditor)
+ imageEditorView.source.setImageURI(Uri.parse(filepath))
+
+ val photoEditor = PhotoEditor.Builder(this, imageEditorView)
+ .setPinchTextScalable(true)
+ .build()
+
+ setButtonListeners(photoEditor)
+ }
+
+ private fun setButtonListeners(photoEditor: PhotoEditor) {
+ var currentlyDrawing = false
+
+ photoDrawButton.setOnClickListener {
+ currentlyDrawing = !currentlyDrawing
+ photoEditor.setBrushDrawingMode(currentlyDrawing)
+
+ if (currentlyDrawing) drawColorSeekbar.visibility = View.VISIBLE
+ else {
+ drawColorSeekbar.visibility = View.GONE
+ photoDrawButton.setBackgroundColor(View.INVISIBLE)
+ }
+ }
+
+ drawColorSeekbar.setOnColorChangeListener { _, _, color ->
+ if (currentlyDrawing) {
+ photoEditor.brushColor = color
+ photoDrawButton.setBackgroundColor(color)
+ }
+ }
+ }
+}
diff --git a/app/src/main/res/drawable/ic_mode_edit_black_24dp.xml b/app/src/main/res/drawable/ic_mode_edit_black_24dp.xml
new file mode 100644
index 0000000..b49930d
--- /dev/null
+++ b/app/src/main/res/drawable/ic_mode_edit_black_24dp.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z" />
+</vector>
diff --git a/app/src/main/res/layout/activity_photo_editor.xml b/app/src/main/res/layout/activity_photo_editor.xml
new file mode 100644
index 0000000..dd0abba
--- /dev/null
+++ b/app/src/main/res/layout/activity_photo_editor.xml
@@ -0,0 +1,58 @@
+<?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"
+ android:animateLayoutChanges="true"
+ tools:context=".PhotoEditorActivity">
+
+ <ja.burhanrashid52.photoeditor.PhotoEditorView
+ android:id="@+id/imageEditor"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:contentDescription="Kwel image"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintHorizontal_bias="0.0"
+ app:layout_constraintStart_toStartOf="parent">
+
+ </ja.burhanrashid52.photoeditor.PhotoEditorView>
+
+ <android.support.design.widget.FloatingActionButton
+ android:id="@+id/floatingActionButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="24dp"
+ android:layout_marginEnd="24dp"
+ android:clickable="true"
+ app:fabSize="normal"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:srcCompat="@drawable/ic_send_black_24dp" />
+
+ <Button
+ android:id="@+id/photoDrawButton"
+ android:layout_width="50dp"
+ android:layout_height="50dp"
+ android:layout_marginEnd="24dp"
+ android:layout_marginTop="24dp"
+ android:background="@drawable/ic_mode_edit_black_24dp"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <com.rtugeek.android.colorseekbar.ColorSeekBar
+ android:id="@+id/drawColorSeekbar"
+ android:layout_width="50dp"
+ android:layout_height="300dp"
+ android:layout_marginEnd="24dp"
+ android:layout_marginTop="16dp"
+ android:visibility="gone"
+ app:barHeight="15dp"
+ app:colorSeeds="@array/material_colors"
+ app:isVertical="true"
+ app:layout_constraintEnd_toEndOf="@+id/imageEditor"
+ app:layout_constraintTop_toBottomOf="@+id/photoDrawButton"
+ app:thumbHeight="40dp" />
+
+</android.support.constraint.ConstraintLayout> \ No newline at end of file