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; | 5 package org.chromium.chrome.browser.widget; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.util.AttributeSet; | 8 import android.util.AttributeSet; |
| 9 import android.view.View; |
9 import android.view.ViewGroup; | 10 import android.view.ViewGroup; |
10 import android.view.ViewStub; | 11 import android.view.ViewStub; |
11 import android.widget.ImageView; | 12 import android.widget.ImageView; |
12 import android.widget.LinearLayout; | 13 import android.widget.LinearLayout; |
13 import android.widget.TextView; | 14 import android.widget.TextView; |
14 | 15 |
15 import org.chromium.base.ApiCompatibilityUtils; | 16 import org.chromium.base.ApiCompatibilityUtils; |
16 import org.chromium.chrome.R; | 17 import org.chromium.chrome.R; |
17 import org.chromium.chrome.browser.infobar.InfoBarControlLayout; | |
18 import org.chromium.chrome.browser.widget.PromoDialog.DialogParams; | 18 import org.chromium.chrome.browser.widget.PromoDialog.DialogParams; |
19 | 19 |
20 /** | 20 /** |
21 * Lays out a promo dialog that is shown when Clank starts up. | 21 * Lays out a promo dialog that is shown when Clank starts up. |
22 * | 22 * |
23 * Because of the versatility of dialog content and screen sizes, this layout ex
hibits a bunch of | 23 * Because of the versatility of dialog content and screen sizes, this layout ex
hibits a bunch of |
24 * specific behaviors (see go/snowflake-dialogs for details): | 24 * specific behaviors (see go/snowflake-dialogs for details): |
25 * | 25 * |
26 * + It hides controls when their resources are not specified by the {@link Dial
ogParams}. | 26 * + It hides controls when their resources are not specified by the {@link Dial
ogParams}. |
27 * The only two required components are the header text and the primary button
label. | 27 * The only two required components are the header text and the primary button
label. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 138 |
139 if (availableWidth > availableHeight * 1.5) { | 139 if (availableWidth > availableHeight * 1.5) { |
140 mFlippableContent.setOrientation(LinearLayout.HORIZONTAL); | 140 mFlippableContent.setOrientation(LinearLayout.HORIZONTAL); |
141 } else { | 141 } else { |
142 mFlippableContent.setOrientation(LinearLayout.VERTICAL); | 142 mFlippableContent.setOrientation(LinearLayout.VERTICAL); |
143 } | 143 } |
144 | 144 |
145 super.onMeasure(widthMeasureSpec, heightMeasureSpec); | 145 super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
146 } | 146 } |
147 | 147 |
148 /** Adds a standardized set of controls to the layout. */ | 148 /** Adds a View to the layout within the scrollable area. */ |
149 InfoBarControlLayout addControlLayout() { | 149 void addControl(View control) { |
150 InfoBarControlLayout layout = new InfoBarControlLayout(getContext()); | |
151 mScrollableContent.addView( | 150 mScrollableContent.addView( |
152 layout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams
.WRAP_CONTENT)); | 151 control, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParam
s.WRAP_CONTENT)); |
153 return layout; | |
154 } | 152 } |
155 } | 153 } |
OLD | NEW |