List of usage examples for android.content Context ACCESSIBILITY_SERVICE
String ACCESSIBILITY_SERVICE
To view the source code for android.content Context ACCESSIBILITY_SERVICE.
Click Source Link
From source file:com.klinker.deskclock.widget.multiwaveview.GlowPadView.java
private void handleMove(MotionEvent event) { int activeTarget = -1; final int historySize = event.getHistorySize(); ArrayList<TargetDrawable> targets = mTargetDrawables; int ntargets = targets.size(); float x = 0.0f; float y = 0.0f; int actionIndex = event.findPointerIndex(mPointerId); if (actionIndex == -1) { return; // no data for this pointer }//w ww. j ava 2s . c o m for (int k = 0; k < historySize + 1; k++) { float eventX = k < historySize ? event.getHistoricalX(actionIndex, k) : event.getX(actionIndex); float eventY = k < historySize ? event.getHistoricalY(actionIndex, k) : event.getY(actionIndex); // tx and ty are relative to wave center float tx = eventX - mWaveCenterX; float ty = eventY - mWaveCenterY; float touchRadius = (float) Math.sqrt(dist2(tx, ty)); final float scale = touchRadius > mOuterRadius ? mOuterRadius / touchRadius : 1.0f; float limitX = tx * scale; float limitY = ty * scale; double angleRad = Math.atan2(-ty, tx); if (!mDragging) { trySwitchToFirstTouchState(eventX, eventY); } if (mDragging) { // For multiple targets, snap to the one that matches final float snapRadius = mOuterRadius - mSnapMargin; final float snapDistance2 = snapRadius * snapRadius; // Find first target in range for (int i = 0; i < ntargets; i++) { TargetDrawable target = targets.get(i); double targetMinRad = (i - 0.5) * 2 * Math.PI / ntargets; double targetMaxRad = (i + 0.5) * 2 * Math.PI / ntargets; if (target.isEnabled()) { boolean angleMatches = (angleRad > targetMinRad && angleRad <= targetMaxRad) || (angleRad + 2 * Math.PI > targetMinRad && angleRad + 2 * Math.PI <= targetMaxRad); if (angleMatches && (dist2(tx, ty) > snapDistance2)) { activeTarget = i; } } } } x = limitX; y = limitY; } if (!mDragging) { return; } if (activeTarget != -1) { switchToState(STATE_SNAP, x, y); updateGlowPosition(x, y); } else { switchToState(STATE_TRACKING, x, y); updateGlowPosition(x, y); } if (mActiveTarget != activeTarget) { // Defocus the old target if (mActiveTarget != -1) { TargetDrawable target = targets.get(mActiveTarget); target.setState(TargetDrawable.STATE_INACTIVE); } // Focus the new target if (activeTarget != -1) { TargetDrawable target = targets.get(activeTarget); target.setState(TargetDrawable.STATE_FOCUSED); final AccessibilityManager accessibilityManager = (AccessibilityManager) getContext() .getSystemService(Context.ACCESSIBILITY_SERVICE); if (accessibilityManager.isEnabled()) { String targetContentDescription = getTargetDescription(activeTarget); if (Build.VERSION.SDK_INT >= 16) { announceForAccessibility(targetContentDescription); } else { AccessibilityEvent acc_event = AccessibilityEvent .obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED); AccessibilityRecordCompat arc = new AccessibilityRecordCompat(acc_event); arc.setSource(this); acc_event.setClassName(this.getClass().getName()); acc_event.setPackageName(this.getContext().getPackageName()); acc_event.setEnabled(this.isEnabled()); acc_event.getText().add(targetContentDescription); accessibilityManager.sendAccessibilityEvent(acc_event); } } } } mActiveTarget = activeTarget; }
From source file:io.authme.sdk.widget.LockPatternView.java
@Override public boolean onHoverEvent(MotionEvent event) { if (((AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE)) .isTouchExplorationEnabled()) { final int action = event.getAction(); switch (action) { case MotionEvent.ACTION_HOVER_ENTER: event.setAction(MotionEvent.ACTION_DOWN); break; case MotionEvent.ACTION_HOVER_MOVE: event.setAction(MotionEvent.ACTION_MOVE); break; case MotionEvent.ACTION_HOVER_EXIT: event.setAction(MotionEvent.ACTION_UP); break; }//from w w w .j a v a 2 s . c o m onTouchEvent(event); event.setAction(action); } return super.onHoverEvent(event); }
From source file:com.android.incallui.widget.multiwaveview.GlowPadView.java
private void handleMove(MotionEvent event) { int activeTarget = -1; final int historySize = event.getHistorySize(); ArrayList<TargetDrawable> targets = mTargetDrawables; int ntargets = targets.size(); float x = 0.0f; float y = 0.0f; int actionIndex = event.findPointerIndex(mPointerId); if (actionIndex == -1) { return; // no data for this pointer }//from w w w . j a v a2 s . c o m for (int k = 0; k < historySize + 1; k++) { float eventX = k < historySize ? event.getHistoricalX(actionIndex, k) : event.getX(actionIndex); float eventY = k < historySize ? event.getHistoricalY(actionIndex, k) : event.getY(actionIndex); // tx and ty are relative to wave center float tx = eventX - mWaveCenterX; float ty = eventY - mWaveCenterY; float touchRadius = (float) Math.hypot(tx, ty); final float scale = touchRadius > mOuterRadius ? mOuterRadius / touchRadius : 1.0f; float limitX = tx * scale; float limitY = ty * scale; double angleRad = Math.atan2(-ty, tx); if (!mDragging) { trySwitchToFirstTouchState(eventX, eventY); } if (mDragging) { // For multiple targets, snap to the one that matches final float snapRadius = mRingScaleFactor * mOuterRadius - mSnapMargin; final float snapDistance2 = snapRadius * snapRadius; // Find first target in range for (int i = 0; i < ntargets; i++) { TargetDrawable target = targets.get(i); double targetMinRad = (i - 0.5) * 2 * Math.PI / ntargets; double targetMaxRad = (i + 0.5) * 2 * Math.PI / ntargets; if (target.isEnabled()) { boolean angleMatches = (angleRad > targetMinRad && angleRad <= targetMaxRad) || (angleRad + 2 * Math.PI > targetMinRad && angleRad + 2 * Math.PI <= targetMaxRad); if (angleMatches && (dist2(tx, ty) > snapDistance2)) { activeTarget = i; } } } } x = limitX; y = limitY; } if (!mDragging) { return; } if (activeTarget != -1) { switchToState(STATE_SNAP, x, y); updateGlowPosition(x, y); } else { switchToState(STATE_TRACKING, x, y); updateGlowPosition(x, y); } if (mActiveTarget != activeTarget) { // Defocus the old target if (mActiveTarget != -1) { TargetDrawable target = targets.get(mActiveTarget); target.setState(TargetDrawable.STATE_INACTIVE); } // Focus the new target if (activeTarget != -1) { TargetDrawable target = targets.get(activeTarget); target.setState(TargetDrawable.STATE_FOCUSED); final AccessibilityManager accessibilityManager = (AccessibilityManager) getContext() .getSystemService(Context.ACCESSIBILITY_SERVICE); if (accessibilityManager.isEnabled()) { String targetContentDescription = getTargetDescription(activeTarget); announceForAccessibility(targetContentDescription); } } } mActiveTarget = activeTarget; }
From source file:com.ferdi2005.secondgram.support.widget.RecyclerView.java
public RecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, CLIP_TO_PADDING_ATTR, defStyle, 0); mClipToPadding = a.getBoolean(0, true); a.recycle();/* w ww .j av a2 s . c om*/ } else { mClipToPadding = true; } setScrollContainer(true); setFocusableInTouchMode(true); final ViewConfiguration vc = ViewConfiguration.get(context); mTouchSlop = vc.getScaledTouchSlop(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity(); mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); setWillNotDraw(getOverScrollMode() == View.OVER_SCROLL_NEVER); mItemAnimator.setListener(mItemAnimatorListener); initAdapterManager(); initChildrenHelper(); // If not explicitly specified this view is important for accessibility. if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) { ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); } mAccessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); setAccessibilityDelegateCompat(new RecyclerViewAccessibilityDelegate(this)); // Create the layoutManager if specified. boolean nestedScrollingEnabled = true; setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); // Re-set whether nested scrolling is enabled so that it is set on all API levels setNestedScrollingEnabled(nestedScrollingEnabled); }
From source file:com.android.incallui.widget.multiwaveview.GlowPadView.java
@Override public boolean onHoverEvent(MotionEvent event) { final AccessibilityManager accessibilityManager = (AccessibilityManager) getContext() .getSystemService(Context.ACCESSIBILITY_SERVICE); if (accessibilityManager.isTouchExplorationEnabled()) { final int action = event.getAction(); switch (action) { case MotionEvent.ACTION_HOVER_ENTER: event.setAction(MotionEvent.ACTION_DOWN); break; case MotionEvent.ACTION_HOVER_MOVE: event.setAction(MotionEvent.ACTION_MOVE); break; case MotionEvent.ACTION_HOVER_EXIT: event.setAction(MotionEvent.ACTION_UP); break; }//from w w w. j ava 2 s . c o m onTouchEvent(event); event.setAction(action); } super.onHoverEvent(event); return true; }
From source file:com.klinker.deskclock.widget.multiwaveview.GlowPadView.java
private void announceTargets() { StringBuilder utterance = new StringBuilder(); final int targetCount = mTargetDrawables.size(); for (int i = 0; i < targetCount; i++) { String targetDescription = getTargetDescription(i); String directionDescription = getDirectionDescription(i); if (!TextUtils.isEmpty(targetDescription) && !TextUtils.isEmpty(directionDescription)) { String text = String.format(directionDescription, targetDescription); utterance.append(text);// w w w . ja v a 2s . co m } } if (utterance.length() > 0) { final AccessibilityManager accessibilityManager = (AccessibilityManager) getContext() .getSystemService(Context.ACCESSIBILITY_SERVICE); if (accessibilityManager.isEnabled()) { if (Build.VERSION.SDK_INT >= 16) { announceForAccessibility(utterance.toString()); } else { AccessibilityEvent acc_event = AccessibilityEvent .obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED); AccessibilityRecordCompat arc = new AccessibilityRecordCompat(acc_event); arc.setSource(this); acc_event.setClassName(this.getClass().getName()); acc_event.setPackageName(this.getContext().getPackageName()); acc_event.setEnabled(this.isEnabled()); acc_event.getText().add(utterance.toString()); accessibilityManager.sendAccessibilityEvent(acc_event); } } } }
From source file:com.aliyun.homeshell.Folder.java
public void sendCustomAccessibilityEvent(int type, String text) { AccessibilityManager accessibilityManager = (AccessibilityManager) getContext() .getSystemService(Context.ACCESSIBILITY_SERVICE); if (accessibilityManager.isEnabled()) { AccessibilityEvent event = AccessibilityEvent.obtain(type); onInitializeAccessibilityEvent(event); event.getText().add(text);//w ww.java2 s . com accessibilityManager.sendAccessibilityEvent(event); } }
From source file:com.android.incallui.widget.multiwaveview.GlowPadView.java
private float getScaledGlowRadiusSquared() { final float scaledTapRadius; final AccessibilityManager accessibilityManager = (AccessibilityManager) getContext() .getSystemService(Context.ACCESSIBILITY_SERVICE); if (accessibilityManager.isEnabled()) { scaledTapRadius = TAP_RADIUS_SCALE_ACCESSIBILITY_ENABLED * mGlowRadius; } else {//from w ww .j a v a2 s.c o m scaledTapRadius = mGlowRadius; } return square(scaledTapRadius); }
From source file:com.android.incallui.CallCardFragment.java
@Override public void sendAccessibilityAnnouncement() { mHandler.postDelayed(new Runnable() { @Override/*from www . ja v a 2 s.c o m*/ public void run() { if (getView() != null && getView().getParent() != null && isAccessibilityEnabled(getContext())) { AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_ANNOUNCEMENT); dispatchPopulateAccessibilityEvent(event); getView().getParent().requestSendAccessibilityEvent(getView(), event); } } private boolean isAccessibilityEnabled(Context context) { AccessibilityManager accessibilityManager = (AccessibilityManager) context .getSystemService(Context.ACCESSIBILITY_SERVICE); return accessibilityManager != null && accessibilityManager.isEnabled(); } }, ACCESSIBILITY_ANNOUNCEMENT_DELAY_MS); }
From source file:org.mozilla.gecko.GeckoAppShell.java
public static boolean getAccessibilityEnabled() { AccessibilityManager accessibilityManager = (AccessibilityManager) GeckoApp.mAppContext .getSystemService(Context.ACCESSIBILITY_SERVICE); return accessibilityManager.isEnabled(); }