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 | 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.graphics.Color; | |
10 import android.graphics.drawable.GradientDrawable; | |
newt (away)
2013/09/09 20:20:42
unused
keishi
2013/09/19 11:53:05
Done.
| |
11 import android.graphics.drawable.LayerDrawable; | |
9 import android.text.TextUtils; | 12 import android.text.TextUtils; |
10 | |
11 import android.view.LayoutInflater; | 13 import android.view.LayoutInflater; |
12 import android.view.View; | 14 import android.view.View; |
13 import android.view.ViewGroup; | 15 import android.view.ViewGroup; |
14 import android.widget.ArrayAdapter; | 16 import android.widget.ArrayAdapter; |
15 import android.widget.TextView; | 17 import android.widget.TextView; |
16 | 18 |
17 import org.chromium.ui.R; | 19 import org.chromium.ui.R; |
18 | 20 |
19 import java.util.ArrayList; | 21 import java.util.ArrayList; |
22 import java.util.Set; | |
20 | 23 |
21 /** | 24 /** |
22 * Autofill suggestion adapter for AutofillWindow. | 25 * Autofill suggestion adapter for AutofillWindow. |
23 */ | 26 */ |
24 public class AutofillListAdapter extends ArrayAdapter<AutofillSuggestion> { | 27 public class AutofillListAdapter extends ArrayAdapter<AutofillSuggestion> { |
25 private Context mContext; | 28 private Context mContext; |
29 private Set<Integer> mSeparators; | |
26 | 30 |
27 AutofillListAdapter(Context context, ArrayList<AutofillSuggestion> objects) { | 31 AutofillListAdapter(Context context, |
32 ArrayList<AutofillSuggestion> objects, | |
33 Set<Integer> separators) { | |
28 super(context, R.layout.autofill_text, objects); | 34 super(context, R.layout.autofill_text, objects); |
35 mSeparators = separators; | |
29 mContext = context; | 36 mContext = context; |
30 } | 37 } |
31 | 38 |
32 @Override | 39 @Override |
33 public View getView(int position, View convertView, ViewGroup parent) { | 40 public View getView(int position, View convertView, ViewGroup parent) { |
34 View layout = convertView; | 41 View layout = convertView; |
35 if (convertView == null) { | 42 if (convertView == null) { |
36 LayoutInflater inflater = | 43 LayoutInflater inflater = |
37 (LayoutInflater) mContext.getSystemService(Context.LAYOUT_IN FLATER_SERVICE); | 44 (LayoutInflater) mContext.getSystemService(Context.LAYOUT_IN FLATER_SERVICE); |
38 layout = inflater.inflate(R.layout.autofill_text, null); | 45 layout = inflater.inflate(R.layout.autofill_text, null); |
46 layout.setBackground(new AutofillDividerDrawable()); | |
39 } | 47 } |
40 TextView labelView = (TextView) layout.findViewById(R.id.autofill_label) ; | 48 TextView labelView = (TextView) layout.findViewById(R.id.autofill_label) ; |
41 labelView.setText(getItem(position).mLabel); | 49 labelView.setText(getItem(position).mLabel); |
42 | 50 |
51 int dividerColor; | |
52 int dividerWidth; | |
53 if (position == 0) { | |
54 dividerWidth = 0; | |
55 dividerColor = Color.TRANSPARENT; | |
56 } else { | |
57 dividerWidth = 1; | |
58 if (mSeparators.contains(position)) { | |
59 dividerColor = mContext.getResources().getColor( | |
60 R.color.autofill_dark_divider_color); | |
61 } else { | |
62 dividerColor = mContext.getResources().getColor(R.color.autofill _divider_color); | |
63 } | |
64 } | |
65 layout.setPaddingRelative(layout.getPaddingStart(), dividerWidth, | |
newt (away)
2013/09/09 20:20:42
getPaddingX() returns user-specific padding plus i
keishi
2013/09/10 09:19:56
The default ListView seems to have a default divid
newt (away)
2013/09/10 17:45:10
divider_horizontal_dark_opaque.9.png is just a sin
keishi
2013/09/19 11:53:05
I'm not sure what you are getting at. We don't use
| |
66 layout.getPaddingEnd(), layout.getPaddingBotto m()); | |
67 AutofillDividerDrawable divider = (AutofillDividerDrawable) layout.getBa ckground(); | |
68 divider.setColor(dividerColor); | |
newt (away)
2013/09/09 20:20:42
and add divider.setHeight() here
| |
69 | |
43 TextView sublabelView = (TextView) layout.findViewById(R.id.autofill_sub label); | 70 TextView sublabelView = (TextView) layout.findViewById(R.id.autofill_sub label); |
44 CharSequence sublabel = getItem(position).mSublabel; | 71 CharSequence sublabel = getItem(position).mSublabel; |
45 if (TextUtils.isEmpty(sublabel)) { | 72 if (TextUtils.isEmpty(sublabel)) { |
46 sublabelView.setVisibility(View.GONE); | 73 sublabelView.setVisibility(View.GONE); |
47 } else { | 74 } else { |
48 sublabelView.setText(sublabel); | 75 sublabelView.setText(sublabel); |
49 sublabelView.setVisibility(View.VISIBLE); | 76 sublabelView.setVisibility(View.VISIBLE); |
50 } | 77 } |
51 | 78 |
52 return layout; | 79 return layout; |
53 } | 80 } |
54 } | 81 } |
OLD | NEW |