Skip to content

Commit

Permalink
Merge branch 'master' into android-companion-and-bonding
Browse files Browse the repository at this point in the history
  • Loading branch information
ened committed Apr 7, 2024
2 parents 345f7ee + e6f04d3 commit 4834fcd
Show file tree
Hide file tree
Showing 117 changed files with 4,852 additions and 2,315 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[*.{kt,kts}]
max_line_length=210
ktlint_standard_property-naming=disabled
17 changes: 17 additions & 0 deletions .github/workflows/ktlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: ktlint
on: [pull_request]
jobs:
ktlint:
name: Check Code Quality
runs-on: ubuntu-latest

steps:
- name: Clone repo
uses: actions/checkout@master
with:
fetch-depth: 1
- name: ktlint
uses: ScaCap/action-ktlint@master
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review # Change reporter
59 changes: 59 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "Build"

on:
pull_request:
push:
branches:
- master

jobs:
build:
name: Build
runs-on: macos-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set Up Java
uses: actions/setup-java@v3.12.0
with:
distribution: 'oracle'
java-version: '19.0.2'

- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.16.3'
channel: 'stable'

- name: Set up debug keystore
run: |
rm -f ~/.android/debug.keystore
keytool -genkeypair \
-alias androiddebugkey \
-keypass android \
-keystore ~/.android/debug.keystore \
-storepass android \
-dname 'CN=Android Debug,O=Android,C=US' \
-keyalg 'RSA' \
-keysize 2048 \
-validity 10000
- name: Quality checks monorepo
run: |
./bin/quality_checks.sh
- name: Android native tests
run: |
#!/bin/bash -ex
cd example/android && ls && ./gradlew detekt && ./gradlew testDebugUnitTest
- name: Build android app
run: |
cd example && flutter build apk --debug
- name: Build iOS app
run: |
find . -name "Podfile" -execdir pod install \;
cd example && flutter build ios --debug --no-codesign
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ Setup melos to point to the dependencies in your local folder: `melos bootstrap`

### Android

Library requires kotlin version `1.5.31`.
Library requires kotlin version `1.8.21`.

### Update kotlin version

To update the kotlin version open Android studio and go to `Tools > Kotlin > Configure Kotlin plugin updates` and update `Update channel` to `1.5.x`.
To update the kotlin version open Android studio and go to `Tools > Kotlin > Configure Kotlin plugin updates` and update `Update channel` to `1.8.x`.

## Features

Expand Down
10 changes: 5 additions & 5 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
include: package:flutter_lints/flutter.yaml

analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
language:
# strict-casts: true -- DISABLED: was introduced in Dart 2.16
strict-inference: true
strict-raw-types: true
exclude:
- "bin/cache/**"
- "**/*.freezed.dart"
Expand All @@ -27,8 +28,7 @@ linter:
- empty_statements
- hash_and_equals
- invariant_booleans
- iterable_contains_unrelated_type
- list_remove_unrelated_type
- collection_methods_unrelated_type
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
- no_duplicate_case_values
Expand Down
6 changes: 2 additions & 4 deletions bin/quality_checks.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/bash -ex
#workaround for codemagic CI since melos is not in bash
echo 'export PATH="$PATH":"$FLUTTER_ROOT/.pub-cache/bin"' >>~/.bashrc
echo 'export PATH="$PATH":"$FLUTTER_ROOT/bin"' >>~/.bashrc
source ~/.bashrc
export PATH="$PATH:$FLUTTER_ROOT/.pub-cache/bin"
export PATH="$PATH:$FLUTTER_ROOT/bin"

dart pub global activate melos

Expand Down
58 changes: 0 additions & 58 deletions codemagic.yaml

This file was deleted.

10 changes: 6 additions & 4 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ android {
main.java.srcDirs += 'src/main/kotlin'
}

lintOptions {
disable 'InvalidPackage'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -48,7 +45,7 @@ android {
defaultConfig {
applicationId "com.signify.hue.reactivebleexample"
minSdkVersion 21
targetSdkVersion 31
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand All @@ -59,6 +56,11 @@ android {
signingConfig signingConfigs.debug
}
}
namespace 'com.signify.hue.reactivebleexample'

lint {
disable 'InvalidPackage'
}
}

flutter {
Expand Down
3 changes: 1 addition & 2 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.signify.hue.reactivebleexample">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<!-- required for API 18 - 30 -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.signify.hue.reactivebleexample


import androidx.annotation.NonNull
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant


class MainActivity: FlutterActivity(){
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine)
}
class MainActivity : FlutterActivity() {
override fun configureFlutterEngine(
@NonNull flutterEngine: FlutterEngine,
) {
GeneratedPluginRegistrant.registerWith(flutterEngine)
}
}
4 changes: 2 additions & 2 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.5.31'
ext.kotlin_version = '1.8.21'
repositories {
mavenCentral()
google()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.0.2'
classpath 'com.android.tools.build:gradle:8.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
5 changes: 4 additions & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
android.enableJetifier=true
android.defaults.buildfeatures.buildconfig=true
android.enableJetifier=false
android.nonFinalResIds=false
android.nonTransitiveRClass=false
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536M
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
18 changes: 7 additions & 11 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
include ':app'

def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()

def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }

plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}
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"
10 changes: 5 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ void main() {
logMessage: _bleLogger.addToLog,
);
final _serviceDiscoverer = BleDeviceInteractor(
bleDiscoverServices: _ble.discoverServices,
readCharacteristic: _ble.readCharacteristic,
writeWithResponse: _ble.writeCharacteristicWithResponse,
writeWithOutResponse: _ble.writeCharacteristicWithoutResponse,
subscribeToCharacteristic: _ble.subscribeToCharacteristic,
bleDiscoverServices: (deviceId) async {
await _ble.discoverAllServices(deviceId);
return _ble.getDiscoveredServices(deviceId);
},
logMessage: _bleLogger.addToLog,
readRssi: _ble.readRssi,
);
runApp(
MultiProvider(
Expand Down
2 changes: 1 addition & 1 deletion example/lib/src/ble/ble_device_connector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:flutter_reactive_ble_example/src/ble/reactive_state.dart';
class BleDeviceConnector extends ReactiveState<ConnectionStateUpdate> {
BleDeviceConnector({
required FlutterReactiveBle ble,
required Function(String message) logMessage,
required void Function(String message) logMessage,
}) : _ble = ble,
_logMessage = logMessage;

Expand Down
Loading

0 comments on commit 4834fcd

Please sign in to comment.