Commit 31d35513 by Maurits van Beusekom

Merge branch 'develop'

parents 76a08363 0a8daa15
MIT License
Copyright (c) 2020 Baseflow
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# 5.0.1+1
* Fixes Typo
* Issue #233 - on 5.0: Solved a bug that prevented Android applications running in the background to check the permission status.
# 5.0.1
* Update `permission_handler_platform_interface 2.0.1`
......
......@@ -63,7 +63,7 @@ final class PermissionConstants {
static final int PERMISSION_STATUS_GRANTED = 1;
static final int PERMISSION_STATUS_RESTRICTED = 2;
static final int PERMISSION_STATUS_NOT_DETERMINED = 3;
static final int PERMISSION_STATUS_NEWER_ASK_AGAIN = 4;
static final int PERMISSION_STATUS_NEVER_ASK_AGAIN = 4;
@Retention(RetentionPolicy.SOURCE)
@IntDef({
......@@ -71,7 +71,7 @@ final class PermissionConstants {
PERMISSION_STATUS_GRANTED,
PERMISSION_STATUS_RESTRICTED,
PERMISSION_STATUS_NOT_DETERMINED,
PERMISSION_STATUS_NEWER_ASK_AGAIN,
PERMISSION_STATUS_NEVER_ASK_AGAIN,
})
@interface PermissionStatus {
}
......
......@@ -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,12 +196,11 @@ 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)) {
return PermissionConstants.PERMISSION_STATUS_NEWER_ASK_AGAIN;
return PermissionConstants.PERMISSION_STATUS_NEVER_ASK_AGAIN;
} else {
return PermissionConstants.PERMISSION_STATUS_DENIED;
}
......
......@@ -11,7 +11,6 @@ import android.util.Log;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import java.util.ArrayList;
import java.util.Arrays;
......@@ -241,7 +240,7 @@ public class PermissionUtils {
static int toPermissionStatus(final Activity activity, final String permissionName, int grantResult) {
if (grantResult == PackageManager.PERMISSION_DENIED) {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && PermissionUtils.isNeverAskAgainSelected(activity, permissionName)
? PermissionConstants.PERMISSION_STATUS_NEWER_ASK_AGAIN
? PermissionConstants.PERMISSION_STATUS_NEVER_ASK_AGAIN
: PermissionConstants.PERMISSION_STATUS_DENIED;
}
......
......@@ -31,7 +31,7 @@ class MyApp extends StatelessWidget {
if (Platform.isIOS) {
return permission != Permission.unknown &&
permission != Permission.sms &&
permission != Permission.storage &&
//permission != Permission.storage &&
permission != Permission.ignoreBatteryOptimizations &&
permission != Permission.accessMediaLocation;
} else {
......
......@@ -3,7 +3,7 @@
#
Pod::Spec.new do |s|
s.name = 'permission_handler'
s.version = '5.0.1'
s.version = '5.0.1+1'
s.summary = 'Permission plugin for Flutter.'
s.description = <<-DESC
Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.
......
......@@ -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.
......
name: permission_handler
description: Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.
version: 5.0.1
version: 5.0.1+1
homepage: https://github.com/baseflowit/flutter-permission-handler
flutter:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment