org.chromium.chrome.browser.util.AccessibilityUtil Java Examples

The following examples show how to use org.chromium.chrome.browser.util.AccessibilityUtil. 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: ToolbarTablet.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onLongClick(View v) {
    String description = null;
    Context context = getContext();
    Resources resources = context.getResources();

    if (v == mReloadButton) {
        description = resources.getString(R.string.menu_refresh);
    } else if (v == mBookmarkButton) {
        description = resources.getString(R.string.menu_bookmark);
    } else if (v == mSaveOfflineButton) {
        description = resources.getString(R.string.menu_download);
    } else if (v == mSecurityButton) {
        description = resources.getString(R.string.menu_page_info);
    }
    return AccessibilityUtil.showAccessibilityToast(context, v, description);
}
 
Example #3
Source File: CustomTabToolbar.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onLongClick(View v) {
    if (v == mCloseButton) {
        return AccessibilityUtil.showAccessibilityToast(
                getContext(), v, getResources().getString(R.string.close_tab));
    } else if (v == mCustomActionButton) {
        return AccessibilityUtil.showAccessibilityToast(
                getContext(), v, mCustomActionButton.getContentDescription());
    } else if (v == mTitleUrlContainer) {
        ClipboardManager clipboard = (ClipboardManager) getContext()
                .getSystemService(Context.CLIPBOARD_SERVICE);
        Tab tab = getCurrentTab();
        if (tab == null) return false;
        String url = tab.getOriginalUrl();
        ClipData clip = ClipData.newPlainText("url", url);
        clipboard.setPrimaryClip(clip);
        Toast.makeText(getContext(), R.string.url_copied, Toast.LENGTH_SHORT).show();
        return true;
    }
    return false;
}
 
Example #4
Source File: AppMenu.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Handles long clicks on image buttons on the AppMenu popup.
 * @param menuItem The menu item in the popup that was long clicked.
 * @param view The anchor view of the menu item.
 */
boolean onItemLongClick(MenuItem menuItem, View view) {
    if (!menuItem.isEnabled()) return false;

    String description = null;
    Context context = ContextUtils.getApplicationContext();
    Resources resources = context.getResources();
    final int itemId = menuItem.getItemId();

    if (itemId == R.id.forward_menu_id) {
        description = resources.getString(R.string.menu_forward);
    } else if (itemId == R.id.bookmark_this_page_id) {
        description = resources.getString(R.string.menu_bookmark);
    } else if (itemId == R.id.offline_page_id) {
        description = resources.getString(R.string.menu_download);
    } else if (itemId == R.id.info_menu_id) {
        description = resources.getString(R.string.menu_page_info);
    } else if (itemId == R.id.reload_menu_id) {
        description = resources.getString(R.string.menu_refresh);
    }
    return AccessibilityUtil.showAccessibilityToast(context, view, description);
}
 
Example #5
Source File: AppMenuIconRowFooter.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onLongClick(View v) {
    String description = null;
    Context context = getContext();
    Resources resources = context.getResources();
    final int itemId = v.getId();

    if (itemId == R.id.forward_menu_id) {
        description = resources.getString(R.string.menu_forward);
    } else if (itemId == R.id.bookmark_this_page_id) {
        description = resources.getString(R.string.menu_bookmark);
    } else if (itemId == R.id.offline_page_id) {
        description = resources.getString(R.string.menu_download);
    } else if (itemId == R.id.info_menu_id) {
        description = resources.getString(R.string.menu_page_info);
    } else if (itemId == R.id.reload_menu_id) {
        description = resources.getString(R.string.menu_refresh);
    }
    return AccessibilityUtil.showAccessibilityToast(context, v, description);
}
 
Example #6
Source File: TextBubble.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void createContentView() {
    if (mPopupWindow.getContentView() != null) return;

    View view = LayoutInflater.from(mContext).inflate(R.layout.textbubble_text, null);
    ((TextView) view)
            .setText(AccessibilityUtil.isAccessibilityEnabled() ? mAccessibilityStringId
                                                                : mStringId);
    mPopupWindow.setContentView(view);

    // On some versions of Android, the LayoutParams aren't set until after the popup window
    // is shown. Explicitly set the LayoutParams to avoid crashing. See crbug.com/713759.
    view.setLayoutParams(
            new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
 
Example #7
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 #8
Source File: ToolbarPhone.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onLongClick(View v) {
    CharSequence description = null;
    if (v == mToggleTabStackButton) {
        description = getResources().getString(R.string.open_tabs);
    } else if (v == mNewTabButton) {
        description = getResources().getString(
                isIncognito() ? R.string.button_new_incognito_tab : R.string.button_new_tab);
    } else {
        return false;
    }
    return AccessibilityUtil.showAccessibilityToast(getContext(), v, description);
}
 
Example #9
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 #10
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 #11
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 #12
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 #13
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 #14
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 #15
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();
}
 
Example #16
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 #17
Source File: ChromeActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private void checkAccessibility() {
    onAccessibilityModeChanged(AccessibilityUtil.isAccessibilityEnabled());
}