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:com.huangj.huangjlibrary.widget.drawerlayout.DrawerLayout.java

void dispatchOnDrawerOpened(View drawerView) {
    final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams();
    if ((lp.openState & LayoutParams.FLAG_IS_OPENED) == 0) {
        lp.openState = LayoutParams.FLAG_IS_OPENED;
        if (mListeners != null) {
            // Notify the listeners. Do that from the end of the list so that if a listener
            // removes itself as the result of being called, it won't mess up with our iteration
            int listenerCount = mListeners.size();
            for (int i = listenerCount - 1; i >= 0; i--) {
                mListeners.get(i).onDrawerOpened(drawerView);
            }/*from   ww  w  .  j ava 2s. co  m*/
        }

        updateChildrenImportantForAccessibility(drawerView, true);

        // Only send WINDOW_STATE_CHANGE if the host has window focus.
        if (hasWindowFocus()) {
            sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
        }

        drawerView.requestFocus();
    }
}

From source file:com.borax12.materialdaterangepicker.single.time.RadialPickerLayout.java

/**
 * Announce the currently-selected time when launched.
 */// w w  w. j a  v a 2 s. co  m
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
        // Clear the event's current text so that only the current time will be spoken.
        event.getText().clear();
        Calendar time = Calendar.getInstance();
        time.set(Calendar.HOUR, getHours());
        time.set(Calendar.MINUTE, getMinutes());
        time.set(Calendar.SECOND, getSeconds());
        long millis = time.getTimeInMillis();
        int flags = DateUtils.FORMAT_SHOW_TIME;
        if (mIs24HourMode) {
            flags |= DateUtils.FORMAT_24HOUR;
        }
        String timeString = DateUtils.formatDateTime(getContext(), millis, flags);
        event.getText().add(timeString);
        return true;
    }
    return super.dispatchPopulateAccessibilityEvent(event);
}

From source file:com.mojtaba.materialdatetimepicker.time.RadialPickerLayout.java

/**
 * Announce the currently-selected time when launched.
 *//*from   ww  w .  j  av  a2s . c  o m*/
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
        // Clear the event's current text so that only the current time will be spoken.
        event.getText().clear();
        Calendar time = Calendar.getInstance();
        time.set(Calendar.HOUR, getHours());
        time.set(Calendar.MINUTE, getMinutes());
        time.set(Calendar.SECOND, getSeconds());
        long millis = time.getTimeInMillis();
        int flags = DateUtils.FORMAT_SHOW_TIME;
        if (mIs24HourMode) {
            flags |= DateUtils.FORMAT_24HOUR;
        }
        String timeString = LanguageUtils
                .getPersianNumbers(DateUtils.formatDateTime(getContext(), millis, flags)); //TODO: Changed Here.
        event.getText().add(timeString);
        return true;
    }
    return super.dispatchPopulateAccessibilityEvent(event);
}

From source file:com.aliyun.homeshell.Folder.java

public void animateOpen() {
    positionAndSizeAsIcon();/* w w  w .j  av  a 2s. c  o  m*/
    if (!(getParent() instanceof DragLayer))
        return;
    centerAboutIcon();
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1);
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f);
    final ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY);

    oa.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
                    String.format(getContext().getString(R.string.folder_opened), mContent.getCountX(),
                            mContent.getCountY()));
            mState = STATE_ANIMATING;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mState = STATE_OPEN;
            setLayerType(LAYER_TYPE_NONE, null);

            /* YUNOS BEGIN */
            // ##date:2013/11/27 ##author:zhangqiang.zq
            // remove cling
            /*
             * Cling cling = mLauncher.showFirstRunFoldersCling(); if (cling
             * != null) { cling.bringToFront(); }
             */
            /* YUNOS END */
            setFocusOnFirstChild();
            setAlpha(1);
            setScaleX(1);
            setScaleY(1);
            /*YUNOS BEGIN*/
            //##date:2014/06/10 ##author:guoshuai.lgs ##BugID:
            //support the folder feature in mainmenu
            if (mInfo.isMainmenuFolder() && (LauncherApplication.isMainmenuMode())) {
                mLauncher.getAppsCustomizeTabHost().setVisibility(View.INVISIBLE);
            }
            /*YUNOS END*/
        }
    });
    oa.setDuration(mExpandDuration);
    setLayerType(LAYER_TYPE_HARDWARE, null);
    oa.start();
}

From source file:com.android.contacts.quickcontact.QuickContactActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Trace.beginSection("onCreate()");
    super.onCreate(savedInstanceState);

    if (RequestPermissionsActivity.startPermissionActivity(this)
            || RequestDesiredPermissionsActivity.startPermissionActivity(this)) {
        return;//www  .  ja v  a2  s.com
    }

    final int previousScreenType = getIntent().getIntExtra(EXTRA_PREVIOUS_SCREEN_TYPE, ScreenType.UNKNOWN);
    Logger.logScreenView(this, ScreenType.QUICK_CONTACT, previousScreenType);

    if (CompatUtils.isLollipopCompatible()) {
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }

    processIntent(getIntent());

    // Show QuickContact in front of soft input
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
            WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

    setContentView(R.layout.quickcontact_activity);

    mMaterialColorMapUtils = new MaterialColorMapUtils(getResources());

    mScroller = (MultiShrinkScroller) findViewById(R.id.multiscroller);

    mContactCard = (ExpandingEntryCardView) findViewById(R.id.communication_card);
    mNoContactDetailsCard = (ExpandingEntryCardView) findViewById(R.id.no_contact_data_card);
    mRecentCard = (ExpandingEntryCardView) findViewById(R.id.recent_card);
    mAboutCard = (ExpandingEntryCardView) findViewById(R.id.about_card);

    mCollapsedSuggestionCardView = (CardView) findViewById(R.id.collapsed_suggestion_card);
    mExpandSuggestionCardView = (CardView) findViewById(R.id.expand_suggestion_card);
    mCollapasedSuggestionHeader = findViewById(R.id.collapsed_suggestion_header);
    mCollapsedSuggestionCardTitle = (TextView) findViewById(R.id.collapsed_suggestion_card_title);
    mExpandSuggestionCardTitle = (TextView) findViewById(R.id.expand_suggestion_card_title);
    mSuggestionSummaryPhoto = (ImageView) findViewById(R.id.suggestion_icon);
    mSuggestionForName = (TextView) findViewById(R.id.suggestion_for_name);
    mSuggestionContactsNumber = (TextView) findViewById(R.id.suggestion_for_contacts_number);
    mSuggestionList = (LinearLayout) findViewById(R.id.suggestion_list);
    mSuggestionsCancelButton = (Button) findViewById(R.id.cancel_button);
    mSuggestionsLinkButton = (Button) findViewById(R.id.link_button);
    if (savedInstanceState != null) {
        mIsSuggestionListCollapsed = savedInstanceState.getBoolean(KEY_IS_SUGGESTION_LIST_COLLAPSED, true);
        mPreviousContactId = savedInstanceState.getLong(KEY_PREVIOUS_CONTACT_ID);
        mSuggestionsShouldAutoSelected = savedInstanceState.getBoolean(KEY_SUGGESTIONS_AUTO_SELECTED, true);
        mSelectedAggregationIds = (TreeSet<Long>) savedInstanceState
                .getSerializable(KEY_SELECTED_SUGGESTION_CONTACTS);
    } else {
        mIsSuggestionListCollapsed = true;
        mSelectedAggregationIds.clear();
    }
    if (mSelectedAggregationIds.isEmpty()) {
        disableLinkButton();
    } else {
        enableLinkButton();
    }
    mCollapasedSuggestionHeader.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            mCollapsedSuggestionCardView.setVisibility(View.GONE);
            mExpandSuggestionCardView.setVisibility(View.VISIBLE);
            mIsSuggestionListCollapsed = false;
            mExpandSuggestionCardTitle.requestFocus();
            mExpandSuggestionCardTitle.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
        }
    });

    mSuggestionsCancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            mCollapsedSuggestionCardView.setVisibility(View.VISIBLE);
            mExpandSuggestionCardView.setVisibility(View.GONE);
            mIsSuggestionListCollapsed = true;
        }
    });

    mNoContactDetailsCard.setOnClickListener(mEntryClickHandler);
    mContactCard.setOnClickListener(mEntryClickHandler);
    mContactCard.setExpandButtonText(getResources().getString(R.string.expanding_entry_card_view_see_all));
    mContactCard.setOnCreateContextMenuListener(mEntryContextMenuListener);

    mRecentCard.setOnClickListener(mEntryClickHandler);
    mRecentCard.setTitle(getResources().getString(R.string.recent_card_title));

    mAboutCard.setOnClickListener(mEntryClickHandler);
    mAboutCard.setOnCreateContextMenuListener(mEntryContextMenuListener);

    mPhotoView = (QuickContactImageView) findViewById(R.id.photo);
    final View transparentView = findViewById(R.id.transparent_view);
    if (mScroller != null) {
        transparentView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mScroller.scrollOffBottom();
            }
        });
    }

    // Allow a shadow to be shown under the toolbar.
    ViewUtil.addRectangularOutlineProvider(findViewById(R.id.toolbar_parent), getResources());

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setActionBar(toolbar);
    getActionBar().setTitle(null);
    // Put a TextView with a known resource id into the ActionBar. This allows us to easily
    // find the correct TextView location & size later.
    toolbar.addView(getLayoutInflater().inflate(R.layout.quickcontact_title_placeholder, null));

    mHasAlreadyBeenOpened = savedInstanceState != null;
    mIsEntranceAnimationFinished = mHasAlreadyBeenOpened;
    mWindowScrim = new ColorDrawable(SCRIM_COLOR);
    mWindowScrim.setAlpha(0);
    getWindow().setBackgroundDrawable(mWindowScrim);

    mScroller.initialize(mMultiShrinkScrollerListener, mExtraMode == MODE_FULLY_EXPANDED);
    // mScroller needs to perform asynchronous measurements after initalize(), therefore
    // we can't mark this as GONE.
    mScroller.setVisibility(View.INVISIBLE);

    setHeaderNameText(R.string.missing_name);

    mSelectAccountFragmentListener = (SelectAccountDialogFragmentListener) getFragmentManager()
            .findFragmentByTag(FRAGMENT_TAG_SELECT_ACCOUNT);
    if (mSelectAccountFragmentListener == null) {
        mSelectAccountFragmentListener = new SelectAccountDialogFragmentListener();
        getFragmentManager().beginTransaction()
                .add(0, mSelectAccountFragmentListener, FRAGMENT_TAG_SELECT_ACCOUNT).commit();
        mSelectAccountFragmentListener.setRetainInstance(true);
    }
    mSelectAccountFragmentListener.setQuickContactActivity(this);

    SchedulingUtils.doOnPreDraw(mScroller, /* drawNextFrame = */ true, new Runnable() {
        @Override
        public void run() {
            if (!mHasAlreadyBeenOpened) {
                // The initial scrim opacity must match the scrim opacity that would be
                // achieved by scrolling to the starting position.
                final float alphaRatio = mExtraMode == MODE_FULLY_EXPANDED ? 1
                        : mScroller.getStartingTransparentHeightRatio();
                final int duration = getResources().getInteger(android.R.integer.config_shortAnimTime);
                final int desiredAlpha = (int) (0xFF * alphaRatio);
                ObjectAnimator o = ObjectAnimator.ofInt(mWindowScrim, "alpha", 0, desiredAlpha)
                        .setDuration(duration);

                o.start();
            }
        }
    });

    if (savedInstanceState != null) {
        final int color = savedInstanceState.getInt(KEY_THEME_COLOR, 0);
        SchedulingUtils.doOnPreDraw(mScroller, /* drawNextFrame = */ false, new Runnable() {
            @Override
            public void run() {
                // Need to wait for the pre draw before setting the initial scroll
                // value. Prior to pre draw all scroll values are invalid.
                if (mHasAlreadyBeenOpened) {
                    mScroller.setVisibility(View.VISIBLE);
                    mScroller.setScroll(mScroller.getScrollNeededToBeFullScreen());
                }
                // Need to wait for pre draw for setting the theme color. Setting the
                // header tint before the MultiShrinkScroller has been measured will
                // cause incorrect tinting calculations.
                if (color != 0) {
                    setThemeColor(mMaterialColorMapUtils.calculatePrimaryAndSecondaryColor(color));
                }
            }
        });
    }

    Trace.endSection();
}

From source file:com.android.leanlauncher.LauncherTransitionable.java

void showWorkspace(boolean animated, Runnable onCompleteRunnable) {
    if (mState != State.WORKSPACE || mWorkspace.getState() != Workspace.State.NORMAL) {
        mWorkspace.setVisibility(View.VISIBLE);
        hideAppsCustomizeHelper(Workspace.State.NORMAL, animated, false, onCompleteRunnable);

        // Set focus to the AppsCustomize button
        if (mAllAppsButton != null) {
            mAllAppsButton.requestFocus();
        }//from w ww  .j a  v a  2 s. c  om
    }

    // Change the state *after* we've called all the transition code
    mState = State.WORKSPACE;

    // Resume the auto-advance of widgets
    mUserPresent = true;
    updateRunning();

    // Send an accessibility event to announce the context change
    getWindow().getDecorView().sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);

    onWorkspaceShown(animated);
}

From source file:com.android.leanlauncher.LauncherTransitionable.java

void showAllApps(boolean animated, AppsCustomizePagedView.ContentType contentType, boolean resetPageToZero) {
    if (mState != State.WORKSPACE)
        return;//  w ww . j  a  v  a 2  s . com

    if (resetPageToZero) {
        mAppsCustomizeTabHost.reset();
    }
    showAppsCustomizeHelper(animated, false, contentType);
    mAppsCustomizeTabHost.post(new Runnable() {
        @Override
        public void run() {
            // We post this in-case the all apps view isn't yet constructed.
            mAppsCustomizeTabHost.requestFocus();
        }
    });

    // Change the state *after* we've called all the transition code
    mState = State.APPS_CUSTOMIZE;

    // Pause the auto-advance of widgets until we are out of AllApps
    mUserPresent = false;
    updateRunning();

    // Send an accessibility event to announce the context change
    getWindow().getDecorView().sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}

From source file:com.android.soma.Launcher.java

/**
 * Opens the user folder described by the specified tag. The opening of the folder
 * is animated relative to the specified View. If the View is null, no animation
 * is played.//from   w ww .  ja v  a2 s .com
 *
 * @param folderInfo The FolderInfo describing the folder to open.
 */
public void openFolder(FolderIcon folderIcon) {
    Folder folder = folderIcon.getFolder();
    FolderInfo info = folder.mInfo;

    info.opened = true;

    // Just verify that the folder hasn't already been added to the DragLayer.
    // There was a one-off crash where the folder had a parent already.
    if (folder.getParent() == null) {
        mDragLayer.addView(folder);
        mDragController.addDropTarget((DropTarget) folder);
    } else {
        Log.w(TAG, "Opening folder (" + folder + ") which already has a parent (" + folder.getParent() + ").");
    }
    folder.animateOpen();
    growAndFadeOutFolderIcon(folderIcon);

    // Notify the accessibility manager that this folder "window" has appeared and occluded
    // the workspace items
    folder.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
    getDragLayer().sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
}

From source file:com.android.soma.Launcher.java

void closeFolder(Folder folder) {
    folder.getInfo().opened = false;/*  w  w  w .  j a  v  a 2 s  .  c o m*/

    ViewGroup parent = (ViewGroup) folder.getParent().getParent();
    if (parent != null) {
        FolderIcon fi = (FolderIcon) mWorkspace.getViewForTag(folder.mInfo);
        shrinkAndFadeInFolderIcon(fi);
    }
    folder.animateClosed();

    // Notify the accessibility manager that this folder "window" has disappeard and no
    // longer occludeds the workspace items
    getDragLayer().sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}

From source file:com.android.launcher2.Launcher.java

void showWorkspace(boolean animated, Runnable onCompleteRunnable) {
    if (mState != State.WORKSPACE) {
        boolean wasInSpringLoadedMode = (mState == State.APPS_CUSTOMIZE_SPRING_LOADED);
        mWorkspace.setVisibility(View.VISIBLE);
        hideAppsCustomizeHelper(State.WORKSPACE, animated, false, onCompleteRunnable);

        // Show the search bar (only animate if we were showing the drop target bar in spring
        // loaded mode)
        if (mSearchDropTargetBar != null) {
            mSearchDropTargetBar.showSearchBar(wasInSpringLoadedMode);
        }/*from www .ja v  a 2s . c  om*/

        // We only need to animate in the dock divider if we're going from spring loaded mode
        showDockDivider(animated && wasInSpringLoadedMode);

        // Set focus to the AppsCustomize button
        if (mAllAppsButton != null) {
            mAllAppsButton.requestFocus();
        }
    }

    mWorkspace.flashScrollingIndicator(animated);

    // Change the state *after* we've called all the transition code
    mState = State.WORKSPACE;

    // Resume the auto-advance of widgets
    mUserPresent = true;
    updateRunning();

    // Send an accessibility event to announce the context change
    getWindow().getDecorView().sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}