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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 | 344 |
345 if (!wasOpenBeforeSwipe && mIsSheetOpen) { | 345 if (!wasOpenBeforeSwipe && mIsSheetOpen) { |
346 mMetrics.recordSheetOpenReason(BottomSheetMetrics.OPENED_BY_SWIP E); | 346 mMetrics.recordSheetOpenReason(BottomSheetMetrics.OPENED_BY_SWIP E); |
347 } | 347 } |
348 | 348 |
349 return true; | 349 return true; |
350 } | 350 } |
351 } | 351 } |
352 | 352 |
353 /** | 353 /** |
354 * Returns whether the provided bottom sheet state is in one of the stable o pen or closed | |
355 * states: {@link #SHEET_STATE_FULL}, {@link #SHEET_STATE_PEEK} or {@link #S HEET_STATE_HALF} | |
356 * @param sheetState A {@link SheetState} to test. | |
357 */ | |
358 public static boolean isStateStable(@SheetState int sheetState) { | |
359 switch (sheetState) { | |
360 case SHEET_STATE_PEEK: | |
361 case SHEET_STATE_HALF: | |
362 case SHEET_STATE_FULL: | |
363 return true; | |
364 case SHEET_STATE_NONE: | |
365 assert false; // Should never be tested, internal only value. | |
mdjones
2017/05/09 17:20:15
nit: make "assert false;" the default. This is wha
dgn
2017/05/11 17:23:06
Done.
| |
366 case SHEET_STATE_SCROLLING: | |
367 default: | |
368 return false; | |
369 } | |
370 } | |
371 | |
372 /** | |
354 * Constructor for inflation from XML. | 373 * Constructor for inflation from XML. |
355 * @param context An Android context. | 374 * @param context An Android context. |
356 * @param atts The XML attributes. | 375 * @param atts The XML attributes. |
357 */ | 376 */ |
358 public BottomSheet(Context context, AttributeSet atts) { | 377 public BottomSheet(Context context, AttributeSet atts) { |
359 super(context, atts); | 378 super(context, atts); |
360 | 379 |
361 mFullHeightDistanceFromTop = | 380 mFullHeightDistanceFromTop = |
362 getResources().getDimensionPixelSize(R.dimen.chrome_home_full_he ight_from_top); | 381 getResources().getDimensionPixelSize(R.dimen.chrome_home_full_he ight_from_top); |
363 | 382 |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1156 getContext(), mControlContainer, R.string.bottom_sheet_help_bubb le_message); | 1175 getContext(), mControlContainer, R.string.bottom_sheet_help_bubb le_message); |
1157 int inset = getContext().getResources().getDimensionPixelSize( | 1176 int inset = getContext().getResources().getDimensionPixelSize( |
1158 R.dimen.bottom_sheet_help_bubble_inset); | 1177 R.dimen.bottom_sheet_help_bubble_inset); |
1159 helpBubble.setInsetPx(0, inset, 0, inset); | 1178 helpBubble.setInsetPx(0, inset, 0, inset); |
1160 helpBubble.setDismissOnTouchInteraction(true); | 1179 helpBubble.setDismissOnTouchInteraction(true); |
1161 helpBubble.show(); | 1180 helpBubble.show(); |
1162 | 1181 |
1163 preferences.edit().putBoolean(BOTTOM_SHEET_HELP_BUBBLE_SHOWN, true).appl y(); | 1182 preferences.edit().putBoolean(BOTTOM_SHEET_HELP_BUBBLE_SHOWN, true).appl y(); |
1164 } | 1183 } |
1165 } | 1184 } |
OLD | NEW |