diff --git a/packages/esense_flutter/CHANGELOG.md b/packages/esense_flutter/CHANGELOG.md
index 28ec5b406..2d0129dc4 100644
--- a/packages/esense_flutter/CHANGELOG.md
+++ b/packages/esense_flutter/CHANGELOG.md
@@ -1,80 +1,84 @@
+## 1.1.1
+
+* upgrade to Android APK
+
## 1.0.0
-- first stable release
-- update to Bluetooth permissions in demo app
-- improved handling of disconnection
+* first stable release
+* update to Bluetooth permissions in demo app
+* improved handling of disconnection
## 0.7.0
-- Upgrade of Kotlin and AGP
-- Dart fix
+* Upgrade of Kotlin and AGP
+* Dart fix
## 0.6.2
-- Added podspec file to iOS
+* Added podspec file to iOS
## 0.6.1
-- fixed bug in sampling rate configuration on Android
-- small improvement to API doc and example app
+* fixed bug in sampling rate configuration on Android
+* small improvement to API doc and example app
## 0.6.0
-- moved permission handling to app level
-- improved on iOS implementation
-- improvement to example app
-- improvement to README
+* moved permission handling to app level
+* improved on iOS implementation
+* improvement to example app
+* improvement to README
## 0.5.0
-- upgrade to Android embedding v2
+* upgrade to Android embedding v2
## 0.4.3
-- fix of error in setSamplingRate method on iOS
+* fix of error in setSamplingRate method on iOS
## 0.4.0
-- upgrade to null-safety
+* upgrade to null-safety
## 0.3.0
-- singleton changed to recommended dart style using `ESenseManager()`.
-- fixed bug in reconnection.
-- updated the Android app to [post 1.12 Android project](https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects).
-- small improvement to the demo app (now supports connection via a button).
+* singleton changed to recommended dart style using `ESenseManager()`.
+* fixed bug in reconnection.
+* updated the Android app to [post 1.12 Android project](https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects).
+* small improvement to the demo app (now supports connection via a button).
## 0.2.1
-- updated Swift implementation to version 5
+* updated Swift implementation to version 5
## 0.2.0+2
-- update to readme on iOS
-- added bluetooth permission to `Info.plist`
+* update to readme on iOS
+* added bluetooth permission to `Info.plist`
## 0.2.0+1
-- small update to documentation
+* small update to documentation
## 0.2.0
-- support for iOS implemented
-- improved example app
-- improvement to documentation
+* support for iOS implemented
+* improved example app
+* improvement to documentation
## 0.1.3
-- sampling rate can be set before connecting to device.
+* sampling rate can be set before connecting to device.
## 0.1.2
-- small improvement to the example app (still not very good though...)
+* small improvement to the example app (still not very good though...)
## 0.1.1+1
-- update of readme documentation on API.
+* update of readme documentation on API.
## 0.1.0
-- Initial release supporting 1st released version of the Android eSense library, dated April 2019.
+* Initial release supporting 1st released version of the Android eSense library, dated April 2019.
diff --git a/packages/esense_flutter/android/build.gradle b/packages/esense_flutter/android/build.gradle
index fb6ca09c3..46d4c106f 100644
--- a/packages/esense_flutter/android/build.gradle
+++ b/packages/esense_flutter/android/build.gradle
@@ -1,36 +1,68 @@
-group 'dk.cachet.esense_flutter'
-version '1.0'
+group = "k.cachet.esense_flutter"
+version = "1.0-SNAPSHOT"
buildscript {
+ ext.kotlin_version = "1.8.22"
repositories {
google()
mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:4.1.0'
+ classpath("com.android.tools.build:gradle:8.1.0")
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
}
}
-rootProject.allprojects {
+allprojects {
repositories {
google()
mavenCentral()
}
}
-apply plugin: 'com.android.library'
+apply plugin: "com.android.library"
+apply plugin: "kotlin-android"
android {
- compileSdkVersion 31
+ namespace "dk.cachet.esense_flutter"
+
+ compileSdk = 31
compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
+ sourceCompatibility = JavaVersion.VERSION_11
+ targetCompatibility = JavaVersion.VERSION_11
+ }
+
+ kotlinOptions {
+ jvmTarget = JavaVersion.VERSION_11
+ }
+
+ sourceSets {
+ main.java.srcDirs += "src/main/kotlin"
+ test.java.srcDirs += "src/test/kotlin"
}
defaultConfig {
- minSdkVersion 16
+ minSdk = 21
+ }
+
+ dependencies {
+ testImplementation("org.jetbrains.kotlin:kotlin-test")
+ testImplementation("org.mockito:mockito-core:5.0.0")
+ }
+
+ testOptions {
+ unitTests.all {
+ useJUnitPlatform()
+
+ testLogging {
+ events "passed", "skipped", "failed", "standardOut", "standardError"
+ outputs.upToDateWhen {false}
+ showStandardStreams = true
+ }
+ }
}
- namespace "dk.cachet.esense_flutter"
}
+
+
diff --git a/packages/esense_flutter/example/android/app/build.gradle b/packages/esense_flutter/example/android/app/build.gradle
index 2043a4db3..174546eb4 100644
--- a/packages/esense_flutter/example/android/app/build.gradle
+++ b/packages/esense_flutter/example/android/app/build.gradle
@@ -1,56 +1,45 @@
-def localProperties = new Properties()
-def localPropertiesFile = rootProject.file('local.properties')
-if (localPropertiesFile.exists()) {
- localPropertiesFile.withReader('UTF-8') { reader ->
- localProperties.load(reader)
- }
-}
-
-def flutterRoot = localProperties.getProperty('flutter.sdk')
-if (flutterRoot == null) {
- throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
+plugins {
+ id "com.android.application"
+ id "kotlin-android"
+ // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
+ id "dev.flutter.flutter-gradle-plugin"
}
-def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
-if (flutterVersionCode == null) {
- flutterVersionCode = '1'
-}
-
-def flutterVersionName = localProperties.getProperty('flutter.versionName')
-if (flutterVersionName == null) {
- flutterVersionName = '1.0'
-}
-
-apply plugin: 'com.android.application'
-apply plugin: 'kotlin-android'
-apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
-
android {
- compileSdkVersion flutter.compileSdkVersion
+ namespace = "dk.cachet.esense_flutter_example"
+ compileSdk = flutter.compileSdkVersion
+ ndkVersion = flutter.ndkVersion
compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
+ sourceCompatibility = JavaVersion.VERSION_1_8
+ targetCompatibility = JavaVersion.VERSION_1_8
+ }
+
+ kotlinOptions {
+ jvmTarget = JavaVersion.VERSION_1_8
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "dk.cachet.esense_flutter_example"
- minSdkVersion flutter.minSdkVersion
- targetSdkVersion flutter.targetSdkVersion
- versionCode flutterVersionCode.toInteger()
- versionName flutterVersionName
+ // You can update the following values to match your application needs.
+ // For more information, see: https://flutter.dev/to/review-gradle-config.
+ 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.debug
+ signingConfig = signingConfigs.debug
}
}
}
flutter {
- source '../..'
+ source = "../.."
}
+
diff --git a/packages/esense_flutter/example/android/app/src/main/AndroidManifest.xml b/packages/esense_flutter/example/android/app/src/main/AndroidManifest.xml
index eaf22b319..31b7459a4 100644
--- a/packages/esense_flutter/example/android/app/src/main/AndroidManifest.xml
+++ b/packages/esense_flutter/example/android/app/src/main/AndroidManifest.xml
@@ -1,5 +1,4 @@
@@ -51,4 +50,15 @@
android:name="flutterEmbedding"
android:value="2" />
+
+
+
+
+
+
+
diff --git a/packages/esense_flutter/example/android/build.gradle b/packages/esense_flutter/example/android/build.gradle
index f7eb7f63c..d2ffbffa4 100644
--- a/packages/esense_flutter/example/android/build.gradle
+++ b/packages/esense_flutter/example/android/build.gradle
@@ -1,16 +1,3 @@
-buildscript {
- ext.kotlin_version = '1.7.10'
- repositories {
- google()
- mavenCentral()
- }
-
- dependencies {
- classpath 'com.android.tools.build:gradle:7.3.0'
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
- }
-}
-
allprojects {
repositories {
google()
@@ -18,12 +5,12 @@ allprojects {
}
}
-rootProject.buildDir = '../build'
+rootProject.buildDir = "../build"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
- project.evaluationDependsOn(':app')
+ project.evaluationDependsOn(":app")
}
tasks.register("clean", Delete) {
diff --git a/packages/esense_flutter/example/android/gradle.properties b/packages/esense_flutter/example/android/gradle.properties
index 94adc3a3f..259717082 100644
--- a/packages/esense_flutter/example/android/gradle.properties
+++ b/packages/esense_flutter/example/android/gradle.properties
@@ -1,3 +1,3 @@
-org.gradle.jvmargs=-Xmx1536M
+org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true
diff --git a/packages/esense_flutter/example/android/gradle/wrapper/gradle-wrapper.properties b/packages/esense_flutter/example/android/gradle/wrapper/gradle-wrapper.properties
index 31cca4913..7bb2df6ba 100644
--- a/packages/esense_flutter/example/android/gradle/wrapper/gradle-wrapper.properties
+++ b/packages/esense_flutter/example/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
diff --git a/packages/esense_flutter/example/android/settings.gradle b/packages/esense_flutter/example/android/settings.gradle
index 44e62bcf0..b9e43bd37 100644
--- a/packages/esense_flutter/example/android/settings.gradle
+++ b/packages/esense_flutter/example/android/settings.gradle
@@ -1,11 +1,25 @@
-include ':app'
+pluginManagement {
+ def flutterSdkPath = {
+ def properties = new Properties()
+ file("local.properties").withInputStream { properties.load(it) }
+ def flutterSdkPath = properties.getProperty("flutter.sdk")
+ assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
+ return flutterSdkPath
+ }()
-def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
-def properties = new Properties()
+ includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
-assert localPropertiesFile.exists()
-localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
+ repositories {
+ google()
+ mavenCentral()
+ gradlePluginPortal()
+ }
+}
-def flutterSdkPath = properties.getProperty("flutter.sdk")
-assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
-apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
+plugins {
+ id "dev.flutter.flutter-plugin-loader" version "1.0.0"
+ id "com.android.application" version "8.1.0" apply false
+ id "org.jetbrains.kotlin.android" version "1.8.22" apply false
+}
+
+include ":app"
diff --git a/packages/esense_flutter/pubspec.yaml b/packages/esense_flutter/pubspec.yaml
index cffdb38e6..38555a49a 100644
--- a/packages/esense_flutter/pubspec.yaml
+++ b/packages/esense_flutter/pubspec.yaml
@@ -1,6 +1,6 @@
name: esense_flutter
description: The eSense Flutter Plugin supporting the eSense earable computing devices from Nokia Bell Labs, Cambridge.
-version: 1.0.0
+version: 1.1.1
homepage: https://github.com/cph-cachet/flutter-plugins/tree/master/packages/esense_flutter
environment:
diff --git a/packages/screen_state/CHANGELOG.md b/packages/screen_state/CHANGELOG.md
index 4721e8f0e..e5cb51b85 100644
--- a/packages/screen_state/CHANGELOG.md
+++ b/packages/screen_state/CHANGELOG.md
@@ -1,32 +1,38 @@
+## 4.1.1
+
+* upgrade of Android APK
+* adding linter
+* removing `ScreenStateException` and instead returning an empty stream on unsupported platforms for more graceful handling
+
## 4.0.0
-- Added support for iOS.
-- Restructuring of the interaction between the plugin and native applications.
+* Added support for iOS.
+* Restructuring of the interaction between the plugin and native applications.
## 3.0.1
-- Reduced minSdk version to 23
+* Reduced minSdk version to 23
## 3.0.0
-- `Screen()` implemented as singleton.
-- Updates Kotlin plugin and AGP.
-- Upgrade of `compileSdkVersion` to 33.
-- Upgrade to Dart 3.
+* `Screen()` implemented as singleton.
+* Updates Kotlin plugin and AGP.
+* Upgrade of `compileSdkVersion` to 33.
+* Upgrade to Dart 3.
## 2.0.0
-- Null safety migration
+* Null safety migration
## 1.0.1
-- Fixed an issue causing the plugin to crash when the stream was cancelled and then opened again.
- - See
+* Fixed an issue causing the plugin to crash when the stream was cancelled and then opened again.
+ * See
## 1.0.0
-- Migrated to new Android Plugin API (Flutter 1.12)
+* Migrated to new Android Plugin API (Flutter 1.12)
## 0.5.0
-- Migrated to AndroidX
+* Migrated to AndroidX
diff --git a/packages/screen_state/example/analysis_options.yaml b/packages/screen_state/analysis_options.yaml
similarity index 94%
rename from packages/screen_state/example/analysis_options.yaml
rename to packages/screen_state/analysis_options.yaml
index 0d2902135..f9c6c8fb2 100644
--- a/packages/screen_state/example/analysis_options.yaml
+++ b/packages/screen_state/analysis_options.yaml
@@ -21,7 +21,7 @@ linter:
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
- # avoid_print: false # Uncomment to disable the `avoid_print` rule
+ avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
diff --git a/packages/screen_state/android/build.gradle b/packages/screen_state/android/build.gradle
index 10bdb080c..4904c5bbe 100644
--- a/packages/screen_state/android/build.gradle
+++ b/packages/screen_state/android/build.gradle
@@ -1,44 +1,68 @@
-group 'dk.cachet.screen_state'
-version '1.0-SNAPSHOT'
+group = "dk.cachet.screen_state"
+version = "1.0-SNAPSHOT"
buildscript {
- ext.kotlin_version = '1.7.20'
+ ext.kotlin_version = "1.8.22"
repositories {
google()
- jcenter()
+ mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:7.3.0'
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ classpath("com.android.tools.build:gradle:8.1.0")
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
}
}
-rootProject.allprojects {
+allprojects {
repositories {
google()
- jcenter()
+ mavenCentral()
}
}
-apply plugin: 'com.android.library'
-apply plugin: 'kotlin-android'
+apply plugin: "com.android.library"
+apply plugin: "kotlin-android"
android {
- compileSdkVersion 33
+ namespace "dk.cachet.screen_state"
+
+ compileSdk = 33
+
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_11
+ targetCompatibility = JavaVersion.VERSION_11
+ }
+
+ kotlinOptions {
+ jvmTarget = JavaVersion.VERSION_11
+ }
sourceSets {
- main.java.srcDirs += 'src/main/kotlin'
+ main.java.srcDirs += "src/main/kotlin"
+ test.java.srcDirs += "src/test/kotlin"
}
+
defaultConfig {
- minSdkVersion 23
+ minSdk = 21
}
- lintOptions {
- disable 'InvalidPackage'
+
+ dependencies {
+ testImplementation("org.jetbrains.kotlin:kotlin-test")
+ testImplementation("org.mockito:mockito-core:5.0.0")
}
- namespace "dk.cachet.screen_state"
-}
-dependencies {
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+ testOptions {
+ unitTests.all {
+ useJUnitPlatform()
+
+ testLogging {
+ events "passed", "skipped", "failed", "standardOut", "standardError"
+ outputs.upToDateWhen {false}
+ showStandardStreams = true
+ }
+ }
+ }
}
+
+
diff --git a/packages/screen_state/android/gradle.properties b/packages/screen_state/android/gradle.properties
deleted file mode 100644
index 38c8d4544..000000000
--- a/packages/screen_state/android/gradle.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-org.gradle.jvmargs=-Xmx1536M
-android.enableR8=true
-android.useAndroidX=true
-android.enableJetifier=true
diff --git a/packages/screen_state/android/gradle/wrapper/gradle-wrapper.properties b/packages/screen_state/android/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index 09523c0e5..000000000
--- a/packages/screen_state/android/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
-networkTimeout=10000
-validateDistributionUrl=true
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
diff --git a/packages/screen_state/example/android/app/build.gradle b/packages/screen_state/example/android/app/build.gradle
index 3578f3e4f..b5511a9a3 100644
--- a/packages/screen_state/example/android/app/build.gradle
+++ b/packages/screen_state/example/android/app/build.gradle
@@ -1,67 +1,44 @@
plugins {
id "com.android.application"
id "kotlin-android"
+ // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id "dev.flutter.flutter-gradle-plugin"
}
-def localProperties = new Properties()
-def localPropertiesFile = rootProject.file('local.properties')
-if (localPropertiesFile.exists()) {
- localPropertiesFile.withReader('UTF-8') { reader ->
- localProperties.load(reader)
- }
-}
-
-def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
-if (flutterVersionCode == null) {
- flutterVersionCode = '1'
-}
-
-def flutterVersionName = localProperties.getProperty('flutter.versionName')
-if (flutterVersionName == null) {
- flutterVersionName = '1.0'
-}
-
android {
- namespace "com.example.example"
- compileSdkVersion flutter.compileSdkVersion
- ndkVersion flutter.ndkVersion
+ namespace = "com.example.example"
+ compileSdk = flutter.compileSdkVersion
+ ndkVersion = flutter.ndkVersion
compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
+ sourceCompatibility = JavaVersion.VERSION_1_8
+ targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
- jvmTarget = '1.8'
- }
-
- sourceSets {
- main.java.srcDirs += 'src/main/kotlin'
+ jvmTarget = JavaVersion.VERSION_1_8
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
- applicationId "com.example.example"
+ applicationId = "com.example.example"
// You can update the following values to match your application needs.
- // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
- minSdkVersion 23
- targetSdkVersion flutter.targetSdkVersion
- versionCode flutterVersionCode.toInteger()
- versionName flutterVersionName
+ // For more information, see: https://flutter.dev/to/review-gradle-config.
+ 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.debug
+ signingConfig = signingConfigs.debug
}
}
}
flutter {
- source '../..'
+ source = "../.."
}
-
-dependencies {}
diff --git a/packages/screen_state/example/android/build.gradle b/packages/screen_state/example/android/build.gradle
index e83fb5dac..d2ffbffa4 100644
--- a/packages/screen_state/example/android/build.gradle
+++ b/packages/screen_state/example/android/build.gradle
@@ -1,15 +1,3 @@
-buildscript {
- ext.kotlin_version = '1.7.10'
- repositories {
- google()
- mavenCentral()
- }
-
- dependencies {
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
- }
-}
-
allprojects {
repositories {
google()
@@ -17,12 +5,12 @@ allprojects {
}
}
-rootProject.buildDir = '../build'
+rootProject.buildDir = "../build"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
- project.evaluationDependsOn(':app')
+ project.evaluationDependsOn(":app")
}
tasks.register("clean", Delete) {
diff --git a/packages/screen_state/example/android/gradle.properties b/packages/screen_state/example/android/gradle.properties
index 598d13fee..259717082 100644
--- a/packages/screen_state/example/android/gradle.properties
+++ b/packages/screen_state/example/android/gradle.properties
@@ -1,3 +1,3 @@
-org.gradle.jvmargs=-Xmx4G
+org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true
diff --git a/packages/screen_state/example/android/gradle/wrapper/gradle-wrapper.properties b/packages/screen_state/example/android/gradle/wrapper/gradle-wrapper.properties
index 3c472b99c..7bb2df6ba 100644
--- a/packages/screen_state/example/android/gradle/wrapper/gradle-wrapper.properties
+++ b/packages/screen_state/example/android/gradle/wrapper/gradle-wrapper.properties
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
diff --git a/packages/screen_state/example/android/settings.gradle b/packages/screen_state/example/android/settings.gradle
index 7cd712855..b9e43bd37 100644
--- a/packages/screen_state/example/android/settings.gradle
+++ b/packages/screen_state/example/android/settings.gradle
@@ -5,25 +5,21 @@ pluginManagement {
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
- }
- settings.ext.flutterSdkPath = flutterSdkPath()
+ }()
- includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
+ includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
-
- plugins {
- id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false
- }
}
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
- id "com.android.application" version "7.3.0" apply false
+ id "com.android.application" version "8.1.0" apply false
+ id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}
include ":app"
diff --git a/packages/screen_state/example/lib/main.dart b/packages/screen_state/example/lib/main.dart
index 38e2be0d2..b3ed41fe0 100644
--- a/packages/screen_state/example/lib/main.dart
+++ b/packages/screen_state/example/lib/main.dart
@@ -3,11 +3,13 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:screen_state/screen_state.dart';
-void main() => runApp(new MyApp());
+void main() => runApp(ScreenStateApp());
+
+class ScreenStateApp extends StatefulWidget {
+ const ScreenStateApp({super.key});
-class MyApp extends StatefulWidget {
@override
- _MyAppState createState() => new _MyAppState();
+ ScreenStateAppState createState() => ScreenStateAppState();
}
class ScreenStateEventEntry {
@@ -19,12 +21,13 @@ class ScreenStateEventEntry {
}
}
-class _MyAppState extends State {
- Screen _screen = Screen();
+class ScreenStateAppState extends State {
+ final Screen _screen = Screen();
StreamSubscription? _subscription;
bool started = false;
- List _log = [];
+ final List _log = [];
+ @override
void initState() {
super.initState();
startListening();
@@ -33,18 +36,17 @@ class _MyAppState extends State {
/// Start listening to screen events
void startListening() {
try {
- _subscription = _screen.screenStateStream!.listen(_onData);
+ _subscription = _screen.screenStateStream.listen(onData);
setState(() => started = true);
- } on ScreenStateException catch (exception) {
+ } catch (exception) {
print(exception);
}
}
- void _onData(ScreenStateEvent event) {
+ void onData(ScreenStateEvent event) {
setState(() {
_log.add(ScreenStateEventEntry(event));
});
- print(event);
}
/// Stop listening to screen events
@@ -55,13 +57,13 @@ class _MyAppState extends State {
@override
Widget build(BuildContext context) {
- return new MaterialApp(
- home: new Scaffold(
- appBar: new AppBar(
+ return MaterialApp(
+ home: Scaffold(
+ appBar: AppBar(
title: const Text('Screen State Example'),
),
- body: new Center(
- child: new ListView.builder(
+ body: Center(
+ child: ListView.builder(
itemCount: _log.length,
reverse: true,
itemBuilder: (BuildContext context, int idx) {
@@ -70,7 +72,7 @@ class _MyAppState extends State {
leading: Text(entry.time.toString().substring(0, 19)),
trailing: Text(entry.event.toString().split('.').last));
})),
- floatingActionButton: new FloatingActionButton(
+ floatingActionButton: FloatingActionButton(
onPressed: started ? stopListening : startListening,
tooltip: 'Start/Stop Listening',
child: started ? Icon(Icons.stop) : Icon(Icons.play_arrow),
diff --git a/packages/screen_state/lib/screen_state.dart b/packages/screen_state/lib/screen_state.dart
index 8fb2a4bc1..cba995ac9 100644
--- a/packages/screen_state/lib/screen_state.dart
+++ b/packages/screen_state/lib/screen_state.dart
@@ -24,7 +24,7 @@ enum ScreenStateEvent {
? 'android.intent.action.SCREEN_OFF'
: 'SCREEN_OFF';
default:
- throw new ArgumentError('Unknown ScreenStateEvent: $this');
+ throw ArgumentError('Unknown ScreenStateEvent: $this');
}
}
@@ -41,52 +41,28 @@ enum ScreenStateEvent {
case 'android.intent.action.SCREEN_OFF': // Android only 'SCREEN_OFF'
return ScreenStateEvent.SCREEN_OFF;
default:
- throw new ArgumentError('Unknown ScreenStateEvent: $name');
+ throw ArgumentError('Unknown ScreenStateEvent: $name');
}
}
}
-/// Custom Exception for the `screen_state` plugin, used whenever the plugin
-class ScreenStateException implements Exception {
- String _cause;
-
- ScreenStateException(this._cause);
-
- @override
- String toString() => '$runtimeType - $_cause';
-}
-
-/// Screen representation as object which holds the stream for [ScreenStateEvent]s.
+/// Screen state events as they occur on the phone.
class Screen {
static Screen? _singleton;
- EventChannel _eventChannel = const EventChannel('screenStateEvents');
+ final EventChannel _eventChannel = const EventChannel('screenStateEvents');
Stream? _screenStateStream;
- ScreenStateEvent? _lastScreenState;
/// Constructs a singleton instance of [Screen].
- ///
- /// [Screen] is designed to work as a singleton.
factory Screen() => _singleton ??= Screen._();
Screen._();
- /// Stream of [ScreenStateEvent]s.
- /// Each event is streamed as it occurs on the phone.
- Stream get screenStateStream {
- if (!Platform.isAndroid && !Platform.isIOS) {
- throw ScreenStateException(
- 'Screen State API only available on Android and iOS.',
- );
- }
-
- if (_screenStateStream == null) {
- _screenStateStream = _eventChannel.receiveBroadcastStream().map(
- (event) => ScreenStateEvent.fromName(
- event,
- ),
- );
- }
-
- return _screenStateStream!;
- }
+ /// Stream of [ScreenStateEvent]s as they occurs on the phone.
+ /// Returns an empty stream on unsupported platforms.
+ Stream get screenStateStream =>
+ _screenStateStream ??= Platform.isAndroid || Platform.isIOS
+ ? _screenStateStream ??= _eventChannel
+ .receiveBroadcastStream()
+ .map((event) => ScreenStateEvent.fromName(event))
+ : Stream.empty();
}
diff --git a/packages/screen_state/pubspec.yaml b/packages/screen_state/pubspec.yaml
index fd0e9ebd4..b9fc0b326 100644
--- a/packages/screen_state/pubspec.yaml
+++ b/packages/screen_state/pubspec.yaml
@@ -1,6 +1,6 @@
name: screen_state
description: A plugin for reporting screen events while the flutter application is running in background. Works for Android and iOS only.
-version: 4.0.0
+version: 4.1.1
homepage: https://github.com/cph-cachet/flutter-plugins/tree/master/packages/screen_state
environment:
@@ -14,6 +14,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
+ flutter_lints: any
flutter:
plugin: