Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Protected Member Functions | List of all members
io.flutter.plugin.platform.SingleViewPresentation Class Reference
Inheritance diagram for io.flutter.plugin.platform.SingleViewPresentation:

Classes

class  PresentationState
 

Public Member Functions

 SingleViewPresentation (Context outerContext, Display display, PlatformView view, AccessibilityEventsDelegate accessibilityEventsDelegate, int viewId, OnFocusChangeListener focusChangeListener)
 
 SingleViewPresentation (Context outerContext, Display display, AccessibilityEventsDelegate accessibilityEventsDelegate, PresentationState state, OnFocusChangeListener focusChangeListener, boolean startFocused)
 
PresentationState detachState ()
 
PlatformView getView ()
 

Protected Member Functions

void onCreate (Bundle savedInstanceState)
 

Detailed Description

Definition at line 45 of file SingleViewPresentation.java.

Constructor & Destructor Documentation

◆ SingleViewPresentation() [1/2]

io.flutter.plugin.platform.SingleViewPresentation.SingleViewPresentation ( Context  outerContext,
Display  display,
PlatformView  view,
AccessibilityEventsDelegate  accessibilityEventsDelegate,
int  viewId,
OnFocusChangeListener  focusChangeListener 
)
inline

Creates a presentation that will use the view factory to create a new platform view in the presentation's onCreate, and attach it.

Definition at line 98 of file SingleViewPresentation.java.

104 {
105 super(new ImmContext(outerContext), display);
106 this.accessibilityEventsDelegate = accessibilityEventsDelegate;
107 this.viewId = viewId;
108 this.focusChangeListener = focusChangeListener;
109 this.outerContext = outerContext;
110 state = new PresentationState();
111 state.platformView = view;
112 getWindow()
113 .setFlags(
114 WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
115 WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
116 getWindow().setType(WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION);
117 }

◆ SingleViewPresentation() [2/2]

io.flutter.plugin.platform.SingleViewPresentation.SingleViewPresentation ( Context  outerContext,
Display  display,
AccessibilityEventsDelegate  accessibilityEventsDelegate,
PresentationState  state,
OnFocusChangeListener  focusChangeListener,
boolean  startFocused 
)
inline

Creates a presentation that will attach an already existing view as its root view.

The display's density must match the density of the context used when the view was created.

Definition at line 124 of file SingleViewPresentation.java.

130 {
131 super(new ImmContext(outerContext), display);
132 this.accessibilityEventsDelegate = accessibilityEventsDelegate;
133 this.state = state;
134 this.focusChangeListener = focusChangeListener;
135 this.outerContext = outerContext;
136 getWindow()
137 .setFlags(
138 WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
139 WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
140 this.startFocused = startFocused;
141 }

Member Function Documentation

◆ detachState()

PresentationState io.flutter.plugin.platform.SingleViewPresentation.detachState ( )
inline

Definition at line 203 of file SingleViewPresentation.java.

203 {
204 // These views can be null before onCreate() is called
205 if (container != null) {
206 container.removeAllViews();
207 }
208 if (rootView != null) {
209 rootView.removeAllViews();
210 }
211 return state;
212 }

◆ getView()

PlatformView io.flutter.plugin.platform.SingleViewPresentation.getView ( )
inline

Definition at line 215 of file SingleViewPresentation.java.

215 {
216 return state.platformView;
217 }

◆ onCreate()

void io.flutter.plugin.platform.SingleViewPresentation.onCreate ( Bundle  savedInstanceState)
inlineprotected

Definition at line 144 of file SingleViewPresentation.java.

144 {
145 super.onCreate(savedInstanceState);
146 // This makes sure we preserve alpha for the VD's content.
147 getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
148 if (state.fakeWindowViewGroup == null) {
149 state.fakeWindowViewGroup = new SingleViewFakeWindowViewGroup(getContext());
150 }
151 if (state.windowManagerHandler == null) {
152 WindowManager windowManagerDelegate =
153 (WindowManager) getContext().getSystemService(WINDOW_SERVICE);
154 state.windowManagerHandler =
155 new WindowManagerHandler(windowManagerDelegate, state.fakeWindowViewGroup);
156 }
157
158 container = new FrameLayout(getContext());
159
160 // Our base mContext has already been wrapped with an IMM cache at instantiation time, but
161 // we want to wrap it again here to also return state.windowManagerHandler.
162 Context baseContext =
163 new PresentationContext(getContext(), state.windowManagerHandler, outerContext);
164
165 View embeddedView = state.platformView.getView();
166 if (embeddedView.getContext() instanceof MutableContextWrapper) {
167 MutableContextWrapper currentContext = (MutableContextWrapper) embeddedView.getContext();
168 currentContext.setBaseContext(baseContext);
169 } else {
170 // In some cases, such as when using LayoutInflator, the original context
171 // may not be preserved. For backward compatibility with previous
172 // implementations of Virtual Display, which didn't validate the context,
173 // continue, but log a warning indicating that some functionality may not
174 // work as expected.
175 // See https://github.com/flutter/flutter/issues/110146 for context.
176 Log.w(
177 TAG,
178 "Unexpected platform view context for view ID "
179 + viewId
180 + "; some functionality may not work correctly. When constructing a platform view "
181 + "in the factory, ensure that the view returned from PlatformViewFactory#create "
182 + "returns the provided context from getContext(). If you are unable to associate "
183 + "the view with that context, consider using Hybrid Composition instead.");
184 }
185
186 container.addView(embeddedView);
187 rootView =
188 new AccessibilityDelegatingFrameLayout(
189 getContext(), accessibilityEventsDelegate, embeddedView);
190 rootView.addView(container);
191 rootView.addView(state.fakeWindowViewGroup);
192
193 embeddedView.setOnFocusChangeListener(focusChangeListener);
194 rootView.setFocusableInTouchMode(true);
195 if (startFocused) {
196 embeddedView.requestFocus();
197 } else {
198 rootView.requestFocus();
199 }
200 setContentView(rootView);
201 }
void Log(const char *format,...) SK_PRINTF_LIKE(1
Definition: TestRunner.cpp:137

The documentation for this class was generated from the following file: