org.chromium.chrome.browser.widget.ControlContainer Java Examples

The following examples show how to use org.chromium.chrome.browser.widget.ControlContainer. 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: ChromeActivity.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the {@link CompositorViewHolder} with the relevant content it needs to properly
 * show content on the screen.
 * @param layoutManager             A {@link LayoutManagerDocument} instance.  This class is
 *                                  responsible for driving all high level screen content and
 *                                  determines which {@link Layout} is shown when.
 * @param urlBar                    The {@link View} representing the URL bar (must be
 *                                  focusable) or {@code null} if none exists.
 * @param contentContainer          A {@link ViewGroup} that can have content attached by
 *                                  {@link Layout}s.
 * @param controlContainer          A {@link ControlContainer} instance to draw.
 */
protected void initializeCompositorContent(
        LayoutManagerDocument layoutManager, View urlBar, ViewGroup contentContainer,
        ControlContainer controlContainer) {
    if (mContextualSearchManager != null) {
        mContextualSearchManager.initialize(contentContainer);
        mContextualSearchManager.setSearchContentViewDelegate(layoutManager);
    }

    layoutManager.addSceneChangeObserver(this);
    mCompositorViewHolder.setLayoutManager(layoutManager);
    mCompositorViewHolder.setFocusable(false);
    mCompositorViewHolder.setControlContainer(controlContainer);
    mCompositorViewHolder.setFullscreenHandler(getFullscreenManager());
    mCompositorViewHolder.setUrlBar(urlBar);
    mCompositorViewHolder.onFinishNativeInitialization(getTabModelSelector(), this,
            getTabContentManager(), contentContainer, mContextualSearchManager,
            mReaderModeManager);

    if (controlContainer != null
            && DeviceClassManager.enableToolbarSwipe()) {
        controlContainer.setSwipeHandler(
                getCompositorViewHolder().getLayoutManager().getTopSwipeHandler());
    }
}
 
Example #2
Source File: ChromeFullscreenManager.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an instance of the fullscreen mode manager.
 * @param activity The activity that supports fullscreen.
 * @param controlContainer Container holding the controls (Toolbar).
 * @param modelSelector The model selector providing access to the current tab.
 * @param resControlContainerHeight The dimension resource ID for the control container height.
 * @param supportsBrowserOverride Whether we want to disable the token system used by the
                                  browser.
 */
public ChromeFullscreenManager(Activity activity, ControlContainer controlContainer,
        TabModelSelector modelSelector, int resControlContainerHeight,
        boolean supportsBrowserOverride) {
    super(activity.getWindow(), modelSelector);

    mActivity = activity;
    ApplicationStatus.registerStateListenerForActivity(this, activity);
    ((BaseChromiumApplication) activity.getApplication())
            .registerWindowFocusChangedListener(this);

    mWindow = activity.getWindow();
    mHandler = new FullscreenHandler(this);
    assert controlContainer != null;
    mControlContainer = controlContainer;
    Resources resources = mWindow.getContext().getResources();
    mControlContainerHeight = resources.getDimensionPixelSize(resControlContainerHeight);
    mRendererContentOffset = mControlContainerHeight;
    mSupportsBrowserOverride = supportsBrowserOverride;
    updateControlOffset();
}
 
Example #3
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the {@link CompositorViewHolder} with the relevant content it needs to properly
 * show content on the screen.
 * @param layoutManager             A {@link LayoutManagerDocument} instance.  This class is
 *                                  responsible for driving all high level screen content and
 *                                  determines which {@link Layout} is shown when.
 * @param urlBar                    The {@link View} representing the URL bar (must be
 *                                  focusable) or {@code null} if none exists.
 * @param contentContainer          A {@link ViewGroup} that can have content attached by
 *                                  {@link Layout}s.
 * @param controlContainer          A {@link ControlContainer} instance to draw.
 */
protected void initializeCompositorContent(
        LayoutManagerDocument layoutManager, View urlBar, ViewGroup contentContainer,
        ControlContainer controlContainer) {
    if (mContextualSearchManager != null) {
        mContextualSearchManager.initialize(contentContainer);
        mContextualSearchManager.setSearchContentViewDelegate(layoutManager);
    }

    layoutManager.addSceneChangeObserver(this);
    mCompositorViewHolder.setLayoutManager(layoutManager);
    mCompositorViewHolder.setFocusable(false);
    mCompositorViewHolder.setControlContainer(controlContainer);
    mCompositorViewHolder.setFullscreenHandler(getFullscreenManager());
    mCompositorViewHolder.setUrlBar(urlBar);
    mCompositorViewHolder.onFinishNativeInitialization(getTabModelSelector(), this,
            getTabContentManager(), contentContainer, mContextualSearchManager,
            mReaderModeManager);

    if (controlContainer != null
            && DeviceClassManager.enableToolbarSwipe()) {
        controlContainer.setSwipeHandler(
                getCompositorViewHolder().getLayoutManager().getTopSwipeHandler());
    }
}
 
Example #4
Source File: FullScreenActivity.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void finishNativeInitialization() {
    mTab = createTab();
    handleTabContentChanged();
    getTabModelSelector().setTab(mTab);
    mTab.show(TabSelectionType.FROM_NEW);

    ControlContainer controlContainer = (ControlContainer) findViewById(R.id.control_container);
    initializeCompositorContent(new LayoutManagerDocument(getCompositorViewHolder()),
            (View) controlContainer, (ViewGroup) findViewById(android.R.id.content),
            controlContainer);

    if (getFullscreenManager() != null) getFullscreenManager().setTab(getActivityTab());
    super.finishNativeInitialization();
}
 
Example #5
Source File: FullScreenActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void finishNativeInitialization() {
    ControlContainer controlContainer = (ControlContainer) findViewById(R.id.control_container);
    initializeCompositorContent(new LayoutManagerDocument(getCompositorViewHolder()),
            (View) controlContainer, (ViewGroup) findViewById(android.R.id.content),
            controlContainer);

    if (getFullscreenManager() != null) getFullscreenManager().setTab(getActivityTab());
    super.finishNativeInitialization();
}
 
Example #6
Source File: CompositorViewHolder.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @param controlContainer The ControlContainer.
 */
public void setControlContainer(ControlContainer controlContainer) {
    DynamicResourceLoader loader = mCompositorView.getResourceManager() != null
            ? mCompositorView.getResourceManager().getDynamicResourceLoader()
            : null;
    if (loader != null && mControlContainer != null) {
        loader.unregisterResource(R.id.control_container);
    }
    mControlContainer = controlContainer;
    if (loader != null && mControlContainer != null) {
        loader.registerResource(
                R.id.control_container, mControlContainer.getToolbarResourceAdapter());
    }
}
 
Example #7
Source File: CompositorViewHolder.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @param controlContainer The ControlContainer.
 */
public void setControlContainer(ControlContainer controlContainer) {
    DynamicResourceLoader loader = mCompositorView.getResourceManager() != null
            ? mCompositorView.getResourceManager().getDynamicResourceLoader()
            : null;
    if (loader != null && mControlContainer != null) {
        loader.unregisterResource(R.id.control_container);
    }
    mControlContainer = controlContainer;
    if (loader != null && mControlContainer != null) {
        loader.registerResource(
                R.id.control_container, mControlContainer.getToolbarResourceAdapter());
    }
}
 
Example #8
Source File: ChromeActivity.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the {@link CompositorViewHolder} with the relevant content it needs to properly
 * show content on the screen.
 * @param layoutManager             A {@link LayoutManagerDocument} instance.  This class is
 *                                  responsible for driving all high level screen content and
 *                                  determines which {@link Layout} is shown when.
 * @param urlBar                    The {@link View} representing the URL bar (must be
 *                                  focusable) or {@code null} if none exists.
 * @param contentContainer          A {@link ViewGroup} that can have content attached by
 *                                  {@link Layout}s.
 * @param controlContainer          A {@link ControlContainer} instance to draw.
 */
protected void initializeCompositorContent(
        LayoutManagerDocument layoutManager, View urlBar, ViewGroup contentContainer,
        ControlContainer controlContainer) {
    if (controlContainer != null) {
        mFullscreenManager = createFullscreenManager(controlContainer);
    }

    if (mContextualSearchManager != null) {
        mContextualSearchManager.initialize(contentContainer);
        mContextualSearchManager.setSearchContentViewDelegate(layoutManager);
    }

    layoutManager.addSceneChangeObserver(this);
    mCompositorViewHolder.setLayoutManager(layoutManager);
    mCompositorViewHolder.setFocusable(false);
    mCompositorViewHolder.setControlContainer(controlContainer);
    mCompositorViewHolder.setFullscreenHandler(mFullscreenManager);
    mCompositorViewHolder.setUrlBar(urlBar);
    mCompositorViewHolder.onFinishNativeInitialization(getTabModelSelector(), this,
            getTabContentManager(), contentContainer, mContextualSearchManager,
            mReaderModeManager);

    if (controlContainer != null
            && DeviceClassManager.enableToolbarSwipe(FeatureUtilities.isDocumentMode(this))) {
        controlContainer.setSwipeHandler(
                getCompositorViewHolder().getLayoutManager().getTopSwipeHandler());
    }
}
 
Example #9
Source File: FullScreenActivity.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void finishNativeInitialization() {
    mTab = createTab();
    getTabModelSelector().setTab(mTab);
    mTab.show(TabSelectionType.FROM_NEW);

    ControlContainer controlContainer = (ControlContainer) findViewById(R.id.control_container);
    initializeCompositorContent(new LayoutManagerDocument(getCompositorViewHolder()),
            (View) controlContainer, (ViewGroup) findViewById(android.R.id.content),
            controlContainer);

    getActivityTab().setFullscreenManager(getFullscreenManager());
    super.finishNativeInitialization();
}
 
Example #10
Source File: CompositorViewHolder.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * @param controlContainer The ControlContainer.
 */
public void setControlContainer(ControlContainer controlContainer) {
    DynamicResourceLoader loader = mCompositorView.getResourceManager() != null
            ? mCompositorView.getResourceManager().getDynamicResourceLoader()
            : null;
    if (loader != null && mControlContainer != null) {
        loader.unregisterResource(R.id.control_container);
    }
    mControlContainer = controlContainer;
    if (loader != null && mControlContainer != null) {
        loader.registerResource(
                R.id.control_container, mControlContainer.getToolbarResourceAdapter());
    }
}
 
Example #11
Source File: ChromeFullscreenManager.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Initializes the fullscreen manager with the required dependencies.
 *
 * @param controlContainer Container holding the controls (Toolbar).
 * @param modelSelector The tab model selector that will be monitored for tab changes.
 * @param resControlContainerHeight The dimension resource ID for the control container height.
 */
public void initialize(ControlContainer controlContainer, TabModelSelector modelSelector,
        int resControlContainerHeight) {
    ApplicationStatus.registerStateListenerForActivity(this, mActivity);
    ((BaseChromiumApplication) mActivity.getApplication())
            .registerWindowFocusChangedListener(this);

    mTabModelSelector = modelSelector;
    mTabModelObserver = new TabModelSelectorTabModelObserver(mTabModelSelector) {
        @Override
        public void tabClosureCommitted(Tab tab) {
            setTab(mTabModelSelector.getCurrentTab());
        }

        @Override
        public void allTabsClosureCommitted() {
            setTab(mTabModelSelector.getCurrentTab());
        }

        @Override
        public void tabRemoved(Tab tab) {
            setTab(mTabModelSelector.getCurrentTab());
        }

        @Override
        public void didSelectTab(Tab tab, TabSelectionType type, int lastId) {
            setTab(mTabModelSelector.getCurrentTab());
        }

        @Override
        public void didCloseTab(int tabId, boolean incognito) {
            setTab(mTabModelSelector.getCurrentTab());
        }
    };

    assert controlContainer != null;
    mControlContainer = controlContainer;
    Resources resources = mWindow.getContext().getResources();

    int controlContainerHeight = resources.getDimensionPixelSize(resControlContainerHeight);
    if (mIsBottomControls) {
        mTopControlContainerHeight = 0;
        mBottomControlContainerHeight = controlContainerHeight;
    } else {
        mTopControlContainerHeight = controlContainerHeight;
        mBottomControlContainerHeight = 0;
    }

    mRendererTopContentOffset = mTopControlContainerHeight;
    updateControlOffset();
}
 
Example #12
Source File: ChromeFullscreenManager.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * @return The toolbar control container.
 */
public ControlContainer getControlContainer() {
    return mControlContainer;
}
 
Example #13
Source File: EmbedContentViewActivity.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
protected final ChromeFullscreenManager createFullscreenManager(
        ControlContainer controlContainer) {
    return null;
}
 
Example #14
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@SuppressLint("NewApi")
@Override
public void postInflationStartup() {
    super.postInflationStartup();

    mSnackbarManager = new SnackbarManager(this);
    mDataUseSnackbarController = new DataUseSnackbarController(this, getSnackbarManager());

    mAssistStatusHandler = createAssistStatusHandler();
    if (mAssistStatusHandler != null) {
        if (mTabModelSelector != null) {
            mAssistStatusHandler.setTabModelSelector(mTabModelSelector);
        }
        mAssistStatusHandler.updateAssistState();
    }

    // If a user had ALLOW_LOW_END_DEVICE_UI explicitly set to false then we manually override
    // SysUtils.isLowEndDevice() with a switch so that they continue to see the normal UI. This
    // is only the case for grandfathered-in svelte users. We no longer do so for newer users.
    if (!ChromePreferenceManager.getInstance(this).getAllowLowEndDeviceUi()) {
        CommandLine.getInstance().appendSwitch(
                BaseSwitches.DISABLE_LOW_END_DEVICE_MODE);
    }

    AccessibilityManager manager = (AccessibilityManager)
            getBaseContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    manager.addAccessibilityStateChangeListener(this);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        mTouchExplorationStateChangeListener = new TouchExplorationStateChangeListener() {
            @Override
            public void onTouchExplorationStateChanged(boolean enabled) {
                checkAccessibility();
            }
        };
        manager.addTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
    }

    // Make the activity listen to policy change events
    CombinedPolicyProvider.get().addPolicyChangeListener(this);

    // Set up the animation placeholder to be the SurfaceView. This disables the
    // SurfaceView's 'hole' clipping during animations that are notified to the window.
    mWindowAndroid.setAnimationPlaceholderView(mCompositorViewHolder.getSurfaceView());

    // Inform the WindowAndroid of the keyboard accessory view.
    mWindowAndroid.setKeyboardAccessoryView((ViewGroup) findViewById(R.id.keyboard_accessory));
    initializeToolbar();
    initializeTabModels();
    if (!isFinishing() && getFullscreenManager() != null) {
        getFullscreenManager().initialize(
                (ControlContainer) findViewById(R.id.control_container),
                getTabModelSelector(),
                getControlContainerHeightResource());
    }
}
 
Example #15
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * This function builds the {@link CompositorViewHolder}.  Subclasses *must* call
 * super.setContentView() before using {@link #getTabModelSelector()} or
 * {@link #getCompositorViewHolder()}.
 */
@Override
protected final void setContentView() {
    final long begin = SystemClock.elapsedRealtime();
    TraceEvent.begin("onCreate->setContentView()");

    enableHardwareAcceleration();
    setLowEndTheme();
    int controlContainerLayoutId = getControlContainerLayoutId();
    WarmupManager warmupManager = WarmupManager.getInstance();
    if (warmupManager.hasViewHierarchyWithToolbar(controlContainerLayoutId)) {
        View placeHolderView = new View(this);
        setContentView(placeHolderView);
        ViewGroup contentParent = (ViewGroup) placeHolderView.getParent();
        warmupManager.transferViewHierarchyTo(contentParent);
        contentParent.removeView(placeHolderView);
    } else {
        warmupManager.clearViewHierarchy();

        // Allow disk access for the content view and toolbar container setup.
        // On certain android devices this setup sequence results in disk writes outside
        // of our control, so we have to disable StrictMode to work. See crbug.com/639352.
        StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
        try {
            setContentView(R.layout.main);
            if (controlContainerLayoutId != NO_CONTROL_CONTAINER) {
                ViewStub toolbarContainerStub =
                        ((ViewStub) findViewById(R.id.control_container_stub));
                toolbarContainerStub.setLayoutResource(controlContainerLayoutId);
                toolbarContainerStub.inflate();
            }

            // It cannot be assumed that the result of toolbarContainerStub.inflate() will be
            // the control container since it may be wrapped in another view.
            ControlContainer controlContainer =
                    (ControlContainer) findViewById(R.id.control_container);

            // Inflate the correct toolbar layout for the device.
            int toolbarLayoutId = getToolbarLayoutId();
            if (toolbarLayoutId != NO_TOOLBAR_LAYOUT && controlContainer != null) {
                controlContainer.initWithToolbar(toolbarLayoutId);
            }
        } finally {
            StrictMode.setThreadPolicy(oldPolicy);
        }
    }
    TraceEvent.end("onCreate->setContentView()");
    mInflateInitialLayoutDurationMs = SystemClock.elapsedRealtime() - begin;

    // Set the status bar color to black by default. This is an optimization for
    // Chrome not to draw under status and navigation bars when we use the default
    // black status bar
    ApiCompatibilityUtils.setStatusBarColor(getWindow(), Color.BLACK);

    ViewGroup rootView = (ViewGroup) getWindow().getDecorView().getRootView();
    mCompositorViewHolder = (CompositorViewHolder) findViewById(R.id.compositor_view_holder);
    mCompositorViewHolder.setRootView(rootView);

    // Setting fitsSystemWindows to false ensures that the root view doesn't consume the insets.
    rootView.setFitsSystemWindows(false);

    // Add a custom view right after the root view that stores the insets to access later.
    // ContentViewCore needs the insets to determine the portion of the screen obscured by
    // non-content displaying things such as the OSK.
    mInsetObserverView = InsetObserverView.create(this);
    rootView.addView(mInsetObserverView, 0);
}
 
Example #16
Source File: WebappActivity.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
protected final ChromeFullscreenManager createFullscreenManager(
        ControlContainer controlContainer) {
    return new ChromeFullscreenManager(this, controlContainer, getTabModelSelector(),
            getControlContainerHeightResource(), false /* supportsBrowserOverride */);
}
 
Example #17
Source File: ChromeFullscreenManager.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Initializes the fullscreen manager with the required dependencies.
 *
 * @param controlContainer Container holding the controls (Toolbar).
 * @param modelSelector The tab model selector that will be monitored for tab changes.
 * @param resControlContainerHeight The dimension resource ID for the control container height.
 */
public void initialize(ControlContainer controlContainer, TabModelSelector modelSelector,
        int resControlContainerHeight) {
    ApplicationStatus.registerStateListenerForActivity(this, mActivity);
    ((BaseChromiumApplication) mActivity.getApplication())
            .registerWindowFocusChangedListener(this);

    mTabModelSelector = modelSelector;
    mTabModelObserver = new TabModelSelectorTabModelObserver(mTabModelSelector) {
        @Override
        public void tabClosureCommitted(Tab tab) {
            setTab(mTabModelSelector.getCurrentTab());
        }

        @Override
        public void allTabsClosureCommitted() {
            setTab(mTabModelSelector.getCurrentTab());
        }

        @Override
        public void tabRemoved(Tab tab) {
            setTab(mTabModelSelector.getCurrentTab());
        }

        @Override
        public void didSelectTab(Tab tab, TabSelectionType type, int lastId) {
            setTab(mTabModelSelector.getCurrentTab());
        }

        @Override
        public void didCloseTab(int tabId, boolean incognito) {
            setTab(mTabModelSelector.getCurrentTab());
        }
    };

    assert controlContainer != null;
    mControlContainer = controlContainer;
    Resources resources = mWindow.getContext().getResources();

    int controlContainerHeight = resources.getDimensionPixelSize(resControlContainerHeight);
    if (mIsBottomControls) {
        mTopControlContainerHeight = 0;
        mBottomControlContainerHeight = controlContainerHeight;
    } else {
        mTopControlContainerHeight = controlContainerHeight;
        mBottomControlContainerHeight = 0;
    }

    mRendererTopContentOffset = mTopControlContainerHeight;
    updateControlOffset();
}
 
Example #18
Source File: ChromeFullscreenManager.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * @return The toolbar control container.
 */
public ControlContainer getControlContainer() {
    return mControlContainer;
}
 
Example #19
Source File: ChromeFullscreenManager.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * @return The toolbar control container.
 */
public ControlContainer getControlContainer() {
    return mControlContainer;
}
 
Example #20
Source File: ChromeActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@SuppressLint("NewApi")
@Override
public void postInflationStartup() {
    super.postInflationStartup();

    mSnackbarManager = new SnackbarManager(this, null);
    mDataUseSnackbarController = new DataUseSnackbarController(this, getSnackbarManager());

    mAssistStatusHandler = createAssistStatusHandler();
    if (mAssistStatusHandler != null) {
        if (mTabModelSelector != null) {
            mAssistStatusHandler.setTabModelSelector(mTabModelSelector);
        }
        mAssistStatusHandler.updateAssistState();
    }

    // If a user had ALLOW_LOW_END_DEVICE_UI explicitly set to false then we manually override
    // SysUtils.isLowEndDevice() with a switch so that they continue to see the normal UI. This
    // is only the case for grandfathered-in svelte users. We no longer do so for newer users.
    if (!ChromePreferenceManager.getInstance().getAllowLowEndDeviceUi()) {
        CommandLine.getInstance().appendSwitch(
                BaseSwitches.DISABLE_LOW_END_DEVICE_MODE);
    }

    AccessibilityManager manager = (AccessibilityManager)
            getBaseContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    manager.addAccessibilityStateChangeListener(this);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        mTouchExplorationStateChangeListener = new TouchExplorationStateChangeListener() {
            @Override
            public void onTouchExplorationStateChanged(boolean enabled) {
                checkAccessibility();
            }
        };
        manager.addTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
    }

    // Make the activity listen to policy change events
    CombinedPolicyProvider.get().addPolicyChangeListener(this);
    mDidAddPolicyChangeListener = true;

    // Set up the animation placeholder to be the SurfaceView. This disables the
    // SurfaceView's 'hole' clipping during animations that are notified to the window.
    getWindowAndroid().setAnimationPlaceholderView(mCompositorViewHolder.getCompositorView());

    // Inform the WindowAndroid of the keyboard accessory view.
    getWindowAndroid().setKeyboardAccessoryView(
            (ViewGroup) findViewById(R.id.keyboard_accessory));
    initializeToolbar();
    initializeTabModels();
    if (!isFinishing() && getFullscreenManager() != null) {
        getFullscreenManager().initialize(
                (ControlContainer) findViewById(R.id.control_container),
                getTabModelSelector(),
                getControlContainerHeightResource());
    }

    if (mBottomSheet != null) {
        mBottomSheet.setTabModelSelector(mTabModelSelector);
        mBottomSheet.setFullscreenManager(mFullscreenManager);

        mFadingBackgroundView = (FadingBackgroundView) findViewById(R.id.fading_focus_target);
        mBottomSheet.addObserver(new EmptyBottomSheetObserver() {
            @Override
            public void onTransitionPeekToHalf(float transitionFraction) {
                mFadingBackgroundView.setViewAlpha(transitionFraction);
            }
        });
        mFadingBackgroundView.addObserver(mBottomSheet);

        mBottomSheetContentController =
                (BottomSheetContentController) ((ViewStub) findViewById(R.id.bottom_nav_stub))
                        .inflate();
        int controlContainerHeight =
                ((ControlContainer) findViewById(R.id.control_container)).getView().getHeight();
        mBottomSheetContentController.init(
                mBottomSheet, controlContainerHeight, mTabModelSelector, this);
    }
    ((BottomContainer) findViewById(R.id.bottom_container)).initialize(mFullscreenManager);
}
 
Example #21
Source File: ChromeActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * This function builds the {@link CompositorViewHolder}.  Subclasses *must* call
 * super.setContentView() before using {@link #getTabModelSelector()} or
 * {@link #getCompositorViewHolder()}.
 */
@Override
protected final void setContentView() {
    final long begin = SystemClock.elapsedRealtime();
    TraceEvent.begin("onCreate->setContentView()");

    enableHardwareAcceleration();
    setLowEndTheme();
    int controlContainerLayoutId = getControlContainerLayoutId();
    WarmupManager warmupManager = WarmupManager.getInstance();
    if (warmupManager.hasViewHierarchyWithToolbar(controlContainerLayoutId)) {
        View placeHolderView = new View(this);
        setContentView(placeHolderView);
        ViewGroup contentParent = (ViewGroup) placeHolderView.getParent();
        warmupManager.transferViewHierarchyTo(contentParent);
        contentParent.removeView(placeHolderView);
    } else {
        warmupManager.clearViewHierarchy();

        // Allow disk access for the content view and toolbar container setup.
        // On certain android devices this setup sequence results in disk writes outside
        // of our control, so we have to disable StrictMode to work. See crbug.com/639352.
        StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
        try {
            setContentView(R.layout.main);
            if (controlContainerLayoutId != NO_CONTROL_CONTAINER) {
                ViewStub toolbarContainerStub =
                        ((ViewStub) findViewById(R.id.control_container_stub));

                toolbarContainerStub.setLayoutResource(controlContainerLayoutId);
                View container = toolbarContainerStub.inflate();
            }

            // It cannot be assumed that the result of toolbarContainerStub.inflate() will be
            // the control container since it may be wrapped in another view.
            ControlContainer controlContainer =
                    (ControlContainer) findViewById(R.id.control_container);

            // Inflate the correct toolbar layout for the device.
            int toolbarLayoutId = getToolbarLayoutId();
            if (toolbarLayoutId != NO_TOOLBAR_LAYOUT && controlContainer != null) {
                controlContainer.initWithToolbar(toolbarLayoutId);
            }

            // Get a handle to the bottom sheet if using the bottom control container.
            if (controlContainerLayoutId == R.layout.bottom_control_container) {
                View coordinator = findViewById(R.id.coordinator);
                mBottomSheet = (BottomSheet) findViewById(R.id.bottom_sheet);
                mBottomSheet.init(coordinator, controlContainer.getView(), this);
            }
        } finally {
            StrictMode.setThreadPolicy(oldPolicy);
        }
    }
    TraceEvent.end("onCreate->setContentView()");
    mInflateInitialLayoutDurationMs = SystemClock.elapsedRealtime() - begin;

    // Set the status bar color to black by default. This is an optimization for
    // Chrome not to draw under status and navigation bars when we use the default
    // black status bar
    setStatusBarColor(null, Color.BLACK);

    ViewGroup rootView = (ViewGroup) getWindow().getDecorView().getRootView();
    mCompositorViewHolder = (CompositorViewHolder) findViewById(R.id.compositor_view_holder);
    mCompositorViewHolder.setRootView(rootView);

    // Setting fitsSystemWindows to false ensures that the root view doesn't consume the insets.
    rootView.setFitsSystemWindows(false);

    // Add a custom view right after the root view that stores the insets to access later.
    // ContentViewCore needs the insets to determine the portion of the screen obscured by
    // non-content displaying things such as the OSK.
    mInsetObserverView = InsetObserverView.create(this);
    rootView.addView(mInsetObserverView, 0);
}
 
Example #22
Source File: ChromeActivity.java    From delion with Apache License 2.0 2 votes vote down vote up
/**
 * Create a full-screen manager to be used by this activity.
 * @param controlContainer The control container that will be controlled by the full-screen
 *                         manager.
 * @return A {@link ChromeFullscreenManager} instance that's been created.
 */
protected ChromeFullscreenManager createFullscreenManager(ControlContainer controlContainer) {
    return new ChromeFullscreenManager(this, controlContainer, getTabModelSelector(),
            getControlContainerHeightResource(), true);
}