str-settings
v2.0.0
Published
Allows for checking if certain settings are enabled as well as quick launching settings menus on android TV.
Maintainers
Readme
str-settings
Allows for checking if certain settings are enabled as well as quick launching settings menus on android TV.
Install
To use npm
npm install str-settingsTo use yarn
yarn add str-settingsSync native files
npx cap syncAPI
echo(...)checkOverlayPermission()requestOverlayPermission(...)checkAccessibilityService(...)requestAccessibilityService(...)openWifiSettings()openRemotesSettings()openAllSettings()openHdmiCecSettings()openAppSettings(...)- Interfaces
echo(...)
echo(options: { value: string; }) => Promise<{ value: string; }>| Param | Type |
| ------------- | ------------------------------- |
| options | { value: string; } |
Returns: Promise<{ value: string; }>
checkOverlayPermission()
checkOverlayPermission() => Promise<OverlayPermissionResult>Returns the current overlay permission state without prompting the user.
Returns: Promise<OverlayPermissionResult>
requestOverlayPermission(...)
requestOverlayPermission(options?: RequestOverlayPermissionOptions | undefined) => Promise<OverlayPermissionResult>Shows a native confirmation dialog, then opens the system overlay settings screen. Resolves once the user returns from that screen. No-ops (resolves immediately) when already granted or unsupported.
| Param | Type |
| ------------- | ------------------------------------------------------------------------------------------- |
| options | RequestOverlayPermissionOptions |
Returns: Promise<OverlayPermissionResult>
checkAccessibilityService(...)
checkAccessibilityService(options: CheckAccessibilityServiceOptions) => Promise<AccessibilityServiceResult>Returns whether the given accessibility service is currently enabled.
| Param | Type |
| ------------- | --------------------------------------------------------------------------------------------- |
| options | CheckAccessibilityServiceOptions |
Returns: Promise<AccessibilityServiceResult>
requestAccessibilityService(...)
requestAccessibilityService(options: RequestAccessibilityServiceOptions) => Promise<AccessibilityServiceResult>Shows a dialog explaining that the user needs to enable the accessibility service (with a cancel option), then opens Accessibility Settings. Resolves immediately if the service is already enabled, or if the user cancels.
| Param | Type |
| ------------- | ------------------------------------------------------------------------------------------------- |
| options | RequestAccessibilityServiceOptions |
Returns: Promise<AccessibilityServiceResult>
openWifiSettings()
openWifiSettings() => Promise<SettingsPageResult>Opens the system Wi-Fi settings page. Resolves when the user presses back.
Returns: Promise<SettingsPageResult>
openRemotesSettings()
openRemotesSettings() => Promise<SettingsPageResult>Opens the Remotes & Accessories (Bluetooth) settings page. Resolves when the user presses back.
Returns: Promise<SettingsPageResult>
openAllSettings()
openAllSettings() => Promise<SettingsPageResult>Opens the top-level system Settings page. Resolves when the user presses back.
Returns: Promise<SettingsPageResult>
openHdmiCecSettings()
openHdmiCecSettings() => Promise<SettingsPageResult>Opens HDMI-CEC settings. Falls back to Display Settings if no dedicated HDMI-CEC screen is found. Resolves when the user presses back.
Returns: Promise<SettingsPageResult>
openAppSettings(...)
openAppSettings(options?: OpenAppSettingsOptions | undefined) => Promise<SettingsPageResult>Opens the system app details page for the given package (force-stop, clear cache, etc.). Defaults to the host app's own package when packageName is omitted. Resolves when the user presses back.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options | OpenAppSettingsOptions |
Returns: Promise<SettingsPageResult>
Interfaces
OverlayPermissionResult
| Prop | Type | Description |
| --------------- | -------------------- | ------------------------------------------------------------- |
| supported | boolean | Whether the device/OS supports the overlay permission screen. |
| granted | boolean | Whether the app currently has draw-over-apps permission. |
RequestOverlayPermissionOptions
| Prop | Type | Description |
| -------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| isManual | boolean | Skip the confirmation dialog and navigate directly to system settings. Use this when the user is toggling the feature off from your own UI. |
AccessibilityServiceResult
| Prop | Type | Description |
| ------------- | -------------------- | ----------------------------------------------------------------- |
| enabled | boolean | Whether the specified accessibility service is currently enabled. |
CheckAccessibilityServiceOptions
| Prop | Type | Description |
| ------------------ | ------------------- | ---------------------------------------------------------------------------------------------------- |
| serviceClass | string | Fully-qualified class name of the accessibility service, e.g. "com.strtv.www.HomeInterceptorService" |
RequestAccessibilityServiceOptions
| Prop | Type | Description |
| ------------------ | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| serviceClass | string | Fully-qualified class name of the accessibility service, e.g. "com.strtv.app.HomeInterceptorService" |
| isManual | boolean | Skip the confirmation dialog and navigate directly to system settings. Use this when the user is toggling the feature off from your own UI. |
SettingsPageResult
| Prop | Type | Description |
| -------------- | -------------------- | ------------------------------------------------------------ |
| returned | boolean | True once the user has pressed back and returned to the app. |
OpenAppSettingsOptions
| Prop | Type | Description |
| ----------------- | ------------------- | ------------------------------------------------------------------------- |
| packageName | string | Package name of the app to show. Defaults to the host app's package name. |
