| 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.infobar; | 5 package org.chromium.chrome.browser.infobar; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
| 9 import android.view.Gravity; | 9 import android.view.Gravity; |
| 10 import android.view.View; | 10 import android.view.View; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 /** | 50 /** |
| 51 * Inserts a view before the close button. | 51 * Inserts a view before the close button. |
| 52 * @param view View to insert. | 52 * @param view View to insert. |
| 53 * @param weight Weight to assign to it. | 53 * @param weight Weight to assign to it. |
| 54 */ | 54 */ |
| 55 protected void addContent(View view, float weight) { | 55 protected void addContent(View view, float weight) { |
| 56 LinearLayout.LayoutParams params; | 56 LinearLayout.LayoutParams params; |
| 57 if (weight <= 0.0f) { | 57 if (weight <= 0.0f) { |
| 58 params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, mC
ompactInfoBarSize); | 58 params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, mC
ompactInfoBarSize); |
| 59 } else { | 59 } else { |
| 60 params = new LinearLayout.LayoutParams(0, mCompactInfoBarSize); | 60 params = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT,
weight); |
| 61 params.weight = weight; | |
| 62 } | 61 } |
| 62 view.setMinimumHeight(mCompactInfoBarSize); |
| 63 params.gravity = Gravity.BOTTOM; | 63 params.gravity = Gravity.BOTTOM; |
| 64 addView(view, indexOfChild(mCloseButton), params); | 64 addView(view, indexOfChild(mCloseButton), params); |
| 65 } | 65 } |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * Adds an icon to the start of the infobar, if the infobar requires one. | 68 * Adds an icon to the start of the infobar, if the infobar requires one. |
| 69 * @param iconResourceId Resource ID of the icon to use. | 69 * @param iconResourceId Resource ID of the icon to use. |
| 70 * @param iconBitmap Raw {@link Bitmap} to use instead of a resource. | 70 * @param iconBitmap Raw {@link Bitmap} to use instead of a resource. |
| 71 */ | 71 */ |
| 72 private void prepareIcon(int iconResourceId, Bitmap iconBitmap) { | 72 private void prepareIcon(int iconResourceId, Bitmap iconBitmap) { |
| 73 ImageView iconView = InfoBarLayout.createIconView(getContext(), iconReso
urceId, iconBitmap); | 73 ImageView iconView = InfoBarLayout.createIconView(getContext(), iconReso
urceId, iconBitmap); |
| 74 if (iconView != null) { | 74 if (iconView != null) { |
| 75 LinearLayout.LayoutParams iconParams = | 75 LinearLayout.LayoutParams iconParams = |
| 76 new LinearLayout.LayoutParams(mCompactInfoBarSize, mCompactI
nfoBarSize); | 76 new LinearLayout.LayoutParams(mCompactInfoBarSize, mCompactI
nfoBarSize); |
| 77 addView(iconView, iconParams); | 77 addView(iconView, iconParams); |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 | 80 |
| 81 /** Adds a close button to the end of the infobar. */ | 81 /** Adds a close button to the end of the infobar. */ |
| 82 private View prepareCloseButton() { | 82 private View prepareCloseButton() { |
| 83 ImageButton closeButton = InfoBarLayout.createCloseButton(getContext()); | 83 ImageButton closeButton = InfoBarLayout.createCloseButton(getContext()); |
| 84 closeButton.setOnClickListener(this); | 84 closeButton.setOnClickListener(this); |
| 85 LinearLayout.LayoutParams closeParams = | 85 LinearLayout.LayoutParams closeParams = |
| 86 new LinearLayout.LayoutParams(mCompactInfoBarSize, mCompactInfoB
arSize); | 86 new LinearLayout.LayoutParams(mCompactInfoBarSize, mCompactInfoB
arSize); |
| 87 addView(closeButton, closeParams); | 87 addView(closeButton, closeParams); |
| 88 return closeButton; | 88 return closeButton; |
| 89 } | 89 } |
| 90 } | 90 } |
| OLD | NEW |