Skip to content
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
8 changes: 8 additions & 0 deletions packages/noise_meter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 6.0.0

- **Breaking:** requires Flutter `>=3.44.0`
- Updated the example app to AGP 9.0.1, Kotlin 2.3.20, Gradle 9.1.0, Java 17 and `compileSdk 37`
- Updated the example app to `permission_handler: ^13.0.1`
- Updated to `audio_streamer: ^5.0.0`
- Updated documentation

## 5.1.0

- update to `audio_streamer: ^4.2.0`
Expand Down
30 changes: 26 additions & 4 deletions packages/noise_meter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,29 @@ A noise meter plugin for iOS and Android.
Add `noise_meter` as a dependency in `pubspec.yaml`.
For help on adding as a dependency, view the [documentation](https://flutter.io/using-packages/).

On **Android** you need to add a permission to `AndroidManifest.xml`:
### Requirements

This plugin builds on [`audio_streamer`](https://pub.dev/packages/audio_streamer) and inherits its
platform requirements: Flutter 3.44 or later, iOS 16.0 or later, and Android `minSdk` 24 or later.

### Android

Add the microphone permission to `AndroidManifest.xml`:

```xml
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
```

On **iOS** enable the following in XCode:
### iOS

Enable the following in Xcode:

- Capabilities > Background Modes > _Audio, AirPlay and Picture in Picture_
- In the Runner Xcode project edit the _Info.plist_ file. Add an entry for _'Privacy - Microphone Usage Description'_
- Edit the `Podfile` to include the permission for the microphone:

If your app requests the permission with [`permission_handler`](https://pub.dev/packages/permission_handler)
**and still integrates iOS dependencies with CocoaPods**, edit the `Podfile` to enable the
microphone permission:

```ruby
post_install do |installer|
Expand All @@ -34,6 +45,17 @@ post_install do |installer|
end
```

This step is not needed with Swift Package Manager — `permission_handler_apple` enables the
microphone permission automatically when `NSMicrophoneUsageDescription` is present in
`Info.plist`.

## Swift Package Manager

iOS dependencies are resolved with
[Swift Package Manager](https://docs.flutter.dev/packages-and-plugins/swift-package-manager/for-app-developers)
on Flutter 3.44 and later; no configuration is needed. CocoaPods remains supported for apps that
have not migrated. The example app is integrated with SPM only and has no `Podfile`.

## Usage

See the example app for how to use the plugin. This app also illustrated how to obtain permission to access the microphone.
Expand Down
68 changes: 0 additions & 68 deletions packages/noise_meter/example/android/app/build.gradle

This file was deleted.

44 changes: 44 additions & 0 deletions packages/noise_meter/example/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
plugins {
id("com.android.application")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}

android {
namespace = "com.noise_meter.example"
// permission_handler_android 14 requires compiling against API 37, which is
// ahead of Flutter's default (flutter.compileSdkVersion == 36).
compileSdk = 37
ndkVersion = flutter.ndkVersion

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

defaultConfig {
applicationId = "com.noise_meter.example"
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.getByName("debug")
}
}
}

kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
}
}

flutter {
source = "../.."
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECORD_AUDIO" />
</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<application
android:name="${applicationName}"
android:label="Noise Meter Example"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.noise_meter.example

import io.flutter.embedding.android.FlutterActivity

class MainActivity : FlutterActivity()
31 changes: 0 additions & 31 deletions packages/noise_meter/example/android/build.gradle

This file was deleted.

24 changes: 24 additions & 0 deletions packages/noise_meter/example/android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
allprojects {
repositories {
google()
mavenCentral()
}
}

val newBuildDir: Directory =
rootProject.layout.buildDirectory
.dir("../../build")
.get()
rootProject.layout.buildDirectory.value(newBuildDir)

subprojects {
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
project.layout.buildDirectory.value(newSubprojectBuildDir)
}
subprojects {
project.evaluationDependsOn(":app")
}

tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}
7 changes: 5 additions & 2 deletions packages/noise_meter/example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
org.gradle.jvmargs=-Xmx1536M
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true
# This newDsl flag was added by the Flutter template
android.newDsl=false
# This builtInKotlin flag was added by the Flutter template
android.builtInKotlin=false
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-all.zip
25 changes: 0 additions & 25 deletions packages/noise_meter/example/android/settings.gradle

This file was deleted.

26 changes: 26 additions & 0 deletions packages/noise_meter/example/android/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
pluginManagement {
val flutterSdkPath =
run {
val properties = java.util.Properties()
file("local.properties").inputStream().use { properties.load(it) }
val flutterSdkPath = properties.getProperty("flutter.sdk")
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
flutterSdkPath
}

includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "9.0.1" apply false
id("org.jetbrains.kotlin.android") version "2.3.20" apply false
}

include(":app")
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>13.0</string>
</dict>
</plist>
1 change: 0 additions & 1 deletion packages/noise_meter/example/ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
1 change: 0 additions & 1 deletion packages/noise_meter/example/ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
Loading
Loading