Talkback问题汇总

Talkback问题汇总

Talkback问题汇总

导航页面界面与读屏内容不一致移除引导页面

导航页面

界面与读屏内容不一致

现象:界面显示在page2,tts输出内容为page1+page2,返回上一页现象雷同修改

talkback-master\compositor\src\main\res\raw\compositor.json

"TYPE_VIEW_FOCUSED": {

//modify>>>

//"ttsOutput": "%event_description",

"ttsOutput": "",

"ttsAddToHistory": true,

// From FallbackFormatter

// TODO: Delete porting comments.

"earcon": {

"if": "$event.sourceIsNull",

"then": "@raw/focus_actionable"

},

"haptic": {

"if": "$event.sourceIsNull",

"then": "@array/view_focused_or_selected_pattern"

}

},

由于json是全局配置文件,修改有风险,继而java中做判断条件修改

talkback-master\compositor\src\main\java\com\google\android\accessibility\compositor\Compositor.java

private void handleEvent(

int event,

@Nullable EventId eventId,

ParseTree.VariableDelegate delegate,

HandleEventOptions options) {

...

// custom for training >>>

CharSequence ttsOutput ="";

if (eventObject!= null) {

Log.i(TAG, "handleEvent: " + eventObject.toString());

}

if (eventObject!= null

&& eventObject.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED

&& "com.android.talkback".equals(eventObject.getPackageName())){

ttsOutput ="";

}else {

ttsOutput = mParseTree.parseEventToString(event, OUTPUT_TTS_OUTPUT, delegate);

}

CharSequence ttsOutput = mParseTree.parseEventToString(event, OUTPUT_TTS_OUTPUT, delegate);

Log.i(TAG, "handleEvent: ttsOutput="+ttsOutput);

...

}

talkback-master\talkback\src\main\java\com\google\android\accessibility\talkback\eventprocessor\ProcessorScreen.java

此处修改可以避免title重复读

@Override

protected boolean allowAnnounce(AccessibilityEvent event) {

// If the user performs a cursor control(copy, paste, start selection mode, etc) in the

// talkback context menu and lands back to the edit text, a TYPE_WINDOWS_CHANGED and a

// TYPE_WINDOW_STATE_CHANGED events will be fired. We should skip these two events to

// avoid announcing the window title.

boolean allowAnnounce = true;

if (event.getEventType() == AccessibilityEvent.TYPE_WINDOWS_CHANGED

&& EventState.getInstance()

.checkAndClearRecentFlag(

EventState.EVENT_SKIP_WINDOWS_CHANGED_PROCESSING_AFTER_CURSOR_CONTROL)) {

allowAnnounce = false;

}

if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED

&& EventState.getInstance()

.checkAndClearRecentFlag(

EventState.EVENT_SKIP_WINDOW_STATE_CHANGED_PROCESSING_AFTER_CURSOR_CONTROL)) {

allowAnnounce = false;

}

Log.i(TAG, "allowAnnounce: "+allowAnnounce);

//modify>>>>>

if (WindowUtils.rootChildMatchesResId(service, TrainingActivity.ROOT_RES_ID)){

Log.i(TAG, "allowAnnounce: is TrainingActivity>>>");

allowAnnounce = false;

}

return allowAnnounce;

}

talkback-master\talkback\src\main\java\com\google\android\accessibility\talkback\training\TrainingFragment.java

修改后辅助功能的焦点框会直接选中界面外布局而非内部子布局

@Override

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {

final View view = inflater.inflate(R.layout.training_fragment_name, container, false);

pageLayout = view.findViewById(R.id.training_page);

@Nullable PageId pageId = (PageId) getArguments().get(EXTRA_PAGE);

if (pageId == null) {

LogUtils.e(TAG, "Cannot create view because no page ID.");

return view;

}

page = PageConfig.getPage(pageId);

if (page == null) {

LogUtils.e(TAG, "Cannot create view because unknown PageId. [%s]", pageId.name());

return view;

}

addView(inflater, container);

//modify>>>>>

//pageLayout.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_AUTO);

pageLayout.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);

if (FeatureSupport.isWatch(getContext())) {

// Support rotary input.

view.requestFocus();

}

return view;

}

talkback-master\talkback\src\main\java\com\google\android\accessibility\talkback\utils\DiagnosticOverlayControllerImpl.java

以上修改后在返回上一页时会出现辅助功能的焦点框丢失,继而添加以下修改

/**

* Receives and appends Feedback object to log controller. Feedback objects are filtered for swipe

* gestures.

*/

public void appendLog(Feedback feedback) {

Feedback.@Nullable Part failover =

(feedback.failovers() == null || feedback.failovers().size() < 1

? null

: feedback.failovers().get(0));

if (failover == null) {

return;

}

// Filter for FOCUS and FOCUS DIRECTION actions,

// which mark beg/end of swipe gesture + associated focus

if (failover.focus() == null

&& failover.focusDirection() == null

&& failover.scroll() == null) {

return;

}

/** Check to make sure eventID isn't null before checking for gestures */

if (!this.enabled

|| feedback.eventId() == null

|| highlightOverlay == null

|| diagnosticOverlay == null) {

return;

}

/**

* Clear/recycle traversed/unfocused nodes when window changes/scrolls to new screen because

* usually {@link FocusProcessorForLogicalNavigation} tells when clear/recycle, but with new

* screen change/scroll, we must call {@link

* DiagnosticOverlayControllerImpl#clearAndRecycleCollectionNodes} from here

*/

if (feedback.eventId().getEventSubtype() == AccessibilityEvent.TYPE_WINDOWS_CHANGED

|| feedback.eventId().getEventSubtype() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED

|| failover.scroll() != null) {

Log.i(TAG, "appendLog: >>>>>>>>>>>>>>>>>>>>>>");

//modify>>>>>需要添加判断条件

//clearAndRecycleCollectionNodes(/* recycleFocusedNode= */ false);

//highlightOverlay.clearHighlight();

}

移除引导页面

找到对应的显示界面数组后跟踪,修改: talkback-master\talkback\src\main\java\com\google\android\accessibility\talkback\TalkBackService.java

@Override

protected void onServiceConnected() {

LogUtils.v(TAG, "System bound to service.");

...

//modify>>>>

if (false && !FeatureSupport.isTv(getApplicationContext())

&& !FeatureSupport.isWatch(getApplicationContext())) {

OnboardingInitiator.showOnboarding91IfNecessary(this);

}

...

}

相关推荐

第五套人民币100元券99年版首发券投资收藏浅析
365足球外围平台

第五套人民币100元券99年版首发券投资收藏浅析

📅 10-01 👁️ 1699
哔哩哔哩工资待遇怎么样
365足球外围平台

哔哩哔哩工资待遇怎么样

📅 09-23 👁️ 1146
斗蟹游戏盒子怎么样
365官网国内怎么进

斗蟹游戏盒子怎么样

📅 07-12 👁️ 729
融贝网怎么样?靠谱吗?真实测评带你了解理财平台优势与风险
小学语文句子仿写100例全汇总,期末考试不用愁~
“神三鬼四”磕头文化:祭祖只能拜四次,千万别弄错了