1
- export const mainActivityFixture = `package com.poc.bam.tech;
1
+ export const mainJavaActivityFixture = `package com.poc.bam.tech;
2
2
3
3
import com.facebook.react.ReactActivity;
4
4
@@ -15,7 +15,7 @@ public class MainActivity extends ReactActivity {
15
15
}
16
16
` ;
17
17
18
- export const mainActivityExpectedFixture = `package com.poc.bam.tech;
18
+ export const mainJavaActivityExpectedFixture = `package com.poc.bam.tech;
19
19
20
20
import com.facebook.react.ReactActivity;
21
21
import android.content.Intent;
@@ -35,9 +35,138 @@ public class MainActivity extends ReactActivity {
35
35
@Override
36
36
public void onNewIntent(Intent intent)
37
37
{
38
- Batch.onNewIntent(this, intent);
39
38
super.onNewIntent(intent);
39
+ Batch.onNewIntent(this, intent);
40
40
}
41
41
42
42
}
43
43
` ;
44
+
45
+ export const mainKotlinActivityFixture = `package com.arnaudr.expobeta50
46
+
47
+ import android.os.Build
48
+ import android.os.Bundle
49
+
50
+ import com.facebook.react.ReactActivity
51
+ import com.facebook.react.ReactActivityDelegate
52
+ import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
53
+ import com.facebook.react.defaults.DefaultReactActivityDelegate
54
+
55
+ import expo.modules.ReactActivityDelegateWrapper
56
+
57
+ class MainActivity : ReactActivity() {
58
+ override fun onCreate(savedInstanceState: Bundle?) {
59
+ // Set the theme to AppTheme BEFORE onCreate to support
60
+ // coloring the background, status bar, and navigation bar.
61
+ // This is required for expo-splash-screen.
62
+ setTheme(R.style.AppTheme);
63
+ super.onCreate(null)
64
+ }
65
+
66
+ /**
67
+ * Returns the name of the main component registered from JavaScript. This is used to schedule
68
+ * rendering of the component.
69
+ */
70
+ override fun getMainComponentName(): String = "main"
71
+
72
+ /**
73
+ * Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
74
+ * which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
75
+ */
76
+ override fun createReactActivityDelegate(): ReactActivityDelegate {
77
+ return ReactActivityDelegateWrapper(
78
+ this,
79
+ BuildConfig.IS_NEW_ARCHITECTURE_ENABLED,
80
+ object : DefaultReactActivityDelegate(
81
+ this,
82
+ mainComponentName,
83
+ fabricEnabled
84
+ ){})
85
+ }
86
+
87
+ /**
88
+ * Align the back button behavior with Android S
89
+ * where moving root activities to background instead of finishing activities.
90
+ */
91
+ override fun invokeDefaultOnBackPressed() {
92
+ if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
93
+ if (!moveTaskToBack(false)) {
94
+ // For non-root activities, use the default implementation to finish them.
95
+ super.invokeDefaultOnBackPressed()
96
+ }
97
+ return
98
+ }
99
+
100
+ // Use the default back button implementation on Android S
101
+ // because it's doing more than [Activity.moveTaskToBack] in fact.
102
+ super.invokeDefaultOnBackPressed()
103
+ }
104
+ }` ;
105
+
106
+ export const mainKotlinActivityExpectedFixture = `package com.arnaudr.expobeta50
107
+
108
+ import android.os.Build
109
+ import android.os.Bundle
110
+
111
+ import com.facebook.react.ReactActivity
112
+ import com.facebook.react.ReactActivityDelegate
113
+ import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
114
+ import com.facebook.react.defaults.DefaultReactActivityDelegate
115
+ import android.content.Intent
116
+ import com.batch.android.Batch
117
+
118
+ import expo.modules.ReactActivityDelegateWrapper
119
+
120
+ class MainActivity : ReactActivity() {
121
+ override fun onCreate(savedInstanceState: Bundle?) {
122
+ // Set the theme to AppTheme BEFORE onCreate to support
123
+ // coloring the background, status bar, and navigation bar.
124
+ // This is required for expo-splash-screen.
125
+ setTheme(R.style.AppTheme);
126
+ super.onCreate(null)
127
+ }
128
+
129
+ /**
130
+ * Returns the name of the main component registered from JavaScript. This is used to schedule
131
+ * rendering of the component.
132
+ */
133
+ override fun getMainComponentName(): String = "main"
134
+
135
+ /**
136
+ * Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
137
+ * which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
138
+ */
139
+ override fun createReactActivityDelegate(): ReactActivityDelegate {
140
+ return ReactActivityDelegateWrapper(
141
+ this,
142
+ BuildConfig.IS_NEW_ARCHITECTURE_ENABLED,
143
+ object : DefaultReactActivityDelegate(
144
+ this,
145
+ mainComponentName,
146
+ fabricEnabled
147
+ ){})
148
+ }
149
+
150
+ /**
151
+ * Align the back button behavior with Android S
152
+ * where moving root activities to background instead of finishing activities.
153
+ */
154
+ override fun invokeDefaultOnBackPressed() {
155
+ if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
156
+ if (!moveTaskToBack(false)) {
157
+ // For non-root activities, use the default implementation to finish them.
158
+ super.invokeDefaultOnBackPressed()
159
+ }
160
+ return
161
+ }
162
+
163
+ // Use the default back button implementation on Android S
164
+ // because it's doing more than [Activity.moveTaskToBack] in fact.
165
+ super.invokeDefaultOnBackPressed()
166
+ }
167
+
168
+ override fun onNewIntent(intent: Intent?) {
169
+ super.onNewIntent(intent)
170
+ Batch.onNewIntent(this, intent)
171
+ }
172
+ }` ;
0 commit comments