Skip to content

Commit 1fc3e96

Browse files
authored
Merge pull request #1131 from cph-cachet/1116-light-release-new-version-to-pubdev-to-fix-android-namespace-issue
Light version 4.0.0
2 parents f1f4ee0 + 055c8f6 commit 1fc3e96

File tree

14 files changed

+153
-137
lines changed

14 files changed

+153
-137
lines changed

packages/light/CHANGELOG.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
1+
## 4.0.0
2+
3+
* Upgrade of APK (issue [[#1116](https://github.com/cph-cachet/flutter-plugins/issues/1116)])
4+
* Added linter to the code
5+
* Removed marked support for iOS in pubspec file
6+
* Refactor of error handling (removing the `LightException`)
7+
* Refactor of example app code
8+
19
## 3.0.1
210

3-
- Updated pubspec.yaml
11+
* Updated pubspec.yaml
412

513
## 3.0.0
614

7-
- `Light()` implemented as singleton.
8-
- Updates Kotlin plugin and AGP.
9-
- Upgrade of `compileSdkVersion` to 33.
10-
- Upgrade to Dart 3.
15+
* `Light()` implemented as singleton.
16+
* Updates Kotlin plugin and AGP.
17+
* Upgrade of `compileSdkVersion` to 33.
18+
* Upgrade to Dart 3.
1119

1220
## 2.1.0
1321

14-
- `lightSensorStream` is not returning `null` values.
15-
- update to example app
22+
* `lightSensorStream` is not returning `null` values.
23+
* update to example app
1624

1725
## 2.0.0
1826

19-
- Migration to null safety
27+
* Migration to null safety
2028

2129
## 1.0.1
2230

23-
- fix: issue [#139](https://github.com/cph-cachet/carp.sensing-flutter/issues/139)
31+
* fix: issue [#139](https://github.com/cph-cachet/carp.sensing-flutter/issues/139)
2432

2533
## 1.0.0
2634

27-
- Updated version of the old plugin.
35+
* Updated version of the old plugin.

packages/light/README.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![pub package](https://img.shields.io/pub/v/light.svg)](https://pub.dartlang.org/packages/light)
44

5-
A Flutter plugin for collecting data from the [ambient light sensor on Android](https://developer.android.com/guide/topics/sensors/sensors_environment#java).
5+
A Flutter plugin for collecting ambient light data from the [Android Environment Sensors](https://developer.android.com/develop/sensors-and-location/sensors/sensors_environment).
66

77
## Install
88

@@ -12,27 +12,23 @@ For help on adding as a dependency, view the [documentation](https://flutter.io/
1212

1313
## Usage
1414

15-
Instantiate an instance of the `Light()` plugin and listen on the `lightSensorStream` stream.
15+
Use the singleton `Light()` to listen on the `lightSensorStream` stream.
1616

1717
```dart
18-
Light? _light;
19-
StreamSubscription? _subscription;
20-
21-
void onData(int luxValue) async {
22-
print("Lux value: $luxValue");
23-
}
24-
18+
StreamSubscription<int>? _lightEvents;
2519
2620
void startListening() {
27-
_light = Light();
2821
try {
29-
_subscription = _light?.lightSensorStream.listen(onData);
30-
} on LightException catch (exception) {
22+
_lightEvents =
23+
Light().lightSensorStream.listen((luxValue) => setState(() {
24+
// Do something with the lux value
25+
}));
26+
} catch (exception) {
3127
print(exception);
3228
}
3329
}
3430
3531
void stopListening() {
36-
_subscription?.cancel();
32+
_lightEvents?.cancel();
3733
}
3834
```
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Additional information about this file can be found at
2+
# https://dart.dev/guides/language/analysis-options
3+
4+
include: package:lints/recommended.yaml
5+
6+
analyzer:
7+
exclude: [build/**]
8+
language:
9+
strict-casts: true
10+
strict-inference: true
11+
strict-raw-types: true
12+
13+
linter:
14+
rules:
15+
cancel_subscriptions: true
16+
constant_identifier_names: false
17+
depend_on_referenced_packages: false
18+
use_string_in_part_of_directives: false
Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
group 'dk.cachet.light'
2-
version '1.0-SNAPSHOT'
1+
group = "dk.cachet.light"
2+
version = "1.0-SNAPSHOT"
33

44
buildscript {
5-
ext.kotlin_version = '1.7.10'
5+
ext.kotlin_version = "1.8.22"
66
repositories {
77
google()
88
mavenCentral()
99
}
1010

1111
dependencies {
12-
classpath 'com.android.tools.build:gradle:7.3.0'
13-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12+
classpath("com.android.tools.build:gradle:8.1.0")
13+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
1414
}
1515
}
1616

@@ -21,34 +21,46 @@ allprojects {
2121
}
2222
}
2323

24-
apply plugin: 'com.android.library'
25-
apply plugin: 'kotlin-android'
24+
apply plugin: "com.android.library"
25+
apply plugin: "kotlin-android"
2626

2727
android {
28-
compileSdkVersion 31
29-
namespace 'dk.cachet.light'
28+
namespace = "dk.cachet.light"
29+
30+
compileSdk = 35
3031

3132
compileOptions {
32-
sourceCompatibility JavaVersion.VERSION_1_8
33-
targetCompatibility JavaVersion.VERSION_1_8
33+
sourceCompatibility = JavaVersion.VERSION_11
34+
targetCompatibility = JavaVersion.VERSION_11
35+
}
36+
37+
kotlinOptions {
38+
jvmTarget = JavaVersion.VERSION_11
3439
}
3540

3641
sourceSets {
37-
main.java.srcDirs += 'src/main/kotlin'
38-
test.java.srcDirs += 'src/test/kotlin'
42+
main.java.srcDirs += "src/main/kotlin"
43+
test.java.srcDirs += "src/test/kotlin"
3944
}
4045

4146
defaultConfig {
42-
minSdkVersion 16
47+
minSdk = 21
4348
}
4449

45-
dependencies {
46-
testImplementation 'org.jetbrains.kotlin:kotlin-test'
47-
testImplementation 'org.mockito:mockito-core:5.0.0'
50+
def flutterRoot = {
51+
testImplementation("org.jetbrains.kotlin:kotlin-test")
52+
testImplementation("org.mockito:mockito-core:5.0.0")
4853
}
4954

50-
lintOptions {
51-
disable 'InvalidPackage'
55+
testOptions {
56+
unitTests.all {
57+
useJUnitPlatform()
58+
59+
testLogging {
60+
events "passed", "skipped", "failed", "standardOut", "standardError"
61+
outputs.upToDateWhen {false}
62+
showStandardStreams = true
63+
}
64+
}
5265
}
53-
namespace "dk.cachet.light"
5466
}

packages/light/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
36
zipStoreBase=GRADLE_USER_HOME
47
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip

packages/light/example/android/app/build.gradle

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
plugins {
2+
id "com.android.application"
3+
id "kotlin-android"
4+
id "dev.flutter.flutter-gradle-plugin"
5+
}
6+
17
def localProperties = new Properties()
28
def localPropertiesFile = rootProject.file('local.properties')
39
if (localPropertiesFile.exists()) {
@@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
612
}
713
}
814

9-
def flutterRoot = localProperties.getProperty('flutter.sdk')
10-
if (flutterRoot == null) {
11-
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12-
}
13-
1415
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
1516
if (flutterVersionCode == null) {
1617
flutterVersionCode = '1'
@@ -21,9 +22,6 @@ if (flutterVersionName == null) {
2122
flutterVersionName = '1.0'
2223
}
2324

24-
apply plugin: 'com.android.application'
25-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
26-
2725
android {
2826
namespace "dk.cachet.light_example"
2927
compileSdkVersion flutter.compileSdkVersion

packages/light/example/android/build.gradle

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
1-
buildscript {
2-
ext.kotlin_version = '1.7.10'
3-
repositories {
4-
google()
5-
mavenCentral()
6-
}
7-
8-
dependencies {
9-
classpath 'com.android.tools.build:gradle:7.3.0'
10-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11-
}
12-
}
13-
141
allprojects {
152
repositories {
163
google()
174
mavenCentral()
185
}
196
}
207

21-
rootProject.buildDir = '../build'
8+
rootProject.buildDir = "../build"
229
subprojects {
2310
project.buildDir = "${rootProject.buildDir}/${project.name}"
2411
}
2512
subprojects {
26-
project.evaluationDependsOn(':app')
13+
project.evaluationDependsOn(":app")
2714
}
2815

2916
tasks.register("clean", Delete) {
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
org.gradle.jvmargs=-Xmx1536M
2-
android.enableR8=true
1+
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
32
android.useAndroidX=true
43
android.enableJetifier=true
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Fri Jun 23 08:50:38 CEST 2017
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
43
zipStoreBase=GRADLE_USER_HOME
54
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1-
// Copyright 2014 The Flutter Authors. All rights reserved.
2-
// Use of this source code is governed by a BSD-style license that can be
3-
// found in the LICENSE file.
1+
pluginManagement {
2+
def flutterSdkPath = {
3+
def properties = new Properties()
4+
file("local.properties").withInputStream { properties.load(it) }
5+
def flutterSdkPath = properties.getProperty("flutter.sdk")
6+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7+
return flutterSdkPath
8+
}()
49

5-
include ':app'
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
611

7-
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
8-
def properties = new Properties()
12+
repositories {
13+
google()
14+
mavenCentral()
15+
gradlePluginPortal()
16+
}
17+
}
918

10-
assert localPropertiesFile.exists()
11-
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
19+
plugins {
20+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21+
id "com.android.application" version "8.1.0" apply false
22+
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
23+
}
1224

13-
def flutterSdkPath = properties.getProperty("flutter.sdk")
14-
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
15-
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
25+
include ":app"

0 commit comments

Comments
 (0)