Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit dc18b07

Browse files
author
Emmanuel Garcia
committed
refactor
1 parent 75a21bb commit dc18b07

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

shell/platform/android/io/flutter/plugin/platform/PlatformView.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,16 @@ default void onFlutterViewDetached() {}
6666
*
6767
* <p>This hook only exists for rare cases where the plugin relies on the state of the input
6868
* connection. This probably doesn't need to be implemented.
69-
*
70-
* <p>This method is deprecated, and will be removed in a future release.
7169
*/
7270
@SuppressLint("NewApi")
73-
@Deprecated
7471
default void onInputConnectionLocked() {}
7572

7673
/**
7774
* Callback fired when the platform input connection has been unlocked.
7875
*
7976
* <p>This hook only exists for rare cases where the plugin relies on the state of the input
8077
* connection. This probably doesn't need to be implemented.
81-
*
82-
* <p>This method is deprecated, and will be removed in a future release.
8378
*/
8479
@SuppressLint("NewApi")
85-
@Deprecated
8680
default void onInputConnectionUnlocked() {}
8781
}

shell/platform/android/io/flutter/plugin/platform/SingleViewPresentation.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import android.app.Presentation;
1313
import android.content.Context;
1414
import android.content.ContextWrapper;
15+
import android.content.MutableContextWrapper;
1516
import android.graphics.Rect;
1617
import android.graphics.drawable.ColorDrawable;
1718
import android.os.Build;
@@ -72,8 +73,6 @@ static class PresentationState {
7273
private FakeWindowViewGroup fakeWindowViewGroup;
7374
}
7475

75-
private final PlatformViewFactory viewFactory;
76-
7776
// A reference to the current accessibility bridge to which accessibility events will be
7877
// delegated.
7978
private final AccessibilityEventsDelegate accessibilityEventsDelegate;
@@ -112,19 +111,19 @@ static class PresentationState {
112111
public SingleViewPresentation(
113112
Context outerContext,
114113
Display display,
115-
PlatformViewFactory viewFactory,
114+
PlatformView view,
116115
AccessibilityEventsDelegate accessibilityEventsDelegate,
117116
int viewId,
118117
Object createParams,
119118
OnFocusChangeListener focusChangeListener) {
120119
super(new ImmContext(outerContext), display);
121-
this.viewFactory = viewFactory;
122120
this.accessibilityEventsDelegate = accessibilityEventsDelegate;
123121
this.viewId = viewId;
124122
this.createParams = createParams;
125123
this.focusChangeListener = focusChangeListener;
126124
this.outerContext = outerContext;
127125
state = new PresentationState();
126+
state.platformView = view;
128127
getWindow()
129128
.setFlags(
130129
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
@@ -148,7 +147,6 @@ public SingleViewPresentation(
148147
boolean startFocused) {
149148
super(new ImmContext(outerContext), display);
150149
this.accessibilityEventsDelegate = accessibilityEventsDelegate;
151-
viewFactory = null;
152150
this.state = state;
153151
this.focusChangeListener = focusChangeListener;
154152
this.outerContext = outerContext;
@@ -178,14 +176,18 @@ protected void onCreate(Bundle savedInstanceState) {
178176

179177
// Our base mContext has already been wrapped with an IMM cache at instantiation time, but
180178
// we want to wrap it again here to also return state.windowManagerHandler.
181-
Context context =
179+
Context baseContext =
182180
new PresentationContext(getContext(), state.windowManagerHandler, outerContext);
183181

184-
if (state.platformView == null) {
185-
state.platformView = viewFactory.create(context, viewId, createParams);
182+
View embeddedView = state.platformView.getView();
183+
if (embeddedView.getContext() instanceof MutableContextWrapper) {
184+
MutableContextWrapper currentContext = (MutableContextWrapper) embeddedView.getContext();
185+
currentContext.setBaseContext(baseContext);
186+
} else {
187+
throw new IllegalStateException(
188+
"embedded view context must be a MutableContextWrapper: " + viewId);
186189
}
187190

188-
View embeddedView = state.platformView.getView();
189191
container.addView(embeddedView);
190192
rootView =
191193
new AccessibilityDelegatingFrameLayout(

shell/platform/android/io/flutter/plugin/platform/VirtualDisplayController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class VirtualDisplayController {
2525
public static VirtualDisplayController create(
2626
Context context,
2727
AccessibilityEventsDelegate accessibilityEventsDelegate,
28-
PlatformViewFactory viewFactory,
28+
PlatformView view,
2929
TextureRegistry.SurfaceTextureEntry textureEntry,
3030
int width,
3131
int height,
@@ -49,7 +49,7 @@ public static VirtualDisplayController create(
4949
context,
5050
accessibilityEventsDelegate,
5151
virtualDisplay,
52-
viewFactory,
52+
view,
5353
surface,
5454
textureEntry,
5555
focusChangeListener,
@@ -70,7 +70,7 @@ private VirtualDisplayController(
7070
Context context,
7171
AccessibilityEventsDelegate accessibilityEventsDelegate,
7272
VirtualDisplay virtualDisplay,
73-
PlatformViewFactory viewFactory,
73+
PlatformView view,
7474
Surface surface,
7575
TextureRegistry.SurfaceTextureEntry textureEntry,
7676
OnFocusChangeListener focusChangeListener,
@@ -87,7 +87,7 @@ private VirtualDisplayController(
8787
new SingleViewPresentation(
8888
context,
8989
this.virtualDisplay.getDisplay(),
90-
viewFactory,
90+
view,
9191
accessibilityEventsDelegate,
9292
viewId,
9393
createParams,

0 commit comments

Comments
 (0)