package com.rajarsheechatterjee.LNReader; import android.graphics.Color; import android.os.Build; import android.os.Bundle; import android.view.KeyEvent; import android.view.View; import android.view.Window; import android.view.WindowManager; import expo.modules.ReactActivityDelegateWrapper; import com.facebook.react.ReactActivity; import com.facebook.react.ReactActivityDelegate; import com.facebook.react.ReactRootView; import com.rajarsheechatterjee.VolumeButtonListener.VolumeButtonListener; import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView; import org.devio.rn.splashscreen.SplashScreen; public class MainActivity extends ReactActivity { @Override protected void onCreate(Bundle savedInstanceState) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); layoutParams.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; getWindow().setAttributes(layoutParams); } Window w = getWindow(); w.setStatusBarColor(Color.TRANSPARENT); w.setNavigationBarColor(Color.TRANSPARENT); w.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); super.onCreate(null); SplashScreen.show(this,R.style.SplashScreenTheme, R.id.lottie); SplashScreen.setAnimationFinished(true); } @Override public boolean dispatchKeyEvent(KeyEvent event) { if (VolumeButtonListener.isActive()) { int action = event.getAction(); int keyCode = event.getKeyCode(); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: if (action == KeyEvent.ACTION_DOWN) { // volup VolumeButtonListener.up(VolumeButtonListener.getScrollAmount()); if (!VolumeButtonListener.prevent) return super.dispatchKeyEvent(event); } return true; case KeyEvent.KEYCODE_VOLUME_DOWN: if (action == KeyEvent.ACTION_DOWN) { // voldown VolumeButtonListener.down(VolumeButtonListener.getScrollAmount()); if (!VolumeButtonListener.prevent) return super.dispatchKeyEvent(event); } return true; default: return super.dispatchKeyEvent(event); } } return super.dispatchKeyEvent(event); } /** * Returns the name of the main component registered from JavaScript. * This is used to schedule rendering of the component. */ @Override protected String getMainComponentName() { return "main"; } @Override protected ReactActivityDelegate createReactActivityDelegate() { return new ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, new MainActivityDelegate(this, getMainComponentName() )); } public static class MainActivityDelegate extends ReactActivityDelegate { public MainActivityDelegate(ReactActivity activity, String mainComponentName) { super(activity, mainComponentName); } @Override protected ReactRootView createRootView() { ReactRootView reactRootView = new ReactRootView(getContext()); // If you opted-in for the New Architecture, we enable the Fabric Renderer. reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED); return reactRootView; } @Override protected boolean isConcurrentRootEnabled() { // If you opted-in for the New Architecture, we enable Concurrent Root (i.e. React 18). // More on this on https://reactjs.org/blog/2022/03/29/react-v18.html return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; } } }