Skip to content
Permalink
Browse files

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
  • Loading branch information...
YangXiaomei authored and Titozzz committed Jan 22, 2019
1 parent 05f2086 commit d3fc5e6cde979e865a776977331efa349c2a067f
@@ -529,6 +529,13 @@ public void setJavaScriptEnabled(WebView view, boolean enabled) {
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;
@@ -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.
@@ -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'}
@@ -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
@@ -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

0 comments on commit d3fc5e6

Please sign in to comment.
You can’t perform that action at this time.