From 5970d42414aaa9582aa1bf856d4c6a5977392696 Mon Sep 17 00:00:00 2001 From: zeemyself Date: Wed, 12 Feb 2020 17:46:47 +0700 Subject: [PATCH] Add sound settings --- README.md | 3 +++ .../androidopensettings/AndroidOpenSettings.java | 12 +++++++++++- index.d.ts | 1 + index.js | 3 +++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 41a0314..28c99a3 100644 --- a/README.md +++ b/README.md @@ -121,4 +121,7 @@ AndroidOpenSettings.deviceInfoSettings() // Open application notification settings menu AndroidOpenSettings.appNotificationSettings() + +// Open sound settings menu +AndroidOpenSettings.soundSettings() ``` diff --git a/android/src/main/java/com/levelasquez/androidopensettings/AndroidOpenSettings.java b/android/src/main/java/com/levelasquez/androidopensettings/AndroidOpenSettings.java index 97f57a9..d0e113d 100644 --- a/android/src/main/java/com/levelasquez/androidopensettings/AndroidOpenSettings.java +++ b/android/src/main/java/com/levelasquez/androidopensettings/AndroidOpenSettings.java @@ -32,7 +32,7 @@ public void generalSettings() { reactContext.startActivity(intent); } } - + @ReactMethod public void homeSettings() { Intent intent = new Intent(Settings.ACTION_HOME_SETTINGS); @@ -231,4 +231,14 @@ public void appNotificationSettings() { reactContext.startActivity(intent); } } + + @ReactMethod + public void soundSettings() { + Intent intent = new Intent(Settings.ACTION_SOUND_SETTINGS); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); + if (intent.resolveActivity(reactContext.getPackageManager()) != null) { + reactContext.startActivity(intent); + } + } } diff --git a/index.d.ts b/index.d.ts index cdb6e2c..458d9e8 100644 --- a/index.d.ts +++ b/index.d.ts @@ -19,4 +19,5 @@ declare module "react-native-android-open-settings" { const applicationSettings: () => void; const deviceInfoSettings: () => void; const appNotificationSettings: () => void; + const soundSettings: () => void; } diff --git a/index.js b/index.js index 2d6156d..fbf9892 100644 --- a/index.js +++ b/index.js @@ -42,6 +42,8 @@ const deviceInfoSettings = () => RNAndroidOpenSettings.deviceInfoSettings() const appNotificationSettings = () => RNAndroidOpenSettings.appNotificationSettings() +const soundSettings = () => RNAndroidOpenSettings.soundSettings() + module.exports = { generalSettings, homeSettings, @@ -63,4 +65,5 @@ module.exports = { applicationSettings, deviceInfoSettings, appNotificationSettings, + soundSettings }