Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
707ff9b4
E
engine
项目概览
weixin_43355755
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
707ff9b4
编写于
2月 04, 2016
作者:
H
Hixie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement hover touch exploration mode on Android.
上级
0fa85242
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
82 addition
and
10 deletion
+82
-10
sky/shell/platform/android/org/domokit/sky/shell/FlutterSemanticsToAndroidAccessibilityBridge.java
...y/shell/FlutterSemanticsToAndroidAccessibilityBridge.java
+50
-0
sky/shell/platform/android/org/domokit/sky/shell/PlatformViewAndroid.java
...rm/android/org/domokit/sky/shell/PlatformViewAndroid.java
+32
-10
未找到文件。
sky/shell/platform/android/org/domokit/sky/shell/FlutterSemanticsToAndroidAccessibilityBridge.java
浏览文件 @
707ff9b4
...
...
@@ -30,6 +30,7 @@ public class FlutterSemanticsToAndroidAccessibilityBridge extends AccessibilityN
private
PlatformViewAndroid
mOwner
;
private
SemanticsServer
.
Proxy
mSemanticsServer
;
private
PersistentAccessibilityNode
mFocusedNode
;
private
PersistentAccessibilityNode
mHoveredNode
;
FlutterSemanticsToAndroidAccessibilityBridge
(
PlatformViewAndroid
owner
,
SemanticsServer
.
Proxy
semanticsServer
)
{
assert
owner
!=
null
;
...
...
@@ -177,6 +178,32 @@ public class FlutterSemanticsToAndroidAccessibilityBridge extends AccessibilityN
return
false
;
}
// TODO(ianh): implement findAccessibilityNodeInfosByText()
// TODO(ianh): implement findFocus()
public
void
handleTouchExplorationExit
()
{
if
(
mHoveredNode
!=
null
)
{
sendAccessibilityEvent
(
mHoveredNode
.
id
,
AccessibilityEvent
.
TYPE_VIEW_HOVER_EXIT
);
mHoveredNode
=
null
;
}
}
public
void
handleTouchExploration
(
float
x
,
float
y
)
{
if
(
mTreeNodes
.
isEmpty
())
return
;
assert
mTreeNodes
.
containsKey
(
0
);
PersistentAccessibilityNode
newNode
=
mTreeNodes
.
get
(
0
).
hitTest
(
Math
.
round
(
x
),
Math
.
round
(
y
));
if
(
newNode
!=
mHoveredNode
)
{
if
(
newNode
!=
null
)
{
sendAccessibilityEvent
(
newNode
.
id
,
AccessibilityEvent
.
TYPE_VIEW_HOVER_ENTER
);
}
if
(
mHoveredNode
!=
null
)
{
sendAccessibilityEvent
(
mHoveredNode
.
id
,
AccessibilityEvent
.
TYPE_VIEW_HOVER_EXIT
);
}
mHoveredNode
=
newNode
;
}
}
@Override
public
void
updateSemanticsTree
(
SemanticsNode
[]
nodes
)
{
for
(
SemanticsNode
node
:
nodes
)
{
...
...
@@ -212,6 +239,12 @@ public class FlutterSemanticsToAndroidAccessibilityBridge extends AccessibilityN
assert
mTreeNodes
.
containsKey
(
node
.
id
);
assert
mTreeNodes
.
get
(
node
.
id
).
parent
==
null
;
mTreeNodes
.
remove
(
node
.
id
);
if
(
mFocusedNode
==
node
)
{
mFocusedNode
=
null
;
}
if
(
mHoveredNode
==
node
)
{
mHoveredNode
=
null
;
}
for
(
PersistentAccessibilityNode
child
:
node
.
children
)
{
removePersistentNode
(
child
);
}
...
...
@@ -219,7 +252,10 @@ public class FlutterSemanticsToAndroidAccessibilityBridge extends AccessibilityN
public
void
reset
(
SemanticsServer
.
Proxy
newSemanticsServer
)
{
mTreeNodes
.
clear
();
mFocusedNode
=
null
;
mHoveredNode
=
null
;
mSemanticsServer
.
close
();
sendAccessibilityEvent
(
0
,
AccessibilityEvent
.
TYPE_WINDOW_CONTENT_CHANGED
);
mSemanticsServer
=
newSemanticsServer
;
mSemanticsServer
.
addSemanticsListener
(
this
);
}
...
...
@@ -375,6 +411,20 @@ public class FlutterSemanticsToAndroidAccessibilityBridge extends AccessibilityN
}
return
globalRect
;
}
public
PersistentAccessibilityNode
hitTest
(
int
x
,
int
y
)
{
Rect
rect
=
getGlobalRect
();
if
(!
rect
.
contains
(
x
,
y
))
return
null
;
for
(
int
index
=
children
.
size
()-
1
;
index
>=
0
;
index
-=
1
)
{
PersistentAccessibilityNode
child
=
children
.
get
(
index
);
PersistentAccessibilityNode
result
=
child
.
hitTest
(
x
,
y
);
if
(
result
!=
null
)
{
return
result
;
}
}
return
this
;
}
}
@Override
...
...
sky/shell/platform/android/org/domokit/sky/shell/PlatformViewAndroid.java
浏览文件 @
707ff9b4
...
...
@@ -248,6 +248,16 @@ public class PlatformViewAndroid extends SurfaceView
return
true
;
}
@Override
public
boolean
onHoverEvent
(
MotionEvent
event
)
{
boolean
handled
=
handleAccessibilityHoverEvent
(
event
);
if
(!
handled
)
{
// TODO(ianh): Expose hover events to the platform,
// implementing ADD, REMOVE, etc.
}
return
handled
;
}
@Override
protected
void
onSizeChanged
(
int
width
,
int
height
,
int
oldWidth
,
int
oldHeight
)
{
mMetrics
.
physicalWidth
=
width
;
...
...
@@ -332,10 +342,13 @@ public class PlatformViewAndroid extends SurfaceView
// ACCESSIBILITY
private
boolean
mTouchExplorationEnabled
=
false
;
@Override
protected
void
onAttachedToWindow
()
{
super
.
onAttachedToWindow
();
if
(
mAccessibilityManager
.
isEnabled
()
||
mAccessibilityManager
.
isTouchExplorationEnabled
())
mTouchExplorationEnabled
=
mAccessibilityManager
.
isTouchExplorationEnabled
();
if
(
mAccessibilityManager
.
isEnabled
()
||
mTouchExplorationEnabled
)
ensureAccessibilityEnabled
();
mAccessibilityManager
.
addAccessibilityStateChangeListener
(
this
);
mAccessibilityManager
.
addTouchExplorationStateChangeListener
(
this
);
...
...
@@ -349,9 +362,15 @@ public class PlatformViewAndroid extends SurfaceView
@Override
public
void
onTouchExplorationStateChanged
(
boolean
enabled
)
{
if
(
enabled
)
if
(
enabled
)
{
mTouchExplorationEnabled
=
true
;
ensureAccessibilityEnabled
();
// TODO(ianh): else, actually discard the state for exploration
}
else
{
mTouchExplorationEnabled
=
false
;
if
(
mAccessibilityNodeProvider
!=
null
)
{
mAccessibilityNodeProvider
.
handleTouchExplorationExit
();
}
}
}
@Override
...
...
@@ -382,12 +401,15 @@ public class PlatformViewAndroid extends SurfaceView
}
}
// TODO(ianh): implement findAccessibilityNodeInfosByText()
// TODO(ianh): implement findFocus()
// TODO(ianh): implement touch exploration
// TODO(ianh): implement accessibility focus
private
boolean
handleAccessibilityHoverEvent
(
MotionEvent
event
)
{
if
(!
mTouchExplorationEnabled
)
return
false
;
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_HOVER_EXIT
)
{
mAccessibilityNodeProvider
.
handleTouchExplorationExit
();
}
else
{
mAccessibilityNodeProvider
.
handleTouchExploration
(
event
.
getX
(),
event
.
getY
());
}
return
true
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录