| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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; | 5 package org.chromium.chrome.browser.compositor.bottombar; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.view.View; | 8 import android.view.View; |
| 9 import android.view.ViewGroup; | 9 import android.view.ViewGroup; |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 @Override | 50 @Override |
| 51 public void destroy() { | 51 public void destroy() { |
| 52 super.destroy(); | 52 super.destroy(); |
| 53 | 53 |
| 54 mOverlayPanel = null; | 54 mOverlayPanel = null; |
| 55 } | 55 } |
| 56 | 56 |
| 57 @Override | 57 @Override |
| 58 protected void onFinishInflate() { | 58 protected void onFinishInflate() { |
| 59 if (!mOverlayPanel.isFullWidthSizePanel()) { | 59 if (!mOverlayPanel.isFullWidthSizePanel()) { |
| 60 setWidth(mOverlayPanel.getMaximumWidthPx()); | 60 requestLayout(); |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 | 63 |
| 64 @Override | 64 @Override |
| 65 protected int getWidthMeasureSpec() { | 65 protected int getWidthMeasureSpec() { |
| 66 return View.MeasureSpec.makeMeasureSpec( | 66 return View.MeasureSpec.makeMeasureSpec( |
| 67 mOverlayPanel.getMaximumWidthPx(), View.MeasureSpec.EXACTLY); | 67 mOverlayPanel.getMaximumWidthPx(), View.MeasureSpec.EXACTLY); |
| 68 } | 68 } |
| 69 | 69 |
| 70 /** | 70 /** |
| 71 * @param width The width of the view to be inforced. | |
| 72 */ | |
| 73 private void setWidth(int width) { | |
| 74 // When the view is attached, we need to force the layout to have a spec
ific width | |
| 75 // because the container is "full-width" (as wide as a tab). When not at
tached, | |
| 76 // ViewResourceInflater#layout() will properly resize the view offscreen
. | |
| 77 if (shouldAttachView()) { | |
| 78 View view = getView(); | |
| 79 if (view != null) { | |
| 80 view.getLayoutParams().width = width; | |
| 81 view.requestLayout(); | |
| 82 } | |
| 83 } | |
| 84 } | |
| 85 | |
| 86 /** | |
| 87 * Sanitizes a string to be displayed on the Overlay Panel Bar. | 71 * Sanitizes a string to be displayed on the Overlay Panel Bar. |
| 88 * @param text The text to be sanitized. | 72 * @param text The text to be sanitized. |
| 89 * @return The sanitized text. | 73 * @return The sanitized text. |
| 90 */ | 74 */ |
| 91 public static String sanitizeText(String text) { | 75 public static String sanitizeText(String text) { |
| 92 if (text == null) return null; | 76 if (text == null) return null; |
| 93 return text.replace(OBJ_CHARACTER, " ").trim(); | 77 return text.replace(OBJ_CHARACTER, " ").trim(); |
| 94 } | 78 } |
| 95 | 79 |
| 96 } | 80 } |
| OLD | NEW |