Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: ui/android/java/src/org/chromium/ui/DropdownAdapter.java

Issue 2664083007: Always adds margin at the end of the label to handle case where label (Closed)
Patch Set: Sets label's layout params to sublabel only when label and sublabel are not on the same line. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.ui; 5 package org.chromium.ui;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.graphics.Color; 8 import android.graphics.Color;
9 import android.graphics.Typeface; 9 import android.graphics.Typeface;
10 import android.support.annotation.Nullable; 10 import android.support.annotation.Nullable;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 labelView.setTextColor(ApiCompatibilityUtils.getColor( 183 labelView.setTextColor(ApiCompatibilityUtils.getColor(
184 mContext.getResources(), item.getLabelFontColorResId())); 184 mContext.getResources(), item.getLabelFontColorResId()));
185 labelView.setTextSize(TypedValue.COMPLEX_UNIT_PX, 185 labelView.setTextSize(TypedValue.COMPLEX_UNIT_PX,
186 mContext.getResources().getDimension(item.getLabelFontSizeResId( ))); 186 mContext.getResources().getDimension(item.getLabelFontSizeResId( )));
187 187
188 TextView sublabelView = (TextView) layout.findViewById(R.id.dropdown_sub label); 188 TextView sublabelView = (TextView) layout.findViewById(R.id.dropdown_sub label);
189 CharSequence sublabel = item.getSublabel(); 189 CharSequence sublabel = item.getSublabel();
190 if (TextUtils.isEmpty(sublabel)) { 190 if (TextUtils.isEmpty(sublabel)) {
191 sublabelView.setVisibility(View.GONE); 191 sublabelView.setVisibility(View.GONE);
192 } else { 192 } else {
193 sublabelView.setLayoutParams(layoutParams); 193 // Use the layout params in |dropdown_item.xml| for the sublabel if it is on the same
194 // line as the label.
195 if (!item.isLabelAndSublabelOnSameLine()) {
196 sublabelView.setLayoutParams(layoutParams);
Ted C 2017/02/02 23:19:22 by conditionally overwriting the layout params, if
csashi 2017/02/03 00:03:37 Done.
197 }
194 sublabelView.setText(sublabel); 198 sublabelView.setText(sublabel);
195 sublabelView.setTextSize(TypedValue.COMPLEX_UNIT_PX, 199 sublabelView.setTextSize(TypedValue.COMPLEX_UNIT_PX,
196 mContext.getResources().getDimension(item.getSublabelFontSiz eResId())); 200 mContext.getResources().getDimension(item.getSublabelFontSiz eResId()));
197 sublabelView.setVisibility(View.VISIBLE); 201 sublabelView.setVisibility(View.VISIBLE);
198 } 202 }
199 203
200 ImageView iconViewStart = (ImageView) layout.findViewById(R.id.start_dro pdown_icon); 204 ImageView iconViewStart = (ImageView) layout.findViewById(R.id.start_dro pdown_icon);
201 ImageView iconViewEnd = (ImageView) layout.findViewById(R.id.end_dropdow n_icon); 205 ImageView iconViewEnd = (ImageView) layout.findViewById(R.id.end_dropdow n_icon);
202 if (item.isIconAtStart()) { 206 if (item.isIconAtStart()) {
203 iconViewEnd.setVisibility(View.GONE); 207 iconViewEnd.setVisibility(View.GONE);
(...skipping 30 matching lines...) Expand all
234 return mAreAllItemsEnabled; 238 return mAreAllItemsEnabled;
235 } 239 }
236 240
237 @Override 241 @Override
238 public boolean isEnabled(int position) { 242 public boolean isEnabled(int position) {
239 if (position < 0 || position >= getCount()) return false; 243 if (position < 0 || position >= getCount()) return false;
240 DropdownItem item = getItem(position); 244 DropdownItem item = getItem(position);
241 return item.isEnabled() && !item.isGroupHeader(); 245 return item.isEnabled() && !item.isGroupHeader();
242 } 246 }
243 } 247 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698