mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2025-06-05 21:59:19 +02:00
allow customizing the editor drawing color
This commit is contained in:
@ -24,6 +24,7 @@ import com.bumptech.glide.load.engine.GlideException
|
||||
import com.bumptech.glide.request.RequestListener
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.bumptech.glide.request.target.Target
|
||||
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
|
||||
@ -46,6 +47,7 @@ import kotlinx.android.synthetic.main.activity_edit.*
|
||||
import kotlinx.android.synthetic.main.bottom_actions_aspect_ratio.*
|
||||
import kotlinx.android.synthetic.main.bottom_editor_actions_filter.*
|
||||
import kotlinx.android.synthetic.main.bottom_editor_crop_rotate_actions.*
|
||||
import kotlinx.android.synthetic.main.bottom_editor_draw_actions.*
|
||||
import kotlinx.android.synthetic.main.bottom_editor_primary_actions.*
|
||||
import java.io.*
|
||||
|
||||
@ -73,6 +75,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||
private lateinit var saveUri: Uri
|
||||
private var resizeWidth = 0
|
||||
private var resizeHeight = 0
|
||||
private var drawColor = 0
|
||||
private var lastOtherAspectRatio: Pair<Int, Int>? = null
|
||||
private var currPrimaryAction = PRIMARY_ACTION_NONE
|
||||
private var currCropRotateAction = CROP_ROTATE_NONE
|
||||
@ -312,6 +315,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||
setupPrimaryActionButtons()
|
||||
setupCropRotateActionButtons()
|
||||
setupAspectRatioButtons()
|
||||
setupDrawButtons()
|
||||
}
|
||||
|
||||
private fun setupPrimaryActionButtons() {
|
||||
@ -416,6 +420,17 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||
updateAspectRatioButtons()
|
||||
}
|
||||
|
||||
private fun setupDrawButtons() {
|
||||
updateDrawColor(config.lastEditorDrawColor)
|
||||
bottom_draw_color.setOnClickListener {
|
||||
ColorPickerDialog(this, drawColor) { wasPositivePressed, color ->
|
||||
if (wasPositivePressed) {
|
||||
updateDrawColor(color)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updatePrimaryActionButtons() {
|
||||
if (crop_image_view.isGone() && currPrimaryAction == PRIMARY_ACTION_CROP_ROTATE) {
|
||||
loadCropImageView()
|
||||
@ -439,6 +454,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||
currentPrimaryActionButton?.applyColorFilter(config.primaryColor)
|
||||
bottom_editor_filter_actions.beVisibleIf(currPrimaryAction == PRIMARY_ACTION_FILTER)
|
||||
bottom_editor_crop_rotate_actions.beVisibleIf(currPrimaryAction == PRIMARY_ACTION_CROP_ROTATE)
|
||||
bottom_editor_draw_actions.beVisibleIf(currPrimaryAction == PRIMARY_ACTION_DRAW)
|
||||
|
||||
if (currPrimaryAction == PRIMARY_ACTION_FILTER && bottom_actions_filter_list.adapter == null) {
|
||||
Thread {
|
||||
@ -541,6 +557,13 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||
primaryActionView?.applyColorFilter(config.primaryColor)
|
||||
}
|
||||
|
||||
private fun updateDrawColor(color: Int) {
|
||||
drawColor = color
|
||||
bottom_draw_color.applyColorFilter(color)
|
||||
config.lastEditorDrawColor = color
|
||||
editor_draw_canvas.updateColor(color)
|
||||
}
|
||||
|
||||
private fun resizeImage() {
|
||||
val point = getAreaSize()
|
||||
if (point == null) {
|
||||
|
@ -453,4 +453,8 @@ class Config(context: Context) : BaseConfig(context) {
|
||||
var allowOneToOneZoom: Boolean
|
||||
get() = prefs.getBoolean(ALLOW_ONE_TO_ONE_ZOOM, false)
|
||||
set(allowOneToOneZoom) = prefs.edit().putBoolean(ALLOW_ONE_TO_ONE_ZOOM, allowOneToOneZoom).apply()
|
||||
|
||||
var lastEditorDrawColor: Int
|
||||
get() = prefs.getInt(LAST_EDITOR_DRAW_COLOR, primaryColor)
|
||||
set(lastEditorDrawColor) = prefs.edit().putInt(LAST_EDITOR_DRAW_COLOR, lastEditorDrawColor).apply()
|
||||
}
|
||||
|
@ -76,6 +76,7 @@ const val LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_Y = "last_editor_crop_other_aspect
|
||||
const val GROUP_DIRECT_SUBFOLDERS = "group_direct_subfolders"
|
||||
const val SHOW_WIDGET_FOLDER_NAME = "show_widget_folder_name"
|
||||
const val ALLOW_ONE_TO_ONE_ZOOM = "allow_one_to_one_zoom"
|
||||
const val LAST_EDITOR_DRAW_COLOR = "last_editor_draw_color"
|
||||
|
||||
// slideshow
|
||||
const val SLIDESHOW_INTERVAL = "slideshow_interval"
|
||||
|
@ -119,6 +119,10 @@ class EditorDrawCanvas(context: Context, attrs: AttributeSet) : View(context, at
|
||||
mPaint.strokeWidth = paintOptions.strokeWidth
|
||||
}
|
||||
|
||||
fun updateColor(newColor: Int) {
|
||||
mPaintOptions.color = newColor
|
||||
}
|
||||
|
||||
fun updateBackgroundBitmap(bitmap: Bitmap) {
|
||||
backgroundBitmap = bitmap
|
||||
invalidate()
|
||||
|
Reference in New Issue
Block a user