1 package dev.expo.payments; 2 3 import android.content.Intent; 4 import android.content.SharedPreferences; 5 import android.net.Uri; 6 import android.os.Bundle; 7 8 import com.facebook.react.ReactActivity; 9 import com.facebook.react.ReactActivityDelegate; 10 import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; 11 import com.facebook.react.defaults.DefaultReactActivityDelegate; 12 13 14 import expo.modules.ReactActivityDelegateWrapper; 15 16 public class MainActivity extends ReactActivity { 17 18 /** 19 * Returns the name of the main component registered from JavaScript. 20 * This is used to schedule rendering of the component. 21 */ 22 @Override getMainComponentName()23 protected String getMainComponentName() { 24 return "main"; 25 } 26 27 @Override onCreate(Bundle savedInstanceState)28 protected void onCreate(Bundle savedInstanceState) { 29 // https://github.com/software-mansion/react-native-screens/issues/17#issuecomment-424704067 30 // https://reactnavigation.org/docs/getting-started/#installing-dependencies-into-a-bare-react-native-project 31 super.onCreate(null); 32 } 33 34 /** 35 * Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link 36 * DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React 37 * (aka React 18) with two boolean flags. 38 */ 39 @Override createReactActivityDelegate()40 protected ReactActivityDelegate createReactActivityDelegate() { 41 return new ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, new DefaultReactActivityDelegate( 42 this, 43 getMainComponentName(), 44 // If you opted-in for the New Architecture, we enable the Fabric Renderer. 45 DefaultNewArchitectureEntryPoint.getFabricEnabled()) { 46 47 @Override 48 protected void onCreate(Bundle savedInstanceState) { 49 super.onCreate(savedInstanceState); 50 51 // Hacky way to prevent onboarding DevMenuActivity breaks detox testing, 52 // we do this by setting the dev-menu internal setting. 53 final Intent intent = getIntent(); 54 final String action = intent.getAction(); 55 final Uri initialUri = intent.getData(); 56 if (action.equals(Intent.ACTION_VIEW) && 57 initialUri != null && 58 initialUri.getHost().equals("test-suite")) { 59 final String devMenuPrefKey = "expo.modules.devmenu.sharedpreferences"; 60 final SharedPreferences pref = getApplicationContext().getSharedPreferences(devMenuPrefKey, MODE_PRIVATE); 61 pref.edit().putBoolean("isOnboardingFinished", true).apply(); 62 } 63 } 64 }); 65 } 66 } 67