Example usage for android.view.accessibility AccessibilityEvent TYPE_WINDOW_STATE_CHANGED

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

Introduction

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

Prototype

int TYPE_WINDOW_STATE_CHANGED

To view the source code for android.view.accessibility AccessibilityEvent TYPE_WINDOW_STATE_CHANGED.

Click Source Link

Document

Represents the event of a change to a visually distinct section of the user interface.

Usage

From source file:Main.java

public static void sendAccessibilityEvent(Context context) {
    AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (am.isEnabled()) {
        am.sendAccessibilityEvent(AccessibilityEvent.obtain(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED));
    }//from  w  w w  . ja  v  a2s.  co  m
}

From source file:com.android.screenspeak.controller.TextCursorControllerApp.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED:
        processTextSelectionChange(event);
        break;//from w w  w. j  a v  a2 s . com
    case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
        clear();
        break;
    }
}

From source file:net.grayswander.rotationmanager.RotationManagerService.java

@Override
protected void onServiceConnected() {
    super.onServiceConnected();

    //Configure these here for compatibility with API 13 and below.
    AccessibilityServiceInfo config = new AccessibilityServiceInfo();
    config.eventTypes = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
    config.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;

    if (Build.VERSION.SDK_INT >= 16)
        //Just in case this helps
        config.flags = AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;

    setServiceInfo(config);/*from  w w  w.j av a  2s . c  o  m*/

    this.context = getApplicationContext();

    PreferenceManager.setDefaultValues(context, R.xml.preferences, false);

    configuration = new Configuration(this.context);
    this.resources = context.getResources();

}

From source file:com.android.talkback.eventprocessor.ProcessorAccessibilityHints.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    if (!areHintsEnabled()) {
        return;/*w ww.j  ava2s  . com*/
    }

    // Clear hints that were generated before a click or in an old window configuration.
    final int eventType = event.getEventType();
    if (eventType == AccessibilityEvent.TYPE_VIEW_CLICKED
            || eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
            || eventType == AccessibilityEvent.TYPE_WINDOWS_CHANGED) {
        cancelA11yHint();
        return;
    }

    if (eventType == AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUSED) {
        EventState eventState = EventState.getInstance();
        if (eventState.checkAndClearRecentEvent(EventState.EVENT_SKIP_HINT_AFTER_GRANULARITY_MOVE)) {
            return;
        }
        if (eventState.checkAndClearRecentEvent(EventState.EVENT_SKIP_HINT_AFTER_CURSOR_CONTROL)) {
            return;
        }

        AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
        AccessibilityNodeInfoCompat source = record.getSource();
        if (source != null) {
            postA11yHintRunnable(source);
            // DO NOT RECYCLE. postA11yHintRunnable will save the node.
        }
    }
}

From source file:net.grayswander.rotationmanager.RotationManagerService.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {

    if (event == null) {
        debug("Null event");
        return;/*from   ww w .j  a va2 s  .c o m*/
    }

    if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {

        String package_name;
        String class_name;
        try {
            package_name = event.getPackageName().toString();
            class_name = event.getClassName().toString();
        } catch (Exception e) {
            debug("Unable to get component");
            return;
        }

        ComponentName componentName = new ComponentName(package_name, class_name);

        Log.d("Service",
                "Package: " + componentName.getPackageName() + " Class: " + componentName.getClassName());

        ActivityInfo activityInfo = tryGetActivity(componentName);
        boolean isActivity = activityInfo != null;
        if (!isActivity) {
            debug("Received event with NULL activity.");
            return;
        }

        debug("Received app " + package_name);

        if (package_name.equals(this.currentPackage)) {
            debug("App has not been changed");
            return;
        }

        debug("App has been changed");

        boolean is_rotation_enabled = this.getAutoOrientationEnabled();

        debug("Rotation: " + is_rotation_enabled);
        if (!appStartedFullScreen) {
            Log.d("Service", "Saving rotation settings, as fullscreen hack is inactive");
            if (is_rotation_enabled != this.lastSetRotation) {
                debug("Setting rotation " + is_rotation_enabled + " for " + this.currentPackage);
                this.configuration.setRotationSetting(this.currentPackage, is_rotation_enabled);
            }
        } else {
            Log.d("Service", "Not saving rotation settings, as fullscreen hack is active");
        }

        this.appStartedFullScreen = false;

        if (this.configuration.isForFullscreenWatcher(package_name)) {
            this.startFullscreenWatcher();
        } else {
            if (this.configuration.isForFullscreenWatcher(this.currentPackage)) {
                this.stopFullscreenWatcher();
            }
        }

        this.currentPackage = package_name;

        boolean app_rotation_setting = this.getAppRotationSetting(componentName);

        debug("Got rotation " + app_rotation_setting + " for " + package_name);

        if (is_rotation_enabled != app_rotation_setting) {
            debug("Setting rotation " + app_rotation_setting);
            this.setAutoOrientationEnabled(app_rotation_setting);
        }

    }

}

From source file:com.android.screenspeak.formatter.TouchExplorationFormatter.java

/**
 * Resets cached scrollable state when touch exploration after window state
 * changes.//from  w ww  .  j  ava  2 s  . c  o m
 */
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
        // Reset cached scrollable state.
        mLastNodeWasScrollable = false;
        break;
    }
}

From source file:com.android.screenspeak.eventprocessor.ProcessorScrollPosition.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    if (shouldIgnoreEvent(event)) {
        return;/* ww w .  jav  a  2 s.  com*/
    }

    switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
        // Window state changes clear the cache.
        mCachedFromValues.clear();
        mCachedItemCounts.clear();
        mHandler.cancelScrollFeedback();
        break;
    case AccessibilityEvent.TYPE_VIEW_SCROLLED:
    case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
        mHandler.postScrollFeedback(event);
        break;
    }
}

From source file:com.google.android.marvin.mytalkback.ProcessorScrollPosition.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    updateRecentlyExplored(event);// w  w  w .j  a  va 2 s.com

    if (shouldIgnoreEvent(event)) {
        return;
    }

    mHandler.cancelSeekFeedback();
    mHandler.cancelScrollFeedback();

    switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
        // Window state changes clear the cache.
        mCachedFromValues.clear();
        break;
    case AccessibilityEvent.TYPE_VIEW_SCROLLED:
        mHandler.postScrollFeedback(event);
        break;
    case AccessibilityEvent.TYPE_VIEW_SELECTED:
        // SeekBars incorrectly send TYPE_VIEW_SELECTED events (verified
        // up to 4.1.2).
        if (AccessibilityEventUtils.eventMatchesClass(mContext, event,
                android.widget.SeekBar.class.getName())) {
            mHandler.postSeekFeedback(event);
        }
        break;
    }
}

From source file:com.android.utils.AccessibilityEventUtils.java

public static int[] getAllEventTypes() {
    return new int[] { AccessibilityEvent.TYPE_ANNOUNCEMENT, AccessibilityEvent.TYPE_ASSIST_READING_CONTEXT,
            AccessibilityEvent.TYPE_GESTURE_DETECTION_END, AccessibilityEvent.TYPE_GESTURE_DETECTION_START,
            AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED,
            AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END,
            AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START,
            AccessibilityEvent.TYPE_TOUCH_INTERACTION_END, AccessibilityEvent.TYPE_TOUCH_INTERACTION_START,
            AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED,
            AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED, AccessibilityEvent.TYPE_VIEW_CLICKED,
            AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED, AccessibilityEvent.TYPE_VIEW_FOCUSED,
            AccessibilityEvent.TYPE_VIEW_HOVER_ENTER, AccessibilityEvent.TYPE_VIEW_HOVER_EXIT,
            AccessibilityEvent.TYPE_VIEW_LONG_CLICKED, AccessibilityEvent.TYPE_VIEW_SCROLLED,
            AccessibilityEvent.TYPE_VIEW_SELECTED, AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED,
            AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED,
            AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY,
            AccessibilityEvent.TYPE_WINDOWS_CHANGED, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED,
            AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED };
}

From source file:com.android.screenspeak.eventprocessor.ProcessorEventQueue.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    final int eventType = event.getEventType();

    if (eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
        mLastWindowStateChanged = SystemClock.uptimeMillis();
    }//from w ww. j a  v  a2s .  c  o  m

    synchronized (mEventQueue) {
        mEventQueue.enqueue(event);
        mHandler.postSpeak();
    }
}