feat(android props): Add `androidHardwareAccelerationDisabled` prop (#265)

* add test code for disable hardware acceleration

* add interface to disable android hardware acceleration

* Update index.d.ts
This commit is contained in:
Margaret 2019-01-22 17:21:10 +08:00 committed by Thibault Malbranche
parent 05f20862d6
commit d3fc5e6cde
5 changed files with 34 additions and 0 deletions

View File

@ -529,6 +529,13 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
view.getSettings().setJavaScriptEnabled(enabled);
}
@ReactProp(name = "androidHardwareAccelerationDisabled")
public void setHardwareAccelerationDisabled(WebView view, boolean disabled) {
if (disabled) {
view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
}
@ReactProp(name = "overScrollMode")
public void setOverScrollMode(WebView view, String overScrollModeString) {
Integer overScrollMode;

View File

@ -28,6 +28,7 @@ This document lays out the current public properties and methods for the React N
- [`decelerationRate`](Reference.md#decelerationrate)
- [`domStorageEnabled`](Reference.md#domstorageenabled)
- [`javaScriptEnabled`](Reference.md#javascriptenabled)
- [`androidHardwareAccelerationDisabled`](Reference.md#androidHardwareAccelerationDisabled)
- [`mixedContentMode`](Reference.md#mixedcontentmode)
- [`thirdPartyCookiesEnabled`](Reference.md#thirdpartycookiesenabled)
- [`userAgent`](Reference.md#useragent)
@ -319,6 +320,16 @@ Boolean value to enable JavaScript in the `WebView`. Used on Android only as Jav
---
### `androidHardwareAccelerationDisabled`
Boolean value to disable Hardware Acceleration in the `WebView`. Used on Android only as Hardware Acceleration is a feature only for Android. The default value is `false`.
| Type | Required | Platform |
| ---- | -------- | -------- |
| bool | No | Android |
---
### `mixedContentMode`
Specifies the mixed content mode. i.e WebView will allow a secure origin to load content from any other origin.

View File

@ -67,6 +67,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
scalesPageToFit: true,
allowFileAccess: false,
saveFormDataDisabled: false,
androidHardwareAccelerationDisabled: false,
originWhitelist: defaultOriginWhitelist,
};
@ -150,6 +151,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
injectedJavaScript={this.props.injectedJavaScript}
userAgent={this.props.userAgent}
javaScriptEnabled={this.props.javaScriptEnabled}
androidHardwareAccelerationDisabled={this.props.androidHardwareAccelerationDisabled}
thirdPartyCookiesEnabled={this.props.thirdPartyCookiesEnabled}
domStorageEnabled={this.props.domStorageEnabled}
messagingEnabled={typeof this.props.onMessage === 'function'}

View File

@ -313,6 +313,13 @@ export type AndroidWebViewProps = $ReadOnly<{|
*/
javaScriptEnabled?: ?boolean,
/**
* Boolean value to disable Hardware Acceleration in the `WebView`. Used on Android only
* as Hardware Acceleration is a feature only for Android. The default value is `false`.
* @platform android
*/
androidHardwareAccelerationDisabled?: ?boolean,
/**
* Boolean value to enable third party cookies in the `WebView`. Used on
* Android Lollipop and above only as third party cookies are enabled by

7
typings/index.d.ts vendored
View File

@ -287,6 +287,13 @@ export interface AndroidWebViewProps {
*/
javaScriptEnabled?: boolean;
/**
* Boolean value to disable Hardware Acceleration in the `WebView`. Used on Android only
* as Hardware Acceleration is a feature only for Android. The default value is `false`.
* @platform android
*/
androidHardwareAccelerationDisabled?: boolean;
/**
* Boolean value to enable third party cookies in the `WebView`. Used on
* Android Lollipop and above only as third party cookies are enabled by