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

Side by Side Diff: trunk/src/ui/android/java/src/org/chromium/ui/autofill/AutofillListAdapter.java

Issue 68243003: Revert 234194 "Add support for datalist to text input element on..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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 5
6 package org.chromium.ui.autofill; 6 package org.chromium.ui.autofill;
7 7
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.res.Resources;
10 import android.graphics.Color;
11 import android.graphics.drawable.LayerDrawable;
12 import android.text.TextUtils; 9 import android.text.TextUtils;
10
13 import android.view.LayoutInflater; 11 import android.view.LayoutInflater;
14 import android.view.View; 12 import android.view.View;
15 import android.view.ViewGroup; 13 import android.view.ViewGroup;
16 import android.widget.AbsListView.LayoutParams;
17 import android.widget.ArrayAdapter; 14 import android.widget.ArrayAdapter;
18 import android.widget.TextView; 15 import android.widget.TextView;
19 16
20 import org.chromium.ui.R; 17 import org.chromium.ui.R;
21 18
22 import org.chromium.base.ApiCompatibilityUtils;
23
24 import java.util.ArrayList; 19 import java.util.ArrayList;
25 import java.util.Set;
26 20
27 /** 21 /**
28 * Autofill suggestion adapter for AutofillWindow. 22 * Autofill suggestion adapter for AutofillWindow.
29 */ 23 */
30 public class AutofillListAdapter extends ArrayAdapter<AutofillSuggestion> { 24 public class AutofillListAdapter extends ArrayAdapter<AutofillSuggestion> {
31 private Context mContext; 25 private Context mContext;
32 private Set<Integer> mSeparators;
33 26
34 AutofillListAdapter(Context context, 27 AutofillListAdapter(Context context, ArrayList<AutofillSuggestion> objects) {
35 ArrayList<AutofillSuggestion> objects,
36 Set<Integer> separators) {
37 super(context, R.layout.autofill_text, objects); 28 super(context, R.layout.autofill_text, objects);
38 mSeparators = separators;
39 mContext = context; 29 mContext = context;
40 } 30 }
41 31
42 @Override 32 @Override
43 public View getView(int position, View convertView, ViewGroup parent) { 33 public View getView(int position, View convertView, ViewGroup parent) {
44 View layout = convertView; 34 View layout = convertView;
45 if (convertView == null) { 35 if (convertView == null) {
46 LayoutInflater inflater = 36 LayoutInflater inflater =
47 (LayoutInflater) mContext.getSystemService(Context.LAYOUT_IN FLATER_SERVICE); 37 (LayoutInflater) mContext.getSystemService(Context.LAYOUT_IN FLATER_SERVICE);
48 layout = inflater.inflate(R.layout.autofill_text, null); 38 layout = inflater.inflate(R.layout.autofill_text, null);
49 ApiCompatibilityUtils.setBackgroundForView(layout, new AutofillDivid erDrawable());
50 } 39 }
51 TextView labelView = (TextView) layout.findViewById(R.id.autofill_label) ; 40 TextView labelView = (TextView) layout.findViewById(R.id.autofill_label) ;
52 labelView.setText(getItem(position).mLabel); 41 labelView.setText(getItem(position).mLabel);
53 42
54 AutofillDividerDrawable divider = (AutofillDividerDrawable) layout.getBa ckground();
55 int height = mContext.getResources().getDimensionPixelSize(R.dimen.autof ill_text_height);
56 if (position == 0) {
57 divider.setColor(Color.TRANSPARENT);
58 } else {
59 int dividerHeight = mContext.getResources().getDimensionPixelSize(
60 R.dimen.autofill_text_divider_height);
61 height += dividerHeight;
62 divider.setHeight(dividerHeight);
63 if (mSeparators.contains(position)) {
64 divider.setColor(mContext.getResources().getColor(
65 R.color.autofill_dark_divider_color));
66 } else {
67 divider.setColor(mContext.getResources().getColor(
68 R.color.autofill_divider_color));
69 }
70 }
71 layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, heigh t));
72
73 TextView sublabelView = (TextView) layout.findViewById(R.id.autofill_sub label); 43 TextView sublabelView = (TextView) layout.findViewById(R.id.autofill_sub label);
74 CharSequence sublabel = getItem(position).mSublabel; 44 CharSequence sublabel = getItem(position).mSublabel;
75 if (TextUtils.isEmpty(sublabel)) { 45 if (TextUtils.isEmpty(sublabel)) {
76 sublabelView.setVisibility(View.GONE); 46 sublabelView.setVisibility(View.GONE);
77 } else { 47 } else {
78 sublabelView.setText(sublabel); 48 sublabelView.setText(sublabel);
79 sublabelView.setVisibility(View.VISIBLE); 49 sublabelView.setVisibility(View.VISIBLE);
80 } 50 }
81 51
82 return layout; 52 return layout;
83 } 53 }
84 } 54 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698