Java Code Examples for android.view.View#sendAccessibilityEvent()

The following examples show how to use android.view.View#sendAccessibilityEvent() . 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: BehaviorDelegate.java    From DrawerBehavior with Apache License 2.0 6 votes vote down vote up
private void dispatchOnDrawerClosed(View drawerView) {
  if ((openState & FLAG_IS_OPENED) == FLAG_IS_OPENED) {
    openState = 0;

    updateChildrenImportantForAccessibility(drawerView, false);

    // Only send WINDOW_STATE_CHANGE if the host has window focus. This
    // may change if support for multiple foreground windows (e.g. IME)
    // improves.
    if (parent.hasWindowFocus()) {
      final View rootView = parent.getRootView();
      if (rootView != null) {
        rootView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
      }
    }
  }
}
 
Example 2
Source File: PinnedSectionListView.java    From KUAS-AP-Material with MIT License 6 votes vote down vote up
private boolean performPinnedItemClick() {
	if (mPinnedSection == null) {
		return false;
	}

	OnItemClickListener listener = getOnItemClickListener();
	if (listener != null && getAdapter().isEnabled(mPinnedSection.position)) {
		View view = mPinnedSection.view;
		playSoundEffect(SoundEffectConstants.CLICK);
		if (view != null) {
			view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
		}
		listener.onItemClick(this, view, mPinnedSection.position, mPinnedSection.id);
		return true;
	}
	return false;
}
 
Example 3
Source File: DrawerLayout.java    From adt-leanback-support with Apache License 2.0 6 votes vote down vote up
void dispatchOnDrawerClosed(View drawerView) {
    final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams();
    if (lp.knownOpen) {
        lp.knownOpen = false;
        if (mListener != null) {
            mListener.onDrawerClosed(drawerView);
        }

        updateChildrenImportantForAccessibility(drawerView, false);

        // Only send WINDOW_STATE_CHANGE if the host has window focus. This
        // may change if support for multiple foreground windows (e.g. IME)
        // improves.
        if (hasWindowFocus()) {
            final View rootView = getRootView();
            if (rootView != null) {
                rootView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
            }
        }
    }
}
 
Example 4
Source File: MarginDrawerLayout.java    From something.apk with MIT License 5 votes vote down vote up
void dispatchOnDrawerOpened(View drawerView) {
    final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams();
    if (!lp.knownOpen) {
        lp.knownOpen = true;
        if (mListener != null) {
            mListener.onDrawerOpened(drawerView);
        }
        drawerView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
    }
}
 
Example 5
Source File: TrackSelectionAdapterWrapper.java    From ticdesign with Apache License 2.0 5 votes vote down vote up
/**
 * Call the OnItemClickListener, if it is defined. Performs all normal
 * actions associated with clicking: reporting accessibility event, playing
 * a sound, etc.
 *
 * @param view The view within the AdapterView that was clicked.
 * @param position The position of the view in the adapter.
 * @param id The row id of the item that was clicked.
 * @return True if there was an assigned OnItemClickListener that was
 *         called, false otherwise is returned.
 */
public boolean superPerformItemClick(View view, int position, long id) {
    if (mOnItemClickListener != null) {
        mOnItemClickListener.onItemClick(this, view, position, id);
        if (view != null) {
            view.playSoundEffect(SoundEffectConstants.CLICK);
            view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
        }
        return true;
    }

    return false;
}
 
Example 6
Source File: PinnedSectionListView.java    From PullToRefresh-PinnedSection-ListView with MIT License 5 votes vote down vote up
private boolean performPinnedItemClick() {
    if (mPinnedSection == null) return false;

    OnItemClickListener listener = getOnItemClickListener();
    if (listener != null) {
        View view =  mPinnedSection.view;
        playSoundEffect(SoundEffectConstants.CLICK);
        if (view != null) {
            view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
        }
        listener.onItemClick(this, view, mPinnedSection.position, mPinnedSection.id);
        return true;
    }
    return false;
}
 
Example 7
Source File: DrawerLayout.java    From guideshow with MIT License 5 votes vote down vote up
void dispatchOnDrawerOpened(View drawerView) {
    final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams();
    if (!lp.knownOpen) {
        lp.knownOpen = true;
        if (mListener != null) {
            mListener.onDrawerOpened(drawerView);
        }
        drawerView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
    }
}
 
Example 8
Source File: CardUnmaskPrompt.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void setInitialFocus() {
    InputMethodManager imm = (InputMethodManager) mDialog.getContext().getSystemService(
            Context.INPUT_METHOD_SERVICE);
    View view = mShouldRequestExpirationDate ? mMonthInput : mCardUnmaskInput;
    imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
    view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
    if (sObserverForTest != null) {
        sObserverForTest.onCardUnmaskPromptReadyForInput(this);
    }
}
 
Example 9
Source File: CardUnmaskPrompt.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void setInitialFocus() {
    InputMethodManager imm = (InputMethodManager) mDialog.getContext().getSystemService(
            Context.INPUT_METHOD_SERVICE);
    View view = mShouldRequestExpirationDate ? mMonthInput : mCardUnmaskInput;
    imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
    view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
    if (sObserverForTest != null) {
        sObserverForTest.onCardUnmaskPromptReadyForInput(this);
    }
}
 
Example 10
Source File: DrawerLayout.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
void dispatchOnDrawerOpened(View drawerView) {
    final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams();
    if (!lp.knownOpen) {
        lp.knownOpen = true;
        if (mListener != null) {
            mListener.onDrawerOpened(drawerView);
        }
        drawerView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
    }
}
 
Example 11
Source File: IcsAdapterView.java    From zen4android with MIT License 5 votes vote down vote up
/**
 * Call the OnItemClickListener, if it is defined.
 *
 * @param view The view within the AdapterView that was clicked.
 * @param position The position of the view in the adapter.
 * @param id The row id of the item that was clicked.
 * @return True if there was an assigned OnItemClickListener that was
 *         called, false otherwise is returned.
 */
public boolean performItemClick(View view, int position, long id) {
    if (mOnItemClickListener != null) {
        playSoundEffect(SoundEffectConstants.CLICK);
        if (view != null) {
            view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
        }
        mOnItemClickListener.onItemClick(/*this*/null, view, position, id);
        return true;
    }

    return false;
}
 
Example 12
Source File: CardUnmaskPrompt.java    From delion with Apache License 2.0 5 votes vote down vote up
private void setInitialFocus() {
    InputMethodManager imm = (InputMethodManager) mDialog.getContext().getSystemService(
            Context.INPUT_METHOD_SERVICE);
    View view = mShouldRequestExpirationDate ? mMonthInput : mCardUnmaskInput;
    imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
    view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
    if (sObserverForTest != null) {
        sObserverForTest.onCardUnmaskPromptReadyForInput(this);
    }
}
 
Example 13
Source File: StickyGridHeadersGridView.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
public boolean performHeaderClick(View view, long id) {
    if (mOnHeaderClickListener != null) {
        playSoundEffect(SoundEffectConstants.CLICK);
        if (view != null) {
            view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
        }
        mOnHeaderClickListener.onHeaderClick(this, view, id);
        return true;
    }

    return false;
}
 
Example 14
Source File: PinnedSectionListView.java    From Kernel-Tuner with GNU General Public License v3.0 5 votes vote down vote up
private boolean performPinnedItemClick() {
    if (mPinnedSection == null) return false;

    OnItemClickListener listener = getOnItemClickListener();
    if (listener != null) {
        View view =  mPinnedSection.view;
        playSoundEffect(SoundEffectConstants.CLICK);
        if (view != null) {
            view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
        }
        listener.onItemClick(this, view, mPinnedSection.position, mPinnedSection.id);
        return true;
    }
    return false;
}
 
Example 15
Source File: PinnedSectionListView.java    From AndroidWeekly with Apache License 2.0 5 votes vote down vote up
private boolean performPinnedItemClick() {
    if (mPinnedSection == null) return false;

    OnItemClickListener listener = getOnItemClickListener();
    if (listener != null && getAdapter().isEnabled(mPinnedSection.position)) {
        View view = mPinnedSection.view;
        playSoundEffect(SoundEffectConstants.CLICK);
        if (view != null) {
            view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
        }
        listener.onItemClick(this, view, mPinnedSection.position, mPinnedSection.id);
        return true;
    }
    return false;
}
 
Example 16
Source File: StickyGridHeadersGridView.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean performHeaderLongPress(View view, long id) {
    boolean handled = false;
    if (mOnHeaderLongClickListener != null) {
        handled = mOnHeaderLongClickListener.onHeaderLongClick(this, view, id);
    }

    if (handled) {
        if (view != null) {
            view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
        }
        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }

    return handled;
}
 
Example 17
Source File: StickyGridHeadersGridView.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean performHeaderClick(View view, long id) {
    if (mOnHeaderClickListener != null) {
        playSoundEffect(SoundEffectConstants.CLICK);
        if (view != null) {
            view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
        }
        mOnHeaderClickListener.onHeaderClick(this, view, id);
        return true;
    }

    return false;
}
 
Example 18
Source File: BottomSheetBehavior.java    From bottomsheetrecycler with Apache License 2.0 5 votes vote down vote up
void setStateInternal(@State int state) {
    int previousState = this.state;

    if (this.state == state) {
        return;
    }
    this.state = state;

    if (viewRef == null) {
        return;
    }

    View bottomSheet = viewRef.get();
    if (bottomSheet == null) {
        return;
    }

    if (state == STATE_HALF_EXPANDED || state == STATE_EXPANDED) {
        updateImportantForAccessibility(true);
    } else if (state == STATE_HIDDEN || state == STATE_COLLAPSED) {
        updateImportantForAccessibility(false);
    }

    ViewCompat.setImportantForAccessibility(
            bottomSheet, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    bottomSheet.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);

    updateDrawableOnStateChange(state, previousState);
    if (callback != null) {
        callback.onStateChanged(bottomSheet, state);
    }
}
 
Example 19
Source File: IcsAdapterView.java    From android-apps with MIT License 5 votes vote down vote up
/**
 * Call the OnItemClickListener, if it is defined.
 *
 * @param view The view within the AdapterView that was clicked.
 * @param position The position of the view in the adapter.
 * @param id The row id of the item that was clicked.
 * @return True if there was an assigned OnItemClickListener that was
 *         called, false otherwise is returned.
 */
public boolean performItemClick(View view, int position, long id) {
    if (mOnItemClickListener != null) {
        playSoundEffect(SoundEffectConstants.CLICK);
        if (view != null) {
            view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
        }
        mOnItemClickListener.onItemClick(/*this*/null, view, position, id);
        return true;
    }

    return false;
}
 
Example 20
Source File: AbsLayoutContainer.java    From UltimateAndroid with Apache License 2.0 3 votes vote down vote up
/**
 * Call the OnItemClickListener, if it is defined. Performs all normal
 * actions associated with clicking: reporting accessibility event, playing
 * a sound, etc.
 * 
 * @param view
 *            The view within the AdapterView that was clicked.
 * @param position
 *            The position of the view in the adapter.
 * @param id
 *            The row id of the item that was clicked.
 * @return True if there was an assigned OnItemClickListener that was
 *         called, false otherwise is returned.
 */
public boolean performItemClick(View view, int sectionIndex, int positionInSection, long id) {
	if (mOnItemClickListener != null) {
		// playSoundEffect(SoundEffectConstants.CLICK);
		if (view != null) {
			view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
		}
		mOnItemClickListener.onItemClick(this, getFreeFlowItemForVisibleItemAt(sectionIndex, positionInSection));
		return true;
	}

	return false;
}