Merge pull request #214 from lbryio/fullscreen-navigation-bar
hide navigation bar in fullscreen playback mode
This commit is contained in:
commit
4ae4a7366a
2 changed files with 53 additions and 20 deletions
|
@ -99,9 +99,17 @@ class FilePage extends React.PureComponent {
|
||||||
if (mode) {
|
if (mode) {
|
||||||
// fullscreen, so change orientation to landscape mode
|
// fullscreen, so change orientation to landscape mode
|
||||||
NativeModules.ScreenOrientation.lockOrientationLandscape();
|
NativeModules.ScreenOrientation.lockOrientationLandscape();
|
||||||
|
if (NativeModules.UtilityModule) {
|
||||||
|
// hide the navigation bar (on devices that use have soft navigation bar)
|
||||||
|
NativeModules.UtilityModule.hideNavigationBar();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Switch back to portrait mode when the media is not fullscreen
|
// Switch back to portrait mode when the media is not fullscreen
|
||||||
NativeModules.ScreenOrientation.lockOrientationPortrait();
|
NativeModules.ScreenOrientation.lockOrientationPortrait();
|
||||||
|
if (NativeModules.UtilityModule) {
|
||||||
|
// hide the navigation bar (on devices that use have soft navigation bar)
|
||||||
|
NativeModules.UtilityModule.showNavigationBar();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,9 +146,11 @@ class FilePage extends React.PureComponent {
|
||||||
StatusBar.setHidden(false);
|
StatusBar.setHidden(false);
|
||||||
if (NativeModules.ScreenOrientation) {
|
if (NativeModules.ScreenOrientation) {
|
||||||
NativeModules.ScreenOrientation.unlockOrientation();
|
NativeModules.ScreenOrientation.unlockOrientation();
|
||||||
}
|
}
|
||||||
if (NativeModules.UtilityModule) {
|
if (NativeModules.UtilityModule) {
|
||||||
NativeModules.UtilityModule.keepAwakeOff();
|
const utility = NativeModules.UtilityModule;
|
||||||
|
utility.keepAwakeOff();
|
||||||
|
utility.showNavigationBar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package io.lbry.browser.reactmodules;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import com.facebook.react.bridge.ReactApplicationContext;
|
import com.facebook.react.bridge.ReactApplicationContext;
|
||||||
|
@ -23,29 +24,51 @@ public class UtilityModule extends ReactContextBaseJavaModule {
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void keepAwakeOn() {
|
public void keepAwakeOn() {
|
||||||
final Activity activity = getCurrentActivity();
|
final Activity activity = getCurrentActivity();
|
||||||
|
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void keepAwakeOff() {
|
public void keepAwakeOff() {
|
||||||
final Activity activity = getCurrentActivity();
|
final Activity activity = getCurrentActivity();
|
||||||
|
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ReactMethod
|
||||||
|
public void hideNavigationBar() {
|
||||||
|
if (context != null && context instanceof Activity) {
|
||||||
|
Activity activity = (Activity) context;
|
||||||
|
View decorView = activity.getWindow().getDecorView();
|
||||||
|
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
|
||||||
|
View.SYSTEM_UI_FLAG_IMMERSIVE |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ReactMethod
|
||||||
|
public void showNavigationBar() {
|
||||||
|
if (context != null && context instanceof Activity) {
|
||||||
|
Activity activity = (Activity) context;
|
||||||
|
View decorView = activity.getWindow().getDecorView();
|
||||||
|
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
|
View.SYSTEM_UI_FLAG_VISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue