Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#97: Complete refactoring with best practices #105

Merged
merged 7 commits into from
Feb 1, 2024
Merged
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
6 changes: 3 additions & 3 deletions .scripts/ktlint.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies {
ktlint "com.pinterest:ktlint:0.45.2"
}

tasks.register('ktlintFormat', JavaExec) {
tasks.register('ktlint', JavaExec) {
mainClass = "com.pinterest.ktlint.Main"
classpath = configurations.ktlint
args("$rootDir/**/*.kt", "!$rootDir/**/build/**")
Expand All @@ -26,6 +26,6 @@ tasks.register('ktlintCheck', JavaExec) {
args "src/**/*.kt", "**.kts", "!**/build/**"
}

tasks.preBuild.dependsOn ktlintFormat
tasks.preBuild.dependsOn ktlintCheck

tasks.ktlintFormat.dependsOn ktlintCheck
tasks.ktlintCheck.dependsOn ktlint
4 changes: 2 additions & 2 deletions app/src/main/java/dev/arkbuilders/arkretouch/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package dev.arkbuilders.arkretouch

import android.app.Application
import dev.arkbuilders.arkfilepicker.folders.FoldersRepo
import dev.arkbuilders.arkretouch.common.CommonModule
import dev.arkbuilders.arkretouch.edition.EditModule
import dev.arkbuilders.arkretouch.di.EditModule
import dev.arkbuilders.arkretouch.di.common.CommonModule
import org.acra.config.dialog
import org.acra.config.httpSender
import org.acra.data.StringFormat
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.arkbuilders.arkretouch.edition
package dev.arkbuilders.arkretouch.di

import com.etherean.app.common.di.InjectionModule
import dev.arkbuilders.arkretouch.edition.ui.main.EditViewModel
import dev.arkbuilders.arkretouch.di.common.InjectionModule
import dev.arkbuilders.arkretouch.editing.ui.main.EditViewModel
import dev.arkbuilders.arkretouch.storage.Resolution
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.module
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.arkbuilders.arkretouch.common
package dev.arkbuilders.arkretouch.di.common

import com.etherean.app.common.di.InjectionModule
import dev.arkbuilders.arkretouch.edition.repository.FilesRepository
import dev.arkbuilders.arkretouch.editing.repository.FilesRepository
import dev.arkbuilders.arkretouch.storage.OldStorageRepository
import org.koin.core.module.dsl.singleOf
import org.koin.dsl.module
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.etherean.app.common.di
package dev.arkbuilders.arkretouch.di.common

import org.koin.core.module.Module

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.arkbuilders.arkretouch.common.dispatchers
package dev.arkbuilders.arkretouch.di.common.dispatchers

import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.arkbuilders.arkretouch.edition.manager
package dev.arkbuilders.arkretouch.editing.manager

import androidx.compose.runtime.MutableState
import androidx.compose.runtime.State
Expand All @@ -14,14 +14,14 @@ import androidx.compose.ui.graphics.PaintingStyle
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.unit.IntSize
import android.graphics.Matrix
import dev.arkbuilders.arkretouch.edition.model.DrawPath
import dev.arkbuilders.arkretouch.edition.model.ImageViewParams
import dev.arkbuilders.arkretouch.edition.model.Operation
import dev.arkbuilders.arkretouch.edition.ui.blur.BlurOperation
import dev.arkbuilders.arkretouch.edition.ui.crop.CropOperation
import dev.arkbuilders.arkretouch.edition.ui.crop.CropWindow
import dev.arkbuilders.arkretouch.edition.ui.main.fitBackground
import dev.arkbuilders.arkretouch.edition.ui.main.fitImage
import dev.arkbuilders.arkretouch.editing.model.DrawPath
import dev.arkbuilders.arkretouch.editing.model.ImageViewParams
import dev.arkbuilders.arkretouch.editing.model.Operation
import dev.arkbuilders.arkretouch.editing.ui.blur.BlurOperation
import dev.arkbuilders.arkretouch.editing.ui.crop.CropOperation
import dev.arkbuilders.arkretouch.editing.ui.crop.CropWindow
import dev.arkbuilders.arkretouch.editing.ui.main.fitBackground
import dev.arkbuilders.arkretouch.editing.ui.main.fitImage
import dev.arkbuilders.arkretouch.presentation.edit.draw.DrawOperation
import dev.arkbuilders.arkretouch.presentation.edit.resize.ResizeOperation
import dev.arkbuilders.arkretouch.presentation.edit.rotate.RotateOperation
Expand Down Expand Up @@ -168,7 +168,7 @@ class EditManager {
private val _isCropMode = mutableStateOf(false)
val isCropMode = _isCropMode

var editionMode: EditionMode by mutableStateOf(EditionMode.IDLE)
var editingMode: EditingMode by mutableStateOf(EditingMode.IDLE)

val cropStack = Stack<ImageBitmap>()
val redoCropStack = Stack<ImageBitmap>()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package dev.arkbuilders.arkretouch.editing.manager

enum class EditingMode {
IDLE,
CROP,
RESIZE,
ROTATE,
ZOOM
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.arkbuilders.arkretouch.edition.model
package dev.arkbuilders.arkretouch.editing.model

import androidx.compose.ui.graphics.Paint
import androidx.compose.ui.graphics.Path
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package dev.arkbuilders.arkretouch.editing.model

import androidx.compose.ui.graphics.Color

data class EditingState(
val strokeSliderExpanded: Boolean = false,
val strokeWidth: Float = 5f,
val menusVisible: Boolean = true,
val showSavePathDialog: Boolean = false,
val showExitDialog: Boolean = false,
val showMoreOptionsPopup: Boolean = false,
val imageSaved: Boolean = false,
val isSavingImage: Boolean = false,
val showEyeDropperHint: Boolean = false,
val showConfirmClearDialog: Boolean = false,
val isLoaded: Boolean = false,
val exitConfirmed: Boolean = false,
val bottomButtonsScrollIsAtStart: Boolean = false,
val bottomButtonsScrollIsAtEnd: Boolean = false,
val usedColors: List<Color> = listOf()
) {

companion object {
val DEFAULT = EditingState()
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.arkbuilders.arkretouch.edition.model
package dev.arkbuilders.arkretouch.editing.model

import androidx.compose.ui.unit.IntSize
import dev.arkbuilders.arkretouch.presentation.edit.resize.ResizeOperation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.arkbuilders.arkretouch.edition.model
package dev.arkbuilders.arkretouch.editing.model

interface Operation {
fun apply()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.arkbuilders.arkretouch.edition.repository
package dev.arkbuilders.arkretouch.editing.repository

import androidx.core.content.FileProvider
import android.content.Context
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.arkbuilders.arkretouch.edition.ui.blur
package dev.arkbuilders.arkretouch.editing.ui.blur

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
Expand All @@ -12,7 +12,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import dev.arkbuilders.arkretouch.R
import dev.arkbuilders.arkretouch.edition.manager.EditManager
import dev.arkbuilders.arkretouch.editing.manager.EditManager

@Composable
fun BlurIntensityPopup(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.arkbuilders.arkretouch.edition.ui.blur
package dev.arkbuilders.arkretouch.editing.ui.blur

import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.geometry.Offset
Expand All @@ -12,8 +12,8 @@ import androidx.compose.ui.unit.IntOffset
import android.content.Context
import android.graphics.Bitmap
import com.hoko.blur.processor.HokoBlurBuild
import dev.arkbuilders.arkretouch.edition.manager.EditManager
import dev.arkbuilders.arkretouch.edition.model.Operation
import dev.arkbuilders.arkretouch.editing.manager.EditManager
import dev.arkbuilders.arkretouch.editing.model.Operation
import java.util.Stack

class BlurOperation(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.arkbuilders.arkretouch.edition.ui.canvas
package dev.arkbuilders.arkretouch.editing.ui.canvas

import androidx.compose.foundation.Canvas
import androidx.compose.runtime.Composable
Expand All @@ -10,7 +10,7 @@ import androidx.compose.ui.graphics.asAndroidBitmap
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
import androidx.compose.ui.graphics.nativeCanvas
import androidx.compose.ui.unit.toSize
import dev.arkbuilders.arkretouch.edition.manager.EditManager
import dev.arkbuilders.arkretouch.editing.manager.EditManager

@Composable
fun BackgroundCanvas(modifier: Modifier, editManager: EditManager) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.arkbuilders.arkretouch.edition.ui.canvas
package dev.arkbuilders.arkretouch.editing.ui.canvas

import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.fillMaxSize
Expand All @@ -19,9 +19,9 @@ import androidx.compose.ui.unit.toSize
import android.graphics.Matrix
import android.graphics.PointF
import android.view.MotionEvent
import dev.arkbuilders.arkretouch.edition.ui.crop.CropWindow.Companion.computeDeltaX
import dev.arkbuilders.arkretouch.edition.ui.crop.CropWindow.Companion.computeDeltaY
import dev.arkbuilders.arkretouch.edition.ui.main.EditViewModel
import dev.arkbuilders.arkretouch.editing.ui.crop.CropWindow.Companion.computeDeltaX
import dev.arkbuilders.arkretouch.editing.ui.crop.CropWindow.Companion.computeDeltaY
import dev.arkbuilders.arkretouch.editing.ui.main.EditViewModel

@OptIn(ExperimentalComposeUiApi::class)
@Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.arkbuilders.arkretouch.edition.ui.canvas
package dev.arkbuilders.arkretouch.editing.ui.canvas

import androidx.compose.foundation.Canvas
import androidx.compose.foundation.gestures.awaitFirstDown
Expand All @@ -18,7 +18,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.input.pointer.pointerInput
import dev.arkbuilders.arkretouch.edition.ui.main.EditViewModel
import dev.arkbuilders.arkretouch.editing.ui.main.EditViewModel
import dev.arkbuilders.arkretouch.picker.toDp
import dev.arkbuilders.arkretouch.presentation.edit.TransparencyChessBoardCanvas
import dev.arkbuilders.arkretouch.utils.calculateRotationFromOneFingerGesture
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.arkbuilders.arkretouch.edition.ui.crop
package dev.arkbuilders.arkretouch.editing.ui.crop

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
Expand Down Expand Up @@ -26,13 +26,13 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp
import dev.arkbuilders.arkretouch.R
import dev.arkbuilders.arkretouch.edition.ui.crop.AspectRatio.aspectRatios
import dev.arkbuilders.arkretouch.edition.ui.crop.AspectRatio.isChanged
import dev.arkbuilders.arkretouch.edition.ui.crop.AspectRatio.isCropFree
import dev.arkbuilders.arkretouch.edition.ui.crop.AspectRatio.isCropSquare
import dev.arkbuilders.arkretouch.edition.ui.crop.AspectRatio.isCrop_2_3
import dev.arkbuilders.arkretouch.edition.ui.crop.AspectRatio.isCrop_4_5
import dev.arkbuilders.arkretouch.edition.ui.crop.AspectRatio.isCrop_9_16
import dev.arkbuilders.arkretouch.editing.ui.crop.AspectRatio.aspectRatios
import dev.arkbuilders.arkretouch.editing.ui.crop.AspectRatio.isChanged
import dev.arkbuilders.arkretouch.editing.ui.crop.AspectRatio.isCropFree
import dev.arkbuilders.arkretouch.editing.ui.crop.AspectRatio.isCropSquare
import dev.arkbuilders.arkretouch.editing.ui.crop.AspectRatio.isCrop_2_3
import dev.arkbuilders.arkretouch.editing.ui.crop.AspectRatio.isCrop_4_5
import dev.arkbuilders.arkretouch.editing.ui.crop.AspectRatio.isCrop_9_16

@Composable
fun CropAspectRatiosMenu(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.arkbuilders.arkretouch.edition.ui.crop
package dev.arkbuilders.arkretouch.editing.ui.crop

import androidx.compose.ui.graphics.asImageBitmap
import dev.arkbuilders.arkretouch.edition.manager.EditManager
import dev.arkbuilders.arkretouch.edition.model.Operation
import dev.arkbuilders.arkretouch.editing.manager.EditManager
import dev.arkbuilders.arkretouch.editing.model.Operation
import dev.arkbuilders.arkretouch.utils.crop

class CropOperation(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.arkbuilders.arkretouch.edition.ui.crop
package dev.arkbuilders.arkretouch.editing.ui.crop

import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.geometry.Offset
Expand All @@ -9,16 +9,16 @@ import androidx.compose.ui.graphics.Paint
import androidx.compose.ui.graphics.PaintingStyle
import androidx.compose.ui.unit.IntSize
import android.graphics.Bitmap
import dev.arkbuilders.arkretouch.edition.manager.EditManager
import dev.arkbuilders.arkretouch.edition.ui.crop.AspectRatio.CROP_2_3
import dev.arkbuilders.arkretouch.edition.ui.crop.AspectRatio.CROP_4_5
import dev.arkbuilders.arkretouch.edition.ui.crop.AspectRatio.CROP_9_16
import dev.arkbuilders.arkretouch.edition.ui.crop.AspectRatio.CROP_SQUARE
import dev.arkbuilders.arkretouch.edition.ui.crop.AspectRatio.isCropFree
import dev.arkbuilders.arkretouch.edition.ui.crop.AspectRatio.isCropSquare
import dev.arkbuilders.arkretouch.edition.ui.crop.AspectRatio.isCrop_2_3
import dev.arkbuilders.arkretouch.edition.ui.crop.AspectRatio.isCrop_4_5
import dev.arkbuilders.arkretouch.edition.ui.crop.AspectRatio.isCrop_9_16
import dev.arkbuilders.arkretouch.editing.manager.EditManager
import dev.arkbuilders.arkretouch.editing.ui.crop.AspectRatio.CROP_2_3
import dev.arkbuilders.arkretouch.editing.ui.crop.AspectRatio.CROP_4_5
import dev.arkbuilders.arkretouch.editing.ui.crop.AspectRatio.CROP_9_16
import dev.arkbuilders.arkretouch.editing.ui.crop.AspectRatio.CROP_SQUARE
import dev.arkbuilders.arkretouch.editing.ui.crop.AspectRatio.isCropFree
import dev.arkbuilders.arkretouch.editing.ui.crop.AspectRatio.isCropSquare
import dev.arkbuilders.arkretouch.editing.ui.crop.AspectRatio.isCrop_2_3
import dev.arkbuilders.arkretouch.editing.ui.crop.AspectRatio.isCrop_4_5
import dev.arkbuilders.arkretouch.editing.ui.crop.AspectRatio.isCrop_9_16
import dev.arkbuilders.arkretouch.presentation.edit.resize.ResizeOperation
import timber.log.Timber

Expand Down
Loading
Loading