Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
permission_handler
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
songyanzhi
permission_handler
Commits
dca891c3
Commit
dca891c3
authored
Jun 15, 2020
by
Sebastian Roth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the need for Activity to determine the permission status
parent
912c24d5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
12 deletions
+8
-12
permission_handler/android/src/main/java/com/baseflow/permissionhandler/PermissionManager.java
+4
-12
permission_handler/lib/permission_handler.dart
+4
-0
No files found.
permission_handler/android/src/main/java/com/baseflow/permissionhandler/PermissionManager.java
View file @
dca891c3
...
...
@@ -10,6 +10,7 @@ import android.os.PowerManager;
import
android.provider.Settings
;
import
android.util.Log
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.VisibleForTesting
;
import
androidx.core.app.ActivityCompat
;
import
androidx.core.app.NotificationManagerCompat
;
...
...
@@ -57,14 +58,6 @@ final class PermissionManager {
CheckPermissionsSuccessCallback
successCallback
,
ErrorCallback
errorCallback
)
{
if
(
activity
==
null
)
{
Log
.
d
(
PermissionConstants
.
LOG_TAG
,
"Activity cannot be null."
);
errorCallback
.
onError
(
"PermissionHandler.PermissionManager"
,
"Android activity is required to check for permissions and cannot be null."
);
return
;
}
successCallback
.
onSuccess
(
determinePermissionStatus
(
permission
,
context
,
...
...
@@ -78,7 +71,7 @@ final class PermissionManager {
PermissionRegistry
permissionRegistry
,
RequestPermissionsSuccessCallback
successCallback
,
ErrorCallback
errorCallback
)
{
if
(
ongoing
)
{
if
(
ongoing
)
{
errorCallback
.
onError
(
"PermissionHandler.PermissionManager"
,
"A request for permissions is already running, please wait for it to finish before doing another request (note that you can request multiple permissions at the same time)."
);
...
...
@@ -162,7 +155,7 @@ final class PermissionManager {
private
int
determinePermissionStatus
(
@PermissionConstants
.
PermissionGroup
int
permission
,
Context
context
,
Activity
activity
)
{
@Nullable
Activity
activity
)
{
if
(
permission
==
PermissionConstants
.
PERMISSION_GROUP_NOTIFICATION
)
{
return
checkNotificationPermissionStatus
(
context
);
...
...
@@ -203,8 +196,7 @@ final class PermissionManager {
}
final
int
permissionStatus
=
ContextCompat
.
checkSelfPermission
(
context
,
name
);
if
(
permissionStatus
==
PackageManager
.
PERMISSION_DENIED
)
{
if
(!
PermissionUtils
.
getRequestedPermissionBefore
(
context
,
name
))
{
if
(!
PermissionUtils
.
getRequestedPermissionBefore
(
context
,
name
))
{
return
PermissionConstants
.
PERMISSION_STATUS_NOT_DETERMINED
;
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
&&
PermissionUtils
.
isNeverAskAgainSelected
(
activity
,
name
))
{
...
...
permission_handler/lib/permission_handler.dart
View file @
dca891c3
...
...
@@ -23,6 +23,10 @@ Future<bool> openAppSettings() => _handler.openAppSettings();
/// Actions that can be executed on a permission.
extension
PermissionActions
on
Permission
{
/// The current status of this permission.
///
/// The Android-only [PermissionStatus.permanentlyDenied] status will only be
/// calculated if the active context is an Activity. If it isn't,
/// [PermissionStatus.denied] will be returned.
Future
<
PermissionStatus
>
get
status
=>
_handler
.
checkPermissionStatus
(
this
);
/// If you should show a rationale for requesting permission.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment