Java Code Examples for android.view.accessibility.AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED
The following examples show how to use
android.view.accessibility.AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DebugDrawerLayout.java From u2020 with Apache License 2.0 | 6 votes |
@Override public boolean dispatchPopulateAccessibilityEvent(View host, AccessibilityEvent event) { // Special case to handle window state change events. As far as // accessibility services are concerned, state changes from // DrawerLayout invalidate the entire contents of the screen (like // an Activity or Dialog) and they should announce the title of the // new content. if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { final List<CharSequence> eventText = event.getText(); final View visibleDrawer = findVisibleDrawer(); if (visibleDrawer != null) { final int edgeGravity = getDrawerViewAbsoluteGravity(visibleDrawer); final CharSequence title = getDrawerTitle(edgeGravity); if (title != null) { eventText.add(title); } } return true; } return super.dispatchPopulateAccessibilityEvent(host, event); }
Example 2
Source File: RadialPickerLayout.java From AssistantBySDK with Apache License 2.0 | 6 votes |
/** * Announce the currently-selected time when launched. */ @Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { // Clear the event's current text so that only the current time will be spoken. event.getText().clear(); Calendar time = Calendar.getInstance(); time.set(Calendar.HOUR, getHours()); time.set(Calendar.MINUTE, getMinutes()); time.set(Calendar.SECOND, getSeconds()); long millis = time.getTimeInMillis(); int flags = DateUtils.FORMAT_SHOW_TIME; if (mIs24HourMode) { flags |= DateUtils.FORMAT_24HOUR; } String timeString = DateUtils.formatDateTime(getContext(), millis, flags); event.getText().add(timeString); return true; } return super.dispatchPopulateAccessibilityEvent(event); }
Example 3
Source File: TranslucentDrawerLayout.java From 920-text-editor-v2 with Apache License 2.0 | 6 votes |
@Override public boolean dispatchPopulateAccessibilityEvent(View host, AccessibilityEvent event) { // Special case to handle window state change events. As far as // accessibility services are concerned, state changes from // DrawerLayout invalidate the entire contents of the screen (like // an Activity or Dialog) and they should announce the title of the // new content. if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { final List<CharSequence> eventText = event.getText(); final View visibleDrawer = findVisibleDrawer(); if (visibleDrawer != null) { final int edgeGravity = getDrawerViewAbsoluteGravity(visibleDrawer); final CharSequence title = getDrawerTitle(edgeGravity); if (title != null) { eventText.add(title); } } return true; } return super.dispatchPopulateAccessibilityEvent(host, event); }
Example 4
Source File: DefaultNavigationMode.java From brailleback with Apache License 2.0 | 6 votes |
@Override public boolean onAccessibilityEvent(AccessibilityEvent event) { switch (event.getEventType()) { case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: brailleNodeFromEvent(event); break; case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: brailleFocusedNode(); break; case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: if (!brailleFocusedNode()) { // Since focus is typically not set in a newly opened // window, so braille the window as-if the first focusable // node had focus. We don't update the focus because that // will make other services (e.g. talkback) reflect this // change, which is not desired. brailleFirstFocusableNode(); } break; } return true; }
Example 5
Source File: RadialPickerLayout.java From DateTimepicker with Apache License 2.0 | 6 votes |
/** * Announce the currently-selected time when launched. */ @Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { // Clear the event's current text so that only the current time will be spoken. event.getText().clear(); Time time = new Time(); time.hour = getHours(); time.minute = getMinutes(); long millis = time.normalize(true); int flags = DateUtils.FORMAT_SHOW_TIME; if (mIs24HourMode) { flags |= DateUtils.FORMAT_24HOUR; } String timeString = DateUtils.formatDateTime(getContext(), millis, flags); event.getText().add(timeString); return true; } return super.dispatchPopulateAccessibilityEvent(event); }
Example 6
Source File: ViewDebugHelperService.java From ViewDebugHelper with BSD 3-Clause "New" or "Revised" License | 6 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @Override public void onAccessibilityEvent(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { event.getWindowId(); ComponentName componentName = new ComponentName(event.getPackageName().toString(), event.getClassName().toString()); ActivityInfo activityInfo = ActivityHelper.tryGetActivity(this, componentName); boolean isActivity = activityInfo != null; if (isActivity) { String activityName = componentName.flattenToString(); log("CurrentActivity" + activityName); ViewDebugHelperApplication.getInstance().setLastTopActivityName(activityName); ActivityStackManager.getInstance().offer(activityName); } } }
Example 7
Source File: PersianAccessibleDateAnimator.java From PersianDateRangePicker with Apache License 2.0 | 6 votes |
/** * Announce the currently-selected date when launched. */ @Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { // Clear the event's current text so that only the current date will be spoken. event.getText().clear(); PersianDate mPersianDate = new PersianDate(); mPersianDate.setTimeInMillis(mDateMillis); String dateString = LanguageUtils.getPersianNumbers( mPersianDate.getPersianMonth() + " " + mPersianDate.getPersianDay() ); event.getText().add(dateString); return true; } return super.dispatchPopulateAccessibilityEvent(event); }
Example 8
Source File: InputFocusInterpreter.java From talkback with Apache License 2.0 | 6 votes |
@Override public void onAccessibilityEvent(AccessibilityEvent event, EventId eventId) { switch (event.getEventType()) { case AccessibilityEvent.TYPE_VIEW_FOCUSED: handleViewInputFocusedEvent(event, eventId); break; case AccessibilityEvent.TYPE_VIEW_SELECTED: handleViewSelectedEvent(event, eventId); break; case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: firstWindowFocusManager.registerWindowStateChangeEvent(event); break; default: break; } }
Example 9
Source File: DebugAccessibilityService.java From DoraemonKit with Apache License 2.0 | 6 votes |
@Override public void onAccessibilityEvent(AccessibilityEvent event) { CharSequence pkgName = event.getPackageName(); if (pkgName == null) { return; } if (!pkgName.equals(getPackageName())) { return; } if (event.getEventType() != AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { return; } if (!isActivityEvent(event)) { return; } AccessibilityNodeInfo info = event.getSource(); if (info == null) { return; } Intent intent = new Intent(BroadcastAction.ACTION_ACCESSIBILITY_UPDATE); intent.putExtra(BundleKey.ACCESSIBILITY_DATA, info); LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent); }
Example 10
Source File: AccessibleDateAnimator.java From AlarmOn with Apache License 2.0 | 5 votes |
/** * Announce the currently-selected date when launched. */ @Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { // Clear the event's current text so that only the current date will be spoken. event.getText().clear(); int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_WEEKDAY; String dateString = DateUtils.formatDateTime(getContext(), mDateMillis, flags); event.getText().add(dateString); return true; } return super.dispatchPopulateAccessibilityEvent(event); }
Example 11
Source File: TestAccessibilityService.java From EasyProtector with Apache License 2.0 | 5 votes |
@Override public void onAccessibilityEvent(AccessibilityEvent event) { int eventType = event.getEventType(); switch (eventType) { case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED:// 通知栏事件 case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:// //切换页面的时候触发 break; } if (event.getPackageName().toString().equals("com.android.packageinstaller")) { installAPK(event); } }
Example 12
Source File: DetectionService.java From MiPushFramework with GNU General Public License v3.0 | 5 votes |
/** * 重载辅助功能事件回调函数,对窗口状态变化事件进行处理 * * @param event event */ @Override public void onAccessibilityEvent(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { CharSequence packageName = event.getPackageName(); if (packageName != null) { foregroundPackageName = packageName.toString(); } } }
Example 13
Source File: AccessibleDateAnimator.java From AssistantBySDK with Apache License 2.0 | 5 votes |
/** * Announce the currently-selected date when launched. */ @Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { // Clear the event's current text so that only the current date will be spoken. event.getText().clear(); int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_WEEKDAY; String dateString = DateUtils.formatDateTime(getContext(), mDateMillis, flags); event.getText().add(dateString); return true; } return super.dispatchPopulateAccessibilityEvent(event); }
Example 14
Source File: LgcAccessibilityService.java From live-group-chat with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void onServiceConnected() { super.onServiceConnected(); run = true; if (Build.VERSION.SDK_INT < 14) { AccessibilityServiceInfo serverInfo = new AccessibilityServiceInfo(); serverInfo.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED | AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED; serverInfo.feedbackType = AccessibilityServiceInfo.FEEDBACK_VISUAL; serverInfo.flags = AccessibilityServiceInfo.DEFAULT; serverInfo.notificationTimeout = 0L; setServiceInfo(serverInfo); } }
Example 15
Source File: WindowChangeEventProvider.java From PrivacyStreams with Apache License 2.0 | 5 votes |
public void handleAccessibilityEvent(AccessibilityEvent event, AccessibilityNodeInfo rootNode){ int eventType = event.getEventType(); if (eventType == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED || eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED || eventType == AccessibilityEvent.TYPE_WINDOWS_CHANGED || eventType == AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED) { this.output(new AccEvent(event, rootNode)); } }
Example 16
Source File: CaptureService.java From WearPay with GNU General Public License v2.0 | 5 votes |
@Override @DebugLog public void onAccessibilityEvent(AccessibilityEvent event) { int eventType = event.getEventType(); if (AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED == eventType) { if (WECHAT_WALLET_ACTIVITY_NAME.equals(event.getClassName())) { AccessibilityNodeInfo nodeInfo = getRootInActiveWindow(); if (nodeInfo != null) { List<AccessibilityNodeInfo> infos = nodeInfo.findAccessibilityNodeInfosByViewId("com.tencent.mm:id/c6a"); CharSequence text = infos.get(0).getText(); Toast.makeText(this, text, Toast.LENGTH_SHORT).show(); } } } }
Example 17
Source File: DetectService.java From AndroidProcess with Apache License 2.0 | 5 votes |
/** * 监听窗口焦点,并且获取焦点窗口的包名 * * @param event */ @Override public void onAccessibilityEvent(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { mForegroundPackageName = event.getPackageName().toString(); } }
Example 18
Source File: AccessibilityEventProcessor.java From talkback with Apache License 2.0 | 4 votes |
public void onAccessibilityEvent(AccessibilityEvent event, EventId eventId) { if (testingListener != null) { testingListener.onAccessibilityEvent(event); } if ((dumpEventMask & event.getEventType()) != 0) { LogUtils.v(TAG, DUMP_EVENT_LOG_FORMAT, event); } if (shouldDropRefocusEvent(event)) { return; } if (shouldDropEvent(event)) { return; } if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { lastWindowStateChanged = SystemClock.uptimeMillis(); } if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED || event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED || event.getEventType() == AccessibilityEvent.TYPE_WINDOWS_CHANGED) { service.setRootDirty(true); } // We need to save the last focused event so that we can filter out related selected events. if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED) { if (lastFocusedEvent != null) { lastFocusedEvent.recycle(); } lastFocusedEvent = AccessibilityEvent.obtain(event); } if (AccessibilityEventUtils.eventMatchesAnyType(event, MASK_DELAYED_EVENT_TYPES)) { handler.postProcessEvent(event, eventId); } else { processEvent(event, eventId); } if (testingListener != null) { testingListener.afterAccessibilityEvent(event); } }
Example 19
Source File: WechatAccService.java From RedEnvelopeAssistant with MIT License | 4 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @Override public void onAccessibilityEvent(AccessibilityEvent event) { if (event == null) return; if(SettingHelper.getREAutoMode()){ handleNotificationChange(event); } AccessibilityNodeInfo nodeInfo = event.getSource(); if (nodeInfo == null) { return; } AccessibilityNodeInfo rowNode = nodeInfo;// we can also use getRootInActiveWindow() instead; if (rowNode == null) { log( "noteInfo is null"); return; } LogUtil.d("eventtype:" + event.getEventType()); // String currentActivityName = // ActivityHelper.getTopActivityName(RedEnvelopeApplication.getInstance()); if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED || event.getEventType() == AccessibilityEvent.TYPE_VIEW_CLICKED) { // if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) { CharSequence currentClassName = event.getClassName(); LogUtil.d("currentClassName:" + currentClassName); if ("com.tencent.mm.ui.LauncherUI".equals(currentClassName) || "com.tencent.mm.ui.chatting.ChattingUI".equals(currentClassName)) { // 聊天以及主页 chat page and the main page LogUtil.d("Chat page"); if (SettingHelper.getREAutoMode()) { handleChatPage(rowNode); } } else if ("com.tencent.mm.plugin.luckymoney.ui.LuckyMoneyReceiveUI".equals(currentClassName)) { //打开红包主页 red envelope open page LogUtil.d("LuckyMoneyReceiveUI page"); if (SettingHelper.getREAutoMode() || SettingHelper.getRESafeMode()){ handleLuckyMoneyReceivePage(rowNode); if(SettingHelper.isRESound()){ ((RedEnvelopeApplication) RedEnvelopeApplication .getInstance()).getSoundHelper() .playSoundRedEnvelopeComing(); } } } else if ("com.tencent.mm.plugin.luckymoney.ui.LuckyMoneyDetailUI".equals(currentClassName)) { // 红包详情主页 red envelope detail page LogUtil.d("red envelope detail page"); if (SettingHelper.getREAutoMode()){ handleLuckyMoneyDetailPage(rowNode); } } else { log( currentClassName + " page"); } } }
Example 20
Source File: AccessibilityEventUtils.java From talkback with Apache License 2.0 | 4 votes |
public static String typeToString(int eventType) { switch (eventType) { case AccessibilityEvent.TYPE_ANNOUNCEMENT: return "TYPE_ANNOUNCEMENT"; case AccessibilityEvent.TYPE_ASSIST_READING_CONTEXT: return "TYPE_ASSIST_READING_CONTEXT"; case AccessibilityEvent.TYPE_GESTURE_DETECTION_END: return "TYPE_GESTURE_DETECTION_END"; case AccessibilityEvent.TYPE_GESTURE_DETECTION_START: return "TYPE_GESTURE_DETECTION_START"; case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED: return "TYPE_NOTIFICATION_STATE_CHANGED"; case AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END: return "TYPE_TOUCH_EXPLORATION_GESTURE_END"; case AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START: return "TYPE_TOUCH_EXPLORATION_GESTURE_START"; case AccessibilityEvent.TYPE_TOUCH_INTERACTION_END: return "TYPE_TOUCH_INTERACTION_END"; case AccessibilityEvent.TYPE_TOUCH_INTERACTION_START: return "TYPE_TOUCH_INTERACTION_START"; case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: return "TYPE_VIEW_ACCESSIBILITY_FOCUSED"; case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED: return "TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED"; case AccessibilityEvent.TYPE_VIEW_CLICKED: return "TYPE_VIEW_CLICKED"; case AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED: return "TYPE_VIEW_CONTEXT_CLICKED"; case AccessibilityEvent.TYPE_VIEW_FOCUSED: return "TYPE_VIEW_FOCUSED"; case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER: return "TYPE_VIEW_HOVER_ENTER"; case AccessibilityEvent.TYPE_VIEW_HOVER_EXIT: return "TYPE_VIEW_HOVER_EXIT"; case AccessibilityEvent.TYPE_VIEW_LONG_CLICKED: return "TYPE_VIEW_LONG_CLICKED"; case AccessibilityEvent.TYPE_VIEW_SCROLLED: return "TYPE_VIEW_SCROLLED"; case AccessibilityEvent.TYPE_VIEW_SELECTED: return "TYPE_VIEW_SELECTED"; case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED: return "TYPE_VIEW_TEXT_CHANGED"; case AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED: return "TYPE_VIEW_TEXT_SELECTION_CHANGED"; case AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY: return "TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY"; case AccessibilityEvent.TYPE_WINDOWS_CHANGED: return "TYPE_WINDOWS_CHANGED"; case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: return "TYPE_WINDOW_CONTENT_CHANGED"; case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: return "TYPE_WINDOW_STATE_CHANGED"; default: return "(unhandled)"; } }