Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

From Ichinke :Suggested in Issue #13 #17

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ class Channels(private val permissionClient: PermissionClient,
}

private fun startMonitoring(request: DataRequest, result: MethodChannel.Result) {
launch(UI) {
result.success(beaconsClient.startMonitoring(request))
}
var operation: BeaconsClient.Operation? = null operation = BeaconsClient.Operation(BeaconsClient.Operation.Kind.Monitoring, request.region, request.inBackground) { result ->} beaconsClient.addRequest(operation!!, request.permission) result.success(null)
}

private fun stopMonitoring(region: RegionModel, result: MethodChannel.Result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class SharedMonitor(private val application: Application,

fun attachForegroundNotifier(notifier: MonitorNotifier) {
Log.d(Tag, "attach foreground notifier")
this.foregroundNotifier = notifier
this.foregroundNotifier = null

// foreground notifier being attached means background logic is already processed
// or not needed anymore
Expand All @@ -50,7 +50,7 @@ class SharedMonitor(private val application: Application,

fun detachForegroundNotifier(notifier: MonitorNotifier) {
Log.d(Tag, "detach foreground notifier")
check(this.foregroundNotifier == notifier)
// check(this.foregroundNotifier == notifier)
this.foregroundNotifier = null
}

Expand Down
19 changes: 0 additions & 19 deletions example/.idea/libraries/Dart_SDK.xml

This file was deleted.

6 changes: 6 additions & 0 deletions example/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 0 additions & 36 deletions example/.idea/workspace.xml

This file was deleted.

2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "io.intheloup.beaconsexample"
minSdkVersion 16
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
Expand Down
1 change: 0 additions & 1 deletion example/beacons_example.iml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Flutter Plugins" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component>
</module>
3 changes: 2 additions & 1 deletion example/beacons_example_android.iml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Flutter for Android" level="project" />
<orderEntry type="library" name="Dart SDK" level="project" />
</component>
</module>
</module>
6 changes: 3 additions & 3 deletions example/lib/header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

/// [Header] in the UI needs to fill either [Generics] or [iBeacon/Eddystone]
/// on a [TextEdittingController]
class Header extends StatefulWidget {
const Header(
{Key key, this.regionIdentifier, this.running, this.onStart, this.onStop})
Expand Down Expand Up @@ -38,9 +40,7 @@ class _HeaderState extends State<Header> {
_formType = Platform.isIOS ? FormType.iBeacon : FormType.generic;

_id1Controller = TextEditingController(
text: _formType == FormType.iBeacon
? '7da11b71-6f6a-4b6d-81c0-8abd031e6113'
: 'C336AA38-54BB-483B-AE75-3BA707855035',
text: _formType == FormType.iBeacon ? '' : '',
);
_id2Controller = TextEditingController();
_id3Controller = TextEditingController();
Expand Down
7 changes: 5 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import 'package:beacons/beacons.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// import 'package:flutter_blue/flutter_blue.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:flutter_local_notifications/initialization_settings.dart';
import 'package:flutter_local_notifications/notification_details.dart';
Expand All @@ -23,7 +24,7 @@ class MyApp extends StatefulWidget {

int notifId = 0;

Beacons.backgroundMonitoringEvents().listen((event) {
Beacons.backgroundMonitoringEvents().listen((event) async {
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
new FlutterLocalNotificationsPlugin();
InitializationSettingsAndroid initializationSettingsAndroid =
Expand All @@ -42,11 +43,12 @@ class MyApp extends StatefulWidget {
new NotificationDetailsIOS();
NotificationDetails platformChannelSpecifics = new NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
flutterLocalNotificationsPlugin.show(
await flutterLocalNotificationsPlugin.show(
++notifId,
event.type.toString(),
event.state.toString(),
platformChannelSpecifics,
payload: event.state.toString(),
);
});

Expand All @@ -65,6 +67,7 @@ class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return new MaterialApp(
showPerformanceOverlay: true,
home: new CupertinoTabScaffold(
tabBar: new CupertinoTabBar(
items: <BottomNavigationBarItem>[
Expand Down
5 changes: 3 additions & 2 deletions example/lib/tab_ranging.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ class RangingTab extends ListTab {
.ranging(
region: region,
inBackground: false,
permission: LocationPermission(android: LocationPermissionAndroid.coarse),
)
.map((result) {
String text;
if (result.isSuccessful) {
if (result.isSuccessful == true) {
text = result.beacons.isNotEmpty
? 'RSSI: ${result.beacons.first.rssi}'
? 'DISTANCE: ${result.beacons.first.distance.toStringAsFixed(2)}'
: 'No beacon in range';
} else {
text = result.error.toString();
Expand Down
61 changes: 0 additions & 61 deletions example/pubspec.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions lib/beacons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ part 'data/result.dart';

part 'data/settings.dart';

///
///
class Beacons {
static Future<void> configure(BeaconsSettings settings) =>
_channel.configure(settings);
Expand Down
4 changes: 3 additions & 1 deletion lib/channel/channels.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ class _Channels {
return;
}

Future<BeaconsResult> startMonitoring(_DataRequest request) async {
/// return `;`
/// It returns nothing, suggest in [Issue #13](https://github.com/loup-v/beacons/issues/13)
Future<void> startMonitoring(_DataRequest request) async {
final response = await _invokeChannelMethod(
_loggingTag,
_channel,
Expand Down
9 changes: 7 additions & 2 deletions lib/data/beacon_region.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

part of beacons;

///
///
///
class BeaconRegion {
BeaconRegion({
@required this.identifier,
Expand All @@ -15,12 +18,14 @@ class BeaconRegion {
final String bluetoothAddress;
}

///TODO: An iBeacon can have a [UUID] and Optional [Major] and [Minor];
///
class BeaconRegionIBeacon extends BeaconRegion {
BeaconRegionIBeacon({
@required String identifier,
@required String proximityUUID,
int major,
int minor,
String major,
String minor,
}) : super(
identifier: identifier,
ids: [],
Expand Down