Example usage for android.view View IMPORTANT_FOR_ACCESSIBILITY_YES

List of usage examples for android.view View IMPORTANT_FOR_ACCESSIBILITY_YES

Introduction

In this page you can find the example usage for android.view View IMPORTANT_FOR_ACCESSIBILITY_YES.

Prototype

int IMPORTANT_FOR_ACCESSIBILITY_YES

To view the source code for android.view View IMPORTANT_FOR_ACCESSIBILITY_YES.

Click Source Link

Document

The view is important for accessibility.

Usage

From source file:com.google.android.apps.common.testing.accessibility.framework.ViewAccessibilityUtils.java

/**
 * @see View#isImportantForAccessibility()
 *//*from   w w w .  j  ava2  s.  co  m*/
public static boolean isImportantForAccessibility(View view) {
    if (view == null) {
        return false;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return view.isImportantForAccessibility();
    } else {
        // On earlier APIs, we must piece together accessibility importance from the available
        // properties. We return false incorrectly for some cases where unretrievable listeners
        // prevent us from determining importance.

        // If the developer marked the view as explicitly not important, it isn't.
        int mode = view.getImportantForAccessibility();
        if ((mode == View.IMPORTANT_FOR_ACCESSIBILITY_NO)
                || (mode == View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS)) {
            return false;
        }

        // No parent view can be hiding us. (APIs 19 to 21)
        ViewParent parent = view.getParent();
        while (parent instanceof View) {
            if (((View) parent)
                    .getImportantForAccessibility() == View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS) {
                return false;
            }
            parent = parent.getParent();
        }

        // Interrogate the view's other properties to determine importance.
        return (mode == View.IMPORTANT_FOR_ACCESSIBILITY_YES) || isActionableForAccessibility(view)
                || hasListenersForAccessibility(view) || (view.getAccessibilityNodeProvider() != null)
                || (ViewCompat.getAccessibilityLiveRegion(view) != ViewCompat.ACCESSIBILITY_LIVE_REGION_NONE);
    }
}

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

/**
 * Used to inflate the Workspace from XML.
 *
 * @param context The application's context.
 * @param attrs The attributes set containing the Workspace's customization values.
 * @param defStyle Unused./*from   ww w . j a v  a 2  s.  c  o  m*/
 */
public Workspace(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    mOutlineHelper = HolographicOutlineHelper.obtain(context);

    mLauncher = (Launcher) context;
    final Resources res = getResources();
    mWallpaperManager = WallpaperManager.getInstance(context);

    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0);
    mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f;
    mOverviewModeShrinkFactor = grid.getOverviewModeScale();
    a.recycle();

    setOnHierarchyChangeListener(this);
    setHapticFeedbackEnabled(false);

    initWorkspace();

    // Disable multitouch across the workspace/all apps/customize tray
    setMotionEventSplittingEnabled(true);
    setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}

From source file:com.zyk.launcher.AsyncTaskCallback.java

public AppsCustomizePagedView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mLayoutInflater = LayoutInflater.from(context);
    mPackageManager = context.getPackageManager();
    mApps = new ArrayList<ItemInfo>();
    mWidgets = new ArrayList<Object>();
    mIconCache = (LauncherAppState.getInstance()).getIconCache();
    mRunningTasks = new ArrayList<AppsCustomizeAsyncTask>();

    // Save the default widget preview background
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AppsCustomizePagedView, 0, 0);
    mWidgetCountX = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountX, 2);
    mWidgetCountY = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountY, 2);
    a.recycle();// w w w.  ja  v a2 s. co  m
    mWidgetSpacingLayout = new PagedViewCellLayout(getContext());

    // The padding on the non-matched dimension for the default widget preview icons
    // (top + bottom)
    mFadeInAdjacentScreens = false;

    // Unless otherwise specified this view is important for accessibility.
    if (getImportantForAccessibility() == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
    setSinglePageInViewport();
    DeviceProfile grid = LauncherAppState.getInstance().getDynamicGrid().getDeviceProfile();
    mMaxDistanceForFolderCreation = (0.55f * grid.iconSizePx);
    mDragUtils = new DragUtils(mLauncher, this);
    mDragEnforcer = new DropTarget.DragEnforcer(context);
}

From source file:com.phonemetra.turbo.launcher.AsyncTaskCallback.java

public AppsCustomizePagedView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mLayoutInflater = LayoutInflater.from(context);
    mPackageManager = context.getPackageManager();
    mApps = new ArrayList<AppInfo>();
    mFilteredApps = new ArrayList<AppInfo>();
    mWidgets = new ArrayList<Object>();
    mFilteredWidgets = new ArrayList<Object>();
    mIconCache = (LauncherAppState.getInstance()).getIconCache();
    mCanvas = new Canvas();
    mRunningTasks = new ArrayList<AppsCustomizeAsyncTask>();

    // Save the default widget preview background
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AppsCustomizePagedView, 0, 0);
    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
    mWidgetWidthGap = mWidgetHeightGap = grid.edgeMarginPx;
    mWidgetCountX = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountX, 2);
    mWidgetCountY = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountY, 2);
    a.recycle();/*from  w  w w .ja  v a  2 s . c om*/
    mWidgetSpacingLayout = new PagedViewCellLayout(getContext());

    // The padding on the non-matched dimension for the default widget preview icons
    // (top + bottom)
    mAppsCustomizeFadeInAdjacentScreens = SettingsProvider.getBoolean(context,
            SettingsProvider.SETTINGS_UI_DRAWER_SCROLLING_FADE_ADJACENT,
            R.bool.preferences_interface_drawer_scrolling_fade_adjacent_default);

    TransitionEffect.setFromString(this,
            SettingsProvider.getString(context, SettingsProvider.SETTINGS_UI_DRAWER_SCROLLING_TRANSITION_EFFECT,
                    R.string.preferences_interface_drawer_scrolling_transition_effect));

    // Unless otherwise specified this view is important for accessibility.
    if (getImportantForAccessibility() == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }

    updateProtectedAppsList(context);
}

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

public AppsCustomizePagedView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mLayoutInflater = LayoutInflater.from(context);
    mPackageManager = context.getPackageManager();
    mApps = new ArrayList<ApplicationInfo>();
    mWidgets = new ArrayList<Object>();
    mIconCache = ((LauncherApplication) context.getApplicationContext()).getIconCache();
    mCanvas = new Canvas();
    mRunningTasks = new ArrayList<AppsCustomizeAsyncTask>();

    // Save the default widget preview background
    Resources resources = context.getResources();
    mAppIconSize = resources.getDimensionPixelSize(R.dimen.app_icon_size);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AppsCustomizePagedView, 0, 0);
    mMaxAppCellCountX = a.getInt(R.styleable.AppsCustomizePagedView_maxAppCellCountX, -1);
    mMaxAppCellCountY = a.getInt(R.styleable.AppsCustomizePagedView_maxAppCellCountY, -1);
    mWidgetWidthGap = a.getDimensionPixelSize(R.styleable.AppsCustomizePagedView_widgetCellWidthGap, 0);
    mWidgetHeightGap = a.getDimensionPixelSize(R.styleable.AppsCustomizePagedView_widgetCellHeightGap, 0);
    mWidgetCountX = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountX, 2);
    mWidgetCountY = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountY, 2);
    mClingFocusedX = a.getInt(R.styleable.AppsCustomizePagedView_clingFocusedX, 0);
    mClingFocusedY = a.getInt(R.styleable.AppsCustomizePagedView_clingFocusedY, 0);
    a.recycle();/*w  ww  . j a  v  a 2  s .  c o m*/
    mWidgetSpacingLayout = new PagedViewCellLayout(getContext());

    // The padding on the non-matched dimension for the default widget preview icons
    // (top + bottom)
    mFadeInAdjacentScreens = false;

    // Unless otherwise specified this view is important for accessibility.
    if (ViewCompat.getImportantForAccessibility(this) == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this, View.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
}

From source file:cc.flydev.launcher.Workspace.java

/**
 * Used to inflate the Workspace from XML.
 *
 * @param context The application's context.
 * @param attrs The attributes set containing the Workspace's customization values.
 * @param defStyle Unused./*  w  w  w  .  jav  a  2 s .c om*/
 */
public Workspace(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mContentIsRefreshable = false;

    mOutlineHelper = HolographicOutlineHelper.obtain(context);

    mDragEnforcer = new DropTarget.DragEnforcer(context);
    // With workspace, data is available straight from the get-go
    setDataIsReady();

    mLauncher = (Launcher) context;
    final Resources res = getResources();
    mWorkspaceFadeInAdjacentScreens = res.getBoolean(R.bool.config_workspaceFadeAdjacentScreens);
    mFadeInAdjacentScreens = false;
    mWallpaperManager = WallpaperManager.getInstance(context);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0);
    mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f;
    mOverviewModeShrinkFactor = res.getInteger(R.integer.config_workspaceOverviewShrinkPercentage) / 100.0f;
    mOverviewModePageOffset = res.getDimensionPixelSize(R.dimen.overview_mode_page_offset);
    mCameraDistance = res.getInteger(R.integer.config_cameraDistance);
    mOriginalDefaultPage = mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1);
    a.recycle();

    setOnHierarchyChangeListener(this);
    setHapticFeedbackEnabled(false);

    initWorkspace();

    // Disable multitouch across the workspace/all apps/customize tray
    setMotionEventSplittingEnabled(true);
    setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}

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

/**
 * Used to inflate the Workspace from XML.
 *
 * @param context The application's context.
 * @param attrs The attributes set containing the Workspace's customization values.
 * @param defStyle Unused.//from w w w .jav a 2s.c  o m
 */
public Workspace(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mContentIsRefreshable = false;
    mOriginalPageSpacing = mPageSpacing;

    mDragEnforcer = new DropTarget.DragEnforcer(context);
    // With workspace, data is available straight from the get-go
    setDataIsReady();

    mLauncher = (Launcher) context;
    final Resources res = getResources();
    mWorkspaceFadeInAdjacentScreens = res.getBoolean(R.bool.config_workspaceFadeAdjacentScreens);
    mFadeInAdjacentScreens = false;
    mWallpaperManager = WallpaperManager.getInstance(context);

    int cellCountX = DEFAULT_CELL_COUNT_X;
    int cellCountY = DEFAULT_CELL_COUNT_Y;

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0);

    if (LauncherApplication.isScreenLarge()) {
        // Determine number of rows/columns dynamically
        // TODO: This code currently fails on tablets with an aspect ratio < 1.3.
        // Around that ratio we should make cells the same size in portrait and
        // landscape
        TypedArray actionBarSizeTypedArray = context
                .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
        final float actionBarHeight = actionBarSizeTypedArray.getDimension(0, 0f);

        Point minDims = new Point();
        Point maxDims = new Point();
        DisplayCompt.getCurrentSizeRange(mLauncher.getWindowManager().getDefaultDisplay(), minDims, maxDims);

        cellCountX = 1;
        while (CellLayout.widthInPortrait(res, cellCountX + 1) <= minDims.x) {
            cellCountX++;
        }

        cellCountY = 1;
        while (actionBarHeight + CellLayout.heightInLandscape(res, cellCountY + 1) <= minDims.y) {
            cellCountY++;
        }
    }

    mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f;
    mSpringLoadedPageSpacing = res.getDimensionPixelSize(R.dimen.workspace_spring_loaded_page_spacing);
    mCameraDistance = res.getInteger(R.integer.config_cameraDistance);

    // if the value is manually specified, use that instead
    cellCountX = a.getInt(R.styleable.Workspace_cellCountX, cellCountX);
    cellCountY = a.getInt(R.styleable.Workspace_cellCountY, cellCountY);
    mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1);
    a.recycle();

    setOnHierarchyChangeListener(this);

    LauncherModel.updateWorkspaceLayoutCells(cellCountX, cellCountY);
    setHapticFeedbackEnabled(false);

    initWorkspace();

    // Disable multitouch across the workspace/all apps/customize tray
    setMotionEventSplittingEnabled(true);

    // Unless otherwise specified this view is important for accessibility.
    if (ViewCompat.getImportantForAccessibility(this) == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this, View.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
}

From source file:com.zyk.launcher.Workspace.java

/**
 * Used to inflate the Workspace from XML.
 *
 * @param context The application's context.
 * @param attrs The attributes set containing the Workspace's customization values.
 * @param defStyle Unused./*from  w ww.jav  a  2 s .c  om*/
 */
public Workspace(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mContentIsRefreshable = false;

    mOutlineHelper = HolographicOutlineHelper.obtain(context);

    mDragEnforcer = new DropTarget.DragEnforcer(context);
    // With workspace, data is available straight from the get-go
    setDataIsReady();

    mLauncher = (Launcher) context;
    final Resources res = getResources();
    mWorkspaceFadeInAdjacentScreens = LauncherAppState.getInstance().getDynamicGrid().getDeviceProfile()
            .shouldFadeAdjacentWorkspaceScreens();
    mFadeInAdjacentScreens = false;
    mWallpaperManager = WallpaperManager.getInstance(context);

    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0);
    mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f;
    mOverviewModeShrinkFactor = grid.getOverviewModeScale();
    mCameraDistance = res.getInteger(R.integer.config_cameraDistance);
    mOriginalDefaultPage = mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1);
    a.recycle();

    setOnHierarchyChangeListener(this);
    setHapticFeedbackEnabled(false);

    initWorkspace();

    // Disable multitouch across the workspace/all apps/customize tray
    setMotionEventSplittingEnabled(true);
    setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);

    mDragUtils = new DragUtils(mLauncher, this);
}

From source file:com.android.launcher3.Workspace.java

/**
 * Used to inflate the Workspace from XML.
 *
 * @param context The application's context.
 * @param attrs The attributes set containing the Workspace's customization values.
 * @param defStyle Unused./*from  ww w. j av  a  2  s. c o m*/
 */
public Workspace(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mContentIsRefreshable = false;

    mOutlineHelper = HolographicOutlineHelper.obtain(context);

    mDragEnforcer = new DropTarget.DragEnforcer(context);
    // With workspace, data is available straight from the get-go
    setDataIsReady();

    mLauncher = (Launcher) context;
    final Resources res = getResources();
    mWorkspaceFadeInAdjacentScreens = LauncherAppState.getInstance().getDynamicGrid().getDeviceProfile()
            .shouldFadeAdjacentWorkspaceScreens();
    mFadeInAdjacentScreens = false;
    mWallpaperManager = WallpaperManager.getInstance(context);

    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0);
    mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f;
    mOverviewModeShrinkFactor = grid.getOverviewModeScale();
    mCameraDistance = res.getInteger(R.integer.config_cameraDistance);
    mOriginalDefaultPage = mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1);
    a.recycle();

    setOnHierarchyChangeListener(this);
    setHapticFeedbackEnabled(false);

    initWorkspace();

    // Disable multitouch across the workspace/all apps/customize tray
    setMotionEventSplittingEnabled(true);
    setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}

From source file:io.github.runassudo.launchert.Workspace.java

/**
 * Used to inflate the Workspace from XML.
 *
 * @param context// w  w w.  j a va  2s .  c om
 *            The application's context.
 * @param attrs
 *            The attributes set containing the Workspace's customization
 *            values.
 * @param defStyle
 *            Unused.
 */
public Workspace(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mContentIsRefreshable = false;

    mOutlineHelper = HolographicOutlineHelper.obtain(context);

    mDragEnforcer = new DropTarget.DragEnforcer(context);
    // With workspace, data is available straight from the get-go
    setDataIsReady();

    mLauncher = (Launcher) context;
    final Resources res = getResources();
    mWorkspaceFadeInAdjacentScreens = LauncherAppState.getInstance().getDynamicGrid().getDeviceProfile()
            .shouldFadeAdjacentWorkspaceScreens();
    mFadeInAdjacentScreens = false;
    mWallpaperManager = WallpaperManager.getInstance(context);

    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0);
    mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f;
    mOverviewModeShrinkFactor = grid.getOverviewModeScale();
    mCameraDistance = res.getInteger(R.integer.config_cameraDistance);

    //(LauncherT) Custom default page.
    // mOriginalDefaultPage = mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1);
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
    mOriginalDefaultPage = mDefaultPage = Integer.parseInt(sharedPref.getString("desktop_default_screen", "0"));
    a.recycle();

    setOnHierarchyChangeListener(this);
    setHapticFeedbackEnabled(false);

    initWorkspace();

    // Disable multitouch across the workspace/all apps/customize tray
    setMotionEventSplittingEnabled(true);
    setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}