Skip to content

Commit

Permalink
Merge pull request #25 from spencerccf/adding-additional-settings
Browse files Browse the repository at this point in the history
Adding additional settings
  • Loading branch information
spencerccf authored Nov 21, 2019
2 parents 803d981 + 3e5fbb6 commit 53475d2
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 42 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.

Expand Down
134 changes: 109 additions & 25 deletions android/.idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion android/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
connection.project.dir=
connection.project.dir=../example/android
eclipse.preferences.version=1
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
40 changes: 31 additions & 9 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ class _MyAppState extends State<MyApp> {
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(
Expand All @@ -58,41 +56,65 @@ class _MyAppState extends State<MyApp> {

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;
Expand Down
20 changes: 20 additions & 0 deletions lib/app_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ class AppSettings {
_channel.invokeMethod('data_roaming');
}

/// Future async method call to open date settings.
static Future<void> openDateSettings() async {
_channel.invokeMethod('date');
}

/// Future async method call to open display settings.
static Future<void> openDisplaySettings() async {
_channel.invokeMethod('display');
}

/// Future async method call to open notification settings.
static Future<void> openNotificationSettings() async {
_channel.invokeMethod('notification');
}

/// Future async method call to open sound settings.
static Future<void> openSoundSettings() async {
_channel.invokeMethod('sound');
}

/// Future async method call to open app specific settings screen.
static Future<void> openAppSettings() async {
_channel.invokeMethod('app_settings');
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
homepage: https://github.com/spencerccf/app_settings

Expand Down

0 comments on commit 53475d2

Please sign in to comment.