Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into spectrum_legend
Browse files Browse the repository at this point in the history
# Conflicts:
#	shared/src/commonMain/kotlin/org/noise_planet/noisecapture/shared/signal/BluesteinFloat.kt
#	shared/src/commonMain/kotlin/org/noise_planet/noisecapture/shared/signal/SpectrumChannelConfiguration.kt
#	shared/src/commonMain/kotlin/org/noiseplanet/noisecapture/shared/child/MeasurementScreen.kt
#	shared/src/commonMain/kotlin/org/noiseplanet/noisecapture/shared/signal/WindowAnalysis.kt
  • Loading branch information
nicolas-f committed Jul 23, 2024
2 parents acc3ea7 + 695e1cb commit b468fb8
Show file tree
Hide file tree
Showing 74 changed files with 5,346 additions and 874 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/code_review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
branches:
- main
pull_request:
types: [opened, ready_for_review, synchronize]
types: [ opened, reopened, labeled, unlabeled, ready_for_review, synchronize ]
branches:
- main

Expand Down Expand Up @@ -50,16 +50,21 @@ jobs:
shouldRunAndroid: ${{ needs.SetUp.outputs.shouldRunAndroid }}
shouldRunIos: ${{ needs.SetUp.outputs.shouldRunIos }}

Detekt:
uses: ./.github/workflows/lint.yml

AllowMerge:
if: always()
runs-on: ubuntu-latest
needs: [ UnitTests ]
needs: [ UnitTests, Detekt ]
steps:
- run: |
if [ ${{ github.event_name }} == pull_request ] && [ ${{ join(github.event.pull_request.labels.*.name) == '' }} == true ]; then
exit 1
elif [ ${{ (contains(needs.UnitTests.result, 'failure')) }} == true ]; then
exit 1
elif [ ${{ (contains(needs.Detekt.result, 'failure')) }} == true ]; then
exit 1
else
exit 0
fi
16 changes: 16 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: detekt

on: workflow_call

jobs:
detekt:
runs-on: ubuntu-latest

steps:
- name: "checkout"
uses: actions/checkout@v2

- name: "detekt"
uses: natiginfo/action-detekt-all@1.23.6
with:
args: --config "config/detekt.yml" --excludes "**/*Test/**,**/*.kts"
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# About NoiseCapture

![Build status](https://github.com/nicolas-f/NoiseCaptureKotlin/actions/workflows/code_review.yml/badge.svg)
![Build status](https://github.com/Universite-Gustave-Eiffel/NoiseCaptureClient/actions/workflows/code_review.yml/badge.svg)
![Code style status](https://github.com/Universite-Gustave-Eiffel/NoiseCaptureClient/actions/workflows/lint.yml/badge.svg)


**NoiseCapture** is an Android/Ios/Web App dedicated to the measurement of environmental noise.

Expand Down
5 changes: 3 additions & 2 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ plugins {
id("com.android.application")
id("com.google.devtools.ksp")
id("kotlin-parcelize")
id("io.gitlab.arturbosch.detekt") version libs.versions.detekt.get()
}

android {
namespace = "org.noise_planet.noisecapture"
namespace = "org.noiseplanet.noisecapture"
compileSdk = libs.versions.android.compile.sdk.get().toInt()
defaultConfig {
applicationId = "org.noise_planet.noisecapturekmp"
applicationId = "org.noiseplanet.noisecapturekmp"
minSdk = libs.versions.android.min.sdk.get().toInt()
targetSdk = libs.versions.android.target.sdk.get().toInt()
versionCode = 1
Expand Down
8 changes: 4 additions & 4 deletions androidApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
android:supportsRtl="true"
android:theme="@style/Theme.AppyxStarterKit">
<activity
android:name="org.noise_planet.noisecapture.starter.MainActivity"
android:name="org.noiseplanet.noisecapture.starter.MainActivity"
android:exported="true"
android:theme="@style/Theme.AppyxStarterKit">
<intent-filter>
Expand All @@ -31,9 +31,9 @@
</intent-filter>
</activity>

<service android:name=".AndroidMeasurementService"
android:foregroundServiceType="location|microphone"
/>
<service
android:name=".AndroidMeasurementService"
android:foregroundServiceType="location|microphone" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.noise_planet.noisecapture.starter
package org.noiseplanet.noisecapture.starter

import android.annotation.SuppressLint
import android.app.Activity
Expand All @@ -16,21 +16,23 @@ import com.bumble.appyx.navigation.platform.AndroidLifecycle
import org.koin.android.logger.AndroidLogger
import org.koin.core.context.stopKoin
import org.koin.dsl.module
import org.noise_planet.noisecapture.AndroidAudioSource
import org.noise_planet.noisecapture.AndroidDatabase
import org.noise_planet.noisecapture.AndroidMeasurementService
import org.noise_planet.noisecapture.DatabaseDriverFactory
import org.noise_planet.noisecapture.shared.MeasurementService
import org.noise_planet.noisecapture.shared.initKoin
import org.noise_planet.noisecapture.shared.root.RootNode
import org.noise_planet.noisecapture.shared.ui.theme.AppyxStarterKitTheme
import org.noiseplanet.noisecapture.AndroidAudioSource
import org.noiseplanet.noisecapture.AndroidDatabase
import org.noiseplanet.noisecapture.AndroidMeasurementService
import org.noiseplanet.noisecapture.DatabaseDriverFactory
import org.noiseplanet.noisecapture.shared.MeasurementService
import org.noiseplanet.noisecapture.shared.initKoin
import org.noiseplanet.noisecapture.shared.root.RootNode
import org.noiseplanet.noisecapture.shared.ui.theme.AppyxStarterKitTheme
import kotlin.reflect.KProperty

class MainActivity : NodeActivity() {
val androidLogger = AndroidLogger()

private val androidLogger = AndroidLogger()
private val foregroundServiceConnection = ForegroundServiceConnection()

internal class ForegroundServiceConnection : ServiceConnection {

@SuppressLint("MissingPermission")
override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
println("onServiceConnected $name $service")
Expand All @@ -39,15 +41,10 @@ class MainActivity : NodeActivity() {
// interact with the service. Because we have bound to a explicit
// service that we know is running in our own process, we can
// cast its IBinder to a concrete class and directly access it.
if(service != null) {
val androidMeasurementService =
(service as AndroidMeasurementService.LocalBinder).service

}
}

override fun onServiceDisconnected(name: ComponentName?) {

println("onServiceConnected $name")
}
}

Expand All @@ -66,15 +63,19 @@ class MainActivity : NodeActivity() {
println("OnStop")
}

fun onStorageStateChange(property : KProperty<*>, oldValue :Boolean, newValue: Boolean) {
@Suppress("UnusedParameter")
private fun onStorageStateChange(property: KProperty<*>, oldValue: Boolean, newValue: Boolean) {
// bind this application context to Android Foreground service if storage is launched
// in order to avoid application shutdown by Android when moved in background
if(newValue) {
if (newValue) {
val intent = Intent(applicationContext, AndroidMeasurementService::class.java)
if (applicationContext.bindService(intent, foregroundServiceConnection,
Context.BIND_AUTO_CREATE)) {
if (applicationContext.bindService(
intent, foregroundServiceConnection,
Context.BIND_AUTO_CREATE
)
) {
androidLogger.info("Bind with foreground service")
} else{
} else {
androidLogger.info("Can't bind with foreground service")
}
} else {
Expand All @@ -90,9 +91,11 @@ class MainActivity : NodeActivity() {
single<Context> { applicationContext }
single<Activity> { this@MainActivity }
single<MeasurementService> {
val measurementService = MeasurementService(AndroidAudioSource(logger), androidLogger)
val measurementService =
MeasurementService(AndroidAudioSource(logger))
measurementService.storageObservers.add(::onStorageStateChange)
measurementService}
measurementService
}
single<DatabaseDriverFactory> { AndroidDatabase(applicationContext) }
}
)
Expand Down
33 changes: 33 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,40 @@
import io.gitlab.arturbosch.detekt.Detekt

plugins {
kotlin("android") version libs.versions.kotlin.get() apply false
kotlin("multiplatform") version libs.versions.kotlin.get() apply false
id("com.android.application") version libs.versions.agp.get() apply false
id("org.jetbrains.compose") version libs.versions.compose.plugin.get() apply false
id("com.google.devtools.ksp") version libs.versions.ksp.get() apply false
id("io.gitlab.arturbosch.detekt") version libs.versions.detekt.get()
}

repositories {
mavenCentral()
}

allprojects {
apply(plugin = "io.gitlab.arturbosch.detekt")

detekt {
buildUponDefaultConfig = true
allRules = true
config.setFrom("$rootDir/config/detekt.yml")
source.setFrom(
"src/main/kotlin",
"src/iosMain/kotlin",
"src/androidMain/kotlin",
"src/jsMain/kotlin",
"src/commonMain/kotlin",
)
autoCorrect = true
}

tasks.withType<Detekt>().configureEach {
jvmTarget = libs.versions.jvm.target.get()
reports {
html.required.set(true)
}
basePath = rootDir.absolutePath
}
}
Loading

0 comments on commit b468fb8

Please sign in to comment.