Java Code Examples for org.chromium.chrome.browser.device.DeviceClassManager#isAccessibilityModeEnabled()

The following examples show how to use org.chromium.chrome.browser.device.DeviceClassManager#isAccessibilityModeEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LayoutManagerChrome.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isSwipeEnabled(ScrollDirection direction) {
    FullscreenManager manager = mHost.getFullscreenManager();
    if (getActiveLayout() != mStaticLayout
            || !DeviceClassManager.enableToolbarSwipe(
                       FeatureUtilities.isDocumentMode(mHost.getContext()))
            || (manager != null && manager.getPersistentFullscreenMode())) {
        return false;
    }

    boolean isAccessibility =
            DeviceClassManager.isAccessibilityModeEnabled(mHost.getContext());
    return direction == ScrollDirection.LEFT || direction == ScrollDirection.RIGHT
            || (direction == ScrollDirection.DOWN && mOverviewLayout != null
                       && !isAccessibility);
}
 
Example 2
Source File: ReaderModeManager.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * This is a wrapper for "requestPanelShow" that checks if reader mode is possible before
 * showing.
 * @param reason The reason the panel is requesting to be shown.
 */
protected void requestReaderPanelShow(StateChangeReason reason) {
    if (mTabModelSelector == null) return;

    int currentTabId = mTabModelSelector.getCurrentTabId();
    if (currentTabId == Tab.INVALID_TAB_ID) return;

    if (mReaderModePanel == null || !mTabStatusMap.containsKey(currentTabId)
            || mTabStatusMap.get(currentTabId).getStatus() != POSSIBLE
            || mTabStatusMap.get(currentTabId).isDismissed()
            || mIsInfoBarContainerShown
            || mIsFindToolbarShowing
            || mIsFullscreenModeEntered
            || mIsKeyboardShowing
            || DeviceClassManager.isAccessibilityModeEnabled(mChromeActivity)) {
        return;
    }

    mReaderModePanel.requestPanelShow(reason);
}
 
Example 3
Source File: SnackbarManager.java    From delion with Apache License 2.0 5 votes vote down vote up
private int getDuration(Snackbar snackbar) {
    int durationMs = snackbar.getDuration();
    if (durationMs == 0) {
        durationMs = DeviceClassManager.isAccessibilityModeEnabled(mActivity)
                ? sAccessibilitySnackbarDurationMs : sSnackbarDurationMs;
    }
    return durationMs;
}
 
Example 4
Source File: GeolocationSnackbarController.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Shows the geolocation snackbar if it hasn't already been shown and the geolocation snackbar
 * is currently relevant: i.e. the default search engine is Google, location is enabled
 * for Chrome, the tab is not incognito, etc.
 *
 * @param snackbarManager The SnackbarManager used to show the snackbar.
 * @param view Any view that's attached to the view hierarchy.
 * @param isIncognito Whether the currently visible tab is incognito.
 * @param delayMs The delay in ms before the snackbar should be shown. This is intended to
 *                give the keyboard time to animate in.
 */
public static void maybeShowSnackbar(final SnackbarManager snackbarManager, View view,
        boolean isIncognito, int delayMs) {
    final Context context = view.getContext();
    if (getGeolocationSnackbarShown(context)) return;

    // If in incognito mode, don't show the snackbar now, but maybe show it later.
    if (isIncognito) return;

    if (neverShowSnackbar(context)) {
        setGeolocationSnackbarShown(context);
        return;
    }

    Uri searchUri = Uri.parse(TemplateUrlService.getInstance().getUrlForSearchQuery("foo"));
    TypefaceSpan robotoMediumSpan = new TypefaceSpan("sans-serif-medium");
    String messageWithoutSpans = context.getResources().getString(
            R.string.omnibox_geolocation_disclosure, "<b>" + searchUri.getHost() + "</b>");
    SpannableString message = SpanApplier.applySpans(messageWithoutSpans,
            new SpanInfo("<b>", "</b>", robotoMediumSpan));
    String settings = context.getResources().getString(R.string.preferences);
    int durationMs = DeviceClassManager.isAccessibilityModeEnabled(view.getContext())
            ? ACCESSIBILITY_SNACKBAR_DURATION_MS : SNACKBAR_DURATION_MS;
    final GeolocationSnackbarController controller = new GeolocationSnackbarController();
    final Snackbar snackbar = Snackbar
            .make(message, controller, Snackbar.TYPE_ACTION, Snackbar.UMA_OMNIBOX_GEOLOCATION)
            .setAction(settings, view)
            .setSingleLine(false)
            .setDuration(durationMs);

    view.postDelayed(new Runnable() {
        @Override
        public void run() {
            snackbarManager.dismissSnackbars(controller);
            snackbarManager.showSnackbar(snackbar);
            setGeolocationSnackbarShown(context);
        }
    }, delayMs);
}
 
Example 5
Source File: ToolbarTablet.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onFinishInflate() {
    super.onFinishInflate();
    mLocationBar = (LocationBarTablet) findViewById(R.id.location_bar);

    mHomeButton = (TintedImageButton) findViewById(R.id.home_button);
    mBackButton = (TintedImageButton) findViewById(R.id.back_button);
    mForwardButton = (TintedImageButton) findViewById(R.id.forward_button);
    mReloadButton = (TintedImageButton) findViewById(R.id.refresh_button);
    mShowTabStack = DeviceClassManager.isAccessibilityModeEnabled(getContext())
            || CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_TABLET_TAB_STACK);

    mTabSwitcherButtonDrawable =
            TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), false);
    mTabSwitcherButtonDrawableLight =
            TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), true);

    mAccessibilitySwitcherButton = (ImageButton) findViewById(R.id.tab_switcher_button);
    mAccessibilitySwitcherButton.setImageDrawable(mTabSwitcherButtonDrawable);
    updateSwitcherButtonVisibility(mShowTabStack);

    mBookmarkButton = (TintedImageButton) findViewById(R.id.bookmark_button);

    mMenuButton = (TintedImageButton) findViewById(R.id.menu_button);
    mMenuButtonWrapper.setVisibility(
            shouldShowMenuButton() ? View.VISIBLE : View.GONE);

    if (mAccessibilitySwitcherButton.getVisibility() == View.GONE
            && mMenuButtonWrapper.getVisibility() == View.GONE) {
        ApiCompatibilityUtils.setPaddingRelative((View) mMenuButtonWrapper.getParent(), 0, 0,
                getResources().getDimensionPixelSize(R.dimen.tablet_toolbar_end_padding), 0);
    }

    // Initialize values needed for showing/hiding toolbar buttons when the activity size
    // changes.
    mShouldAnimateButtonVisibilityChange = false;
    mToolbarButtonsVisible = true;
    mToolbarButtons = new TintedImageButton[] {mBackButton, mForwardButton, mReloadButton};
}
 
Example 6
Source File: LayoutManagerChrome.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isSwipeEnabled(ScrollDirection direction) {
    FullscreenManager manager = mHost.getFullscreenManager();
    if (getActiveLayout() != mStaticLayout
            || !DeviceClassManager.enableToolbarSwipe()
            || (manager != null && manager.getPersistentFullscreenMode())) {
        return false;
    }

    boolean isAccessibility =
            DeviceClassManager.isAccessibilityModeEnabled(mHost.getContext());
    return direction == ScrollDirection.LEFT || direction == ScrollDirection.RIGHT
            || (direction == ScrollDirection.DOWN && mOverviewLayout != null
                       && !isAccessibility);
}
 
Example 7
Source File: SnackbarManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private int getDuration(Snackbar snackbar) {
    int durationMs = snackbar.getDuration();
    if (durationMs == 0) {
        durationMs = DeviceClassManager.isAccessibilityModeEnabled(mActivity)
                ? sAccessibilitySnackbarDurationMs : sSnackbarDurationMs;
    }
    return durationMs;
}
 
Example 8
Source File: ReaderModeManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * This is a wrapper for "requestPanelShow" that checks if reader mode is possible before
 * showing.
 * @param reason The reason the panel is requesting to be shown.
 */
protected void requestReaderPanelShow(StateChangeReason reason) {
    if (mTabModelSelector == null) return;

    int currentTabId = mTabModelSelector.getCurrentTabId();
    if (currentTabId == Tab.INVALID_TAB_ID) return;

    // Test if the user is requesting the desktop site. Ignore this if distiller is set to
    // ALWAYS_TRUE.
    boolean usingRequestDesktopSite = getBasePageWebContents() != null
            && getBasePageWebContents().getNavigationController().getUseDesktopUserAgent()
            && !mIsReaderHeuristicAlwaysTrue;

    if (mReaderModePanel == null || !mTabStatusMap.containsKey(currentTabId)
            || usingRequestDesktopSite
            || mTabStatusMap.get(currentTabId).getStatus() != POSSIBLE
            || mTabStatusMap.get(currentTabId).isDismissed()
            || mIsInfoBarContainerShown
            || mIsFindToolbarShowing
            || mIsFullscreenModeEntered
            || mIsKeyboardShowing
            || DeviceClassManager.isAccessibilityModeEnabled(mChromeActivity)) {
        return;
    }

    mReaderModePanel.requestPanelShow(reason);
}
 
Example 9
Source File: GeolocationSnackbarController.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Shows the geolocation snackbar if it hasn't already been shown and the geolocation snackbar
 * is currently relevant: i.e. the default search engine is Google, location is enabled
 * for Chrome, the tab is not incognito, etc.
 *
 * @param snackbarManager The SnackbarManager used to show the snackbar.
 * @param view Any view that's attached to the view hierarchy.
 * @param isIncognito Whether the currently visible tab is incognito.
 * @param delayMs The delay in ms before the snackbar should be shown. This is intended to
 *                give the keyboard time to animate in.
 */
public static void maybeShowSnackbar(final SnackbarManager snackbarManager, View view,
        boolean isIncognito, int delayMs) {
    final Context context = view.getContext();
    if (ChromeFeatureList.isEnabled(ChromeFeatureList.CONSISTENT_OMNIBOX_GEOLOCATION)) return;
    if (getGeolocationSnackbarShown(context)) return;

    // If in incognito mode, don't show the snackbar now, but maybe show it later.
    if (isIncognito) return;

    if (neverShowSnackbar(context)) {
        setGeolocationSnackbarShown(context);
        return;
    }

    Uri searchUri = Uri.parse(TemplateUrlService.getInstance().getUrlForSearchQuery("foo"));
    TypefaceSpan robotoMediumSpan = new TypefaceSpan("sans-serif-medium");
    String messageWithoutSpans = context.getResources().getString(
            R.string.omnibox_geolocation_disclosure, "<b>" + searchUri.getHost() + "</b>");
    SpannableString message = SpanApplier.applySpans(messageWithoutSpans,
            new SpanInfo("<b>", "</b>", robotoMediumSpan));
    String settings = context.getResources().getString(R.string.preferences);
    int durationMs = DeviceClassManager.isAccessibilityModeEnabled(view.getContext())
            ? ACCESSIBILITY_SNACKBAR_DURATION_MS : SNACKBAR_DURATION_MS;
    final GeolocationSnackbarController controller = new GeolocationSnackbarController();
    final Snackbar snackbar = Snackbar
            .make(message, controller, Snackbar.TYPE_ACTION, Snackbar.UMA_OMNIBOX_GEOLOCATION)
            .setAction(settings, view)
            .setSingleLine(false)
            .setDuration(durationMs);

    view.postDelayed(new Runnable() {
        @Override
        public void run() {
            snackbarManager.dismissSnackbars(controller);
            snackbarManager.showSnackbar(snackbar);
            setGeolocationSnackbarShown(context);
        }
    }, delayMs);
}
 
Example 10
Source File: ToolbarTablet.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onFinishInflate() {
    super.onFinishInflate();
    mLocationBar = (LocationBarTablet) findViewById(R.id.location_bar);

    mHomeButton = (TintedImageButton) findViewById(R.id.home_button);
    mBackButton = (TintedImageButton) findViewById(R.id.back_button);
    mForwardButton = (TintedImageButton) findViewById(R.id.forward_button);
    mReloadButton = (TintedImageButton) findViewById(R.id.refresh_button);
    mShowTabStack = DeviceClassManager.isAccessibilityModeEnabled(getContext())
            || CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_TABLET_TAB_STACK);

    mTabSwitcherButtonDrawable =
            TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), false);
    mTabSwitcherButtonDrawableLight =
            TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), true);

    mAccessibilitySwitcherButton = (ImageButton) findViewById(R.id.tab_switcher_button);
    mAccessibilitySwitcherButton.setImageDrawable(mTabSwitcherButtonDrawable);
    updateSwitcherButtonVisibility(mShowTabStack);

    mBookmarkButton = (TintedImageButton) findViewById(R.id.bookmark_button);

    mMenuButton = (TintedImageButton) findViewById(R.id.menu_button);
    mMenuButtonWrapper.setVisibility(View.VISIBLE);

    if (mAccessibilitySwitcherButton.getVisibility() == View.GONE
            && mMenuButtonWrapper.getVisibility() == View.GONE) {
        ApiCompatibilityUtils.setPaddingRelative((View) mMenuButtonWrapper.getParent(), 0, 0,
                getResources().getDimensionPixelSize(R.dimen.tablet_toolbar_end_padding), 0);
    }

    mSaveOfflineButton = (TintedImageButton) findViewById(R.id.save_offline_button);

    // Initialize values needed for showing/hiding toolbar buttons when the activity size
    // changes.
    mShouldAnimateButtonVisibilityChange = false;
    mToolbarButtonsVisible = true;
    mToolbarButtons = new TintedImageButton[] {mBackButton, mForwardButton, mReloadButton};
}
 
Example 11
Source File: LayoutManagerDocumentTabSwitcher.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * @return Whether or not to use the accessibility layout.
 */
private boolean useAccessibilityLayout() {
    return DeviceClassManager.isAccessibilityModeEnabled(mHost.getContext())
            || DeviceClassManager.enableAccessibilityLayout();
}
 
Example 12
Source File: LayoutManagerChrome.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * @return Whether or not to use the accessibility layout.
 */
protected boolean useAccessibilityLayout() {
    return DeviceClassManager.isAccessibilityModeEnabled(mHost.getContext())
            || DeviceClassManager.enableAccessibilityLayout();
}
 
Example 13
Source File: LayoutManagerChrome.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * @return Whether or not to use the accessibility layout.
 */
protected boolean useAccessibilityLayout() {
    return DeviceClassManager.isAccessibilityModeEnabled(mHost.getContext())
            || DeviceClassManager.enableAccessibilityLayout();
}