OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.fullscreen; | 5 package org.chromium.chrome.browser.fullscreen; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.content.res.Resources; | 8 import android.content.res.Resources; |
9 import android.view.Gravity; | 9 import android.view.Gravity; |
10 import android.view.MotionEvent; | 10 import android.view.MotionEvent; |
11 import android.view.View; | 11 import android.view.View; |
12 import android.view.ViewGroup; | 12 import android.view.ViewGroup; |
13 import android.view.ViewGroup.LayoutParams; | 13 import android.view.ViewGroup.LayoutParams; |
14 import android.view.Window; | 14 import android.view.Window; |
15 import android.widget.FrameLayout; | 15 import android.widget.FrameLayout; |
16 | 16 |
17 import org.chromium.base.ActivityState; | 17 import org.chromium.base.ActivityState; |
18 import org.chromium.base.ApplicationStatus; | 18 import org.chromium.base.ApplicationStatus; |
19 import org.chromium.base.ApplicationStatus.ActivityStateListener; | 19 import org.chromium.base.ApplicationStatus.ActivityStateListener; |
20 import org.chromium.base.BaseChromiumApplication; | 20 import org.chromium.base.BaseChromiumApplication; |
21 import org.chromium.base.BaseChromiumApplication.WindowFocusChangedListener; | 21 import org.chromium.base.BaseChromiumApplication.WindowFocusChangedListener; |
22 import org.chromium.base.ThreadUtils; | 22 import org.chromium.base.ThreadUtils; |
23 import org.chromium.base.TraceEvent; | 23 import org.chromium.base.TraceEvent; |
24 import org.chromium.base.library_loader.LibraryLoader; | 24 import org.chromium.base.library_loader.LibraryLoader; |
25 import org.chromium.chrome.browser.fullscreen.FullscreenHtmlApiHandler.Fullscree
nHtmlApiDelegate; | 25 import org.chromium.chrome.browser.fullscreen.FullscreenHtmlApiHandler.Fullscree
nHtmlApiDelegate; |
26 import org.chromium.chrome.browser.tab.Tab; | 26 import org.chromium.chrome.browser.tab.Tab; |
27 import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType; | 27 import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType; |
28 import org.chromium.chrome.browser.tabmodel.TabModelSelector; | 28 import org.chromium.chrome.browser.tabmodel.TabModelSelector; |
29 import org.chromium.chrome.browser.tabmodel.TabModelSelectorTabModelObserver; | 29 import org.chromium.chrome.browser.tabmodel.TabModelSelectorTabModelObserver; |
30 import org.chromium.chrome.browser.util.ViewUtils; | |
31 import org.chromium.chrome.browser.widget.ControlContainer; | 30 import org.chromium.chrome.browser.widget.ControlContainer; |
32 import org.chromium.content.browser.ContentVideoView; | 31 import org.chromium.content.browser.ContentVideoView; |
33 import org.chromium.content.browser.ContentViewCore; | 32 import org.chromium.content.browser.ContentViewCore; |
34 import org.chromium.content_public.common.BrowserControlsState; | 33 import org.chromium.content_public.common.BrowserControlsState; |
35 | 34 |
36 import java.util.ArrayList; | 35 import java.util.ArrayList; |
37 | 36 |
38 /** | 37 /** |
39 * A class that manages control and content views to create the fullscreen mode. | 38 * A class that manages control and content views to create the fullscreen mode. |
40 */ | 39 */ |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 mRendererTopControlOffset = rendererTopControlOffset; | 588 mRendererTopControlOffset = rendererTopControlOffset; |
590 mRendererBottomControlOffset = rendererBottomControlOffset; | 589 mRendererBottomControlOffset = rendererBottomControlOffset; |
591 | 590 |
592 mRendererTopContentOffset = rendererTopContentOffset; | 591 mRendererTopContentOffset = rendererTopContentOffset; |
593 updateControlOffset(); | 592 updateControlOffset(); |
594 | 593 |
595 updateVisuals(); | 594 updateVisuals(); |
596 } | 595 } |
597 | 596 |
598 /** | 597 /** |
599 * @param e The dispatched motion event | |
600 * @return Whether or not this motion event is in the top control container
area and should be | |
601 * consumed. | |
602 */ | |
603 public boolean onInterceptMotionEvent(MotionEvent e) { | |
604 int bottomPosition; | |
605 int topPosition = 0; | |
606 float offset; | |
607 | |
608 if (mIsBottomControls) { | |
609 int[] position = new int[2]; | |
610 ViewUtils.getRelativeLayoutPosition(mControlContainer.getView().getR
ootView(), | |
611 mControlContainer.getView(), position); | |
612 | |
613 topPosition = position[1]; | |
614 bottomPosition = topPosition + getBottomControlsHeight(); | |
615 offset = getBottomControlOffset(); | |
616 } else { | |
617 bottomPosition = getTopControlsHeight(); | |
618 offset = getTopControlOffset(); | |
619 } | |
620 | |
621 return e.getY() < topPosition + offset && e.getY() > bottomPosition + of
fset | |
622 && !mBrowserControlsAndroidViewHidden; | |
623 } | |
624 | |
625 /** | |
626 * Notifies the fullscreen manager that a motion event has occurred. | 598 * Notifies the fullscreen manager that a motion event has occurred. |
627 * @param e The dispatched motion event. | 599 * @param e The dispatched motion event. |
628 */ | 600 */ |
629 public void onMotionEvent(MotionEvent e) { | 601 public void onMotionEvent(MotionEvent e) { |
630 int eventAction = e.getActionMasked(); | 602 int eventAction = e.getActionMasked(); |
631 if (eventAction == MotionEvent.ACTION_DOWN | 603 if (eventAction == MotionEvent.ACTION_DOWN |
632 || eventAction == MotionEvent.ACTION_POINTER_DOWN) { | 604 || eventAction == MotionEvent.ACTION_POINTER_DOWN) { |
633 mInGesture = true; | 605 mInGesture = true; |
634 // TODO(qinmin): Probably there is no need to hide the toast as it w
ill go away | 606 // TODO(qinmin): Probably there is no need to hide the toast as it w
ill go away |
635 // by itself. | 607 // by itself. |
636 getHtmlApiHandler().hideNotificationToast(); | 608 getHtmlApiHandler().hideNotificationToast(); |
637 } else if (eventAction == MotionEvent.ACTION_CANCEL | 609 } else if (eventAction == MotionEvent.ACTION_CANCEL |
638 || eventAction == MotionEvent.ACTION_UP) { | 610 || eventAction == MotionEvent.ACTION_UP) { |
639 mInGesture = false; | 611 mInGesture = false; |
640 updateVisuals(); | 612 updateVisuals(); |
641 } | 613 } |
642 } | 614 } |
643 | 615 |
644 @Override | 616 @Override |
645 public void onContentViewScrollingStateChanged(boolean scrolling) { | 617 public void onContentViewScrollingStateChanged(boolean scrolling) { |
646 mContentViewScrolling = scrolling; | 618 mContentViewScrolling = scrolling; |
647 if (!scrolling) updateVisuals(); | 619 if (!scrolling) updateVisuals(); |
648 } | 620 } |
649 } | 621 } |
OLD | NEW |