Skip to content

Instantly share code, notes, and snippets.

@mykltronn
Last active June 12, 2019 16:19
Show Gist options
  • Save mykltronn/972641901bca11cab054b6d26bd019b3 to your computer and use it in GitHub Desktop.
Save mykltronn/972641901bca11cab054b6d26bd019b3 to your computer and use it in GitHub Desktop.
. . .
// other imports
+ import android.view.View;
+ import com.facebook.react.bridge.ReactMethod;
public class ImmersiveMode extends ReactContextBaseJavaModule {
. . .
public ImmersiveMode(ReactApplicationContext reactContext) {
super(reactContext);
}
// our annotation
+ @ReactMethod
// methods annotated with ReactMethod must be public void
// the name of this method is a bit of foreshadowing
+ public void fail() {
// here we call our private method setSystemUIFlags
+ setSystemUIFlags(
// the View class defines a whole mess of constants.
// If you examine the Javadoc for these constants, you'll see that each of these constants is an integer
// the pipe symbol in Java is a bitwise OR operator.
// By combining each of these flags using bitwise OR, we're effecitvely toggling
// a single bit in the resultant integer. This will resolve to an integer that maps to a set of settings.
// Neat, huh?
+ View.SYSTEM_UI_FLAG_IMMERSIVE
+ | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_FULLSCREEN
+ );
+ }
private void setSystemUIFlags(int visibility) {
View decorView = getCurrentActivity().getWindow().getDecorView();
decorView.setSystemUiVisibility(visibility);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment