MainActivity.java 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.safeareaviewexample;
  2. import android.os.Bundle;
  3. import android.view.View;
  4. import android.view.WindowManager;
  5. import com.facebook.react.ReactActivity;
  6. import com.facebook.react.ReactActivityDelegate;
  7. import com.facebook.react.ReactRootView;
  8. import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
  9. public class MainActivity extends ReactActivity {
  10. private static final boolean TEST_TRANSLUCENT_STATUS_BAR = true;
  11. private static final boolean TEST_TRANSLUCENT_NAVBAR = true;
  12. /**
  13. * Returns the name of the main component registered from JavaScript.
  14. * This is used to schedule rendering of the component.
  15. */
  16. @Override
  17. protected String getMainComponentName() {
  18. return "SafeAreaViewExample";
  19. }
  20. @Override
  21. protected ReactActivityDelegate createReactActivityDelegate() {
  22. return new ReactActivityDelegate(this, getMainComponentName()) {
  23. @Override
  24. protected ReactRootView createRootView() {
  25. return new RNGestureHandlerEnabledRootView(MainActivity.this);
  26. }
  27. };
  28. }
  29. @Override
  30. protected void onCreate(Bundle savedInstanceState) {
  31. super.onCreate(savedInstanceState);
  32. if (TEST_TRANSLUCENT_STATUS_BAR) {
  33. getWindow().getDecorView().setSystemUiVisibility(
  34. View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
  35. }
  36. if (TEST_TRANSLUCENT_NAVBAR) {
  37. getWindow().setFlags(
  38. WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
  39. WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
  40. }
  41. }
  42. }