Give FlutterView a view ID (flutter/engine#27052)
This commit is contained in:
@@ -209,6 +209,14 @@ public class FlutterActivity extends Activity
|
||||
implements FlutterActivityAndFragmentDelegate.Host, LifecycleOwner {
|
||||
private static final String TAG = "FlutterActivity";
|
||||
|
||||
/**
|
||||
* The ID of the {@code FlutterView} created by this activity.
|
||||
*
|
||||
* <p>This ID can be used to lookup {@code FlutterView} in the Android view hierarchy. For more,
|
||||
* see {@link android.view.View#findViewById}.
|
||||
*/
|
||||
public static final int FLUTTER_VIEW_ID = 0xF1F2;
|
||||
|
||||
/**
|
||||
* Creates an {@link Intent} that launches a {@code FlutterActivity}, which creates a {@link
|
||||
* FlutterEngine} that executes a {@code main()} Dart entrypoint, and displays the "/" route as
|
||||
@@ -424,7 +432,11 @@ public class FlutterActivity extends Activity
|
||||
lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_CREATE);
|
||||
|
||||
configureWindowForTransparency();
|
||||
setContentView(createFlutterView());
|
||||
|
||||
View flutterView = createFlutterView();
|
||||
flutterView.setId(FLUTTER_VIEW_ID);
|
||||
setContentView(flutterView);
|
||||
|
||||
configureStatusBarForFullscreenFlutterExperience();
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,17 @@ public class FlutterActivityTest {
|
||||
FlutterInjector.reset();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flutterViewHasId() {
|
||||
Intent intent = FlutterActivity.createDefaultIntent(RuntimeEnvironment.application);
|
||||
ActivityController<FlutterActivity> activityController =
|
||||
Robolectric.buildActivity(FlutterActivity.class, intent);
|
||||
FlutterActivity activity = activityController.get();
|
||||
|
||||
activity.onCreate(null);
|
||||
assertNotNull(activity.findViewById(FlutterActivity.FLUTTER_VIEW_ID));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itCreatesDefaultIntentWithExpectedDefaults() {
|
||||
Intent intent = FlutterActivity.createDefaultIntent(RuntimeEnvironment.application);
|
||||
|
||||
Reference in New Issue
Block a user