Commit c5fe2915 by daniel.roek

Merge remote-tracking branch 'origin/develop' into remove_shared_pref

# Conflicts:
#	permission_handler/example/ios/Flutter/Flutter.podspec
#	permission_handler/pubspec.yaml
parents 16c13f4f f557526b
# This is a basic workflow to help you get started with Actions
name: app_facing_package
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the develop branch
on:
push:
branches: [ master, develop ]
paths:
- 'permission_handler/**'
pull_request:
branches: [ master, develop ]
paths:
- 'permission_handler/**'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# Job configuration for the permission_handler (App Facing Package)
permission_handler:
# The type of runner that the job will run on
runs-on: macos-latest
env:
source-directory: ./permission_handler
example-directory: ./permission_handler/example
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Make sure the stable version of Flutter is available
- uses: subosito/flutter-action@v1
with:
channel: 'beta'
# Download all Flutter packages the permission_handler depends on
- name: Download dependencies
run: flutter pub get
working-directory: ${{env.source-directory}}
# Run Flutter Format to ensure formatting is valid
- name: Run Flutter Format
run: flutter format --set-exit-if-changed lib
working-directory: ${{env.source-directory}}
# Run Flutter Analyzer
- name: Run Flutter Analyzer
run: flutter analyze
working-directory: ${{env.source-directory}}
# Build Android version of the example app
- name: Run Android build
run: flutter build apk --release
working-directory: ${{env.example-directory}}
# Build iOS version of the example app
- name: Run iOS build
run: flutter build ios --release --no-codesign
working-directory: ${{env.example-directory}}
# This is a basic workflow to help you get started with Actions
name: platform_interface_package
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the develop branch
on:
push:
branches: [ master, develop ]
paths:
- 'permission_handler_platform_interface/**'
pull_request:
branches: [ master, develop ]
paths:
- 'permission_handler_platform_interface/**'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# Job configuration for the permission_handler_platform_interface (Platform Interface Package)
permission_handler_platform_interface:
# The type of runner that the job will run on
runs-on: macos-latest
env:
source-directory: ./permission_handler_platform_interface
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Make sure the stable version of Flutter is available
- uses: subosito/flutter-action@v1
with:
channel: 'beta'
# Download all Flutter packages the permission_handler_platform_interface depends on
- name: Download dependencies
run: flutter pub get
working-directory: ${{env.source-directory}}
# Run Flutter Format to ensure formatting is valid
- name: Run Flutter Format
run: flutter format --set-exit-if-changed lib
working-directory: ${{env.source-directory}}
# Run Flutter Analyzer
- name: Run Flutter Analyzer
run: flutter analyze
working-directory: ${{env.source-directory}}
[![pub package](https://img.shields.io/pub/v/permission_handler.svg)](https://pub.dartlang.org/packages/permission_handler) [![Build Status](https://app.bitrise.io/app/fa4f5d4bf452bcfb/status.svg?token=HorGpL_AOw2llYz39CjmdQ&branch=master)](https://app.bitrise.io/app/fa4f5d4bf452bcfb) [![style: effective dart](https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://github.com/tenhobi/effective_dart)
[![pub package](https://img.shields.io/pub/v/permission_handler.svg)](https://pub.dartlang.org/packages/permission_handler) ![Build status](https://github.com/Baseflow/flutter-permission-handler/workflows/permission_handler/badge.svg?branch=master) [![style: effective dart](https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://github.com/tenhobi/effective_dart)
On most operating systems, permissions aren't just granted to apps at install time.
Rather, developers have to ask the user for permissions while the app is running.
......
# 5.1.0+2
## 6.0.0
* Migrated to null safety
## 5.1.0+2
* Solve mismatch with permission constants between Dart and Android (due to addition of permission on iOS);
* Fix compile error which occurred when on iOS the "PERMISSION_PHOTOS" macro is deactivated (meaning code dealing with the `PHPhotoLibrary` library is removed from the code base).
# 5.1.0+1
## 5.1.0+1
* Recreate the iOS part of the example project based on the Flutter stable channel (previous version was accidentally created with the Flutter beta channel).
# 5.1.0
## 5.1.0
* Added support for the limited photos permission available on iOS 14 and up;
* Fixed deprecated warning on iOS;
* Added support for the "READ_PHONE_NUMBERS" permission on Android;
* Fix a link to the contribution guide in the README.md.
# 5.0.1+1
## 5.0.1+2
* Pin dependency on permission_handler_platform_interface on version 2.0.1.
## 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
## 5.0.1
* Update `permission_handler_platform_interface 2.0.1`
# 5.0.0+hotfix.10
## 5.0.0+hotfix.10
* Revert pull-request [#317](https://github.com/Baseflow/flutter-permission-handler/pull/317)
# 5.0.0+hotfix.9
## 5.0.0+hotfix.9
* Solved an issue where kCLAuthorizationStatusAuthorizedWhenInUse was returning PermissionStatusDenied (see [#317](https://github.com/Baseflow/flutter-permission-handler/pull/317))
......
[![pub package](https://img.shields.io/pub/v/permission_handler.svg)](https://pub.dartlang.org/packages/permission_handler) [![Build Status](https://app.bitrise.io/app/fa4f5d4bf452bcfb/status.svg?token=HorGpL_AOw2llYz39CjmdQ&branch=master)](https://app.bitrise.io/app/fa4f5d4bf452bcfb) [![style: effective dart](https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://github.com/tenhobi/effective_dart)
# permission_handler_platform_interface
On most operating systems, permissions aren't just granted to apps at install time.
Rather, developers have to ask the user for permissions while the app is running.
[![pub package](https://img.shields.io/pub/v/permission_handler.svg)](https://pub.dartlang.org/packages/permission_handler) ![Build status](https://github.com/Baseflow/flutter-permission-handler/workflows/app_facing_package/badge.svg?branch=master) [![style: effective dart](https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://github.com/tenhobi/effective_dart)
This plugin provides a cross-platform (iOS, Android) API to request permissions and check their status.
You can also open the device's app settings so users can grant a permission.
On Android, you can show a rationale for requesting a permission.
A common platform interface for the [`permission_handler`][1] plugin.
## Setup
This interface allows platform-specific implementations of the `permission_handler`
plugin, as well as the plugin itself, to ensure they are supporting the
same interface. Have a look at the [Federated plugins](https://flutter.dev/docs/development/packages-and-plugins/developing-packages#federated-plugins)
section of the official [Developing packages & plugins](https://flutter.dev/docs/development/packages-and-plugins/developing-packages)
documentation for more information regarding the federated architecture concept.
While the permissions are being requested during runtime, you'll still need to tell the OS which permissions your app might potentially use. That requires adding permission configuration to Android- and iOS-specific files.
## Usage
<details>
<summary>Android</summary>
**Upgrade pre 1.12 Android projects**
Since version 4.4.0 this plugin is implemented using the Flutter 1.12 Android plugin APIs. Unfortunately this means App developers also need to migrate their Apps to support the new Android infrastructure. You can do so by following the [Upgrading pre 1.12 Android projects](https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects) migration guide. Failing to do so might result in unexpected behaviour. Most common known error is the permission_handler not returning after calling the `.request()` method on a permission.
To implement a new platform-specific implementation of `permission_handler`, extend
[`PermissionHandlerPlatform`][2] with an implementation that performs the
platform-specific behavior, and when you register your plugin, set the default
`PermissionHandlerPlatform` by calling
`PermissionHandlerPlatform.instance = MyPlatformPermissionHandler()`.
**AndroidX**
## Note on breaking changes
As of version 3.1.0 the <kbd>permission_handler</kbd> plugin switched to the AndroidX version of the Android Support Libraries. This means you need to make sure your Android project is also upgraded to support AndroidX. Detailed instructions can be found [here](https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility).
Strongly prefer non-breaking changes (such as adding a method to the interface)
over breaking changes for this package.
The TL;DR version is:
1. Add the following to your "gradle.properties" file:
```
android.useAndroidX=true
android.enableJetifier=true
```
2. Make sure you set the `compileSdkVersion` in your "android/app/build.gradle" file to 28:
```
android {
compileSdkVersion 28
...
}
```
3. Make sure you replace all the `android.` dependencies to their AndroidX counterparts (a full list can be found here: https://developer.android.com/jetpack/androidx/migrate).
Add permissions to your `AndroidManifest.xml` file.
There's a `debug`, `main` and `profile` version which are chosen depending on how you start your app.
In general, it's sufficient to add permission only to the `main` version.
[Here]((https://github.com/Baseflow/flutter-permission-handler/blob/develop/example/android/app/src/main/AndroidManifest.xml))'s an example `AndroidManifest.xml` with a complete list of all possible permissions.
</details>
<details>
<summary>iOS</summary>
Add permission to your `Info.plist` file.
[Here](https://github.com/Baseflow/flutter-permission-handler/blob/develop/permission_handler/example/ios/Runner/Info.plist)'s an example `Info.plist` with a complete list of all possible permissions.
> IMPORTANT: ~~You will have to include all permission options when you want to submit your App.~~ This is because the `permission_handler` plugin touches all different SDKs and because the static code analyser (run by Apple upon App submission) detects this and will assert if it cannot find a matching permission option in the `Info.plist`. More information about this can be found [here](https://github.com/BaseflowIT/flutter-permission-handler/issues/26).
The <kbd>permission_handler</kbd> plugin use [macros](https://github.com/BaseflowIT/flutter-permission-handler/blob/develop/permission_handler/ios/Classes/PermissionHandlerEnums.h) to control whether a permission is supported.
You can remove permissions you don't use:
1. Add the following to your `Podfile` file:
```ruby
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
... # Here are some configurations automatically generated by flutter
# You can remove unused permissions here
# for more infomation: https://github.com/BaseflowIT/flutter-permission-handler/blob/develop/permission_handler/ios/Classes/PermissionHandlerEnums.h
# e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
## dart: PermissionGroup.calendar
# 'PERMISSION_EVENTS=0',
## dart: PermissionGroup.reminders
# 'PERMISSION_REMINDERS=0',
## dart: PermissionGroup.contacts
# 'PERMISSION_CONTACTS=0',
## dart: PermissionGroup.camera
# 'PERMISSION_CAMERA=0',
## dart: PermissionGroup.microphone
# 'PERMISSION_MICROPHONE=0',
## dart: PermissionGroup.speech
# 'PERMISSION_SPEECH_RECOGNIZER=0',
## dart: PermissionGroup.photos
# 'PERMISSION_PHOTOS=0',
## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
# 'PERMISSION_LOCATION=0',
## dart: PermissionGroup.notification
# 'PERMISSION_NOTIFICATIONS=0',
## dart: PermissionGroup.mediaLibrary
# 'PERMISSION_MEDIA_LIBRARY=0',
## dart: PermissionGroup.sensors
# 'PERMISSION_SENSORS=0'
]
end
end
end
```
2. Remove the `#` character in front of the permission you do not want to use. For example if you don't need access to the calendar make sure the code looks like this:
```ruby
## dart: PermissionGroup.calendar
'PERMISSION_EVENTS=0',
```
3. Delete the corresponding permission description in `Info.plist`
e.g. when you don't need camera permission, just delete 'NSCameraUsageDescription'
The following lists the relationship between `Permission` and `The key of Info.plist`:
| Permission | Info.plist | Macro |
| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ---------------------------- |
| PermissionGroup.calendar | NSCalendarsUsageDescription | PERMISSION_EVENTS |
| PermissionGroup.reminders | NSRemindersUsageDescription | PERMISSION_REMINDERS |
| PermissionGroup.contacts | NSContactsUsageDescription | PERMISSION_CONTACTS |
| PermissionGroup.camera | NSCameraUsageDescription | PERMISSION_CAMERA |
| PermissionGroup.microphone | NSMicrophoneUsageDescription | PERMISSION_MICROPHONE |
| PermissionGroup.speech | NSSpeechRecognitionUsageDescription | PERMISSION_SPEECH_RECOGNIZER |
| PermissionGroup.photos | NSPhotoLibraryUsageDescription | PERMISSION_PHOTOS |
| PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse | NSLocationUsageDescription, NSLocationAlwaysAndWhenInUseUsageDescription, NSLocationWhenInUseUsageDescription | PERMISSION_LOCATION |
| PermissionGroup.notification | PermissionGroupNotification | PERMISSION_NOTIFICATIONS |
| PermissionGroup.mediaLibrary | NSAppleMusicUsageDescription, kTCCServiceMediaLibrary | PERMISSION_MEDIA_LIBRARY |
| PermissionGroup.sensors | NSMotionUsageDescription | PERMISSION_SENSORS |
4. Clean & Rebuild
</details>
## How to use
There are a number of [`Permission`](https://pub.dev/documentation/permission_handler_platform_interface/latest/permission_handler_platform_interface/Permission-class.html#constants)s.
You can get a `Permission`'s `status`, which is either `undetermined`, `granted`, `denied`, `restricted` or `permanentlyDenied`.
```dart
var status = await Permission.camera.status;
if (status.isUndetermined) {
// We didn't ask for permission yet.
}
// You can can also directly ask the permission about its status.
if (await Permission.location.isRestricted) {
// The OS restricts access, for example because of parental controls.
}
```
Call `request()` on a `Permission` to request it.
If it has already been granted before, nothing happens.
`request()` returns the new status of the `Permission`.
```dart
if (await Permission.contacts.request().isGranted) {
// Either the permission was already granted before or the user just granted it.
}
// You can request multiple permissions at once.
Map<Permission, PermissionStatus> statuses = await [
Permission.location,
Permission.storage,
].request();
print(statuses[Permission.location]);
```
Some permissions, for example location or acceleration sensor permissions, have an associated service, which can be `enabled` or `disabled`.
```dart
if (await Permission.locationWhenInUse.serviceStatus.isEnabled) {
// Use location.
}
```
You can also open the app settings:
```dart
if (await Permission.speech.isPermanentlyDenied) {
// The user opted to never again see the permission request dialog for this
// app. The only way to change the permission's status now is to let the
// user manually enable it in the system settings.
openAppSettings();
}
```
On Android, you can show a rationale for using a permission:
```dart
bool isShown = await Permission.contacts.shouldShowRequestRationale;
```
See https://flutter.dev/go/platform-interface-breaking-changes for a discussion
on why a less-clean interface is preferable to a breaking change.
## Issues
......
#
# NOTE: This podspec is NOT to be published. It is only used as a local source!
# This is a generated file; do not edit or check into version control.
#
Pod::Spec.new do |s|
s.name = 'Flutter'
s.version = '1.0.0'
s.summary = 'High-performance, high-fidelity mobile apps.'
s.homepage = 'https://flutter.io'
s.license = { :type => 'MIT' }
s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
s.ios.deployment_target = '8.0'
# Framework linking is handled by Flutter tooling, not CocoaPods.
# Add a placeholder to satisfy `s.dependency 'Flutter'` plugin podspecs.
s.vendored_frameworks = 'path/to/nothing'
end
......@@ -2,6 +2,6 @@
<Workspace
version = "1.0">
<FileRef
location = "group:Runner.xcodeproj">
location = "self:">
</FileRef>
</Workspace>
......@@ -70,7 +70,7 @@ class _PermissionState extends State<PermissionWidget> {
}
void checkServiceStatus(BuildContext context, Permission permission) async {
Scaffold.of(context).showSnackBar(SnackBar(
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text((await permission.status).toString()),
));
}
......
......@@ -74,11 +74,13 @@ class InfoPage extends StatelessWidget {
margin: const EdgeInsets.only(top: 24.0),
alignment: Alignment.center,
child: SizedBox.expand(
child: RaisedButton(
textTheme: Theme.of(context).buttonTheme.textTheme,
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)),
padding: const EdgeInsets.all(8),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.all(8),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
),
child: Text(text),
onPressed: () => _launchURL(url),
),
......
......@@ -2,7 +2,7 @@ name: permission_handler_example
description: Demonstrates how to use the permission_handler plugin.
environment:
sdk: ">=2.12.0-0 <3.0.0"
sdk: ">=2.12.0-259.9.beta <3.0.0"
dependencies:
flutter:
......@@ -15,7 +15,7 @@ dev_dependencies:
permission_handler:
path: ../
url_launcher: ^6.0.0-nullsafety.6
url_launcher: ^6.0.0
flutter:
uses-material-design: true
......
......@@ -47,7 +47,7 @@ extension PermissionActions on Permission {
/// Returns the new [PermissionStatus].
Future<PermissionStatus> request() async {
final permissionStatus = (await [this].request())[this];
return permissionStatus!;
return permissionStatus ?? PermissionStatus.denied;
}
}
......
name: permission_handler
description: Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.
version: 6.0.0-nullsafety
version: 6.0.0
homepage: https://github.com/baseflowit/flutter-permission-handler
flutter:
......@@ -16,13 +16,12 @@ dependencies:
flutter:
sdk: flutter
meta: ^1.3.0
permission_handler_platform_interface: #^3.0.0-nullsafety.1
path: ../permission_handler_platform_interface
permission_handler_platform_interface: ^3.0.0
dev_dependencies:
effective_dart: ^1.3.0
plugin_platform_interface: ^1.0.3
plugin_platform_interface: ^2.0.0
environment:
sdk: ">=2.12.0-0 <3.0.0"
sdk: ">=2.12.0-259.9.beta <3.0.0"
flutter: ">=1.12.8 <2.0.0"
## 3.0.0-nullsafety
## 3.0.0
* Migrated to null safety.
......
# permission_handler_platform_interface
[![pub package](https://img.shields.io/pub/v/permission_handler_platform_interface.svg)](https://pub.dartlang.org/packages/permission_handler_platform_interface) [![style: effective dart](https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://github.com/tenhobi/effective_dart)
[![pub package](https://img.shields.io/pub/v/permission_handler_platform_interface.svg)](https://pub.dartlang.org/packages/permission_handler_platform_interface) ![Build status](https://github.com/Baseflow/flutter-permission-handler/workflows/platform_interface_package/badge.svg?branch=master) [![style: effective dart](https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://github.com/tenhobi/effective_dart)
A common platform interface for the [`permission_handler`][1] plugin.
......
......@@ -51,8 +51,7 @@ class MethodChannelPermissionHandler extends PermissionHandlerPlatform {
/// Returns [true] if the app settings page could be opened, otherwise
/// [false].
Future<bool> openAppSettings() async {
final wasOpened =
await _methodChannel.invokeMethod('openAppSettings');
final wasOpened = await _methodChannel.invokeMethod('openAppSettings');
return wasOpened ?? false;
}
......
......@@ -3,20 +3,20 @@ description: A common platform interface for the permission_handler plugin.
homepage: https://github.com/baseflow/flutter-permission-handler/tree/master/permission_handler_platform_interface
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 3.0.0-nullsafety
version: 3.0.0
dependencies:
flutter:
sdk: flutter
meta: ^1.0.5
plugin_platform_interface: ^1.1.0-nullsafety
plugin_platform_interface: ^2.0.0
dev_dependencies:
flutter_test:
sdk: flutter
mockito: ^5.0.0-nullsafety
mockito: ^5.0.0
effective_dart: ^1.3.0
environment:
sdk: ">=2.12.0-0 <3.0.0"
flutter: ">=1.9.1+hotfix.4 <2.0.0"
sdk: ">=2.12.0-259.9.beta <3.0.0"
flutter: ">=1.22.0"
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