Allow user to rotate fullscreen video on Android (No Android X) (#815)

This commit is contained in:
Akeem McLennon 2019-08-29 09:37:21 -05:00 committed by Thibault Malbranche
parent 4bc5e2374a
commit d6f90389fc
1 changed files with 4 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import android.annotation.TargetApi;
import android.app.DownloadManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.Uri;
@ -533,6 +534,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
protected void setupWebChromeClient(ReactContext reactContext, WebView webView) {
if (mAllowsFullscreenVideo) {
int initialRequestedOrientation = reactContext.getCurrentActivity().getRequestedOrientation();
mWebChromeClient = new RNCWebChromeClient(reactContext, webView) {
@Override
public void onShowCustomView(View view, CustomViewCallback callback) {
@ -544,6 +546,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
mVideoView = view;
mCustomViewCallback = callback;
mReactContext.getCurrentActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
mVideoView.setSystemUiVisibility(FULLSCREEN_SYSTEM_UI_VISIBILITY);
mReactContext.getCurrentActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
@ -574,6 +577,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
mReactContext.getCurrentActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
mReactContext.getCurrentActivity().setRequestedOrientation(initialRequestedOrientation);
mReactContext.removeLifecycleEventListener(this);
}