Skip to content

Commit

Permalink
Merge pull request #847 from bartekpacia/revive
Browse files Browse the repository at this point in the history
Revive the plugin
  • Loading branch information
bartekpacia committed Jul 10, 2023
2 parents d00c096 + 5358fab commit 5165086
Show file tree
Hide file tree
Showing 34 changed files with 256 additions and 197 deletions.
30 changes: 0 additions & 30 deletions .ci/Dockerfile

This file was deleted.

42 changes: 0 additions & 42 deletions .cirrus.yml

This file was deleted.

17 changes: 0 additions & 17 deletions .github/stale.yml

This file was deleted.

59 changes: 59 additions & 0 deletions .github/workflows/location-prepare.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: location prepare

on:
push:
branches: [master, develop]
tags-ignore: ['*']
pull_request:
branches: [master, develop]

jobs:
prepare-flutter:
name: Flutter ${{ matrix.flutter-version }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
flutter-version: ['3.0.x', '3.3.x', '3.7.x', '3.10.0']

steps:
- name: Clone repository
uses: actions/checkout@v3

- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ matrix.flutter-version }}

- name: Set up Melos
run: dart pub global activate melos ^2.0.0

- name: melos bootstrap
run: melos bootstrap

- name: Format and lint
if: success() || failure()
run: melos run lint:all

- name: Run tests
if: success() || failure()
run: melos run test --no-select

- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11

- name: Generate Gradle wrapper
working-directory: packages/location/example
run: flutter build apk --debug --flavor=does-not-exist || true

- name: Build example app with Gradle
working-directory: packages/location/example/android
run: ./gradlew :app:assembleDebug

- name: Build example app with Flutter tool
working-directory: packages/location/example
run: flutter build apk --debug
36 changes: 36 additions & 0 deletions .github/workflows/location-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: location publish

on:
push:
tags: ['location-v*']

jobs:
publish:
name: Publish on pub.dev
runs-on: ubuntu-latest

permissions:
id-token: write
contents: write

steps:
- name: Clone repository
uses: actions/checkout@v3

# This step adds the auth token for pub.dev
- name: Set up Dart
uses: dart-lang/setup-dart@v1
with:
sdk: stable

- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true

- name: Publish to pub.dev
id: pub_release
uses: leancodepl/mobile-tools/.github/actions/pub-release@pub-release-v1
with:
path: packages/location
36 changes: 36 additions & 0 deletions .github/workflows/location_platform_interface-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: location_platform_interface publish

on:
push:
tags: ['location_platform_interface-v*']

jobs:
publish:
name: Publish on pub.dev
runs-on: ubuntu-latest

permissions:
id-token: write
contents: write

steps:
- name: Clone repository
uses: actions/checkout@v3

# This step adds the auth token for pub.dev
- name: Set up Dart
uses: dart-lang/setup-dart@v1
with:
sdk: stable

- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true

- name: Publish to pub.dev
id: pub_release
uses: leancodepl/mobile-tools/.github/actions/pub-release@pub-release-v1
with:
path: packages/location_platform_interface
36 changes: 36 additions & 0 deletions .github/workflows/location_web-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: location_web publish

on:
push:
tags: ['location_web-v*']

jobs:
publish:
name: Publish on pub.dev
runs-on: ubuntu-latest

permissions:
id-token: write
contents: write

steps:
- name: Clone repository
uses: actions/checkout@v3

# This step adds the auth token for pub.dev
- name: Set up Dart
uses: dart-lang/setup-dart@v1
with:
sdk: stable

- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true

- name: Publish to pub.dev
id: pub_release
uses: leancodepl/mobile-tools/.github/actions/pub-release@pub-release-v1
with:
path: packages/location_web
2 changes: 1 addition & 1 deletion melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ scripts:
Run `dart analyze` in all packages.
- Note: you can also rely on your IDEs Dart Analysis / Issues window.
format:
run: melos exec -c 5 -- flutter format .
run: melos exec -c 5 -- dart format .
description: |
Format all files.
Expand Down
32 changes: 15 additions & 17 deletions packages/location/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ group 'com.lyokone.location'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.4.20'
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:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -25,29 +25,27 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 31
namespace "com.lyokone.location"
compileSdk 33

defaultConfig {
minSdkVersion 16
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
minSdk 16
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '11'
}
}

dependencies {
compileOnly 'androidx.annotation:annotation:1.0.0'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:1.10.19'
testImplementation 'androidx.test:core:1.0.0'
testImplementation 'org.robolectric:robolectric:4.3'

api 'com.google.android.gms:play-services-location:16.+'
implementation "androidx.core:core-ktx:1.3.2"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
compileOnly 'androidx.annotation:annotation:1.6.0'

api 'com.google.android.gms:play-services-location:21.0.1'
implementation "androidx.core:core-ktx:1.10.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import io.flutter.plugin.common.EventChannel.EventSink;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry;
import org.jetbrains.annotations.NotNull;

import java.util.HashMap;

Expand Down Expand Up @@ -118,7 +119,7 @@ void setActivity(@Nullable Activity activity) {
}

@Override
public boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
public boolean onRequestPermissionsResult(int requestCode, @NotNull String[] permissions, @NotNull int[] grantResults) {
return onRequestPermissionsResultHandler(requestCode, permissions, grantResults);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class FlutterLocationService : Service(), PluginRegistry.RequestPermissionsResul
val locationRequestPermissionsResultListener: PluginRegistry.RequestPermissionsResultListener?
get() = location

val serviceRequestPermissionsResultListener: PluginRegistry.RequestPermissionsResultListener?
val serviceRequestPermissionsResultListener: PluginRegistry.RequestPermissionsResultListener
get() = this

inner class LocalBinder : Binder() {
Expand All @@ -172,7 +172,7 @@ class FlutterLocationService : Service(), PluginRegistry.RequestPermissionsResul
)
}

override fun onBind(intent: Intent?): IBinder? {
override fun onBind(intent: Intent?): IBinder {
Log.d(TAG, "Binding to location service.")
return binder
}
Expand Down Expand Up @@ -256,9 +256,9 @@ class FlutterLocationService : Service(), PluginRegistry.RequestPermissionsResul
}

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray): Boolean {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && requestCode == REQUEST_PERMISSIONS_REQUEST_CODE && permissions!!.size == 2 &&
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && requestCode == REQUEST_PERMISSIONS_REQUEST_CODE && permissions.size == 2 &&
permissions[0] == Manifest.permission.ACCESS_FINE_LOCATION && permissions[1] == Manifest.permission.ACCESS_BACKGROUND_LOCATION) {
if (grantResults!![0] == PackageManager.PERMISSION_GRANTED && grantResults[1] == PackageManager.PERMISSION_GRANTED) {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED && grantResults[1] == PackageManager.PERMISSION_GRANTED) {
// Permissions granted, background mode can be enabled
enableBackgroundMode()
result?.success(1)
Expand Down
Loading

0 comments on commit 5165086

Please sign in to comment.