| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.compositor.bottombar.contextualsearch; | 5 package org.chromium.chrome.browser.compositor.bottombar.contextualsearch; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.view.ViewGroup; | 8 import android.view.ViewGroup; |
| 9 | 9 |
| 10 import org.chromium.chrome.R; | 10 import org.chromium.chrome.R; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 * The {@link ContextualSearchCaptionControl} used to control the Caption Vie
w. | 45 * The {@link ContextualSearchCaptionControl} used to control the Caption Vie
w. |
| 46 */ | 46 */ |
| 47 private final ContextualSearchCaptionControl mCaptionControl; | 47 private final ContextualSearchCaptionControl mCaptionControl; |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * The {@link ContextualSearchQuickActionControl} used to control quick acti
on behavior. | 50 * The {@link ContextualSearchQuickActionControl} used to control quick acti
on behavior. |
| 51 */ | 51 */ |
| 52 private final ContextualSearchQuickActionControl mQuickActionControl; | 52 private final ContextualSearchQuickActionControl mQuickActionControl; |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * The {@link ContextualSearchImageControl} for the panel. |
| 56 */ |
| 57 private ContextualSearchImageControl mImageControl; |
| 58 |
| 59 /** |
| 55 * The opacity of the Bar's Search Context. | 60 * The opacity of the Bar's Search Context. |
| 56 */ | 61 */ |
| 57 private float mSearchBarContextOpacity = 1.f; | 62 private float mSearchBarContextOpacity = 1.f; |
| 58 | 63 |
| 59 /** | 64 /** |
| 60 * The opacity of the Bar's Search Term. | 65 * The opacity of the Bar's Search Term. |
| 61 */ | 66 */ |
| 62 private float mSearchBarTermOpacity = 1.f; | 67 private float mSearchBarTermOpacity = 1.f; |
| 63 | 68 |
| 64 // Dimensions used for laying out the search bar. | 69 // Dimensions used for laying out the search bar. |
| 65 private final float mTextLayerMinHeight; | 70 private final float mTextLayerMinHeight; |
| 66 private final float mTermCaptionSpacing; | 71 private final float mTermCaptionSpacing; |
| 67 | 72 |
| 68 /** | 73 /** |
| 69 * Constructs a new bottom bar control container by inflating views from XML
. | 74 * Constructs a new bottom bar control container by inflating views from XML
. |
| 70 * | 75 * |
| 71 * @param panel The panel. | 76 * @param panel The panel. |
| 72 * @param context The context used to build this view. | 77 * @param context The context used to build this view. |
| 73 * @param container The parent view for the bottom bar views. | 78 * @param container The parent view for the bottom bar views. |
| 74 * @param loader The resource loader that will handle the snapshot captur
ing. | 79 * @param loader The resource loader that will handle the snapshot captur
ing. |
| 75 */ | 80 */ |
| 76 public ContextualSearchBarControl(OverlayPanel panel, | 81 public ContextualSearchBarControl(OverlayPanel panel, |
| 77 Context context, | 82 Context context, |
| 78 ViewGroup container, | 83 ViewGroup container, |
| 79 DynamicResourceLoader loader) { | 84 DynamicResourceLoader loader) { |
| 80 mOverlayPanel = panel; | 85 mOverlayPanel = panel; |
| 86 mImageControl = new ContextualSearchImageControl(panel, context); |
| 81 mContextControl = new ContextualSearchContextControl(panel, context, con
tainer, loader); | 87 mContextControl = new ContextualSearchContextControl(panel, context, con
tainer, loader); |
| 82 mSearchTermControl = new ContextualSearchTermControl(panel, context, con
tainer, loader); | 88 mSearchTermControl = new ContextualSearchTermControl(panel, context, con
tainer, loader); |
| 83 mCaptionControl = new ContextualSearchCaptionControl(panel, context, con
tainer, loader); | 89 mCaptionControl = new ContextualSearchCaptionControl(panel, context, con
tainer, loader); |
| 84 mQuickActionControl = new ContextualSearchQuickActionControl(); | 90 mQuickActionControl = new ContextualSearchQuickActionControl(); |
| 85 | 91 |
| 86 mTextLayerMinHeight = context.getResources().getDimension( | 92 mTextLayerMinHeight = context.getResources().getDimension( |
| 87 R.dimen.contextual_search_text_layer_min_height); | 93 R.dimen.contextual_search_text_layer_min_height); |
| 88 mTermCaptionSpacing = context.getResources().getDimension( | 94 mTermCaptionSpacing = context.getResources().getDimension( |
| 89 R.dimen.contextual_search_term_caption_spacing); | 95 R.dimen.contextual_search_term_caption_spacing); |
| 90 } | 96 } |
| 91 | 97 |
| 92 /** | 98 /** |
| 99 * @return The {@link ContextualSearchImageControl} for the panel. |
| 100 */ |
| 101 public ContextualSearchImageControl getImageControl() { |
| 102 return mImageControl; |
| 103 } |
| 104 |
| 105 /** |
| 93 * Returns the minimum height that the text layer (containing the Search Con
text, Term and | 106 * Returns the minimum height that the text layer (containing the Search Con
text, Term and |
| 94 * Caption) should be. | 107 * Caption) should be. |
| 95 */ | 108 */ |
| 96 public float getTextLayerMinHeight() { | 109 public float getTextLayerMinHeight() { |
| 97 return mTextLayerMinHeight; | 110 return mTextLayerMinHeight; |
| 98 } | 111 } |
| 99 | 112 |
| 100 /** | 113 /** |
| 101 * Returns the spacing that should be placed between the Search Term and Cap
tion. | 114 * Returns the spacing that should be placed between the Search Term and Cap
tion. |
| 102 */ | 115 */ |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 * Sets the quick action if one is available. | 215 * Sets the quick action if one is available. |
| 203 * @param quickActionUri The URI for the intent associated with the quick ac
tion. | 216 * @param quickActionUri The URI for the intent associated with the quick ac
tion. |
| 204 * @param quickActionCategory The category for the quick action. | 217 * @param quickActionCategory The category for the quick action. |
| 205 */ | 218 */ |
| 206 public void setQuickAction(String quickActionUri, String quickActionCategory
) { | 219 public void setQuickAction(String quickActionUri, String quickActionCategory
) { |
| 207 mQuickActionControl.setQuickAction(quickActionUri, quickActionCategory); | 220 mQuickActionControl.setQuickAction(quickActionUri, quickActionCategory); |
| 208 if (mQuickActionControl.hasQuickAction()) { | 221 if (mQuickActionControl.hasQuickAction()) { |
| 209 // TODO(twellington): should the quick action caption be stored sepa
rately from the | 222 // TODO(twellington): should the quick action caption be stored sepa
rately from the |
| 210 // regular caption? | 223 // regular caption? |
| 211 mCaptionControl.setCaption(mQuickActionControl.getCaption()); | 224 mCaptionControl.setCaption(mQuickActionControl.getCaption()); |
| 225 mImageControl.setStaticIconResourceId(mQuickActionControl.getIconRes
Id()); |
| 212 } | 226 } |
| 213 } | 227 } |
| 214 | 228 |
| 215 /** | 229 /** |
| 216 * @return The {@link ContextualSearchQuickActionControl} for the panel. | 230 * @return The {@link ContextualSearchQuickActionControl} for the panel. |
| 217 */ | 231 */ |
| 218 public ContextualSearchQuickActionControl getQuickActionControl() { | 232 public ContextualSearchQuickActionControl getQuickActionControl() { |
| 219 return mQuickActionControl; | 233 return mQuickActionControl; |
| 220 } | 234 } |
| 221 | 235 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 // They will both be partially visible for overlapPercentage of the anim
ation duration. | 300 // They will both be partially visible for overlapPercentage of the anim
ation duration. |
| 287 float overlapPercentage = .75f; | 301 float overlapPercentage = .75f; |
| 288 float fadingOutPercentage = Math.max(1 - (percentage / overlapPercentage
), 0.f); | 302 float fadingOutPercentage = Math.max(1 - (percentage / overlapPercentage
), 0.f); |
| 289 float fadingInPercentage = | 303 float fadingInPercentage = |
| 290 Math.max(percentage - (1 - overlapPercentage), 0.f) / overlapPer
centage; | 304 Math.max(percentage - (1 - overlapPercentage), 0.f) / overlapPer
centage; |
| 291 | 305 |
| 292 mSearchBarContextOpacity = fadingOutPercentage; | 306 mSearchBarContextOpacity = fadingOutPercentage; |
| 293 mSearchBarTermOpacity = fadingInPercentage; | 307 mSearchBarTermOpacity = fadingInPercentage; |
| 294 } | 308 } |
| 295 } | 309 } |
| OLD | NEW |