-
Notifications
You must be signed in to change notification settings - Fork 58
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
Change checkPermission method return type in phone log plugin. #4
Changes from 7 commits
112d73f
082ad42
56a4469
4b7564c
43b25b3
ce7e145
9b5a926
9f6d039
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,14 @@ import 'package:fixnum/fixnum.dart'; | |
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/services.dart'; | ||
|
||
/// [PermissionStatus.granted] means that the permission is already granted. | ||
/// [PermissionStatus.denied] means that the permission is not granted yet. | ||
/// [PermissionStatus.deniedAndCannotRequest] means that the permission | ||
/// request is denied previously and user has checked 'never ask again' check | ||
/// box. In this case calling [requestPermission] method, the request | ||
/// permission dialog would not pop up. | ||
enum PermissionStatus {granted, denied, deniedAndCannotRequest} | ||
|
||
/// Provide methods to access and fetch the phone log. | ||
class PhoneLog { | ||
final MethodChannel _channel; | ||
|
@@ -17,13 +25,13 @@ class PhoneLog { | |
@visibleForTesting | ||
PhoneLog.private(MethodChannel platformChannel):_channel = platformChannel; | ||
|
||
/// Check a [permission] and return a [Future] with the result | ||
Future<bool> checkPermission() async { | ||
final bool isGranted = await _channel.invokeMethod("checkPermission", null); | ||
return isGranted; | ||
/// Check a [permission] and return a [Future] of the [PermissionStatus]. | ||
Future<PermissionStatus> checkPermission() async { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a breaking change. Please document it in CHANGELOG.md and up the version. Also update the documentation. "return a Future with the result" is not very informative. Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
final String status = await _channel.invokeMethod("checkPermission", null); | ||
return permissionMap[status]; | ||
} | ||
|
||
/// Request a [permission] and return a [Future] with the result | ||
/// Request a [permission] and return a [Future] of bool. | ||
Future<bool> requestPermission() async { | ||
final bool isGranted = | ||
await _channel.invokeMethod("requestPermission", null); | ||
|
@@ -44,6 +52,12 @@ class PhoneLog { | |
} | ||
} | ||
|
||
var permissionMap = <String, PermissionStatus>{ | ||
'granted': PermissionStatus.granted, | ||
'denied': PermissionStatus.denied, | ||
'deniedAndCannotRequest': PermissionStatus.deniedAndCannotRequest | ||
}; | ||
|
||
/// The class that carries all the data for one call history entry. | ||
class CallRecord { | ||
CallRecord({ | ||
|
@@ -52,6 +66,7 @@ class CallRecord { | |
this.callType, | ||
this.dateYear, | ||
this.dateMonth, | ||
this.dateDay, | ||
this.dateHour, | ||
this.dateMinute, | ||
this.dateSecond, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to change the pubspec.yaml file to rev the version to 0.0.3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thank you for catching this!