| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.widget.bottomsheet; | 5 package org.chromium.chrome.browser.widget.bottomsheet; |
| 6 | 6 |
| 7 import android.animation.Animator; | 7 import android.animation.Animator; |
| 8 import android.animation.AnimatorListenerAdapter; | 8 import android.animation.AnimatorListenerAdapter; |
| 9 import android.animation.AnimatorSet; | 9 import android.animation.AnimatorSet; |
| 10 import android.animation.ObjectAnimator; | 10 import android.animation.ObjectAnimator; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 import org.chromium.chrome.browser.TabLoadStatus; | 36 import org.chromium.chrome.browser.TabLoadStatus; |
| 37 import org.chromium.chrome.browser.firstrun.FirstRunStatus; | 37 import org.chromium.chrome.browser.firstrun.FirstRunStatus; |
| 38 import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager; | 38 import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager; |
| 39 import org.chromium.chrome.browser.ntp.NativePageFactory; | 39 import org.chromium.chrome.browser.ntp.NativePageFactory; |
| 40 import org.chromium.chrome.browser.ntp.NewTabPage; | 40 import org.chromium.chrome.browser.ntp.NewTabPage; |
| 41 import org.chromium.chrome.browser.tab.Tab; | 41 import org.chromium.chrome.browser.tab.Tab; |
| 42 import org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver; | 42 import org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver; |
| 43 import org.chromium.chrome.browser.tabmodel.TabModel; | 43 import org.chromium.chrome.browser.tabmodel.TabModel; |
| 44 import org.chromium.chrome.browser.tabmodel.TabModelSelector; | 44 import org.chromium.chrome.browser.tabmodel.TabModelSelector; |
| 45 import org.chromium.chrome.browser.toolbar.BottomToolbarPhone; | 45 import org.chromium.chrome.browser.toolbar.BottomToolbarPhone; |
| 46 import org.chromium.chrome.browser.util.FeatureUtilities; |
| 46 import org.chromium.chrome.browser.util.MathUtils; | 47 import org.chromium.chrome.browser.util.MathUtils; |
| 47 import org.chromium.chrome.browser.widget.FadingBackgroundView; | 48 import org.chromium.chrome.browser.widget.FadingBackgroundView; |
| 48 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetContentControll
er.ContentType; | 49 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetContentControll
er.ContentType; |
| 49 import org.chromium.chrome.browser.widget.textbubble.ViewAnchoredTextBubble; | 50 import org.chromium.chrome.browser.widget.textbubble.ViewAnchoredTextBubble; |
| 50 import org.chromium.content_public.browser.LoadUrlParams; | 51 import org.chromium.content_public.browser.LoadUrlParams; |
| 51 | 52 |
| 52 import java.lang.annotation.Retention; | 53 import java.lang.annotation.Retention; |
| 53 import java.lang.annotation.RetentionPolicy; | 54 import java.lang.annotation.RetentionPolicy; |
| 54 import java.util.ArrayList; | 55 import java.util.ArrayList; |
| 55 import java.util.List; | 56 import java.util.List; |
| (...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 | 1137 |
| 1137 /** | 1138 /** |
| 1138 * Checks whether the sheet can be moved. It cannot be moved when the activi
ty is in overview | 1139 * Checks whether the sheet can be moved. It cannot be moved when the activi
ty is in overview |
| 1139 * mode, when "find in page" is visible, or when the toolbar is hidden. | 1140 * mode, when "find in page" is visible, or when the toolbar is hidden. |
| 1140 */ | 1141 */ |
| 1141 private boolean canMoveSheet() { | 1142 private boolean canMoveSheet() { |
| 1142 boolean isInOverviewMode = mTabModelSelector != null | 1143 boolean isInOverviewMode = mTabModelSelector != null |
| 1143 && (mTabModelSelector.getCurrentTab() == null | 1144 && (mTabModelSelector.getCurrentTab() == null |
| 1144 || mTabModelSelector.getCurrentTab().getActivity().is
InOverviewMode()); | 1145 || mTabModelSelector.getCurrentTab().getActivity().is
InOverviewMode()); |
| 1145 | 1146 |
| 1147 // If the expand button is enabled, do not allow swiping when the sheet
is in the peeking |
| 1148 // position. |
| 1149 boolean blockPeekingSwipes = FeatureUtilities.isChromeHomeExpandButtonEn
abled() |
| 1150 && getSheetState() == SHEET_STATE_PEEK; |
| 1151 |
| 1146 if (mFindInPageView == null) mFindInPageView = findViewById(R.id.find_to
olbar); | 1152 if (mFindInPageView == null) mFindInPageView = findViewById(R.id.find_to
olbar); |
| 1147 boolean isFindInPageVisible = | 1153 boolean isFindInPageVisible = |
| 1148 mFindInPageView != null && mFindInPageView.getVisibility() == Vi
ew.VISIBLE; | 1154 mFindInPageView != null && mFindInPageView.getVisibility() == Vi
ew.VISIBLE; |
| 1149 return !isToolbarAndroidViewHidden() && !isInOverviewMode && !isFindInPa
geVisible; | 1155 return !isToolbarAndroidViewHidden() && !isInOverviewMode && !isFindInPa
geVisible |
| 1156 && !blockPeekingSwipes; |
| 1150 } | 1157 } |
| 1151 | 1158 |
| 1152 private void showHelpBubbleIfNecessary() { | 1159 private void showHelpBubbleIfNecessary() { |
| 1153 // The help bubble should only be shown after layout has occurred so tha
t the anchor view is | 1160 // The help bubble should only be shown after layout has occurred so tha
t the anchor view is |
| 1154 // in the correct position on the screen. It also must be shown after th
e tab state has been | 1161 // in the correct position on the screen. It also must be shown after th
e tab state has been |
| 1155 // initialized so that any tab that auto-opens the BottomSheet has had a
chance to do so. | 1162 // initialized so that any tab that auto-opens the BottomSheet has had a
chance to do so. |
| 1156 assert mHasRootLayoutOccurred && mTabModelSelector != null | 1163 assert mHasRootLayoutOccurred && mTabModelSelector != null |
| 1157 && mTabModelSelector.isTabStateInitialized(); | 1164 && mTabModelSelector.isTabStateInitialized(); |
| 1158 | 1165 |
| 1159 // If FRE is not complete, the FRE screen is likely covering ChromeTabbe
dActivity so the | 1166 // If FRE is not complete, the FRE screen is likely covering ChromeTabbe
dActivity so the |
| 1160 // help bubble should not be shown. Also skip showing if the bottom shee
t is already open. | 1167 // help bubble should not be shown. Also skip showing if the bottom shee
t is already open. |
| 1161 if (!FirstRunStatus.getFirstRunFlowComplete() || mCurrentState != SHEET_
STATE_PEEK) return; | 1168 if (!FirstRunStatus.getFirstRunFlowComplete() || mCurrentState != SHEET_
STATE_PEEK) return; |
| 1162 | 1169 |
| 1163 SharedPreferences preferences = ContextUtils.getAppSharedPreferences(); | 1170 SharedPreferences preferences = ContextUtils.getAppSharedPreferences(); |
| 1164 if (preferences.getBoolean(BOTTOM_SHEET_HELP_BUBBLE_SHOWN, false)) retur
n; | 1171 if (preferences.getBoolean(BOTTOM_SHEET_HELP_BUBBLE_SHOWN, false)) retur
n; |
| 1165 | 1172 |
| 1166 ViewAnchoredTextBubble helpBubble = new ViewAnchoredTextBubble( | 1173 ViewAnchoredTextBubble helpBubble = new ViewAnchoredTextBubble( |
| 1167 getContext(), mControlContainer, R.string.bottom_sheet_help_bubb
le_message); | 1174 getContext(), mControlContainer, R.string.bottom_sheet_help_bubb
le_message); |
| 1168 int inset = getContext().getResources().getDimensionPixelSize( | 1175 int inset = getContext().getResources().getDimensionPixelSize( |
| 1169 R.dimen.bottom_sheet_help_bubble_inset); | 1176 R.dimen.bottom_sheet_help_bubble_inset); |
| 1170 helpBubble.setInsetPx(0, inset, 0, inset); | 1177 helpBubble.setInsetPx(0, inset, 0, inset); |
| 1171 helpBubble.setDismissOnTouchInteraction(true); | 1178 helpBubble.setDismissOnTouchInteraction(true); |
| 1172 helpBubble.show(); | 1179 helpBubble.show(); |
| 1173 | 1180 |
| 1174 preferences.edit().putBoolean(BOTTOM_SHEET_HELP_BUBBLE_SHOWN, true).appl
y(); | 1181 preferences.edit().putBoolean(BOTTOM_SHEET_HELP_BUBBLE_SHOWN, true).appl
y(); |
| 1175 } | 1182 } |
| 1176 } | 1183 } |
| OLD | NEW |