Example usage for android.view.accessibility AccessibilityEvent setClassName

List of usage examples for android.view.accessibility AccessibilityEvent setClassName

Introduction

In this page you can find the example usage for android.view.accessibility AccessibilityEvent setClassName.

Prototype

public void setClassName(CharSequence className) 

Source Link

Document

Sets the class name of the source.

Usage

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);/*from w  w  w  .  j  a v  a2 s . c  o 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:android.widget.Gallery.java

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(Gallery.class.getName());
}

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
    }//from  w  ww .java  2s  . com

    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:com.albedinsky.android.ui.widget.BaseProgressBar.java

/**
 *///from ww  w.j a  v  a 2 s  .c  om
@Override
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void onInitializeAccessibilityEvent(@NonNull AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(BaseProgressBar.class.getName());
    event.setItemCount(mMax);
    event.setCurrentItemIndex(mProgress);
}

From source file:com.albedinsky.android.support.ui.widget.BaseProgressBar.java

/**
 *///  w w w. j av a  2 s  .  c  o  m
@Override
public void onInitializeAccessibilityEvent(@NonNull AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(BaseProgressBar.class.getName());
    event.setItemCount(mMax);
    event.setCurrentItemIndex(mProgress);
}

From source file:cm.aptoide.com.actionbarsherlock.widget.SearchView.java

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(SearchView.class.getName());
}

From source file:android.support.v7.widget.LinearLayoutCompat.java

public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    if (Build.VERSION.SDK_INT >= 14) {
        super.onInitializeAccessibilityEvent(event);
        event.setClassName(LinearLayoutCompat.class.getName());
    }//from  w  ww.jav  a  2 s.  c o m
}

From source file:com.android.calendar.event.EditEventView.java

private void sendAccessibilityEvent() {
    AccessibilityManager am = (AccessibilityManager) mActivity.getSystemService(Service.ACCESSIBILITY_SERVICE);
    if (!am.isEnabled() || mModel == null) {
        return;//w  ww .ja v  a 2  s. c om
    }
    StringBuilder b = new StringBuilder();
    addFieldsRecursive(b, mView);
    CharSequence msg = b.toString();

    AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_FOCUSED);
    event.setClassName(getClass().getName());
    event.setPackageName(mActivity.getPackageName());
    event.getText().add(msg);
    event.setAddedCount(msg.length());

    am.sendAccessibilityEvent(event);
}

From source file:com.appunite.list.GridView.java

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(GridView.class.getName());
}

From source file:com.android.calendar.EventInfoFragment.java

private void sendAccessibilityEvent() {
    AccessibilityManager am = (AccessibilityManager) getActivity()
            .getSystemService(Service.ACCESSIBILITY_SERVICE);
    if (!am.isEnabled()) {
        return;/*from   w  w  w.  j  a  v a 2 s  .c  o  m*/
    }

    AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_FOCUSED);
    event.setClassName(EventInfoFragment.class.getName());
    event.setPackageName(getActivity().getPackageName());
    List<CharSequence> text = event.getText();

    addFieldToAccessibilityEvent(text, mTitle, null);
    addFieldToAccessibilityEvent(text, mWhenDateTime, null);
    addFieldToAccessibilityEvent(text, mWhere, null);
    addFieldToAccessibilityEvent(text, null, mDesc);

    if (mResponseRadioGroup.getVisibility() == View.VISIBLE) {
        int id = mResponseRadioGroup.getCheckedRadioButtonId();
        if (id != View.NO_ID) {
            text.add(((TextView) getView().findViewById(R.id.response_label)).getText());
            text.add((((RadioButton) (mResponseRadioGroup.findViewById(id))).getText() + PERIOD_SPACE));
        }
    }

    am.sendAccessibilityEvent(event);
}