Java Code Examples for org.chromium.chrome.browser.util.AccessibilityUtil#isAccessibilityEnabled()

The following examples show how to use org.chromium.chrome.browser.util.AccessibilityUtil#isAccessibilityEnabled() . 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 365browser 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()
            || (manager != null && manager.getPersistentFullscreenMode())) {
        return false;
    }

    if (direction == ScrollDirection.DOWN) {
        boolean isAccessibility = AccessibilityUtil.isAccessibilityEnabled();
        return mOverviewLayout != null && !isAccessibility;
    }

    return direction == ScrollDirection.LEFT || direction == ScrollDirection.RIGHT;
}
 
Example 2
Source File: TopControlsVisibilityDelegate.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * @return Whether hiding top controls is enabled or not.
 */
public boolean isHidingTopControlsEnabled() {
    WebContents webContents = mTab.getWebContents();
    if (webContents == null || webContents.isDestroyed()) return false;

    String url = mTab.getUrl();
    boolean enableHidingTopControls = url != null;
    enableHidingTopControls &= !url.startsWith(UrlConstants.CHROME_SCHEME);
    enableHidingTopControls &= !url.startsWith(UrlConstants.CHROME_NATIVE_SCHEME);

    int securityState = mTab.getSecurityLevel();
    enableHidingTopControls &= (securityState != ConnectionSecurityLevel.SECURITY_ERROR
            && securityState != ConnectionSecurityLevel.SECURITY_WARNING);

    enableHidingTopControls &=
            !AccessibilityUtil.isAccessibilityEnabled(mTab.getApplicationContext());

    ContentViewCore cvc = mTab.getContentViewCore();
    enableHidingTopControls &= cvc == null || !cvc.isFocusedNodeEditable();
    enableHidingTopControls &= !mTab.isShowingErrorPage();
    enableHidingTopControls &= !webContents.isShowingInterstitialPage();
    enableHidingTopControls &= (mTab.getFullscreenManager() != null);
    enableHidingTopControls &= DeviceClassManager.enableFullscreen();
    enableHidingTopControls &= !mTab.isFullscreenWaitingForLoad();

    return enableHidingTopControls;
}
 
Example 3
Source File: TabStateBrowserControlsVisibilityDelegate.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isHidingBrowserControlsEnabled() {
    WebContents webContents = mTab.getWebContents();
    if (webContents == null || webContents.isDestroyed()) return false;

    String url = mTab.getUrl();
    boolean enableHidingBrowserControls = url != null;
    enableHidingBrowserControls &= !url.startsWith(UrlConstants.CHROME_SCHEME);
    enableHidingBrowserControls &= !url.startsWith(UrlConstants.CHROME_NATIVE_SCHEME);

    int securityState = mTab.getSecurityLevel();
    enableHidingBrowserControls &= (securityState != ConnectionSecurityLevel.DANGEROUS
            && securityState != ConnectionSecurityLevel.SECURITY_WARNING);

    enableHidingBrowserControls &=
            !AccessibilityUtil.isAccessibilityEnabled(mTab.getApplicationContext());

    ContentViewCore cvc = mTab.getContentViewCore();
    enableHidingBrowserControls &= cvc == null || !cvc.isFocusedNodeEditable();
    enableHidingBrowserControls &= !mTab.isShowingErrorPage();
    enableHidingBrowserControls &= !webContents.isShowingInterstitialPage();
    enableHidingBrowserControls &= !mTab.isRendererUnresponsive();
    enableHidingBrowserControls &= (mTab.getFullscreenManager() != null);
    enableHidingBrowserControls &= DeviceClassManager.enableFullscreen();
    enableHidingBrowserControls &= !mIsFullscreenWaitingForLoad;

    return enableHidingBrowserControls;
}
 
Example 4
Source File: SnackbarManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private int getDuration(Snackbar snackbar) {
    int durationMs = snackbar.getDuration();
    if (durationMs == 0) {
        durationMs = AccessibilityUtil.isAccessibilityEnabled()
                ? sAccessibilitySnackbarDurationMs : sSnackbarDurationMs;
    }
    return durationMs;
}
 
Example 5
Source File: ReaderModeManager.java    From 365browser 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
            || AccessibilityUtil.isAccessibilityEnabled()) {
        return;
    }

    mReaderModePanel.requestPanelShow(reason);
}
 
Example 6
Source File: GeolocationSnackbarController.java    From 365browser 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 = AccessibilityUtil.isAccessibilityEnabled()
            ? 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 7
Source File: TabStateBrowserControlsVisibilityDelegate.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isHidingBrowserControlsEnabled() {
    WebContents webContents = mTab.getWebContents();
    if (webContents == null || webContents.isDestroyed()) return false;

    String url = mTab.getUrl();
    boolean enableHidingBrowserControls = url != null;
    enableHidingBrowserControls &= !url.startsWith(UrlConstants.CHROME_URL_PREFIX);
    enableHidingBrowserControls &= !url.startsWith(UrlConstants.CHROME_NATIVE_URL_PREFIX);

    int securityState = mTab.getSecurityLevel();
    enableHidingBrowserControls &= (securityState != ConnectionSecurityLevel.DANGEROUS
            && securityState != ConnectionSecurityLevel.SECURITY_WARNING);

    enableHidingBrowserControls &= !AccessibilityUtil.isAccessibilityEnabled();

    ContentViewCore cvc = mTab.getContentViewCore();
    enableHidingBrowserControls &= cvc == null || !cvc.isFocusedNodeEditable();
    enableHidingBrowserControls &= !mTab.isShowingErrorPage();
    enableHidingBrowserControls &= !webContents.isShowingInterstitialPage();
    enableHidingBrowserControls &= !mTab.isRendererUnresponsive();
    enableHidingBrowserControls &= (mTab.getFullscreenManager() != null);
    enableHidingBrowserControls &= DeviceClassManager.enableFullscreen();
    enableHidingBrowserControls &= !mIsFullscreenWaitingForLoad;

    return enableHidingBrowserControls;
}
 
Example 8
Source File: ToolbarTablet.java    From 365browser 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);
    mSecurityButton = (TintedImageButton) findViewById(R.id.security_button);
    mShowTabStack = AccessibilityUtil.isAccessibilityEnabled();

    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 9
Source File: DeviceClassManager.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * @return Whether or not should use the accessibility tab switcher.
 */
public static boolean enableAccessibilityLayout() {
    return getInstance().mEnableAccessibilityLayout
            || AccessibilityUtil.isAccessibilityEnabled();
}
 
Example 10
Source File: DeviceClassManager.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * @return Whether or not we are showing animations.
 */
public static boolean enableAnimations() {
    return getInstance().mEnableAnimations && !AccessibilityUtil.isAccessibilityEnabled();
}