Commit 126e07f1 authored by Pedro Amaral's avatar Pedro Amaral Committed by Commit Bot

Moved TouchRestrictingFrameLayout class to its own file.


Bug: 814528
Change-Id: Id48a4a0d90579c68961752747c252338ff6c73c7
Reviewed-on: https://chromium-review.googlesource.com/967246
Commit-Queue: Pedro Amaral <amaralp@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544180}
parent fff09083
......@@ -10,7 +10,7 @@
android:layout_height="wrap_content" >
<view
class="org.chromium.chrome.browser.widget.bottomsheet.BottomSheet$TouchRestrictingFrameLayout"
class="org.chromium.chrome.browser.widget.bottomsheet.TouchRestrictingFrameLayout"
android:id="@+id/bottom_sheet_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
......@@ -39,7 +39,7 @@
android:contentDescription="@null" />
<view
class="org.chromium.chrome.browser.widget.bottomsheet.BottomSheet$TouchRestrictingFrameLayout"
class="org.chromium.chrome.browser.widget.bottomsheet.TouchRestrictingFrameLayout"
android:id="@+id/toolbar_holder"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_control_container_height"
......
......@@ -9,8 +9,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<view
class="org.chromium.chrome.browser.widget.bottomsheet.BottomSheet$TouchRestrictingFrameLayout"
<org.chromium.chrome.browser.widget.bottomsheet.TouchRestrictingFrameLayout
android:id="@+id/bottom_sheet_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
......@@ -33,7 +32,7 @@
android:contentDescription="@null" />
<view
class="org.chromium.chrome.browser.widget.bottomsheet.BottomSheet$TouchRestrictingFrameLayout"
class="org.chromium.chrome.browser.widget.bottomsheet.TouchRestrictingFrameLayout"
android:id="@+id/bottom_sheet_toolbar_container"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_control_container_height"
......
......@@ -102,46 +102,6 @@ public class BottomSheet
int NAVIGATION = 8;
}
/**
* A specialized FrameLayout that is capable of ignoring all user input based on the state of
* the bottom sheet.
*/
public static class TouchRestrictingFrameLayout extends FrameLayout {
/** A handle to the bottom sheet. */
private BottomSheet mBottomSheet;
public TouchRestrictingFrameLayout(Context context, AttributeSet atts) {
super(context, atts);
}
/**
* @param sheet The bottom sheet.
*/
public void setBottomSheet(BottomSheet sheet) {
mBottomSheet = sheet;
}
/**
* @return Whether touch is enabled.
*/
private boolean isTouchDisabled() {
return mBottomSheet == null || mBottomSheet.isRunningContentSwapAnimation()
|| mBottomSheet.getSheetState() == BottomSheet.SHEET_STATE_SCROLLING;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
if (isTouchDisabled()) return false;
return super.onInterceptTouchEvent(event);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (isTouchDisabled()) return false;
return super.onTouchEvent(event);
}
}
/**
* The base duration of the settling animation of the sheet. 218 ms is a spec for material
* design (this is the minimum time a user is guaranteed to pay attention to something).
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.widget.bottomsheet;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.FrameLayout;
/**
* A specialized FrameLayout that is capable of ignoring all user input based on the state of
* the bottom sheet.
*/
public class TouchRestrictingFrameLayout extends FrameLayout {
/** A handle to the bottom sheet. */
private BottomSheet mBottomSheet;
public TouchRestrictingFrameLayout(Context context, AttributeSet atts) {
super(context, atts);
}
/**
* @param sheet The bottom sheet.
*/
public void setBottomSheet(BottomSheet sheet) {
mBottomSheet = sheet;
}
/**
* @return Whether touch is enabled.
*/
private boolean isTouchDisabled() {
return mBottomSheet == null || mBottomSheet.isRunningContentSwapAnimation()
|| mBottomSheet.getSheetState() == BottomSheet.SHEET_STATE_SCROLLING;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
if (isTouchDisabled()) return false;
return super.onInterceptTouchEvent(event);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (isTouchDisabled()) return false;
return super.onTouchEvent(event);
}
}
......@@ -1416,6 +1416,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetObserver.java",
"java/src/org/chromium/chrome/browser/widget/bottomsheet/ChromeHomeIphMenuHeader.java",
"java/src/org/chromium/chrome/browser/widget/bottomsheet/EmptyBottomSheetObserver.java",
"java/src/org/chromium/chrome/browser/widget/bottomsheet/TouchRestrictingFrameLayout.java",
"java/src/org/chromium/chrome/browser/widget/displaystyle/MarginResizer.java",
"java/src/org/chromium/chrome/browser/widget/displaystyle/DisplayStyleObserver.java",
"java/src/org/chromium/chrome/browser/widget/displaystyle/DisplayStyleObserverAdapter.java",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment