From bf125ac46e88c08f9f863162da98d77f684f007c Mon Sep 17 00:00:00 2001 From: Dan Spencer Date: Thu, 21 Nov 2019 13:20:19 -0500 Subject: [PATCH 1/3] Added Date, Display, Notification, and Sound settings access for Android. iOS will still rely on App Settings. --- CHANGELOG.md | 7 +- README.md | 8 +- android/.idea/codeStyles/Project.xml | 134 ++++++++++++++---- .../org.eclipse.buildship.core.prefs | 2 +- .../example/appsettings/AppSettingsPlugin.kt | 8 ++ example/lib/main.dart | 40 ++++-- lib/app_settings.dart | 20 +++ pubspec.yaml | 2 +- 8 files changed, 179 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2efdbd..0204c3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,14 @@ ## Platform Specifics -The following setting options available on both iOS and Android: openWIFISettings, openLocationSettings, openSecuritySettings. +The following setting options available on both iOS and Android: openAppSettings, openWIFISettings, openLocationSettings, openSecuritySettings, openBluetoothSettings, openDataRoamingSettings, openDateSettings, openDisplaySettings, openNotificationSettings, openSoundSettings ### iOS All three options open the current 'app' settings section if there are settings defined. If no current settings are defined for the app the iPhone Settings Screen will be displayed. ### Android -Each option will open and display the corresponding screen: WIFI, Location, or Security. +Each option will open and display the corresponding screen: WIFI, Location, or Security, etc. + +## 2.0.2 +Added Date, Display, Notification, and Sound settings access for Android. iOS will still rely on App Settings. ## 2.0.1+1 Added Bluetooth & Data Roaming settings access for Android (more to come). iOS will still rely on App Settings. diff --git a/README.md b/README.md index 9acabb5..9170ae5 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ A Flutter plugin for opening iOS and Android phone settings from an app. dependencies: flutter: sdk: flutter - app_settings: 2.0.1+1 + app_settings: 2.0.2 ``` Next, import 'app_settings.dart' into your dart code. @@ -22,17 +22,17 @@ import 'package:app_settings/app_settings.dart'; ``` ## Platform Specifics -The following setting options available on both iOS and Android: openAppSettings, openWIFISettings, openLocationSettings, openSecuritySettings +The following setting options available on both iOS and Android: openAppSettings, openWIFISettings, openLocationSettings, openSecuritySettings, openBluetoothSettings, openDataRoamingSettings, openDateSettings, openDisplaySettings, openNotificationSettings, openSoundSettings ### iOS ***TIP: If using Objective-C for iOS in your project, you will need to add `use_frameworks!` to your `Runner project podfile` in order to use this Swift plugin:*** - target 'Runner' do use_frameworks! -All four options open the current 'app' settings section if there are settings defined. If no current settings are defined for the app the iPhone Settings Screen will be displayed. +All options open the current 'app' settings section if there are settings defined. If no current settings are defined for the app the iPhone Settings Screen will be displayed. ### Android -Each option will open and display the exact corresponding system settings screen: WIFI, Location, or Security. +Each option will open and display the exact corresponding system settings screen: WIFI, Location, or Security, etc. Using the openAppSettings option will open the current 'app' settings for the running app. diff --git a/android/.idea/codeStyles/Project.xml b/android/.idea/codeStyles/Project.xml index 30aa626..ae78c11 100644 --- a/android/.idea/codeStyles/Project.xml +++ b/android/.idea/codeStyles/Project.xml @@ -1,29 +1,113 @@ - - - - - - - - - - + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
\ No newline at end of file diff --git a/android/.settings/org.eclipse.buildship.core.prefs b/android/.settings/org.eclipse.buildship.core.prefs index e889521..6aa97a9 100644 --- a/android/.settings/org.eclipse.buildship.core.prefs +++ b/android/.settings/org.eclipse.buildship.core.prefs @@ -1,2 +1,2 @@ -connection.project.dir= +connection.project.dir=../example/android eclipse.preferences.version=1 diff --git a/android/src/main/kotlin/com/example/appsettings/AppSettingsPlugin.kt b/android/src/main/kotlin/com/example/appsettings/AppSettingsPlugin.kt index f6c3065..cab0aab 100644 --- a/android/src/main/kotlin/com/example/appsettings/AppSettingsPlugin.kt +++ b/android/src/main/kotlin/com/example/appsettings/AppSettingsPlugin.kt @@ -58,6 +58,14 @@ class AppSettingsPlugin: MethodCallHandler { openSettings(Settings.ACTION_BLUETOOTH_SETTINGS) } else if (call.method == "data_roaming") { openSettings(Settings.ACTION_DATA_ROAMING_SETTINGS) + } else if (call.method == "date") { + openSettings(Settings.ACTION_DATE_SETTINGS) + } else if (call.method == "display") { + openSettings(Settings.ACTION_DISPLAY_SETTINGS) + } else if (call.method == "notification") { + openSettings(Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS) + } else if (call.method == "sound") { + openSettings(Settings.ACTION_SOUND_SETTINGS) } else if (call.method == "app_settings") { openAppSettings() } diff --git a/example/lib/main.dart b/example/lib/main.dart index feeb9e2..80afd6e 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -39,10 +39,8 @@ class _MyAppState extends State { title: const Text('App Settings Example App'), ), body: GridView.count( - // Create a grid with 2 columns. If you change the scrollDirection to - // horizontal, this produces 2 rows. crossAxisCount: 2, - // Generate 100 widgets that display their index in the List. + childAspectRatio: 2, children: List.generate(actionItems.length, (index) { return Center( child: ButtonTheme( @@ -58,41 +56,65 @@ class _MyAppState extends State { actionItems.addAll([ RaisedButton( - child: Text("Open WIFI"), + child: Text("WIFI"), onPressed: () { AppSettings.openWIFISettings(); }, ), RaisedButton( - child: Text("Open Location"), + child: Text("Location"), onPressed: () { AppSettings.openLocationSettings(); }, ), RaisedButton( - child: Text("Open Security"), + child: Text("Security"), onPressed: () { AppSettings.openSecuritySettings(); }, ), RaisedButton( - child: Text("Open App Settings"), + child: Text("App Settings"), onPressed: () { AppSettings.openAppSettings(); }, ), RaisedButton( - child: Text("Open Bluetooth"), + child: Text("Bluetooth"), onPressed: () { AppSettings.openBluetoothSettings(); }, ), RaisedButton( - child: Text("Open Data Roaming"), + child: Text("Data Roaming"), onPressed: () { AppSettings.openDataRoamingSettings(); }, ), + RaisedButton( + child: Text("Date"), + onPressed: () { + AppSettings.openDateSettings(); + }, + ), + RaisedButton( + child: Text("Display"), + onPressed: () { + AppSettings.openDisplaySettings(); + }, + ), + RaisedButton( + child: Text("Notification"), + onPressed: () { + AppSettings.openNotificationSettings(); + }, + ), + RaisedButton( + child: Text("Sound"), + onPressed: () { + AppSettings.openSoundSettings(); + }, + ), ]); return actionItems; diff --git a/lib/app_settings.dart b/lib/app_settings.dart index 807ebbb..d008b2a 100644 --- a/lib/app_settings.dart +++ b/lib/app_settings.dart @@ -30,6 +30,26 @@ class AppSettings { _channel.invokeMethod('data_roaming'); } + /// Future async method call to open date settings. + static Future openDateSettings() async { + _channel.invokeMethod('date'); + } + + /// Future async method call to open display settings. + static Future openDisplaySettings() async { + _channel.invokeMethod('display'); + } + + /// Future async method call to open notification settings. + static Future openNotificationSettings() async { + _channel.invokeMethod('notification'); + } + + /// Future async method call to open sound settings. + static Future openSoundSettings() async { + _channel.invokeMethod('sound'); + } + /// Future async method call to open app specific settings screen. static Future openAppSettings() async { _channel.invokeMethod('app_settings'); diff --git a/pubspec.yaml b/pubspec.yaml index 26d2d18..0eda28d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: app_settings description: A Flutter plugin for opening iOS and Android phone settings from an app. -version: 2.0.1+1 +version: 2.0.2 author: Spencerccf homepage: https://github.com/spencerccf/app_settings From 07198240adc7f76e3086237f0a018cf966a201da Mon Sep 17 00:00:00 2001 From: Dan Spencer Date: Thu, 21 Nov 2019 13:22:43 -0500 Subject: [PATCH 2/3] Adding version from pub dart. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9170ae5..0e1b658 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ A Flutter plugin for opening iOS and Android phone settings from an app. dependencies: flutter: sdk: flutter - app_settings: 2.0.2 + app_settings: (https://pub.dartlang.org/packages/app_settings) ``` Next, import 'app_settings.dart' into your dart code. From 3e5fbb65ddf219de17ba51d2819234e3a0f92dc8 Mon Sep 17 00:00:00 2001 From: Dan Spencer Date: Thu, 21 Nov 2019 13:33:56 -0500 Subject: [PATCH 3/3] New version number. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e1b658..9170ae5 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ A Flutter plugin for opening iOS and Android phone settings from an app. dependencies: flutter: sdk: flutter - app_settings: (https://pub.dartlang.org/packages/app_settings) + app_settings: 2.0.2 ``` Next, import 'app_settings.dart' into your dart code.