UNPKG

7.57 kBJavaScriptView Raw
1// @flow
2
3import { NativeModules, Platform } from 'react-native';
4
5/**
6 * Constants are from the source code of Settings:
7 * https://developer.android.com/reference/android/provider/Settings.html
8 */
9
10export const ACTION_ACCESSIBILITY_SETTINGS = 'android.settings.ACCESSIBILITY_SETTINGS';
11export const ACTION_APP_NOTIFICATION_REDACTION =
12 'android.settings.ACTION_APP_NOTIFICATION_REDACTION';
13export const ACTION_CONDITION_PROVIDER_SETTINGS =
14 'android.settings.ACTION_CONDITION_PROVIDER_SETTINGS';
15export const ACTION_NOTIFICATION_LISTENER_SETTINGS =
16 'android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS';
17export const ACTION_PRINT_SETTINGS = 'android.settings.ACTION_PRINT_SETTINGS';
18export const ACTION_ADD_ACCOUNT_SETTINGS = 'android.settings.ADD_ACCOUNT_SETTINGS';
19export const ACTION_AIRPLANE_MODE_SETTINGS = 'android.settings.AIRPLANE_MODE_SETTINGS';
20export const ACTION_APN_SETTINGS = 'android.settings.APN_SETTINGS';
21export const ACTION_APPLICATION_DETAILS_SETTINGS = 'android.settings.APPLICATION_DETAILS_SETTINGS';
22export const ACTION_APPLICATION_DEVELOPMENT_SETTINGS =
23 'android.settings.APPLICATION_DEVELOPMENT_SETTINGS';
24export const ACTION_APPLICATION_SETTINGS = 'android.settings.APPLICATION_SETTINGS';
25export const ACTION_APP_NOTIFICATION_SETTINGS = 'android.settings.APP_NOTIFICATION_SETTINGS';
26export const ACTION_APP_OPS_SETTINGS = 'android.settings.APP_OPS_SETTINGS';
27export const ACTION_BATTERY_SAVER_SETTINGS = 'android.settings.BATTERY_SAVER_SETTINGS';
28export const ACTION_BLUETOOTH_SETTINGS = 'android.settings.BLUETOOTH_SETTINGS';
29export const ACTION_CAPTIONING_SETTINGS = 'android.settings.CAPTIONING_SETTINGS';
30export const ACTION_CAST_SETTINGS = 'android.settings.CAST_SETTINGS';
31export const ACTION_DATA_ROAMING_SETTINGS = 'android.settings.DATA_ROAMING_SETTINGS';
32export const ACTION_DATE_SETTINGS = 'android.settings.DATE_SETTINGS';
33export const ACTION_DEVICE_INFO_SETTINGS = 'android.settings.DEVICE_INFO_SETTINGS';
34export const ACTION_DEVICE_NAME = 'android.settings.DEVICE_NAME';
35export const ACTION_DISPLAY_SETTINGS = 'android.settings.DISPLAY_SETTINGS';
36export const ACTION_DREAM_SETTINGS = 'android.settings.DREAM_SETTINGS';
37export const ACTION_HARD_KEYBOARD_SETTINGS = 'android.settings.HARD_KEYBOARD_SETTINGS';
38export const ACTION_HOME_SETTINGS = 'android.settings.HOME_SETTINGS';
39export const ACTION_IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS =
40 'android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS';
41export const ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS =
42 'android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS';
43export const ACTION_INPUT_METHOD_SETTINGS = 'android.settings.INPUT_METHOD_SETTINGS';
44export const ACTION_INPUT_METHOD_SUBTYPE_SETTINGS =
45 'android.settings.INPUT_METHOD_SUBTYPE_SETTINGS';
46export const ACTION_INTERNAL_STORAGE_SETTINGS = 'android.settings.INTERNAL_STORAGE_SETTINGS';
47export const ACTION_LOCALE_SETTINGS = 'android.settings.LOCALE_SETTINGS';
48export const ACTION_LOCATION_SOURCE_SETTINGS = 'android.settings.LOCATION_SOURCE_SETTINGS';
49export const ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS =
50 'android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS';
51export const ACTION_MANAGE_APPLICATIONS_SETTINGS = 'android.settings.MANAGE_APPLICATIONS_SETTINGS';
52export const ACTION_MANAGE_DEFAULT_APPS_SETTINGS = 'android.settings.MANAGE_DEFAULT_APPS_SETTINGS';
53export const ACTION_MEMORY_CARD_SETTINGS = 'android.settings.MEMORY_CARD_SETTINGS';
54export const ACTION_MONITORING_CERT_INFO = 'android.settings.MONITORING_CERT_INFO';
55export const ACTION_NETWORK_OPERATOR_SETTINGS = 'android.settings.NETWORK_OPERATOR_SETTINGS';
56export const ACTION_NFCSHARING_SETTINGS = 'android.settings.NFCSHARING_SETTINGS';
57export const ACTION_NFC_PAYMENT_SETTINGS = 'android.settings.NFC_PAYMENT_SETTINGS';
58export const ACTION_NFC_SETTINGS = 'android.settings.NFC_SETTINGS';
59export const ACTION_NIGHT_DISPLAY_SETTINGS = 'android.settings.NIGHT_DISPLAY_SETTINGS';
60export const ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS =
61 'android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS';
62export const ACTION_NOTIFICATION_SETTINGS = 'android.settings.NOTIFICATION_SETTINGS';
63export const ACTION_PAIRING_SETTINGS = 'android.settings.PAIRING_SETTINGS';
64export const ACTION_PRIVACY_SETTINGS = 'android.settings.PRIVACY_SETTINGS';
65export const ACTION_QUICK_LAUNCH_SETTINGS = 'android.settings.QUICK_LAUNCH_SETTINGS';
66export const ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS =
67 'android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS';
68export const ACTION_SECURITY_SETTINGS = 'android.settings.SECURITY_SETTINGS';
69export const ACTION_SETTINGS = 'android.settings.SETTINGS';
70export const ACTION_SHOW_ADMIN_SUPPORT_DETAILS = 'android.settings.SHOW_ADMIN_SUPPORT_DETAILS';
71export const ACTION_SHOW_INPUT_METHOD_PICKER = 'android.settings.SHOW_INPUT_METHOD_PICKER';
72export const ACTION_SHOW_REGULATORY_INFO = 'android.settings.SHOW_REGULATORY_INFO';
73export const ACTION_SHOW_REMOTE_BUGREPORT_DIALOG = 'android.settings.SHOW_REMOTE_BUGREPORT_DIALOG';
74export const ACTION_SOUND_SETTINGS = 'android.settings.SOUND_SETTINGS';
75export const ACTION_STORAGE_MANAGER_SETTINGS = 'android.settings.STORAGE_MANAGER_SETTINGS';
76export const ACTION_SYNC_SETTINGS = 'android.settings.SYNC_SETTINGS';
77export const ACTION_SYSTEM_UPDATE_SETTINGS = 'android.settings.SYSTEM_UPDATE_SETTINGS';
78export const ACTION_TETHER_PROVISIONING_UI = 'android.settings.TETHER_PROVISIONING_UI';
79export const ACTION_TRUSTED_CREDENTIALS_USER = 'android.settings.TRUSTED_CREDENTIALS_USER';
80export const ACTION_USAGE_ACCESS_SETTINGS = 'android.settings.USAGE_ACCESS_SETTINGS';
81export const ACTION_USER_DICTIONARY_INSERT = 'android.settings.USER_DICTIONARY_INSERT';
82export const ACTION_USER_DICTIONARY_SETTINGS = 'android.settings.USER_DICTIONARY_SETTINGS';
83export const ACTION_USER_SETTINGS = 'android.settings.USER_SETTINGS';
84export const ACTION_VOICE_CONTROL_AIRPLANE_MODE = 'android.settings.VOICE_CONTROL_AIRPLANE_MODE';
85export const ACTION_VOICE_CONTROL_BATTERY_SAVER_MODE =
86 'android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE';
87export const ACTION_VOICE_CONTROL_DO_NOT_DISTURB_MODE =
88 'android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE';
89export const ACTION_VOICE_INPUT_SETTINGS = 'android.settings.VOICE_INPUT_SETTINGS';
90export const ACTION_VPN_SETTINGS = 'android.settings.VPN_SETTINGS';
91export const ACTION_VR_LISTENER_SETTINGS = 'android.settings.VR_LISTENER_SETTINGS';
92export const ACTION_WEBVIEW_SETTINGS = 'android.settings.WEBVIEW_SETTINGS';
93export const ACTION_WIFI_IP_SETTINGS = 'android.settings.WIFI_IP_SETTINGS';
94export const ACTION_WIFI_SETTINGS = 'android.settings.WIFI_SETTINGS';
95export const ACTION_WIRELESS_SETTINGS = 'android.settings.WIRELESS_SETTINGS';
96export const ACTION_ZEN_MODE_AUTOMATION_SETTINGS = 'android.settings.ZEN_MODE_AUTOMATION_SETTINGS';
97export const ACTION_ZEN_MODE_EVENT_RULE_SETTINGS = 'android.settings.ZEN_MODE_EVENT_RULE_SETTINGS';
98export const ACTION_ZEN_MODE_EXTERNAL_RULE_SETTINGS =
99 'android.settings.ZEN_MODE_EXTERNAL_RULE_SETTINGS';
100export const ACTION_ZEN_MODE_PRIORITY_SETTINGS = 'android.settings.ZEN_MODE_PRIORITY_SETTINGS';
101export const ACTION_ZEN_MODE_SCHEDULE_RULE_SETTINGS =
102 'android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS';
103export const ACTION_ZEN_MODE_SETTINGS = 'android.settings.ZEN_MODE_SETTINGS';
104
105export function startActivityAsync(activity: string, data: ?Object = null): Promise<boolean> {
106 if (Platform.OS === 'android') {
107 return NativeModules.ExponentIntentLauncher.startActivity(activity, data);
108 } else {
109 return Promise.reject(new Error('Unsupported platform'));
110 }
111}