Skip to content
Draft
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
50 changes: 50 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
id("io.gitlab.arturbosch.detekt").version("1.23.7")
id("jacoco")
}

Expand Down Expand Up @@ -117,4 +118,53 @@ tasks.register<JacocoReport>("jacocoTestReport") {
)
)
)
}

detekt {
// Version of detekt that will be used. When unspecified the latest detekt
// version found will be used. Override to stay on the same version.
toolVersion = "1.23.7"

// The directories where detekt looks for source files.
// Defaults to `files("src/main/java", "src/test/java", "src/main/kotlin", "src/test/kotlin")`.
source.setFrom("src/main/java", "src/main/kotlin")

// Builds the AST in parallel. Rules are always executed in parallel.
// Can lead to speedups in larger projects. `false` by default.
parallel = false

// Define the detekt configuration(s) you want to use.
// Defaults to the default detekt configuration.
config.setFrom("detekt.yml")

// Applies the config files on top of detekt's default config file. `false` by default.
buildUponDefaultConfig = false

// Turns on all the rules. `false` by default.
allRules = false

// Disables all default detekt rulesets and will only run detekt with custom rules
// defined in plugins passed in with `detektPlugins` configuration. `false` by default.
disableDefaultRuleSets = false

// Adds debug output during task execution. `false` by default.
debug = false

// If set to `true` the build does not fail when the
// maxIssues count was reached. Defaults to `false`.
ignoreFailures = false

// Android: Don't create tasks for the specified build flavor (e.g. "production")
ignoredFlavors = listOf("production")

// Android: Don't create tasks for the specified build variants (e.g. "productionRelease")
ignoredVariants = listOf("productionRelease")

// Specify the base path for file paths in the formatted reports.
// If not set, all file paths reported will be absolute file path.
basePath = projectDir.absolutePath

dependencies {
detektPlugins(libs.detekt.rules.compose)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -458,4 +458,4 @@ class StoneCameraViewModelFactory(
}
throw IllegalArgumentException("Unknown ViewModel class")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package co.stonephone.stonecamera.plugins

import android.app.Application
import android.util.Size
import androidx.camera.core.AspectRatio
import androidx.camera.core.ImageCapture
Expand All @@ -14,7 +13,6 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import co.stonephone.stonecamera.MyApplication
Expand Down Expand Up @@ -91,10 +89,13 @@ class AspectRatioPlugin : IPlugin {
targetSize: Size?, // e.g. 3000×3000 for 1:1
ratio: Float? // e.g. 1.0f for 1:1, 1.333...f for 4:3, etc.
): ResolutionSelector {
val sixteenByNine = 16f / 9f
val fourByThree = 4f / 3f
val wiggleRoom = 0.01f
val aspectRatioConst = when {
ratio == null -> null // “FULL” or unknown
kotlin.math.abs(ratio - (4f / 3f)) < 0.01f -> AspectRatio.RATIO_4_3
kotlin.math.abs(ratio - (16f / 9f)) < 0.01f -> AspectRatio.RATIO_16_9
kotlin.math.abs(ratio - (fourByThree)) < wiggleRoom -> AspectRatio.RATIO_4_3
kotlin.math.abs(ratio - (sixteenByNine)) < wiggleRoom -> AspectRatio.RATIO_16_9
else -> null // e.g. 1:1 or any custom ratio
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import co.stonephone.stonecamera.StoneCameraViewModel
import co.stonephone.stonecamera.utils.calculateImageCoverageRegion
import co.stonephone.stonecamera.utils.selectCameraForStepZoomLevel

class DebugPlugin : IPlugin {
override val id: String = "debugPlugin"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package co.stonephone.stonecamera.plugins

import android.annotation.SuppressLint
import androidx.camera.core.ImageCapture
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package co.stonephone.stonecamera.plugins

import android.annotation.SuppressLint
import android.graphics.Rect
import android.view.MotionEvent
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalContext
import co.stonephone.stonecamera.MyApplication
import co.stonephone.stonecamera.StoneCameraViewModel
import co.stonephone.stonecamera.ui.FocusReticle
import co.stonephone.stonecamera.utils.calculateImageCoverageRegion

class TapToFocusPlugin : IPlugin {
override val id: String = "tapToFocusPlugin"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package co.stonephone.stonecamera.plugins

import android.annotation.SuppressLint
import androidx.compose.ui.platform.LocalContext
import co.stonephone.stonecamera.StoneCameraViewModel
import co.stonephone.stonecamera.ui.ZoomBar
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ private fun getRelativeZoomLevels(infos: List<StoneCameraInfo>):List<StoneCamera
}

return infos
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class ExampleUnitTest {
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
}
Loading