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

Refactor: Extracting most UI state to EditingState #126

Merged
merged 53 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
68a146e
First iteration of refactoring
isakovch Oct 29, 2023
71b2147
- Revert gradle.properties, since CI/CD is not support cache. CI/CD w…
isakovch Oct 29, 2023
0b56a78
NO-TICKET - Ktlint fixes
isakovch Oct 29, 2023
7e9b537
Fix NoBeanDefFoundException in EditModule + add ktlint gradle plugin …
shubertm Jan 21, 2024
b8df169
Update workflow to JDK 17
shubertm Jan 21, 2024
fa814c4
Remove ktlint gradle plugin and add ktlintCheck to ktlint.gradle
shubertm Jan 22, 2024
8244fce
Run ktlintCheck after ktlintFormat
shubertm Jan 22, 2024
b2b9f31
Remove context from shareImage
shubertm Jan 22, 2024
7178dbb
Delete getCachedImageUri
shubertm Jan 22, 2024
6eba793
Extract image loading from EditViewModel file
shubertm Jan 22, 2024
efe609b
#97: Complete refactoring with best practices (#105)
shubertm Feb 1, 2024
2f607b2
Merge remote-tracking branch 'origin/develop' into develop
shubertm Apr 3, 2024
ff0292e
Refactor packages structure
shubertm Apr 4, 2024
1429d2c
Merge branch 'main' into develop
shubertm Apr 6, 2024
85f3a47
Resolve conflicts
shubertm Apr 6, 2024
6e65ad2
Refactor: Extract crop mode to EditingState (#125)
shubertm Apr 10, 2024
ec87906
Extract isRotateMode to editingState
shubertm Apr 19, 2024
cb936fe
Extract isRotateMode to editingState
shubertm Apr 19, 2024
4d3089a
Extract isRotateMode to editingState
shubertm Apr 22, 2024
7e34760
Extract isResizeMode to editingState
shubertm Apr 30, 2024
531e856
Extract isResizeMode to editingState
shubertm Apr 30, 2024
8d33c15
Extract isEraseMode to EditingState
shubertm May 7, 2024
e69f739
Extract isEraseMode to EditingState
shubertm May 8, 2024
1d22478
Extract isZoomMode + isPanMode to EditingState
shubertm May 9, 2024
89768f1
Extract isBlurMode to EditingState
shubertm Jun 2, 2024
76eef62
Extract isBlurMode to EditingState
shubertm Jun 2, 2024
659edee
Extract isBlurMode to EditingState d
shubertm Jun 2, 2024
c8913dc
Fix resize operation
shubertm Jun 4, 2024
b79c800
Extract isEyeDropperMode to EditingState
shubertm Jun 4, 2024
6a8e5cd
Extract canUndo and canRedo to EditingState
shubertm Jun 5, 2024
f1d4c61
Clean up
shubertm Jun 6, 2024
cab01b9
Clean up
shubertm Jun 6, 2024
9f3eee4
Remove commented out code
shubertm Jun 17, 2024
7e2d5bf
Move all toggleCrop logic from EditScreen to EditViewModel
shubertm Jul 10, 2024
ad36a3c
Move operations logic from EditScreen to EditViewModel
shubertm Jul 12, 2024
6fdb288
Fix lint + remove redundant permission requests
shubertm Jul 22, 2024
1d4c825
Fix lint + remove redundant permission requests
shubertm Jul 22, 2024
633fba1
Check lint failure cause
shubertm Jul 22, 2024
2682f02
Check lint failure cause
shubertm Jul 22, 2024
4216f58
Fix lint
shubertm Jul 22, 2024
99e0dc2
Fix lint
shubertm Jul 22, 2024
4b2a12c
Update compose to 1.6.8
shubertm Jul 22, 2024
91ee12c
Update compose to 1.6.8
shubertm Jul 22, 2024
3d873a6
Fix lint
shubertm Jul 22, 2024
36aa214
Fix lint
shubertm Jul 25, 2024
861b1c9
Fix lint
shubertm Jul 25, 2024
ffb97bd
Fix lint
shubertm Jul 25, 2024
570808e
Update workflow
shubertm Jul 25, 2024
3813f97
Update workflows
shubertm Jul 25, 2024
2a93baf
Update gradle
shubertm Jul 26, 2024
68a1a73
Fix SavePathDialog
shubertm Jul 26, 2024
7e24ab3
Fix sharing image
shubertm Jul 26, 2024
9962dc1
Minor refactors
shubertm Aug 15, 2024
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
648 changes: 627 additions & 21 deletions .editorconfig

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ jobs:
environment: Development
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
cache: gradle

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation[email protected]
uses: gradle/actions/wrapper-validation@v3

- name: Build debug APK
run: ./gradlew assembleDebug
Expand All @@ -38,17 +38,17 @@ jobs:
environment: Development
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
cache: gradle

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation[email protected]
uses: gradle/actions/wrapper-validation@v3

- name: Decrypt the keystore for signing
run: |
Expand All @@ -59,7 +59,7 @@ jobs:
run: ./gradlew assembleRelease

- name: Upload release APK
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ark-retouch
path: ./app/build/outputs/apk/release/*.apk
Expand All @@ -69,18 +69,18 @@ jobs:
environment: Development
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'

- name: Run linter
run: ./gradlew lint

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: lint-results
path: ./app/build/reports/*.html
Expand All @@ -90,14 +90,14 @@ jobs:
environment: Development
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'

- name: Kotlin linter
run: ./gradlew ktlintCheck
run: ./gradlew ktlint -PautoCorrect=0

6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ jobs:
ACRA_URI: ${{ secrets.ACRARIUM_URI }}
BRANCH_NAME: ${{ github.ref_name }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation[email protected]
uses: gradle/actions/wrapper-validation@v3

- name: Build Release APK
run: ./gradlew assembleRelease
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
*.tab
*.tab.values.at
misc.xml

*.DS_Store
31 changes: 31 additions & 0 deletions .scripts/ktlint.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
configurations {
ktlint
}

dependencies {
ktlint "com.pinterest:ktlint:0.45.2"
}

tasks.register('ktlint', JavaExec) {
mainClass = "com.pinterest.ktlint.Main"
classpath = configurations.ktlint
args("$rootDir/**/*.kt", "!$rootDir/**/build/**")
jvmArgs "--add-opens=java.base/java.lang=ALL-UNNAMED"

if (project.hasProperty("autoCorrect") && project.property("autoCorrect") == "0") {
logger.quiet("(KTLINT): auto correction is disabled")
} else {
logger.quiet("(KTLINT): auto correction is enabled")
args "-F"
}
}

tasks.register('ktlintCheck', JavaExec) {
classpath = configurations.ktlint
mainClass = "com.pinterest.ktlint.Main"
args "src/**/*.kt", "**.kts", "!**/build/**"
}

tasks.preBuild.dependsOn ktlintCheck

tasks.ktlintCheck.dependsOn ktlint
48 changes: 20 additions & 28 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import org.apache.tools.ant.taskdefs.condition.Os

plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'org.jlleitschuh.gradle.ktlint'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.8.21'
}

apply from: "$project.rootDir/.scripts/ktlint.gradle"

android {
compileSdk 33
compileSdk 34

namespace 'dev.arkbuilders.arkretouch'

defaultConfig {
def login = System.getenv("ACRA_LOGIN") ?: ""
Expand All @@ -18,7 +19,7 @@ android {

applicationId "dev.arkbuilders.arkretouch2"
minSdk 26
targetSdk 32
targetSdk 34
versionCode 1
versionName "1.0"
setProperty("archivesBaseName", "ark-retouch")
Expand Down Expand Up @@ -69,6 +70,7 @@ android {
buildFeatures {
compose true
viewBinding true
buildConfig = true
}
composeOptions {
kotlinCompilerExtensionVersion "1.3.1"
Expand All @@ -82,20 +84,24 @@ android {

dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
implementation "androidx.appcompat:appcompat:1.5.1"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.0"

def composeVersion = "1.6.8"
implementation "androidx.compose.ui:ui-graphics-android:$composeVersion"
implementation "androidx.compose.ui:ui:$composeVersion"
implementation "androidx.compose.material:material:$composeVersion"
implementation "androidx.compose.ui:ui-tooling-preview:$composeVersion"

implementation 'com.jakewharton.timber:timber:5.0.1'
implementation "com.github.bumptech.glide:glide:4.16.0"
kapt "com.github.bumptech.glide:compiler:4.16.0"

implementation 'com.google.dagger:dagger:2.50'
kapt 'com.google.dagger:dagger-compiler:2.50'
def koinVersion = "3.4.3"
implementation("io.insert-koin:koin-android:$koinVersion")
implementation "io.insert-koin:koin-androidx-compose:$koinVersion"

implementation 'com.godaddy.android.colorpicker:compose-color-picker:0.7.0'

Expand All @@ -110,21 +116,7 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
}

task installGitHook(type: Copy) {
def suffix = "linux"
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
suffix = "windows"
}
from new File(rootProject.rootDir, "scripts/pre-commit-$suffix")
into { new File(rootProject.rootDir, '.git/hooks') }
rename("pre-commit-$suffix", 'pre-commit')
fileMode 0775
}

tasks.preBuild.dependsOn installGitHook
tasks.preBuild.dependsOn ktlintCheck
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$composeVersion"
debugImplementation "androidx.compose.ui:ui-tooling:$composeVersion"
debugImplementation "androidx.compose.ui:ui-test-manifest:$composeVersion"
}

This file was deleted.

7 changes: 3 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="dev.arkbuilders.arkretouch">
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
Expand All @@ -17,10 +16,10 @@
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
android:theme="@style/Theme.ARKRetouch"
android:name=".presentation.App"
android:name=".App"
tools:targetApi="31">
<activity
android:name=".presentation.main.MainActivity"
android:name="dev.arkbuilders.arkretouch.presentation.main.RootActivity"
android:exported="true"
android:windowSoftInputMode="adjustResize"
android:theme="@style/Theme.ARKRetouch">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
package dev.arkbuilders.arkretouch.presentation
package dev.arkbuilders.arkretouch

import android.app.Application
import dev.arkbuilders.arkfilepicker.folders.FoldersRepo
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
import org.acra.ktx.initAcra
import org.acra.sender.HttpSender
import dev.arkbuilders.arkretouch.BuildConfig
import dev.arkbuilders.arkretouch.R
import dev.arkbuilders.arkfilepicker.folders.FoldersRepo
import dev.arkbuilders.arkretouch.di.DIManager
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.context.startKoin
import org.koin.core.logger.Level
import timber.log.Timber

class App : Application() {
override fun onCreate() {
super.onCreate()
DIManager.init(this)
Timber.plant(Timber.DebugTree())
FoldersRepo.init(this)

setupKoin()

setupAcra()
}

// FIXME: Let's use Firebase crashlytics instead
private fun setupAcra() {
kirillt marked this conversation as resolved.
Show resolved Hide resolved
initAcra {
buildConfigClass = BuildConfig::class.java
reportFormat = StringFormat.JSON
Expand All @@ -35,4 +44,15 @@ class App : Application() {
}
}
}
}

private fun setupKoin() {
startKoin {
androidContext(applicationContext)
androidLogger(Level.INFO)
modules(
EditModule.create(),
CommonModule.create(),
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package dev.arkbuilders.arkretouch.data.model

import androidx.compose.ui.graphics.Paint
import androidx.compose.ui.graphics.Path

class DrawPath(
val path: Path,
val paint: Paint
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package dev.arkbuilders.arkretouch.data.model

import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Paint
import androidx.compose.ui.graphics.PaintingStyle
import dev.arkbuilders.arkretouch.utils.defaultPaint

data class DrawingState(
val currentPaint: Paint = defaultPaint(),
val drawPaint: Paint = defaultPaint(),
val backgroundPaint: Paint = Paint().also { it.color = Color.Transparent },
val erasePaint: Paint = Paint().apply {
shader = null
color = backgroundPaint.color
style = PaintingStyle.Stroke
blendMode = BlendMode.SrcOut
},
val blurSize: Float = 250f,
val blurIntensity: Float = 12f
)
Loading