Java Code Examples for org.chromium.ui.base.DeviceFormFactor#MINIMUM_TABLET_WIDTH_DP

The following examples show how to use org.chromium.ui.base.DeviceFormFactor#MINIMUM_TABLET_WIDTH_DP . 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: AsyncInitializationActivity.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
protected void attachBaseContext(Context newBase) {
    super.attachBaseContext(newBase);

    // On N+, Chrome should always retain the tab strip layout on tablets. Normally in
    // multi-window, if Chrome is launched into a smaller screen Android will load the tab
    // switcher resources. Overriding the smallestScreenWidthDp in the Configuration ensures
    // Android will load the tab strip resources. See crbug.com/588838.
    if (Build.VERSION.CODENAME.equals("N") || Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
        int smallestDeviceWidthDp = DeviceFormFactor.getSmallestDeviceWidthDp(this);

        if (smallestDeviceWidthDp >= DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP) {
            Configuration overrideConfiguration = new Configuration();
            overrideConfiguration.smallestScreenWidthDp = smallestDeviceWidthDp;
            applyOverrideConfiguration(overrideConfiguration);
        }
    }
}
 
Example 2
Source File: AsyncInitializationActivity.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
// TODO(estevenson): Replace with Build.VERSION_CODES.N when available.
@TargetApi(24)
protected void attachBaseContext(Context newBase) {
    super.attachBaseContext(newBase);

    // On N+, Chrome should always retain the tab strip layout on tablets. Normally in
    // multi-window, if Chrome is launched into a smaller screen Android will load the tab
    // switcher resources. Overriding the smallestScreenWidthDp in the Configuration ensures
    // Android will load the tab strip resources. See crbug.com/588838.
    if (Build.VERSION.CODENAME.equals("N") || Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
        int smallestDeviceWidthDp = DeviceFormFactor.getSmallestDeviceWidthDp(this);

        if (smallestDeviceWidthDp >= DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP) {
            Configuration overrideConfiguration = new Configuration();
            overrideConfiguration.smallestScreenWidthDp = smallestDeviceWidthDp;
            applyOverrideConfiguration(overrideConfiguration);
        }
    }
}
 
Example 3
Source File: AsyncInitializationActivity.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
@TargetApi(Build.VERSION_CODES.N)
protected void attachBaseContext(Context newBase) {
    super.attachBaseContext(newBase);

    // On N+, Chrome should always retain the tab strip layout on tablets. Normally in
    // multi-window, if Chrome is launched into a smaller screen Android will load the tab
    // switcher resources. Overriding the smallestScreenWidthDp in the Configuration ensures
    // Android will load the tab strip resources. See crbug.com/588838.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        int smallestDeviceWidthDp = DeviceFormFactor.getSmallestDeviceWidthDp();

        if (smallestDeviceWidthDp >= DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP) {
            Configuration overrideConfiguration = new Configuration();
            overrideConfiguration.smallestScreenWidthDp = smallestDeviceWidthDp;
            applyOverrideConfiguration(overrideConfiguration);
        }
    }
}
 
Example 4
Source File: ChromeActivity.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Records UMA histograms for the current screen width. Should only be called when the activity
 * is in Android N multi-window mode.
 */
protected void recordMultiWindowModeScreenWidth() {
    if (!DeviceFormFactor.isTablet(this)) return;

    RecordHistogram.recordBooleanHistogram(
            "Android.MultiWindowMode.IsTabletScreenWidthBelow600",
            mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP);

    if (mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP) {
        RecordHistogram.recordLinearCountHistogram(
                "Android.MultiWindowMode.TabletScreenWidth", mScreenWidthDp, 1,
                DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP, 50);
    }
}
 
Example 5
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Records UMA histograms for the current screen width. Should only be called when the activity
 * is in Android N multi-window mode.
 */
protected void recordMultiWindowModeScreenWidth() {
    if (!DeviceFormFactor.isTablet(this)) return;

    RecordHistogram.recordBooleanHistogram(
            "Android.MultiWindowMode.IsTabletScreenWidthBelow600",
            mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP);

    if (mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP) {
        RecordHistogram.recordLinearCountHistogram(
                "Android.MultiWindowMode.TabletScreenWidth", mScreenWidthDp, 1,
                DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP, 50);
    }
}
 
Example 6
Source File: ChromeActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Records UMA histograms for the current screen width. Should only be called when the activity
 * is in Android N multi-window mode.
 */
protected void recordMultiWindowModeScreenWidth() {
    if (!DeviceFormFactor.isTablet()) return;

    RecordHistogram.recordBooleanHistogram(
            "Android.MultiWindowMode.IsTabletScreenWidthBelow600",
            mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP);

    if (mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP) {
        RecordHistogram.recordLinearCountHistogram(
                "Android.MultiWindowMode.TabletScreenWidth", mScreenWidthDp, 1,
                DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP, 50);
    }
}
 
Example 7
Source File: StripLayoutHelper.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Creates an instance of the {@link StripLayoutHelper}.
 * @param context         The current Android {@link Context}.
 * @param updateHost      The parent {@link LayoutUpdateHost}.
 * @param renderHost      The {@link LayoutRenderHost}.
 * @param incognito       Whether or not this tab strip is incognito.
 */
public StripLayoutHelper(Context context, LayoutUpdateHost updateHost,
        LayoutRenderHost renderHost, boolean incognito) {
    mTabOverlapWidth = TAB_OVERLAP_WIDTH_DP;
    mNewTabButtonWidth = NEW_TAB_BUTTON_WIDTH_DP;

    mRightMargin = LocalizationUtils.isLayoutRtl() ? 0 : mNewTabButtonWidth;
    mLeftMargin = LocalizationUtils.isLayoutRtl() ? mNewTabButtonWidth : 0;
    mMinTabWidth = MIN_TAB_WIDTH_DP;
    mMaxTabWidth = MAX_TAB_WIDTH_DP;
    mReorderMoveStartThreshold = REORDER_MOVE_START_THRESHOLD_DP;
    mUpdateHost = updateHost;
    mRenderHost = renderHost;
    mNewTabButton =
            new CompositorButton(context, NEW_TAB_BUTTON_WIDTH_DP, NEW_TAB_BUTTON_HEIGHT_DP);
    mNewTabButton.setResources(R.drawable.btn_tabstrip_new_tab_normal,
            R.drawable.btn_tabstrip_new_tab_pressed,
            R.drawable.btn_tabstrip_new_incognito_tab_normal,
            R.drawable.btn_tabstrip_new_incognito_tab_pressed);
    mNewTabButton.setIncognito(incognito);
    mNewTabButton.setY(NEW_TAB_BUTTON_Y_OFFSET_DP);
    mNewTabButton.setClickSlop(NEW_TAB_BUTTON_CLICK_SLOP_DP);
    Resources res = context.getResources();
    mNewTabButton.setAccessibilityDescription(
            res.getString(R.string.accessibility_toolbar_btn_new_tab),
            res.getString(R.string.accessibility_toolbar_btn_new_incognito_tab));
    mContext = context;
    mIncognito = incognito;
    mBrightness = 1.f;

    // Create tab menu
    mTabMenu = new ListPopupWindow(mContext);
    mTabMenu.setAdapter(new ArrayAdapter<String>(mContext, R.layout.bookmark_popup_item,
            new String[] {
                    mContext.getString(!mIncognito ? R.string.menu_close_all_tabs
                                                   : R.string.menu_close_all_incognito_tabs)}));
    mTabMenu.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mTabMenu.dismiss();
            if (position == ID_CLOSE_ALL_TABS) {
                mModel.closeAllTabs(false, false);
            }
        }
    });

    int menuWidth = mContext.getResources().getDimensionPixelSize(R.dimen.menu_width);
    mTabMenu.setWidth(menuWidth);
    mTabMenu.setModal(true);

    int screenWidthDp = context.getResources().getConfiguration().screenWidthDp;
    mShouldCascadeTabs = screenWidthDp >= DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP;
    mStripStacker = mShouldCascadeTabs ? mCascadingStripStacker : mScrollingStripStacker;
    mIsFirstLayoutPass = true;
}
 
Example 8
Source File: StripLayoutHelper.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Creates an instance of the {@link StripLayoutHelper}.
 * @param context         The current Android {@link Context}.
 * @param updateHost      The parent {@link LayoutUpdateHost}.
 * @param renderHost      The {@link LayoutRenderHost}.
 * @param incognito       Whether or not this tab strip is incognito.
 */
public StripLayoutHelper(Context context, LayoutUpdateHost updateHost,
        LayoutRenderHost renderHost, boolean incognito) {
    mTabOverlapWidth = TAB_OVERLAP_WIDTH_DP;
    mNewTabButtonWidth = NEW_TAB_BUTTON_WIDTH_DP;

    mRightMargin = LocalizationUtils.isLayoutRtl() ? 0 : mNewTabButtonWidth;
    mLeftMargin = LocalizationUtils.isLayoutRtl() ? mNewTabButtonWidth : 0;
    mMinTabWidth = MIN_TAB_WIDTH_DP;
    mMaxTabWidth = MAX_TAB_WIDTH_DP;
    mReorderMoveStartThreshold = REORDER_MOVE_START_THRESHOLD_DP;
    mUpdateHost = updateHost;
    mRenderHost = renderHost;
    mNewTabButton =
            new CompositorButton(context, NEW_TAB_BUTTON_WIDTH_DP, NEW_TAB_BUTTON_HEIGHT_DP);
    mNewTabButton.setResources(R.drawable.btn_tabstrip_new_tab_normal,
            R.drawable.btn_tabstrip_new_tab_pressed,
            R.drawable.btn_tabstrip_new_incognito_tab_normal,
            R.drawable.btn_tabstrip_new_incognito_tab_pressed);
    mNewTabButton.setIncognito(incognito);
    mNewTabButton.setY(NEW_TAB_BUTTON_Y_OFFSET_DP);
    mNewTabButton.setClickSlop(NEW_TAB_BUTTON_CLICK_SLOP_DP);
    Resources res = context.getResources();
    mNewTabButton.setAccessibilityDescription(
            res.getString(R.string.accessibility_toolbar_btn_new_tab),
            res.getString(R.string.accessibility_toolbar_btn_new_incognito_tab));
    mContext = context;
    mIncognito = incognito;
    mBrightness = 1.f;

    // Create tab menu
    mTabMenu = new ListPopupWindow(mContext);
    mTabMenu.setAdapter(new ArrayAdapter<String>(mContext, R.layout.bookmark_popup_item,
            new String[] {
                    mContext.getString(!mIncognito ? R.string.menu_close_all_tabs
                                                   : R.string.menu_close_all_incognito_tabs)}));
    mTabMenu.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mTabMenu.dismiss();
            if (position == ID_CLOSE_ALL_TABS) {
                mModel.closeAllTabs(false, false);
            }
        }
    });

    int menuWidth = mContext.getResources().getDimensionPixelSize(R.dimen.menu_width);
    mTabMenu.setWidth(menuWidth);
    mTabMenu.setModal(true);

    int screenWidthDp = context.getResources().getConfiguration().screenWidthDp;
    mShouldCascadeTabs = screenWidthDp >= DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP;
    mStripStacker = mShouldCascadeTabs ? mCascadingStripStacker : mScrollingStripStacker;
    mIsFirstLayoutPass = true;
}
 
Example 9
Source File: StripLayoutHelper.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Creates an instance of the {@link StripLayoutHelper}.
 * @param context         The current Android {@link Context}.
 * @param updateHost      The parent {@link LayoutUpdateHost}.
 * @param renderHost      The {@link LayoutRenderHost}.
 * @param incognito       Whether or not this tab strip is incognito.
 */
public StripLayoutHelper(Context context, LayoutUpdateHost updateHost,
        LayoutRenderHost renderHost, boolean incognito) {
    mTabOverlapWidth = TAB_OVERLAP_WIDTH_DP;
    mNewTabButtonWidth = NEW_TAB_BUTTON_WIDTH_DP;

    mRightMargin = LocalizationUtils.isLayoutRtl() ? 0 : mNewTabButtonWidth;
    mLeftMargin = LocalizationUtils.isLayoutRtl() ? mNewTabButtonWidth : 0;
    mMinTabWidth = MIN_TAB_WIDTH_DP;
    mMaxTabWidth = MAX_TAB_WIDTH_DP;
    mReorderMoveStartThreshold = REORDER_MOVE_START_THRESHOLD_DP;
    mUpdateHost = updateHost;
    mRenderHost = renderHost;
    CompositorOnClickHandler newTabClickHandler = new CompositorOnClickHandler() {
        @Override
        public void onClick(long time) {
            handleNewTabClick();
        }
    };
    mNewTabButton = new CompositorButton(
            context, NEW_TAB_BUTTON_WIDTH_DP, NEW_TAB_BUTTON_HEIGHT_DP, newTabClickHandler);
    mNewTabButton.setResources(R.drawable.btn_tabstrip_new_tab_normal,
            R.drawable.btn_tabstrip_new_tab_pressed,
            R.drawable.btn_tabstrip_new_incognito_tab_normal,
            R.drawable.btn_tabstrip_new_incognito_tab_pressed);
    mNewTabButton.setIncognito(incognito);
    mNewTabButton.setY(NEW_TAB_BUTTON_Y_OFFSET_DP);
    mNewTabButton.setClickSlop(NEW_TAB_BUTTON_CLICK_SLOP_DP);
    Resources res = context.getResources();
    mNewTabButton.setAccessibilityDescription(
            res.getString(R.string.accessibility_toolbar_btn_new_tab),
            res.getString(R.string.accessibility_toolbar_btn_new_incognito_tab));
    mContext = context;
    mIncognito = incognito;
    mBrightness = 1.f;

    // Create tab menu
    mTabMenu = new ListPopupWindow(mContext);
    mTabMenu.setAdapter(new ArrayAdapter<String>(mContext, R.layout.bookmark_popup_item,
            new String[] {
                    mContext.getString(!mIncognito ? R.string.menu_close_all_tabs
                                                   : R.string.menu_close_all_incognito_tabs)}));
    mTabMenu.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mTabMenu.dismiss();
            if (position == ID_CLOSE_ALL_TABS) {
                mModel.closeAllTabs(false, false);
            }
        }
    });

    int menuWidth = mContext.getResources().getDimensionPixelSize(R.dimen.menu_width);
    mTabMenu.setWidth(menuWidth);
    mTabMenu.setModal(true);

    int screenWidthDp = context.getResources().getConfiguration().screenWidthDp;
    mShouldCascadeTabs = screenWidthDp >= DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP;
    mStripStacker = mShouldCascadeTabs ? mCascadingStripStacker : mScrollingStripStacker;
    mIsFirstLayoutPass = true;
}