List of usage examples for android.view.accessibility AccessibilityWindowInfo getTitle
@Nullable
public CharSequence getTitle()
From source file:com.android.talkback.eventprocessor.ProcessorScreen.java
private CharSequence getWindowTitle(int windowId) { // Try to get window title from the map. CharSequence windowTitle = mWindowTitlesMap.get(windowId); if (windowTitle != null) { return windowTitle; }// w w w.j a v a 2 s . co m if (!BuildCompat.isAtLeastN()) { return null; } // Do not try to get system window title from AccessibilityWindowInfo.getTitle, it can // return non-translated value. if (isSystemWindow(windowId)) { return null; } // Try to get window title from AccessibilityWindowInfo. for (AccessibilityWindowInfo window : mService.getWindows()) { if (window.getId() == windowId) { return window.getTitle(); } } return null; }
From source file:com.android.talkback.formatter.TouchExplorationFormatter.java
/** * Populates utterance about window transition. We populate this feedback only when user is in * split screen mode to avoid verbosity of feedback. */// ww w. j a v a2 s . com private void addWindowTransition(Utterance utterance, AccessibilityNodeInfoCompat announcedNode) { int windowId = announcedNode.getWindowId(); if (windowId == mLastFocusedWindowId) { return; } int windowType = getWindowType(announcedNode); if (windowType != AccessibilityWindowInfoCompat.TYPE_APPLICATION && windowType != AccessibilityWindowInfoCompat.TYPE_SYSTEM) { return; } List<AccessibilityWindowInfo> windows = mService.getWindows(); List<AccessibilityWindowInfo> applicationWindows = new ArrayList<>(); for (AccessibilityWindowInfo window : windows) { if (window.getType() == AccessibilityWindowInfo.TYPE_APPLICATION) { if (window.getParent() == null) { applicationWindows.add(window); } } } // Provide window transition feedback only when user is in split screen mode or navigating // with keyboard. We consider user is in split screen mode if there are two none-parented // application windows. if (applicationWindows.size() != 2 && mService.getInputModeManager().getInputMode() != InputModeManager.INPUT_MODE_KEYBOARD) { return; } WindowManager windowManager = new WindowManager(mService.isScreenLayoutRTL()); windowManager.setWindows(windows); CharSequence title = null; if (!applicationWindows.isEmpty() && windowManager.isStatusBar(windowId)) { title = mService.getString(R.string.status_bar); } else if (!applicationWindows.isEmpty() && windowManager.isNavigationBar(windowId)) { title = mService.getString(R.string.navigation_bar); } else { title = mWindowTitlesMap.get(windowId); if (title == null && BuildCompat.isAtLeastN()) { for (AccessibilityWindowInfo window : windows) { if (window.getId() == windowId) { title = window.getTitle(); break; } } } if (title == null) { title = mService.getApplicationLabel(announcedNode.getPackageName()); } } int templateId = windowType == AccessibilityWindowInfo.TYPE_APPLICATION ? R.string.template_window_switch_application : R.string.template_window_switch_system; utterance.addSpoken( mService.getString(templateId, WindowManager.formatWindowTitleForFeedback(title, mService))); }