| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.text.TextUtils; | 8 import android.text.TextUtils; |
| 9 import android.text.method.LinkMovementMethod; | 9 import android.text.method.LinkMovementMethod; |
| 10 import android.view.LayoutInflater; | 10 import android.view.LayoutInflater; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 * Indices of child Views that start new layout rows. | 100 * Indices of child Views that start new layout rows. |
| 101 * The last entry is the number of child Views, allowing calculation of the
size of each row by | 101 * The last entry is the number of child Views, allowing calculation of the
size of each row by |
| 102 * taking the difference between subsequent indices. | 102 * taking the difference between subsequent indices. |
| 103 */ | 103 */ |
| 104 private final ArrayList<Integer> mIndicesOfRows; | 104 private final ArrayList<Integer> mIndicesOfRows; |
| 105 | 105 |
| 106 /** | 106 /** |
| 107 * Constructs the layout for the specified InfoBar. | 107 * Constructs the layout for the specified InfoBar. |
| 108 * @param context The context used to render. | 108 * @param context The context used to render. |
| 109 * @param infoBarView InfoBarView that listens to events. | 109 * @param infoBarView InfoBarView that listens to events. |
| 110 * @param backgroundType Type of InfoBar background being shown. | |
| 111 * @param iconResourceId ID of the icon to use for the InfoBar. | 110 * @param iconResourceId ID of the icon to use for the InfoBar. |
| 112 */ | 111 */ |
| 113 public InfoBarLayout(Context context, InfoBarView infoBarView, int backgroun
dType, | 112 public InfoBarLayout(Context context, InfoBarView infoBarView, int iconResou
rceId) { |
| 114 int iconResourceId) { | |
| 115 super(context); | 113 super(context); |
| 116 mIndicesOfRows = new ArrayList<Integer>(); | 114 mIndicesOfRows = new ArrayList<Integer>(); |
| 117 mLayoutRTL = LocalizationUtils.isLayoutRtl(); | 115 mLayoutRTL = LocalizationUtils.isLayoutRtl(); |
| 118 mInfoBarView = infoBarView; | 116 mInfoBarView = infoBarView; |
| 119 | 117 |
| 120 // Determine what backgrounds we'll be needing for the buttons. | 118 // Determine what backgrounds we'll be needing for the buttons. |
| 121 if (backgroundType == InfoBar.BACKGROUND_TYPE_INFO) { | 119 mBackgroundFloating = R.drawable.infobar_button_normal_floating; |
| 122 mBackgroundFloating = R.drawable.infobar_button_normal_floating; | 120 mBackgroundFullLeft = R.drawable.infobar_button_normal_full_left; |
| 123 mBackgroundFullLeft = R.drawable.infobar_button_normal_full_left; | 121 mBackgroundFullRight = R.drawable.infobar_button_normal_full_right; |
| 124 mBackgroundFullRight = R.drawable.infobar_button_normal_full_right; | |
| 125 } else { | |
| 126 mBackgroundFloating = R.drawable.infobar_button_warning_floating; | |
| 127 mBackgroundFullLeft = R.drawable.infobar_button_warning_full_left; | |
| 128 mBackgroundFullRight = R.drawable.infobar_button_warning_full_right; | |
| 129 } | |
| 130 | 122 |
| 131 // Grab the dimensions. | 123 // Grab the dimensions. |
| 132 mDimensionMinSize = | 124 mDimensionMinSize = |
| 133 context.getResources().getDimensionPixelSize(R.dimen.infobar_min
_size); | 125 context.getResources().getDimensionPixelSize(R.dimen.infobar_min
_size); |
| 134 mDimensionMargin = | 126 mDimensionMargin = |
| 135 context.getResources().getDimensionPixelSize(R.dimen.infobar_mar
gin); | 127 context.getResources().getDimensionPixelSize(R.dimen.infobar_mar
gin); |
| 136 mDimensionIconSize = | 128 mDimensionIconSize = |
| 137 context.getResources().getDimensionPixelSize(R.dimen.infobar_ico
n_size); | 129 context.getResources().getDimensionPixelSize(R.dimen.infobar_ico
n_size); |
| 138 | 130 |
| 139 // Create the main controls. | 131 // Create the main controls. |
| 140 mCloseButton = new ImageButton(context); | 132 mCloseButton = new ImageButton(context); |
| 141 mIconView = new ImageView(context); | 133 mIconView = new ImageView(context); |
| 142 mMessageView = (TextView) LayoutInflater.from(context).inflate(R.layout.
infobar_text, null); | 134 mMessageView = (TextView) LayoutInflater.from(context).inflate(R.layout.
infobar_text, null); |
| 143 addGroup(mCloseButton, mIconView, mMessageView); | 135 addGroup(mCloseButton, mIconView, mMessageView); |
| 144 | 136 |
| 145 // Set up the close button. | 137 // Set up the close button. |
| 146 mCloseButton.setId(R.id.infobar_close_button); | 138 mCloseButton.setId(R.id.infobar_close_button); |
| 147 mCloseButton.setImageResource(R.drawable.dismiss); | 139 mCloseButton.setImageResource(R.drawable.infobar_close_button); |
| 148 mCloseButton.setBackgroundResource(R.drawable.infobar_close_bg); | 140 mCloseButton.setBackgroundResource(R.drawable.infobar_close_bg); |
| 149 mCloseButton.setOnClickListener(this); | 141 mCloseButton.setOnClickListener(this); |
| 150 | 142 |
| 151 mCloseButton.setContentDescription(getResources().getString(R.string.inf
obar_close)); | 143 mCloseButton.setContentDescription(getResources().getString(R.string.inf
obar_close)); |
| 152 | 144 |
| 153 // Set up the icon. | 145 // Set up the icon. |
| 154 mIconView.setFocusable(false); | 146 mIconView.setFocusable(false); |
| 155 if (iconResourceId != 0) { | 147 if (iconResourceId != 0) { |
| 156 mIconView.setImageResource(iconResourceId); | 148 mIconView.setImageResource(iconResourceId); |
| 157 } else { | 149 } else { |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 if (view.getId() == R.id.infobar_close_button) { | 756 if (view.getId() == R.id.infobar_close_button) { |
| 765 mInfoBarView.onCloseButtonClicked(); | 757 mInfoBarView.onCloseButtonClicked(); |
| 766 } else if (view.getId() == R.id.button_primary) { | 758 } else if (view.getId() == R.id.button_primary) { |
| 767 mInfoBarView.onButtonClicked(true); | 759 mInfoBarView.onButtonClicked(true); |
| 768 } else if (view.getId() == R.id.button_secondary) { | 760 } else if (view.getId() == R.id.button_secondary) { |
| 769 mInfoBarView.onButtonClicked(false); | 761 mInfoBarView.onButtonClicked(false); |
| 770 } | 762 } |
| 771 } | 763 } |
| 772 | 764 |
| 773 } | 765 } |
| OLD | NEW |