Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
760fea25
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
760fea25
编写于
5月 20, 2019
作者:
A
Amir Hardon
提交者:
GitHub
5月 20, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove m prefix from fields in the Android PlatformViews code (#9020)
上级
75678602
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
136 addition
and
136 deletion
+136
-136
shell/platform/android/io/flutter/plugin/platform/PlatformViewFactory.java
...droid/io/flutter/plugin/platform/PlatformViewFactory.java
+3
-3
shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java
...d/io/flutter/plugin/platform/PlatformViewsController.java
+25
-25
shell/platform/android/io/flutter/plugin/platform/SingleViewPresentation.java
...id/io/flutter/plugin/platform/SingleViewPresentation.java
+76
-76
shell/platform/android/io/flutter/plugin/platform/VirtualDisplayController.java
.../io/flutter/plugin/platform/VirtualDisplayController.java
+32
-32
未找到文件。
shell/platform/android/io/flutter/plugin/platform/PlatformViewFactory.java
浏览文件 @
760fea25
...
...
@@ -8,14 +8,14 @@ import android.content.Context;
import
io.flutter.plugin.common.MessageCodec
;
public
abstract
class
PlatformViewFactory
{
private
final
MessageCodec
<
Object
>
mC
reateArgsCodec
;
private
final
MessageCodec
<
Object
>
c
reateArgsCodec
;
/**
*
* @param createArgsCodec the codec used to decode the args parameter of {@link #create}.
*/
public
PlatformViewFactory
(
MessageCodec
<
Object
>
createArgsCodec
)
{
mC
reateArgsCodec
=
createArgsCodec
;
this
.
c
reateArgsCodec
=
createArgsCodec
;
}
/**
...
...
@@ -33,6 +33,6 @@ public abstract class PlatformViewFactory {
* Returns the codec to be used for decoding the args parameter of {@link #create}.
*/
public
final
MessageCodec
<
Object
>
getCreateArgsCodec
()
{
return
mC
reateArgsCodec
;
return
c
reateArgsCodec
;
}
}
shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java
浏览文件 @
760fea25
...
...
@@ -41,26 +41,26 @@ public class PlatformViewsController implements MethodChannel.MethodCallHandler,
// API level 20 is required for VirtualDisplay#setSurface which we use when resizing a platform view.
private
static
final
int
MINIMAL_SDK
=
Build
.
VERSION_CODES
.
KITKAT_WATCH
;
private
final
PlatformViewRegistryImpl
mR
egistry
;
private
final
PlatformViewRegistryImpl
r
egistry
;
// The context of the Activity or Fragment hosting the render target for the Flutter engine.
private
Context
mC
ontext
;
private
Context
c
ontext
;
// The texture registry maintaining the textures into which the embedded views will be rendered.
private
TextureRegistry
mT
extureRegistry
;
private
TextureRegistry
t
extureRegistry
;
// The messenger used to communicate with the framework over the platform views channel.
private
BinaryMessenger
m
M
essenger
;
private
BinaryMessenger
messenger
;
// The accessibility bridge to which accessibility events form the platform views will be dispatched.
private
final
AccessibilityEventsDelegate
mA
ccessibilityEventsDelegate
;
private
final
AccessibilityEventsDelegate
a
ccessibilityEventsDelegate
;
private
final
HashMap
<
Integer
,
VirtualDisplayController
>
vdControllers
;
public
PlatformViewsController
()
{
mR
egistry
=
new
PlatformViewRegistryImpl
();
r
egistry
=
new
PlatformViewRegistryImpl
();
vdControllers
=
new
HashMap
<>();
mA
ccessibilityEventsDelegate
=
new
AccessibilityEventsDelegate
();
a
ccessibilityEventsDelegate
=
new
AccessibilityEventsDelegate
();
}
/**
...
...
@@ -73,15 +73,15 @@ public class PlatformViewsController implements MethodChannel.MethodCallHandler,
* @param messenger The Flutter application on the other side of this messenger drives this platform views controller.
*/
public
void
attach
(
Context
context
,
TextureRegistry
textureRegistry
,
BinaryMessenger
messenger
)
{
if
(
mC
ontext
!=
null
)
{
if
(
this
.
c
ontext
!=
null
)
{
throw
new
AssertionError
(
"A PlatformViewsController can only be attached to a single output target.\n"
+
"attach was called while the PlatformViewsController was already attached."
);
}
mC
ontext
=
context
;
mT
extureRegistry
=
textureRegistry
;
mM
essenger
=
messenger
;
this
.
c
ontext
=
context
;
this
.
t
extureRegistry
=
textureRegistry
;
this
.
m
essenger
=
messenger
;
MethodChannel
channel
=
new
MethodChannel
(
messenger
,
CHANNEL_NAME
,
StandardMethodCodec
.
INSTANCE
);
channel
.
setMethodCallHandler
(
this
);
}
...
...
@@ -95,24 +95,24 @@ public class PlatformViewsController implements MethodChannel.MethodCallHandler,
*/
@UiThread
public
void
detach
()
{
m
M
essenger
.
setMessageHandler
(
CHANNEL_NAME
,
null
);
m
M
essenger
=
null
;
mC
ontext
=
null
;
mT
extureRegistry
=
null
;
messenger
.
setMessageHandler
(
CHANNEL_NAME
,
null
);
messenger
=
null
;
c
ontext
=
null
;
t
extureRegistry
=
null
;
}
@Override
public
void
attachAccessibilityBridge
(
AccessibilityBridge
accessibilityBridge
)
{
mA
ccessibilityEventsDelegate
.
setAccessibilityBridge
(
accessibilityBridge
);
a
ccessibilityEventsDelegate
.
setAccessibilityBridge
(
accessibilityBridge
);
}
@Override
public
void
detachAccessibiltyBridge
()
{
mA
ccessibilityEventsDelegate
.
setAccessibilityBridge
(
null
);
a
ccessibilityEventsDelegate
.
setAccessibilityBridge
(
null
);
}
public
PlatformViewRegistry
getRegistry
()
{
return
mR
egistry
;
return
r
egistry
;
}
public
void
onFlutterViewDestroyed
()
{
...
...
@@ -186,7 +186,7 @@ public class PlatformViewsController implements MethodChannel.MethodCallHandler,
return
;
}
PlatformViewFactory
viewFactory
=
mR
egistry
.
getFactory
(
viewType
);
PlatformViewFactory
viewFactory
=
r
egistry
.
getFactory
(
viewType
);
if
(
viewFactory
==
null
)
{
result
.
error
(
"error"
,
...
...
@@ -205,10 +205,10 @@ public class PlatformViewsController implements MethodChannel.MethodCallHandler,
int
physicalHeight
=
toPhysicalPixels
(
logicalHeight
);
validateVirtualDisplayDimensions
(
physicalWidth
,
physicalHeight
);
TextureRegistry
.
SurfaceTextureEntry
textureEntry
=
mT
extureRegistry
.
createSurfaceTexture
();
TextureRegistry
.
SurfaceTextureEntry
textureEntry
=
t
extureRegistry
.
createSurfaceTexture
();
VirtualDisplayController
vdController
=
VirtualDisplayController
.
create
(
mC
ontext
,
mA
ccessibilityEventsDelegate
,
c
ontext
,
a
ccessibilityEventsDelegate
,
viewFactory
,
textureEntry
,
physicalWidth
,
...
...
@@ -287,7 +287,7 @@ public class PlatformViewsController implements MethodChannel.MethodCallHandler,
private
void
onTouch
(
MethodCall
call
,
MethodChannel
.
Result
result
)
{
List
<
Object
>
args
=
call
.
arguments
();
float
density
=
mC
ontext
.
getResources
().
getDisplayMetrics
().
density
;
float
density
=
c
ontext
.
getResources
().
getDisplayMetrics
().
density
;
int
id
=
(
int
)
args
.
get
(
0
);
Number
downTime
=
(
Number
)
args
.
get
(
1
);
...
...
@@ -420,7 +420,7 @@ public class PlatformViewsController implements MethodChannel.MethodCallHandler,
// Creating a VirtualDisplay larger than the size of the device screen size
// could cause the device to restart: https://github.com/flutter/flutter/issues/28978
private
void
validateVirtualDisplayDimensions
(
int
width
,
int
height
)
{
DisplayMetrics
metrics
=
mC
ontext
.
getResources
().
getDisplayMetrics
();
DisplayMetrics
metrics
=
c
ontext
.
getResources
().
getDisplayMetrics
();
if
(
height
>
metrics
.
heightPixels
||
width
>
metrics
.
widthPixels
)
{
String
error
=
"Creating a virtual display of size: "
+
"["
+
width
+
", "
+
height
+
"]"
...
...
@@ -431,7 +431,7 @@ public class PlatformViewsController implements MethodChannel.MethodCallHandler,
}
private
int
toPhysicalPixels
(
double
logicalPixels
)
{
float
density
=
mC
ontext
.
getResources
().
getDisplayMetrics
().
density
;
float
density
=
c
ontext
.
getResources
().
getDisplayMetrics
().
density
;
return
(
int
)
Math
.
round
(
logicalPixels
*
density
);
}
...
...
shell/platform/android/io/flutter/plugin/platform/SingleViewPresentation.java
浏览文件 @
760fea25
...
...
@@ -24,15 +24,15 @@ import static android.content.Context.WINDOW_SERVICE;
* A presentation used for hosting a single Android view in a virtual display.
*
* This presentation overrides the WindowManager's addView/removeView/updateViewLayout methods, such that views added
* directly to the WindowManager are added as part of the presentation's view hierarchy (to
mFakeWindowRootView
).
* directly to the WindowManager are added as part of the presentation's view hierarchy (to
fakeWindowViewGroup
).
*
* The view hierarchy for the presentation is as following:
*
*
mR
ootView
*
r
ootView
* / \
* / \
* / \
*
mContainer mState.mFakeWindowRootView
*
container state.fakeWindowViewGroup
* |
* EmbeddedView
*/
...
...
@@ -46,37 +46,37 @@ class SingleViewPresentation extends Presentation {
*/
static
class
PresentationState
{
// The Android view we are embedding in the Flutter app.
private
PlatformView
mView
;
private
PlatformView
platfor
mView
;
// The InvocationHandler for a WindowManager proxy. This is essentially the custom window manager for the
// presentation.
private
WindowManagerHandler
mW
indowManagerHandler
;
private
WindowManagerHandler
w
indowManagerHandler
;
// Contains views that were added directly to the window manager (e.g android.widget.PopupWindow).
private
FakeWindowViewGroup
mFakeWindowRootView
;
private
FakeWindowViewGroup
fakeWindowViewGroup
;
}
private
final
PlatformViewFactory
mV
iewFactory
;
private
final
PlatformViewFactory
v
iewFactory
;
// A reference to the current accessibility bridge to which accessibility events will be delegated.
private
final
AccessibilityEventsDelegate
mA
ccessibilityEventsDelegate
;
private
final
AccessibilityEventsDelegate
a
ccessibilityEventsDelegate
;
// This is the view id assigned by the Flutter framework to the embedded view, we keep it here
// so when we create the platform view we can tell it its view id.
private
int
mV
iewId
;
private
int
v
iewId
;
// This is the creation parameters for the platform view, we keep it here
// so when we create the platform view we can tell it its view id.
private
Object
mC
reateParams
;
private
Object
c
reateParams
;
// The root view for the presentation, it has 2 childs:
mC
ontainer which contains the embedded view, and
//
mFakeWindowRootView
which contains views that were added directly to the presentation's window manager.
private
AccessibilityDelegatingFrameLayout
mR
ootView
;
// The root view for the presentation, it has 2 childs:
c
ontainer which contains the embedded view, and
//
fakeWindowViewGroup
which contains views that were added directly to the presentation's window manager.
private
AccessibilityDelegatingFrameLayout
r
ootView
;
// Contains the embedded platform view (mView.getView()) when it is attached to the presentation.
private
FrameLayout
mC
ontainer
;
// Contains the embedded platform view (
platfor
mView.getView()) when it is attached to the presentation.
private
FrameLayout
c
ontainer
;
private
PresentationState
mS
tate
;
private
PresentationState
s
tate
;
/**
* Creates a presentation that will use the view factory to create a new
...
...
@@ -91,11 +91,11 @@ class SingleViewPresentation extends Presentation {
Object
createParams
)
{
super
(
outerContext
,
display
);
mV
iewFactory
=
viewFactory
;
mA
ccessibilityEventsDelegate
=
accessibilityEventsDelegate
;
mV
iewId
=
viewId
;
mC
reateParams
=
createParams
;
mS
tate
=
new
PresentationState
();
this
.
v
iewFactory
=
viewFactory
;
this
.
a
ccessibilityEventsDelegate
=
accessibilityEventsDelegate
;
this
.
v
iewId
=
viewId
;
this
.
c
reateParams
=
createParams
;
s
tate
=
new
PresentationState
();
getWindow
().
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_NOT_FOCUSABLE
,
WindowManager
.
LayoutParams
.
FLAG_NOT_FOCUSABLE
...
...
@@ -116,9 +116,9 @@ class SingleViewPresentation extends Presentation {
PresentationState
state
)
{
super
(
outerContext
,
display
);
mA
ccessibilityEventsDelegate
=
accessibilityEventsDelegate
;
mV
iewFactory
=
null
;
mS
tate
=
state
;
this
.
a
ccessibilityEventsDelegate
=
accessibilityEventsDelegate
;
v
iewFactory
=
null
;
this
.
s
tate
=
state
;
getWindow
().
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_NOT_FOCUSABLE
,
WindowManager
.
LayoutParams
.
FLAG_NOT_FOCUSABLE
...
...
@@ -128,39 +128,39 @@ class SingleViewPresentation extends Presentation {
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
if
(
mState
.
mFakeWindowRootView
==
null
)
{
mState
.
mFakeWindowRootView
=
new
FakeWindowViewGroup
(
getContext
());
if
(
state
.
fakeWindowViewGroup
==
null
)
{
state
.
fakeWindowViewGroup
=
new
FakeWindowViewGroup
(
getContext
());
}
if
(
mState
.
mW
indowManagerHandler
==
null
)
{
if
(
state
.
w
indowManagerHandler
==
null
)
{
WindowManager
windowManagerDelegate
=
(
WindowManager
)
getContext
().
getSystemService
(
WINDOW_SERVICE
);
mState
.
mWindowManagerHandler
=
new
WindowManagerHandler
(
windowManagerDelegate
,
mState
.
mFakeWindowRootView
);
state
.
windowManagerHandler
=
new
WindowManagerHandler
(
windowManagerDelegate
,
state
.
fakeWindowViewGroup
);
}
mC
ontainer
=
new
FrameLayout
(
getContext
());
PresentationContext
context
=
new
PresentationContext
(
getContext
(),
mState
.
mW
indowManagerHandler
);
c
ontainer
=
new
FrameLayout
(
getContext
());
PresentationContext
context
=
new
PresentationContext
(
getContext
(),
state
.
w
indowManagerHandler
);
if
(
mState
.
mView
==
null
)
{
mState
.
mView
=
mViewFactory
.
create
(
context
,
mViewId
,
mC
reateParams
);
if
(
state
.
platfor
mView
==
null
)
{
state
.
platformView
=
viewFactory
.
create
(
context
,
viewId
,
c
reateParams
);
}
View
embeddedView
=
mState
.
mView
.
getView
();
mC
ontainer
.
addView
(
embeddedView
);
mRootView
=
new
AccessibilityDelegatingFrameLayout
(
getContext
(),
mA
ccessibilityEventsDelegate
,
embeddedView
);
mRootView
.
addView
(
mC
ontainer
);
mRootView
.
addView
(
mState
.
mFakeWindowRootView
);
setContentView
(
mR
ootView
);
View
embeddedView
=
state
.
platfor
mView
.
getView
();
c
ontainer
.
addView
(
embeddedView
);
rootView
=
new
AccessibilityDelegatingFrameLayout
(
getContext
(),
a
ccessibilityEventsDelegate
,
embeddedView
);
rootView
.
addView
(
c
ontainer
);
rootView
.
addView
(
state
.
fakeWindowViewGroup
);
setContentView
(
r
ootView
);
}
public
PresentationState
detachState
()
{
mC
ontainer
.
removeAllViews
();
mR
ootView
.
removeAllViews
();
return
mS
tate
;
c
ontainer
.
removeAllViews
();
r
ootView
.
removeAllViews
();
return
s
tate
;
}
public
PlatformView
getView
()
{
if
(
mState
.
mView
==
null
)
if
(
state
.
platfor
mView
==
null
)
return
null
;
return
mState
.
mView
;
return
state
.
platfor
mView
;
}
/*
...
...
@@ -172,16 +172,16 @@ class SingleViewPresentation extends Presentation {
static
class
FakeWindowViewGroup
extends
ViewGroup
{
// Used in onLayout to keep the bounds of the current view.
// We keep it as a member to avoid object allocations during onLayout which are discouraged.
private
final
Rect
mV
iewBounds
;
private
final
Rect
v
iewBounds
;
// Used in onLayout to keep the bounds of the child views.
// We keep it as a member to avoid object allocations during onLayout which are discouraged.
private
final
Rect
mC
hildRect
;
private
final
Rect
c
hildRect
;
public
FakeWindowViewGroup
(
Context
context
)
{
super
(
context
);
mV
iewBounds
=
new
Rect
();
mC
hildRect
=
new
Rect
();
v
iewBounds
=
new
Rect
();
c
hildRect
=
new
Rect
();
}
@Override
...
...
@@ -189,10 +189,10 @@ class SingleViewPresentation extends Presentation {
for
(
int
i
=
0
;
i
<
getChildCount
();
i
++)
{
View
child
=
getChildAt
(
i
);
WindowManager
.
LayoutParams
params
=
(
WindowManager
.
LayoutParams
)
child
.
getLayoutParams
();
mV
iewBounds
.
set
(
l
,
t
,
r
,
b
);
Gravity
.
apply
(
params
.
gravity
,
child
.
getMeasuredWidth
(),
child
.
getMeasuredHeight
(),
mV
iewBounds
,
params
.
x
,
params
.
y
,
mC
hildRect
);
child
.
layout
(
mChildRect
.
left
,
mChildRect
.
top
,
mChildRect
.
right
,
mC
hildRect
.
bottom
);
v
iewBounds
.
set
(
l
,
t
,
r
,
b
);
Gravity
.
apply
(
params
.
gravity
,
child
.
getMeasuredWidth
(),
child
.
getMeasuredHeight
(),
v
iewBounds
,
params
.
x
,
params
.
y
,
c
hildRect
);
child
.
layout
(
childRect
.
left
,
childRect
.
top
,
childRect
.
right
,
c
hildRect
.
bottom
);
}
}
...
...
@@ -214,12 +214,12 @@ class SingleViewPresentation extends Presentation {
* Proxies a Context replacing the WindowManager with our custom instance.
*/
static
class
PresentationContext
extends
ContextWrapper
{
private
WindowManager
mW
indowManager
;
private
final
WindowManagerHandler
mW
indowManagerHandler
;
private
WindowManager
w
indowManager
;
private
final
WindowManagerHandler
w
indowManagerHandler
;
PresentationContext
(
Context
base
,
WindowManagerHandler
windowManagerHandler
)
{
super
(
base
);
mW
indowManagerHandler
=
windowManagerHandler
;
this
.
w
indowManagerHandler
=
windowManagerHandler
;
}
@Override
...
...
@@ -231,10 +231,10 @@ class SingleViewPresentation extends Presentation {
}
private
WindowManager
getWindowManager
()
{
if
(
mW
indowManager
==
null
)
{
mWindowManager
=
mW
indowManagerHandler
.
getWindowManager
();
if
(
w
indowManager
==
null
)
{
windowManager
=
w
indowManagerHandler
.
getWindowManager
();
}
return
mW
indowManager
;
return
w
indowManager
;
}
}
...
...
@@ -256,12 +256,12 @@ class SingleViewPresentation extends Presentation {
static
class
WindowManagerHandler
implements
InvocationHandler
{
private
static
final
String
TAG
=
"PlatformViewsController"
;
private
final
WindowManager
mD
elegate
;
FakeWindowViewGroup
mF
akeWindowRootView
;
private
final
WindowManager
d
elegate
;
FakeWindowViewGroup
f
akeWindowRootView
;
WindowManagerHandler
(
WindowManager
delegate
,
FakeWindowViewGroup
fakeWindowViewGroup
)
{
mD
elegate
=
delegate
;
mF
akeWindowRootView
=
fakeWindowViewGroup
;
this
.
d
elegate
=
delegate
;
f
akeWindowRootView
=
fakeWindowViewGroup
;
}
public
WindowManager
getWindowManager
()
{
...
...
@@ -289,69 +289,69 @@ class SingleViewPresentation extends Presentation {
return
null
;
}
try
{
return
method
.
invoke
(
mD
elegate
,
args
);
return
method
.
invoke
(
d
elegate
,
args
);
}
catch
(
InvocationTargetException
e
)
{
throw
e
.
getCause
();
}
}
private
void
addView
(
Object
[]
args
)
{
if
(
mF
akeWindowRootView
==
null
)
{
if
(
f
akeWindowRootView
==
null
)
{
Log
.
w
(
TAG
,
"Embedded view called addView while detached from presentation"
);
return
;
}
View
view
=
(
View
)
args
[
0
];
WindowManager
.
LayoutParams
layoutParams
=
(
WindowManager
.
LayoutParams
)
args
[
1
];
mF
akeWindowRootView
.
addView
(
view
,
layoutParams
);
f
akeWindowRootView
.
addView
(
view
,
layoutParams
);
}
private
void
removeView
(
Object
[]
args
)
{
if
(
mF
akeWindowRootView
==
null
)
{
if
(
f
akeWindowRootView
==
null
)
{
Log
.
w
(
TAG
,
"Embedded view called removeView while detached from presentation"
);
return
;
}
View
view
=
(
View
)
args
[
0
];
mF
akeWindowRootView
.
removeView
(
view
);
f
akeWindowRootView
.
removeView
(
view
);
}
private
void
removeViewImmediate
(
Object
[]
args
)
{
if
(
mF
akeWindowRootView
==
null
)
{
if
(
f
akeWindowRootView
==
null
)
{
Log
.
w
(
TAG
,
"Embedded view called removeViewImmediate while detached from presentation"
);
return
;
}
View
view
=
(
View
)
args
[
0
];
view
.
clearAnimation
();
mF
akeWindowRootView
.
removeView
(
view
);
f
akeWindowRootView
.
removeView
(
view
);
}
private
void
updateViewLayout
(
Object
[]
args
)
{
if
(
mF
akeWindowRootView
==
null
)
{
if
(
f
akeWindowRootView
==
null
)
{
Log
.
w
(
TAG
,
"Embedded view called updateViewLayout while detached from presentation"
);
return
;
}
View
view
=
(
View
)
args
[
0
];
WindowManager
.
LayoutParams
layoutParams
=
(
WindowManager
.
LayoutParams
)
args
[
1
];
mF
akeWindowRootView
.
updateViewLayout
(
view
,
layoutParams
);
f
akeWindowRootView
.
updateViewLayout
(
view
,
layoutParams
);
}
}
private
static
class
AccessibilityDelegatingFrameLayout
extends
FrameLayout
{
private
final
AccessibilityEventsDelegate
mA
ccessibilityEventsDelegate
;
private
final
View
mE
mbeddedView
;
private
final
AccessibilityEventsDelegate
a
ccessibilityEventsDelegate
;
private
final
View
e
mbeddedView
;
public
AccessibilityDelegatingFrameLayout
(
Context
context
,
AccessibilityEventsDelegate
accessibilityEventsDelegate
,
View
ebeddedView
View
e
m
beddedView
)
{
super
(
context
);
mA
ccessibilityEventsDelegate
=
accessibilityEventsDelegate
;
mEmbeddedView
=
e
beddedView
;
this
.
a
ccessibilityEventsDelegate
=
accessibilityEventsDelegate
;
this
.
embeddedView
=
em
beddedView
;
}
@Override
public
boolean
requestSendAccessibilityEvent
(
View
child
,
AccessibilityEvent
event
)
{
return
mAccessibilityEventsDelegate
.
requestSendAccessibilityEvent
(
mE
mbeddedView
,
child
,
event
);
return
accessibilityEventsDelegate
.
requestSendAccessibilityEvent
(
e
mbeddedView
,
child
,
event
);
}
}
}
shell/platform/android/io/flutter/plugin/platform/VirtualDisplayController.java
浏览文件 @
760fea25
...
...
@@ -49,13 +49,13 @@ class VirtualDisplayController {
context
,
accessibilityEventsDelegate
,
virtualDisplay
,
viewFactory
,
surface
,
textureEntry
,
viewId
,
createParams
);
}
private
final
Context
mC
ontext
;
private
final
AccessibilityEventsDelegate
mA
ccessibilityEventsDelegate
;
private
final
int
mD
ensityDpi
;
private
final
TextureRegistry
.
SurfaceTextureEntry
mT
extureEntry
;
private
VirtualDisplay
mV
irtualDisplay
;
private
SingleViewPresentation
mP
resentation
;
private
Surface
mS
urface
;
private
final
Context
c
ontext
;
private
final
AccessibilityEventsDelegate
a
ccessibilityEventsDelegate
;
private
final
int
d
ensityDpi
;
private
final
TextureRegistry
.
SurfaceTextureEntry
t
extureEntry
;
private
VirtualDisplay
v
irtualDisplay
;
private
SingleViewPresentation
p
resentation
;
private
Surface
s
urface
;
private
VirtualDisplayController
(
...
...
@@ -68,35 +68,35 @@ class VirtualDisplayController {
int
viewId
,
Object
createParams
)
{
mC
ontext
=
context
;
mA
ccessibilityEventsDelegate
=
accessibilityEventsDelegate
;
mT
extureEntry
=
textureEntry
;
mS
urface
=
surface
;
mV
irtualDisplay
=
virtualDisplay
;
mD
ensityDpi
=
context
.
getResources
().
getDisplayMetrics
().
densityDpi
;
mP
resentation
=
new
SingleViewPresentation
(
context
,
mV
irtualDisplay
.
getDisplay
(),
viewFactory
,
accessibilityEventsDelegate
,
viewId
,
createParams
);
mP
resentation
.
show
();
this
.
c
ontext
=
context
;
this
.
a
ccessibilityEventsDelegate
=
accessibilityEventsDelegate
;
this
.
t
extureEntry
=
textureEntry
;
this
.
s
urface
=
surface
;
this
.
v
irtualDisplay
=
virtualDisplay
;
d
ensityDpi
=
context
.
getResources
().
getDisplayMetrics
().
densityDpi
;
p
resentation
=
new
SingleViewPresentation
(
context
,
this
.
v
irtualDisplay
.
getDisplay
(),
viewFactory
,
accessibilityEventsDelegate
,
viewId
,
createParams
);
p
resentation
.
show
();
}
public
void
resize
(
final
int
width
,
final
int
height
,
final
Runnable
onNewSizeFrameAvailable
)
{
final
SingleViewPresentation
.
PresentationState
presentationState
=
mP
resentation
.
detachState
();
final
SingleViewPresentation
.
PresentationState
presentationState
=
p
resentation
.
detachState
();
// We detach the surface to prevent it being destroyed when releasing the vd.
//
// setSurface is only available starting API 20. We could support API 19 by re-creating a new
// SurfaceTexture here. This will require refactoring the TextureRegistry to allow recycling texture
// entry IDs.
mV
irtualDisplay
.
setSurface
(
null
);
mV
irtualDisplay
.
release
();
v
irtualDisplay
.
setSurface
(
null
);
v
irtualDisplay
.
release
();
mT
extureEntry
.
surfaceTexture
().
setDefaultBufferSize
(
width
,
height
);
DisplayManager
displayManager
=
(
DisplayManager
)
mC
ontext
.
getSystemService
(
Context
.
DISPLAY_SERVICE
);
mV
irtualDisplay
=
displayManager
.
createVirtualDisplay
(
t
extureEntry
.
surfaceTexture
().
setDefaultBufferSize
(
width
,
height
);
DisplayManager
displayManager
=
(
DisplayManager
)
c
ontext
.
getSystemService
(
Context
.
DISPLAY_SERVICE
);
v
irtualDisplay
=
displayManager
.
createVirtualDisplay
(
"flutter-vd"
,
width
,
height
,
mD
ensityDpi
,
mS
urface
,
d
ensityDpi
,
s
urface
,
0
);
...
...
@@ -125,22 +125,22 @@ class VirtualDisplayController {
public
void
onViewDetachedFromWindow
(
View
v
)
{}
});
mPresentation
=
new
SingleViewPresentation
(
mContext
,
mVirtualDisplay
.
getDisplay
(),
mA
ccessibilityEventsDelegate
,
presentationState
);
mP
resentation
.
show
();
presentation
=
new
SingleViewPresentation
(
context
,
virtualDisplay
.
getDisplay
(),
a
ccessibilityEventsDelegate
,
presentationState
);
p
resentation
.
show
();
}
public
void
dispose
()
{
PlatformView
view
=
mP
resentation
.
getView
();
mP
resentation
.
detachState
();
PlatformView
view
=
p
resentation
.
getView
();
p
resentation
.
detachState
();
view
.
dispose
();
mV
irtualDisplay
.
release
();
mT
extureEntry
.
release
();
v
irtualDisplay
.
release
();
t
extureEntry
.
release
();
}
public
View
getView
()
{
if
(
mP
resentation
==
null
)
if
(
p
resentation
==
null
)
return
null
;
PlatformView
platformView
=
mP
resentation
.
getView
();
PlatformView
platformView
=
p
resentation
.
getView
();
return
platformView
.
getView
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录