List of usage examples for android.view.accessibility AccessibilityEvent TYPE_WINDOW_STATE_CHANGED
int TYPE_WINDOW_STATE_CHANGED
To view the source code for android.view.accessibility AccessibilityEvent TYPE_WINDOW_STATE_CHANGED.
Click Source Link
From source file:com.googlecode.eyesfree.brailleback.IMEHelper.java
private void checkIMEPicker(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED && "android".equals(event.getPackageName()) && "android.app.AlertDialog".equals(event.getClassName())) { AccessibilityNodeInfo node = event.getSource(); if (node == null) { return; }//from ww w.j av a2 s . co m String IMETitle = mContext.getString(R.string.braille_ime_name); List<AccessibilityNodeInfo> found = node.findAccessibilityNodeInfosByText(IMETitle); if (found.size() == 0) { return; } AccessibilityNodeInfo firstFound = found.get(0); AccessibilityNodeInfo toFocus = firstFound.getParent(); if (toFocus != null) { toFocus.performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS); } } }
From source file:com.onyx.latinime.accessibility.AccessibleKeyboardViewProxy.java
/** * Sends a window state change event with the specified text. * * @param text The text to send with the event. *//* w w w. j a v a 2 s.c o m*/ private void sendWindowStateChanged(final String text) { final AccessibilityEvent stateChange = AccessibilityEvent .obtain(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); mView.onInitializeAccessibilityEvent(stateChange); stateChange.getText().add(text); stateChange.setContentDescription(null); final ViewParent parent = mView.getParent(); if (parent != null) { parent.requestSendAccessibilityEvent(mView, stateChange); } }
From source file:com.google.android.marvin.mytalkback.ProcessorFocusAndSingleTap.java
@Override public void onAccessibilityEvent(AccessibilityEvent event) { if (!mAccessibilityManager.isTouchExplorationEnabled()) { // Don't manage focus when touch exploration is disabled. return;/* w w w . ja v a 2 s . c om*/ } final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event); switch (event.getEventType()) { case AccessibilityEvent.TYPE_VIEW_CLICKED: // Prevent conflicts between lift-to-type and single tap. This // is only necessary when a CLICKED event occurs during a touch // interaction sequence (e.g. before an INTERACTION_END event), // but it isn't harmful to call more often. cancelSingleTap(); break; case AccessibilityEvent.TYPE_VIEW_FOCUSED: setFocusFromViewFocused(event, record); break; case AccessibilityEvent.TYPE_VIEW_SELECTED: setFocusFromViewSelected(event, record); break; case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER: setFocusFromViewHoverEnter(record); break; case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: handleWindowStateChange(event); break; case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: handleWindowContentChanged(record); break; case AccessibilityEvent.TYPE_VIEW_SCROLLED: handleViewScrolled(event, record); break; case AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_START: // This event type only exists on API 17+ (JB MR1). handleTouchInteractionStart(event); break; case AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_END: // This event type only exists on API 17+ (JB MR1). handleTouchInteractionEnd(event); break; } }
From source file:org.mariotaku.twidere.util.TwidereActionModeForChildListener.java
ActionMode startSupportActionModeFromWindow(ActionMode.Callback callback) { if (mActionMode != null) { mActionMode.finish();//from www. j ava2s . c om } final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback); if (mActionModeView == null) { if (mIsFloating && mUsePopup) { // Use the action bar theme. final Context actionBarContext; actionBarContext = ThemeUtils.getActionBarThemedContext(mActivity, mThemed.getCurrentThemeResourceId(), mThemed.getCurrentThemeColor()); mActionModeView = new ActionBarContextView(actionBarContext); mActionModePopup = new PopupWindow(actionBarContext, null, android.support.v7.appcompat.R.attr.actionModePopupWindowStyle); mActionModePopup.setContentView(mActionModeView); mActionModePopup.setWidth(ViewGroup.LayoutParams.MATCH_PARENT); final TypedValue outValue = new TypedValue(); actionBarContext.getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, outValue, true); final int height = TypedValue.complexToDimensionPixelSize(outValue.data, actionBarContext.getResources().getDisplayMetrics()); mActionModeView.setContentHeight(height); ThemeUtils.setActionBarContextViewBackground(mActionModeView, mThemed.getCurrentThemeResourceId(), mThemed.getCurrentThemeColor(), mThemed.getCurrentThemeBackgroundOption(), false); mActionModePopup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); mShowActionModePopup = new Runnable() { @Override public void run() { mActionModePopup.showAtLocation(mWindow.getDecorView(), Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0); } }; } else { mActionModeView = (ActionBarContextView) mWindow.findViewById(R.id.action_context_bar); } } if (mActionModeView != null) { mActionModeView.killMode(); ActionMode mode = new StandaloneActionMode(mActionModeView.getContext(), mActionModeView, wrappedCallback, mActionModePopup == null); if (callback.onCreateActionMode(mode, mode.getMenu())) { mode.invalidate(); mActionModeView.initForMode(mode); mActionModeView.setVisibility(View.VISIBLE); mActionMode = mode; if (mActionModePopup != null) { mWindow.getDecorView().post(mShowActionModePopup); } mActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); if (mActionModeView.getParent() != null) { ViewCompat.requestApplyInsets((View) mActionModeView.getParent()); } } else { mActionMode = null; } } if (mActionMode != null && mAppCompatCallback != null) { mAppCompatCallback.onSupportActionModeStarted(mActionMode); } return mActionMode; }
From source file:com.android.talkback.eventprocessor.AccessibilityEventProcessorTest.java
@MediumTest public void testWindowStateChanged_notFromDialer_screenOff() { mMatchEventType = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED; mMatchNode = null;/*from w ww .j av a 2 s . c om*/ simulateTelephonyState(TelephonyManager.EXTRA_STATE_IDLE); simulateScreenState(false); sendEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, "com.example.app.ExampleClass"); assertFalse(mMatched); }
From source file:com.google.android.marvin.talkback.ProcessorFocusAndSingleTap.java
@Override public void onAccessibilityEvent(AccessibilityEvent event) { if (!mAccessibilityManager.isTouchExplorationEnabled()) { // Don't manage focus when touch exploration is disabled. return;//from ww w . jav a2 s .c o m } final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event); switch (event.getEventType()) { case AccessibilityEvent.TYPE_VIEW_CLICKED: // Prevent conflicts between lift-to-type and single tap. This // is only necessary when a CLICKED event occurs during a touch // interaction sequence (e.g. before an INTERACTION_END event), // but it isn't harmful to call more often. cancelSingleTap(); break; case AccessibilityEvent.TYPE_VIEW_FOCUSED: setFocusFromViewFocused(event, record); break; case AccessibilityEvent.TYPE_VIEW_SELECTED: setFocusFromViewSelected(event, record); break; case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER: final AccessibilityNodeInfoCompat touchedNode = record.getSource(); try { if ((touchedNode != null) && !setFocusFromViewHoverEnter(touchedNode) && FEATURE_FLAG_EMPTY_SPACE) { mHandler.sendEmptyTouchAreaFeedbackDelayed(touchedNode); } } finally { AccessibilityNodeInfoUtils.recycleNodes(touchedNode); } break; case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: mHandler.cancelEmptyTouchAreaFeedback(); break; case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: handleWindowStateChange(event); break; case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: handleWindowContentChanged(record); break; case AccessibilityEvent.TYPE_VIEW_SCROLLED: handleViewScrolled(event, record); break; case AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_START: // This event type only exists on API 17+ (JB MR1). handleTouchInteractionStart(event); break; case AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_END: // This event type only exists on API 17+ (JB MR1). handleTouchInteractionEnd(event); break; } }
From source file:com.android.talkback.eventprocessor.AccessibilityEventProcessorTest.java
@MediumTest public void testWindowStateChanged_notFromDialer_screenOn() { mMatchEventType = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED; mMatchNode = null;/* w w w . j a v a 2 s. co m*/ simulateTelephonyState(TelephonyManager.EXTRA_STATE_IDLE); simulateScreenState(true); sendEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, "com.example.app.ExampleClass"); assertTrue(mMatched); }
From source file:com.android.screenspeak.eventprocessor.AccessibilityEventProcessor.java
public void onAccessibilityEvent(AccessibilityEvent event) { if (mTestingListener != null) { mTestingListener.onAccessibilityEvent(event); }/*from w w w . ja va 2 s . co m*/ // Chrome clears and set a11y focus for each scroll event, it is not intended to be spoken // to the user. Remove this when chromium is fixed. int eventType = event.getEventType(); if (eventType == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED) { if (sGetSourceNodeIdMethod != null) { try { mLastClearedSourceId = (long) sGetSourceNodeIdMethod.invoke(event); mLastClearedWindowId = event.getWindowId(); mLastClearA11yFocus = System.currentTimeMillis(); if (mLastClearedSourceId != mLastPronouncedSourceId || mLastClearedWindowId != mLastPronouncedWindowId) { // something strange. not accessibility focused node sends clear focus event // b/22108305 mLastClearedSourceId = -1; mLastClearedWindowId = -1; mLastClearA11yFocus = 0; } } catch (Exception e) { Log.d(LOGTAG, "Exception accessing field: " + e.toString()); } } return; } if (eventType == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED) { if (System.currentTimeMillis() - mLastClearA11yFocus < CLEAR_SET_A11Y_FOCUS_WINDOW) { if (sGetSourceNodeIdMethod != null) { try { long sourceId = (long) sGetSourceNodeIdMethod.invoke(event); int windowId = event.getWindowId(); if (sourceId == mLastClearedSourceId && windowId == mLastClearedWindowId) { return; } mLastPronouncedSourceId = sourceId; mLastPronouncedWindowId = windowId; } catch (Exception e) { Log.d(LOGTAG, "Exception accessing field: " + e.toString()); } } } } if (shouldDropEvent(event)) { return; } maintainExplorationState(event); if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED || event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED || event.getEventType() == AccessibilityEvent.TYPE_WINDOWS_CHANGED) { mService.setRootDirty(true); } processEvent(event); }
From source file:com.myStress.handlers.NotificationHandlerService.java
/** * Called when an accessibility event occurs - here, we check the particular component packages that fired the event, filtering out the ones we support * @param event Reference to the fired {android.view.accessibility.AccessibilityEvent} * @see android.accessibilityservice.AccessibilityService#onAccessibilityEvent(android.view.accessibility.AccessibilityEvent) *//*from w w w. j a va 2s . c o m*/ @Override public void onAccessibilityEvent(AccessibilityEvent event) { try { int eventType = event.getEventType(); String packageName = event.getPackageName().toString(); String className = event.getClassName().toString(); if (eventType == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) { processNotification(event); } else if (eventType == AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED) { if (event.isPassword()) return; String text = event.getText().toString(); String beforeText = ""; if (event.getBeforeText() != null) beforeText = event.getBeforeText().toString(); text = text.substring(1, text.length() - 1); if (packageName.equals("com.whatsapp")) { if (wasending1 && text.length() == 1) { wasending2 = true; sendButtonClicked(packageName); } } // else if(packageName.equals("com.facebook.orca")){ // wasending1 = false; // } // else if(packageName.equals("com.facebook.katana")){ // wasending1 = false; // } // else if(packageName.equals("com.android.email")){ // wasending1=false; // } else { wasending1 = false; // if(text.length() == 0){ // sending = true; // sendButtonClicked(packageName); // } } boolean del; int length_diff = text.length() - beforeText.length(); typedText = text; if (length_diff == 1 && text.length() == 1) { typingStartTime = (double) System.currentTimeMillis(); typingEndTime = typingStartTime; } else { typingEndTime = (double) System.currentTimeMillis(); } if (text.length() < beforeText.length()) { del = true; length_diff = -length_diff; } else { del = false; } if (del == true) { Intent intent = new Intent("com.myStress.accessibility"); intent.putExtra("KeyLogger", packageName + ":" + length_diff); sendBroadcast(intent); } } else if (eventType == AccessibilityEvent.TYPE_VIEW_CLICKED) { if (packageName.equals("com.whatsapp")) { if (className.equals("android.widget.ImageButton")) { wasending1 = true; } else if (className.equals("com.whatsapp.EmojiPicker$EmojiImageView")) { wasending1 = false; wasending2 = false; } else if (className.equals("android.widget.ListView") || className.equals("android.widget.ImageView")) ; else { if (wasending1) wasending2 = true; sendButtonClicked(packageName); } } else { if (wasending1) { wasending2 = true; sendButtonClicked(packageName); } else if (packageName.equals("com.facebook.orca")) { if (event.getContentDescription() != null) { if (event.getContentDescription().toString().toLowerCase().contains("send")) { sending = true; sendButtonClicked(packageName); } } else { if (className.equals("com.facebook.orca.compose.ComposerButton")) { sending = true; sendButtonClicked(packageName); } } } else if (packageName.equals("com.facebook.katana")) { if (event.getContentDescription() != null) { if (event.getContentDescription().toString().toLowerCase().contains("post")) { sending = true; sendButtonClicked(packageName); } } else { if (className.equals("com.facebook.widget.text.SimpleVariableTextLayoutView")) { sending = true; sendButtonClicked(packageName); } } } else if (packageName.toLowerCase().contains("mail")) { if (event.getContentDescription() != null) { if (event.getContentDescription().toString().toLowerCase().contains("send")) { sending = true; sendButtonClicked(packageName); } } else { if (className.equals("android.widget.ImageButton")) { if (!event.getText().toString().equals("")) { sending = true; sendButtonClicked(packageName); } } } } } } else if (eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { if (wasending1) { wasending2 = true; sendButtonClicked(packageName); } if (packageName.equals("com.android.mms")) { if (className.equals("android.app.ProgressDialog")) { sending = true; sendButtonClicked(packageName); } } } //reset variables sending = false; } catch (Exception e) { } }
From source file:com.android.screenspeak.KeyboardSearchManager.java
@Override public void onAccessibilityEvent(AccessibilityEvent event) { if (!mNodeSearch.isActive()) { return;//from w ww . j a v a 2s .c om } switch (event.getEventType()) { case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: cancelSearch(); break; case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: if (mNodeSearch.hasMatch()) { mNodeSearch.reEvaluateSearch(); } break; default: break; } }