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

Bump com.diffplug.spotless from 6.25.0 to 7.0.1 #203

Merged
merged 3 commits into from
Jan 7, 2025
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
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ ij_kotlin_code_style_defaults = kotlin_official
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
ij_kotlin_name_count_to_use_star_import = 999
ktlint_class_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 3
4 changes: 1 addition & 3 deletions app/src/main/java/fr/smarquis/ar_toolbox/ColorSeekBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ class ColorSeekBar(context: Context, attributeSet: AttributeSet) : View(context,
}
}

private fun mix(start: Int, end: Int, position: Float): Int {
return start + (position * (end - start)).roundToInt()
}
private fun mix(start: Int, end: Int, position: Float): Int = start + (position * (end - start)).roundToInt()

override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/fr/smarquis/ar_toolbox/Coordinator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ class Coordinator(
},
)

override fun getSelectionVisualizer(): Footprint {
return super.getSelectionVisualizer() as Footprint
}
override fun getSelectionVisualizer(): Footprint = super.getSelectionVisualizer() as Footprint

override fun setSelectionVisualizer(selectionVisualizer: SelectionVisualizer?) {
// Prevent changing the selection visualizer
Expand Down
16 changes: 7 additions & 9 deletions app/src/main/java/fr/smarquis/ar_toolbox/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,13 @@ fun Pose.translation() = Vector3(tx(), ty(), tz())

fun Pose.rotation() = Quaternion(qx(), qy(), qz(), qw())

fun UnavailableException?.message(): Int {
return when (this) {
is UnavailableArcoreNotInstalledException -> R.string.exception_arcore_not_installed
is UnavailableApkTooOldException -> R.string.exception_apk_too_old
is UnavailableSdkTooOldException -> R.string.exception_sdk_too_old
is UnavailableDeviceNotCompatibleException -> R.string.exception_device_not_compatible
is UnavailableUserDeclinedInstallationException -> R.string.exception_user_declined_installation
else -> R.string.exception_unknown
}
fun UnavailableException?.message(): Int = when (this) {
is UnavailableArcoreNotInstalledException -> R.string.exception_arcore_not_installed
is UnavailableApkTooOldException -> R.string.exception_apk_too_old
is UnavailableSdkTooOldException -> R.string.exception_sdk_too_old
is UnavailableDeviceNotCompatibleException -> R.string.exception_device_not_compatible
is UnavailableUserDeclinedInstallationException -> R.string.exception_user_declined_installation
else -> R.string.exception_unknown
}

fun ViewBinding.behavior(): BottomSheetBehavior<out View> = root.behavior()
Expand Down
22 changes: 8 additions & 14 deletions app/src/main/java/fr/smarquis/ar_toolbox/ExtrudedCylinder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -296,20 +296,14 @@ object ExtrudedCylinder {
}

/** The dot product of two Quaternions. */
private fun dot(lhs: Quaternion, rhs: Quaternion): Float {
return lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z + lhs.w * rhs.w
}
private fun dot(lhs: Quaternion, rhs: Quaternion): Float = lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z + lhs.w * rhs.w

private fun negated(quat: Quaternion): Quaternion {
return Quaternion(-quat.x, -quat.y, -quat.z, -quat.w)
}
private fun negated(quat: Quaternion): Quaternion = Quaternion(-quat.x, -quat.y, -quat.z, -quat.w)

private fun lerp(a: Quaternion, b: Quaternion, ratio: Float): Quaternion {
return Quaternion(
MathHelper.lerp(a.x, b.x, ratio),
MathHelper.lerp(a.y, b.y, ratio),
MathHelper.lerp(a.z, b.z, ratio),
MathHelper.lerp(a.w, b.w, ratio),
)
}
private fun lerp(a: Quaternion, b: Quaternion, ratio: Float): Quaternion = Quaternion(
MathHelper.lerp(a.x, b.x, ratio),
MathHelper.lerp(a.y, b.y, ratio),
MathHelper.lerp(a.z, b.z, ratio),
MathHelper.lerp(a.w, b.w, ratio),
)
}
23 changes: 11 additions & 12 deletions app/src/main/java/fr/smarquis/ar_toolbox/Nodes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ class Layout(
context: Context,
coordinator: Coordinator,
settings: Settings,
) : Nodes("Layout", coordinator, settings), Footprint.Invisible, Nodes.FacingCamera {
) : Nodes("Layout", coordinator, settings),
Footprint.Invisible,
Nodes.FacingCamera {

companion object {
private const val HEIGHT = 0.3F
Expand Down Expand Up @@ -415,10 +417,8 @@ class Drawing(
private const val PLANE_ANCHORING_DISTANCE = 2F
private const val DEFAULT_DRAWING_DISTANCE = 0.5F

private fun hit(frame: Frame, x: Float, y: Float): HitResult? {
return frame.hitTest(x, y).firstOrNull {
(it.trackable as? Plane)?.isPoseInPolygon(it.hitPose) == true && it.distance <= PLANE_ANCHORING_DISTANCE
}
private fun hit(frame: Frame, x: Float, y: Float): HitResult? = frame.hitTest(x, y).firstOrNull {
(it.trackable as? Plane)?.isPoseInPolygon(it.hitPose) == true && it.distance <= PLANE_ANCHORING_DISTANCE
}

private fun pose(camera: Camera, x: Float, y: Float): Pose {
Expand All @@ -427,12 +427,10 @@ class Drawing(
return Pose.makeTranslation(point.x, point.y, point.z)
}

private fun plane(hitResult: HitResult?): CollisionPlane? {
return (hitResult?.trackable as? Plane)?.let {
val pose = it.centerPose
val normal = Quaternion.rotateVector(pose.rotation(), Vector3.up())
CollisionPlane(pose.translation(), normal)
}
private fun plane(hitResult: HitResult?): CollisionPlane? = (hitResult?.trackable as? Plane)?.let {
val pose = it.centerPose
val normal = Quaternion.rotateVector(pose.rotation(), Vector3.up())
CollisionPlane(pose.translation(), normal)
}

fun create(x: Float, y: Float, fromTouch: Boolean, properties: MaterialProperties, ar: ArSceneView, coordinator: Coordinator, settings: Settings): Drawing? {
Expand Down Expand Up @@ -679,7 +677,8 @@ class Video(
val context: Context,
coordinator: Coordinator,
settings: Settings,
) : Nodes("Video", coordinator, settings), MediaPlayer.OnVideoSizeChangedListener {
) : Nodes("Video", coordinator, settings),
MediaPlayer.OnVideoSizeChangedListener {

private var mediaPlayer: MediaPlayer? = null
private val texture = ExternalTexture()
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/fr/smarquis/ar_toolbox/PointCloud.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,5 @@ object PointCloud {
return RenderableDefinition.builder().setVertices(vertices).setSubmeshes(listOf(submesh)).build()
}

private fun vertex(position: Vector3, normal: Vector3, uv: Vertex.UvCoordinate): Vertex {
return Vertex.builder().setPosition(position).setNormal(normal).setUvCoordinate(uv).build()
}
private fun vertex(position: Vector3, normal: Vector3, uv: Vertex.UvCoordinate): Vertex = Vertex.builder().setPosition(position).setNormal(normal).setUvCoordinate(uv).build()
}
54 changes: 45 additions & 9 deletions app/src/main/java/fr/smarquis/ar_toolbox/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ class Settings(context: Context) {
val faceRegions = FaceRegions(true, "faceRegions", prefs)
val faceMesh = FaceMesh(true, "faceMesh", prefs)

open class AtomicBooleanPref(defaultValue: Boolean, private val key: String, private val prefs: SharedPreferences) {
open class AtomicBooleanPref(
defaultValue: Boolean,
private val key: String,
private val prefs: SharedPreferences,
) {

private val value: AtomicBoolean = AtomicBoolean(prefs.getBoolean(key, defaultValue))

Expand All @@ -44,7 +48,11 @@ class Settings(context: Context) {
}
}

class Sunlight(defaultValue: Boolean, key: String, prefs: SharedPreferences) : AtomicBooleanPref(defaultValue, key, prefs) {
class Sunlight(
defaultValue: Boolean,
key: String,
prefs: SharedPreferences,
) : AtomicBooleanPref(defaultValue, key, prefs) {

fun toggle(menuItem: MenuItem, arSceneView: ArSceneView) {
toggle()
Expand All @@ -61,7 +69,11 @@ class Settings(context: Context) {
}
}

class Shadows(defaultValue: Boolean, key: String, prefs: SharedPreferences) : AtomicBooleanPref(defaultValue, key, prefs) {
class Shadows(
defaultValue: Boolean,
key: String,
prefs: SharedPreferences,
) : AtomicBooleanPref(defaultValue, key, prefs) {

fun toggle(menuItem: MenuItem, arSceneView: ArSceneView) {
toggle()
Expand All @@ -84,7 +96,11 @@ class Settings(context: Context) {
}
}

class Planes(defaultValue: Boolean, key: String, prefs: SharedPreferences) : AtomicBooleanPref(defaultValue, key, prefs) {
class Planes(
defaultValue: Boolean,
key: String,
prefs: SharedPreferences,
) : AtomicBooleanPref(defaultValue, key, prefs) {

fun toggle(menuItem: MenuItem, arSceneView: ArSceneView) {
toggle()
Expand All @@ -101,7 +117,11 @@ class Settings(context: Context) {
}
}

class Selection(defaultValue: Boolean, key: String, prefs: SharedPreferences) : AtomicBooleanPref(defaultValue, key, prefs) {
class Selection(
defaultValue: Boolean,
key: String,
prefs: SharedPreferences,
) : AtomicBooleanPref(defaultValue, key, prefs) {

fun toggle(menuItem: MenuItem, selectionVisualizer: Footprint) {
toggle()
Expand All @@ -118,7 +138,11 @@ class Settings(context: Context) {
}
}

class Reticle(defaultValue: Boolean, key: String, prefs: SharedPreferences) : AtomicBooleanPref(defaultValue, key, prefs) {
class Reticle(
defaultValue: Boolean,
key: String,
prefs: SharedPreferences,
) : AtomicBooleanPref(defaultValue, key, prefs) {

class Node(context: Context) : com.google.ar.sceneform.Node() {

Expand Down Expand Up @@ -197,7 +221,11 @@ class Settings(context: Context) {
}
}

class PointCloud(defaultValue: Boolean, key: String, prefs: SharedPreferences) : AtomicBooleanPref(defaultValue, key, prefs) {
class PointCloud(
defaultValue: Boolean,
key: String,
prefs: SharedPreferences,
) : AtomicBooleanPref(defaultValue, key, prefs) {

class Node(context: Context) : com.google.ar.sceneform.Node() {

Expand Down Expand Up @@ -272,7 +300,11 @@ class Settings(context: Context) {
}
}

class FaceRegions(defaultValue: Boolean, key: String, prefs: SharedPreferences) : AtomicBooleanPref(defaultValue, key, prefs) {
class FaceRegions(
defaultValue: Boolean,
key: String,
prefs: SharedPreferences,
) : AtomicBooleanPref(defaultValue, key, prefs) {

fun toggle(menuItem: MenuItem, arSceneView: ArSceneView) {
toggle()
Expand All @@ -291,7 +323,11 @@ class Settings(context: Context) {
}
}

class FaceMesh(defaultValue: Boolean, key: String, prefs: SharedPreferences) : AtomicBooleanPref(defaultValue, key, prefs) {
class FaceMesh(
defaultValue: Boolean,
key: String,
prefs: SharedPreferences,
) : AtomicBooleanPref(defaultValue, key, prefs) {

fun toggle(menuItem: MenuItem, arSceneView: ArSceneView) {
toggle()
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ google-oss = "17.1.0"
google-oss-plugin = "0.10.6"
junit = "4.13.2"
kotlin = "2.1.0"
spotless = "6.25.0"
spotless = "7.0.1"

[libraries]
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
Expand Down
Loading