org.chromium.chrome.browser.compositor.layouts.components.CompositorButton Java Examples

The following examples show how to use org.chromium.chrome.browser.compositor.layouts.components.CompositorButton. 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: StripLayoutTab.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Create a {@link StripLayoutTab} that represents the {@link Tab} with an id of
 * {@code id}.
 *
 * @param context An Android context for accessing system resources.
 * @param id The id of the {@link Tab} to visually represent.
 * @param loadTrackerCallback The {@link TabLoadTrackerCallback} to be notified of loading state
 *                            changes.
 * @param renderHost The {@link LayoutRenderHost}.
 * @param incogntio Whether or not this layout tab is icognito.
 */
public StripLayoutTab(Context context, int id, TabLoadTrackerCallback loadTrackerCallback,
        LayoutRenderHost renderHost, boolean incognito) {
    mId = id;
    mLoadTracker = new TabLoadTracker(id, loadTrackerCallback);
    mRenderHost = renderHost;
    mIncognito = incognito;
    mCloseButton = new CompositorButton(context, 0, 0);
    mCloseButton.setResources(R.drawable.btn_tab_close_normal, R.drawable.btn_tab_close_pressed,
            R.drawable.btn_tab_close_white_normal, R.drawable.btn_tab_close_white_pressed);
    mCloseButton.setIncognito(mIncognito);
    mCloseButton.setBounds(getCloseRect());
    mCloseButton.setClickSlop(0.f);
    String description =
            context.getResources().getString(R.string.accessibility_tabstrip_btn_close_tab);
    mCloseButton.setAccessibilityDescription(description, description);
}
 
Example #2
Source File: StripLayoutTab.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Create a {@link StripLayoutTab} that represents the {@link Tab} with an id of
 * {@code id}.
 *
 * @param context An Android context for accessing system resources.
 * @param id The id of the {@link Tab} to visually represent.
 * @param delegate The delegate for additional strip tab functionality.
 * @param loadTrackerCallback The {@link TabLoadTrackerCallback} to be notified of loading state
 *                            changes.
 * @param renderHost The {@link LayoutRenderHost}.
 * @param incognito Whether or not this layout tab is incognito.
 */
public StripLayoutTab(Context context, int id, StripLayoutTabDelegate delegate,
        TabLoadTrackerCallback loadTrackerCallback, LayoutRenderHost renderHost,
        boolean incognito) {
    mId = id;
    mDelegate = delegate;
    mLoadTracker = new TabLoadTracker(id, loadTrackerCallback);
    mRenderHost = renderHost;
    mIncognito = incognito;
    CompositorOnClickHandler closeClickAction = new CompositorOnClickHandler() {
        @Override
        public void onClick(long time) {
            mDelegate.handleCloseButtonClick(StripLayoutTab.this, time);
        }
    };
    mCloseButton = new CompositorButton(context, 0, 0, closeClickAction);
    mCloseButton.setResources(R.drawable.btn_tab_close_normal, R.drawable.btn_tab_close_pressed,
            R.drawable.btn_tab_close_white_normal, R.drawable.btn_tab_close_white_pressed);
    mCloseButton.setIncognito(mIncognito);
    mCloseButton.setBounds(getCloseRect());
    mCloseButton.setClickSlop(0.f);
    String description =
            context.getResources().getString(R.string.accessibility_tabstrip_btn_close_tab);
    mCloseButton.setAccessibilityDescription(description, description);
}
 
Example #3
Source File: StripLayoutTab.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Create a {@link StripLayoutTab} that represents the {@link Tab} with an id of
 * {@code id}.
 *
 * @param context An Android context for accessing system resources.
 * @param id The id of the {@link Tab} to visually represent.
 * @param loadTrackerCallback The {@link TabLoadTrackerCallback} to be notified of loading state
 *                            changes.
 * @param renderHost The {@link LayoutRenderHost}.
 * @param incognito Whether or not this layout tab is incognito.
 */
public StripLayoutTab(Context context, int id, TabLoadTrackerCallback loadTrackerCallback,
        LayoutRenderHost renderHost, boolean incognito) {
    mId = id;
    mLoadTracker = new TabLoadTracker(id, loadTrackerCallback);
    mRenderHost = renderHost;
    mIncognito = incognito;
    mCloseButton = new CompositorButton(context, 0, 0);
    mCloseButton.setResources(R.drawable.btn_tab_close_normal, R.drawable.btn_tab_close_pressed,
            R.drawable.btn_tab_close_white_normal, R.drawable.btn_tab_close_white_pressed);
    mCloseButton.setIncognito(mIncognito);
    mCloseButton.setBounds(getCloseRect());
    mCloseButton.setClickSlop(0.f);
    String description =
            context.getResources().getString(R.string.accessibility_tabstrip_btn_close_tab);
    mCloseButton.setAccessibilityDescription(description, description);
}
 
Example #4
Source File: TabStripSceneLayer.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void pushButtonsAndBackground(StripLayoutHelperManager layoutHelper,
        ResourceManager resourceManager, float yOffset) {
    final float width = layoutHelper.getWidth() * mDpToPx;
    final float height = layoutHelper.getHeight() * mDpToPx;
    nativeUpdateTabStripLayer(mNativePtr, width, height, yOffset * mDpToPx,
            layoutHelper.getBackgroundTabBrightness(), layoutHelper.getBrightness(),
            shouldReaddBackground(layoutHelper.getOrientation()));

    CompositorButton newTabButton = layoutHelper.getNewTabButton();
    CompositorButton modelSelectorButton = layoutHelper.getModelSelectorButton();
    boolean newTabButtonVisible = newTabButton.isVisible();
    boolean modelSelectorButtonVisible = modelSelectorButton.isVisible();

    nativeUpdateNewTabButton(mNativePtr, newTabButton.getResourceId(),
            newTabButton.getX() * mDpToPx, newTabButton.getY() * mDpToPx,
            newTabButton.getWidth() * mDpToPx, newTabButton.getHeight() * mDpToPx,
            newTabButtonVisible, resourceManager);

    nativeUpdateModelSelectorButton(mNativePtr, modelSelectorButton.getResourceId(),
            modelSelectorButton.getX() * mDpToPx, modelSelectorButton.getY() * mDpToPx,
            modelSelectorButton.getWidth() * mDpToPx, modelSelectorButton.getHeight() * mDpToPx,
            modelSelectorButton.isIncognito(), modelSelectorButtonVisible, resourceManager);

    int leftFadeDrawable = modelSelectorButtonVisible && LocalizationUtils.isLayoutRtl()
            ? R.drawable.tab_strip_fade_for_model_selector : R.drawable.tab_strip_fade;
    int rightFadeDrawable = modelSelectorButtonVisible && !LocalizationUtils.isLayoutRtl()
            ? R.drawable.tab_strip_fade_for_model_selector : R.drawable.tab_strip_fade;

    nativeUpdateTabStripLeftFade(mNativePtr, leftFadeDrawable,
            layoutHelper.getLeftFadeOpacity(), resourceManager);

    nativeUpdateTabStripRightFade(mNativePtr, rightFadeDrawable,
            layoutHelper.getRightFadeOpacity(), resourceManager);
}
 
Example #5
Source File: StripLayoutHelperManager.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an instance of the {@link StripLayoutHelperManager}.
 * @param context           The current Android {@link Context}.
 * @param updateHost        The parent {@link LayoutUpdateHost}.
 * @param renderHost        The {@link LayoutRenderHost}.
 */
public StripLayoutHelperManager(Context context, LayoutUpdateHost updateHost,
        LayoutRenderHost renderHost, AreaGestureEventFilter eventFilter) {
    mUpdateHost = updateHost;
    mTabStripTreeProvider = new TabStripSceneLayer(context);

    mEventFilter = eventFilter;

    mNormalHelper = new StripLayoutHelper(context, updateHost, renderHost, false);
    mIncognitoHelper = new StripLayoutHelper(context, updateHost, renderHost, true);

    mModelSelectorButton = new CompositorButton(
            context, MODEL_SELECTOR_BUTTON_WIDTH_DP, MODEL_SELECTOR_BUTTON_HEIGHT_DP);
    mModelSelectorButton.setIncognito(false);
    mModelSelectorButton.setVisible(false);
    // Pressed resources are the same as the unpressed resources.
    mModelSelectorButton.setResources(R.drawable.btn_tabstrip_switch_normal,
            R.drawable.btn_tabstrip_switch_normal, R.drawable.btn_tabstrip_switch_incognito,
            R.drawable.btn_tabstrip_switch_incognito);
    mModelSelectorButton.setY(MODEL_SELECTOR_BUTTON_Y_OFFSET_DP);

    Resources res = context.getResources();
    mHeight = res.getDimension(R.dimen.tab_strip_height) / res.getDisplayMetrics().density;
    mModelSelectorButton.setAccessibilityDescription(
            res.getString(R.string.accessibility_tabstrip_btn_incognito_toggle_standard),
            res.getString(R.string.accessibility_tabstrip_btn_incognito_toggle_incognito));

    onContextChanged(context);
}
 
Example #6
Source File: TabStripSceneLayer.java    From delion with Apache License 2.0 5 votes vote down vote up
private void pushButtonsAndBackground(StripLayoutHelperManager layoutHelper,
        ResourceManager resourceManager, float yOffset) {
    final float width = layoutHelper.getWidth() * mDpToPx;
    final float height = layoutHelper.getHeight() * mDpToPx;
    nativeUpdateTabStripLayer(mNativePtr, width, height, yOffset * mDpToPx,
            layoutHelper.getBackgroundTabBrightness(), layoutHelper.getBrightness(),
            shouldReaddBackground(layoutHelper.getOrientation()));

    CompositorButton newTabButton = layoutHelper.getNewTabButton();
    CompositorButton modelSelectorButton = layoutHelper.getModelSelectorButton();
    boolean newTabButtonVisible = newTabButton.isVisible();
    boolean modelSelectorButtonVisible = modelSelectorButton.isVisible();

    nativeUpdateNewTabButton(mNativePtr, newTabButton.getResourceId(),
            newTabButton.getX() * mDpToPx, newTabButton.getY() * mDpToPx,
            newTabButton.getWidth() * mDpToPx, newTabButton.getHeight() * mDpToPx,
            newTabButtonVisible, resourceManager);

    nativeUpdateModelSelectorButton(mNativePtr, modelSelectorButton.getResourceId(),
            modelSelectorButton.getX() * mDpToPx, modelSelectorButton.getY() * mDpToPx,
            modelSelectorButton.getWidth() * mDpToPx, modelSelectorButton.getHeight() * mDpToPx,
            modelSelectorButton.isIncognito(), modelSelectorButtonVisible, resourceManager);

    int leftFadeDrawable = modelSelectorButtonVisible && LocalizationUtils.isLayoutRtl()
            ? R.drawable.tab_strip_fade_for_model_selector : R.drawable.tab_strip_fade;
    int rightFadeDrawable = modelSelectorButtonVisible && !LocalizationUtils.isLayoutRtl()
            ? R.drawable.tab_strip_fade_for_model_selector : R.drawable.tab_strip_fade;

    nativeUpdateTabStripLeftFade(mNativePtr, leftFadeDrawable,
            layoutHelper.getLeftFadeOpacity(), resourceManager);

    nativeUpdateTabStripRightFade(mNativePtr, rightFadeDrawable,
            layoutHelper.getRightFadeOpacity(), resourceManager);
}
 
Example #7
Source File: StripLayoutHelperManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an instance of the {@link StripLayoutHelperManager}.
 * @param context           The current Android {@link Context}.
 * @param updateHost        The parent {@link LayoutUpdateHost}.
 * @param renderHost        The {@link LayoutRenderHost}.
 */
public StripLayoutHelperManager(
        Context context, LayoutUpdateHost updateHost, LayoutRenderHost renderHost) {
    mUpdateHost = updateHost;
    mTabStripTreeProvider = new TabStripSceneLayer(context);
    mTabStripEventHandler = new TabStripEventHandler();
    mEventFilter =
            new AreaGestureEventFilter(context, mTabStripEventHandler, null, false, false);

    mNormalHelper = new StripLayoutHelper(context, updateHost, renderHost, false);
    mIncognitoHelper = new StripLayoutHelper(context, updateHost, renderHost, true);

    CompositorOnClickHandler selectorClickHandler = new CompositorOnClickHandler() {
        @Override
        public void onClick(long time) {
            handleModelSelectorButtonClick();
        }
    };
    mModelSelectorButton = new CompositorButton(context, MODEL_SELECTOR_BUTTON_WIDTH_DP,
            MODEL_SELECTOR_BUTTON_HEIGHT_DP, selectorClickHandler);
    mModelSelectorButton.setIncognito(false);
    mModelSelectorButton.setVisible(false);
    // Pressed resources are the same as the unpressed resources.
    mModelSelectorButton.setResources(R.drawable.btn_tabstrip_switch_normal,
            R.drawable.btn_tabstrip_switch_normal, R.drawable.btn_tabstrip_switch_incognito,
            R.drawable.btn_tabstrip_switch_incognito);
    mModelSelectorButton.setY(MODEL_SELECTOR_BUTTON_Y_OFFSET_DP);

    Resources res = context.getResources();
    mHeight = res.getDimension(R.dimen.tab_strip_height) / res.getDisplayMetrics().density;
    mModelSelectorButton.setAccessibilityDescription(
            res.getString(R.string.accessibility_tabstrip_btn_incognito_toggle_standard),
            res.getString(R.string.accessibility_tabstrip_btn_incognito_toggle_incognito));

    onContextChanged(context);
}
 
Example #8
Source File: StripLayoutHelperManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an instance of the {@link StripLayoutHelperManager}.
 * @param context           The current Android {@link Context}.
 * @param updateHost        The parent {@link LayoutUpdateHost}.
 * @param renderHost        The {@link LayoutRenderHost}.
 */
public StripLayoutHelperManager(Context context, LayoutUpdateHost updateHost,
        LayoutRenderHost renderHost, AreaGestureEventFilter eventFilter) {
    mUpdateHost = updateHost;
    mTabStripTreeProvider = new TabStripSceneLayer(context);

    mEventFilter = eventFilter;

    mNormalHelper = new StripLayoutHelper(context, updateHost, renderHost, false);
    mIncognitoHelper = new StripLayoutHelper(context, updateHost, renderHost, true);

    mModelSelectorButton = new CompositorButton(
            context, MODEL_SELECTOR_BUTTON_WIDTH_DP, MODEL_SELECTOR_BUTTON_HEIGHT_DP);
    mModelSelectorButton.setIncognito(false);
    mModelSelectorButton.setVisible(false);
    // Pressed resources are the same as the unpressed resources.
    mModelSelectorButton.setResources(R.drawable.btn_tabstrip_switch_normal,
            R.drawable.btn_tabstrip_switch_normal, R.drawable.btn_tabstrip_switch_incognito,
            R.drawable.btn_tabstrip_switch_incognito);
    mModelSelectorButton.setY(MODEL_SELECTOR_BUTTON_Y_OFFSET_DP);

    Resources res = context.getResources();
    mHeight = res.getDimension(R.dimen.tab_strip_height) / res.getDisplayMetrics().density;
    mModelSelectorButton.setAccessibilityDescription(
            res.getString(R.string.accessibility_tabstrip_btn_incognito_toggle_standard),
            res.getString(R.string.accessibility_tabstrip_btn_incognito_toggle_incognito));

    onContextChanged(context);
}
 
Example #9
Source File: TabStripSceneLayer.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void pushButtonsAndBackground(StripLayoutHelperManager layoutHelper,
        ResourceManager resourceManager, float yOffset) {
    final float width = layoutHelper.getWidth() * mDpToPx;
    final float height = layoutHelper.getHeight() * mDpToPx;
    nativeUpdateTabStripLayer(mNativePtr, width, height, yOffset * mDpToPx,
            layoutHelper.getBackgroundTabBrightness(), layoutHelper.getBrightness(),
            shouldReaddBackground(layoutHelper.getOrientation()));

    CompositorButton newTabButton = layoutHelper.getNewTabButton();
    CompositorButton modelSelectorButton = layoutHelper.getModelSelectorButton();
    boolean newTabButtonVisible = newTabButton.isVisible();
    boolean modelSelectorButtonVisible = modelSelectorButton.isVisible();

    nativeUpdateNewTabButton(mNativePtr, newTabButton.getResourceId(),
            newTabButton.getX() * mDpToPx, newTabButton.getY() * mDpToPx,
            newTabButton.getWidth() * mDpToPx, newTabButton.getHeight() * mDpToPx,
            newTabButtonVisible, resourceManager);

    nativeUpdateModelSelectorButton(mNativePtr, modelSelectorButton.getResourceId(),
            modelSelectorButton.getX() * mDpToPx, modelSelectorButton.getY() * mDpToPx,
            modelSelectorButton.getWidth() * mDpToPx, modelSelectorButton.getHeight() * mDpToPx,
            modelSelectorButton.isIncognito(), modelSelectorButtonVisible, resourceManager);

    int leftFadeDrawable = modelSelectorButtonVisible && LocalizationUtils.isLayoutRtl()
            ? R.drawable.tab_strip_fade_for_model_selector : R.drawable.tab_strip_fade;
    int rightFadeDrawable = modelSelectorButtonVisible && !LocalizationUtils.isLayoutRtl()
            ? R.drawable.tab_strip_fade_for_model_selector : R.drawable.tab_strip_fade;

    nativeUpdateTabStripLeftFade(mNativePtr, leftFadeDrawable,
            layoutHelper.getLeftFadeOpacity(), resourceManager);

    nativeUpdateTabStripRightFade(mNativePtr, rightFadeDrawable,
            layoutHelper.getRightFadeOpacity(), resourceManager);
}
 
Example #10
Source File: StripLayoutHelperManager.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
public CompositorButton getModelSelectorButton() {
    return mModelSelectorButton;
}
 
Example #11
Source File: StripLayoutTab.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private Animation<Animatable<?>> buildCloseButtonOpacityAnimation(float finalOpacity) {
    return createAnimation(mCloseButton, CompositorButton.Property.OPACITY,
            mCloseButton.getOpacity(), finalOpacity, ANIM_TAB_CLOSE_BUTTON_FADE_MS, 0, false,
            ChromeAnimation.getLinearInterpolator());
}
 
Example #12
Source File: StripLayoutTab.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * @return The close button for this tab.
 */
public CompositorButton getCloseButton() {
    return mCloseButton;
}
 
Example #13
Source File: StripLayoutHelperManager.java    From 365browser with Apache License 2.0 4 votes vote down vote up
public CompositorButton getModelSelectorButton() {
    return mModelSelectorButton;
}
 
Example #14
Source File: StripLayoutHelperManager.java    From 365browser with Apache License 2.0 4 votes vote down vote up
public CompositorButton getNewTabButton() {
    return getActiveStripLayoutHelper().getNewTabButton();
}
 
Example #15
Source File: StripLayoutHelper.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * @return A {@link CompositorButton} that represents the positioning of the new tab button.
 */
public CompositorButton getNewTabButton() {
    return mNewTabButton;
}
 
Example #16
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;
}
 
Example #17
Source File: StripLayoutTab.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private Animation<Animatable<?>> buildCloseButtonOpacityAnimation(float finalOpacity) {
    return createAnimation(mCloseButton, CompositorButton.Property.OPACITY,
            mCloseButton.getOpacity(), finalOpacity, ANIM_TAB_CLOSE_BUTTON_FADE_MS, 0, false,
            ChromeAnimation.getLinearInterpolator());
}
 
Example #18
Source File: StripLayoutTab.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * @return The close button for this tab.
 */
public CompositorButton getCloseButton() {
    return mCloseButton;
}
 
Example #19
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 #20
Source File: StripLayoutHelperManager.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
public CompositorButton getNewTabButton() {
    return getActiveStripLayoutHelper().getNewTabButton();
}
 
Example #21
Source File: StripLayoutHelper.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * @return A {@link CompositorButton} that represents the positioning of the new tab button.
 */
public CompositorButton getNewTabButton() {
    return mNewTabButton;
}
 
Example #22
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 #23
Source File: StripLayoutTab.java    From delion with Apache License 2.0 4 votes vote down vote up
private Animation<Animatable<?>> buildCloseButtonOpacityAnimation(float finalOpacity) {
    return createAnimation(mCloseButton, CompositorButton.Property.OPACITY,
            mCloseButton.getOpacity(), finalOpacity, ANIM_TAB_CLOSE_BUTTON_FADE_MS, 0, false,
            ChromeAnimation.getLinearInterpolator());
}
 
Example #24
Source File: StripLayoutTab.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * @return The close button for this tab.
 */
public CompositorButton getCloseButton() {
    return mCloseButton;
}
 
Example #25
Source File: StripLayoutHelperManager.java    From delion with Apache License 2.0 4 votes vote down vote up
public CompositorButton getModelSelectorButton() {
    return mModelSelectorButton;
}
 
Example #26
Source File: StripLayoutHelperManager.java    From delion with Apache License 2.0 4 votes vote down vote up
public CompositorButton getNewTabButton() {
    return getActiveStripLayoutHelper().getNewTabButton();
}
 
Example #27
Source File: StripLayoutHelper.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * @return A {@link CompositorButton} that represents the positioning of the new tab button.
 */
public CompositorButton getNewTabButton() {
    return mNewTabButton;
}