OLD | NEW |
---|---|
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.chrome.browser.autofill; | 5 package org.chromium.chrome.browser.autofill; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.text.SpannableString; | 8 import android.text.SpannableString; |
9 import android.text.Spanned; | 9 import android.text.Spanned; |
10 import android.text.TextPaint; | 10 import android.text.TextPaint; |
11 import android.text.method.LinkMovementMethod; | 11 import android.text.method.LinkMovementMethod; |
12 import android.text.style.ClickableSpan; | |
13 import android.view.LayoutInflater; | 12 import android.view.LayoutInflater; |
14 import android.view.View; | 13 import android.view.View; |
15 import android.view.View.MeasureSpec; | 14 import android.view.View.MeasureSpec; |
16 import android.view.ViewGroup; | 15 import android.view.ViewGroup; |
17 import android.widget.BaseAdapter; | 16 import android.widget.BaseAdapter; |
18 import android.widget.RelativeLayout.LayoutParams; | 17 import android.widget.RelativeLayout.LayoutParams; |
19 import android.widget.TextView; | 18 import android.widget.TextView; |
20 | 19 |
21 import org.chromium.base.ApiCompatibilityUtils; | 20 import org.chromium.base.ApiCompatibilityUtils; |
22 import org.chromium.chrome.R; | 21 import org.chromium.chrome.R; |
22 import org.chromium.ui.text.NoUnderlineClickableSpan; | |
23 | 23 |
24 import java.util.Arrays; | 24 import java.util.Arrays; |
25 import java.util.List; | 25 import java.util.List; |
26 | 26 |
27 /** | 27 /** |
28 * The adapter that populates the list popup for password generation with data. If the constructor | 28 * The adapter that populates the list popup for password generation with data. If the constructor |
29 * parameter passwordDisplayed is true, then this adapter makes the popup displa y two items in the | 29 * parameter passwordDisplayed is true, then this adapter makes the popup displa y two items in the |
30 * list: (1) the password suggestion and (2) an explanation of the password gene ration feature. If | 30 * list: (1) the password suggestion and (2) an explanation of the password gene ration feature. If |
31 * the passwordDisplayed parameter is false, then the adapter shows only the exp lanation item. | 31 * the passwordDisplayed parameter is false, then the adapter shows only the exp lanation item. |
32 */ | 32 */ |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 ((TextView) view.findViewById(R.id.password_generation_password) ) | 137 ((TextView) view.findViewById(R.id.password_generation_password) ) |
138 .setText(mPassword); | 138 .setText(mPassword); |
139 break; | 139 break; |
140 | 140 |
141 case EXPLANATION: | 141 case EXPLANATION: |
142 view = inflater.inflate(R.layout.password_generation_popup_expla nation, null); | 142 view = inflater.inflate(R.layout.password_generation_popup_expla nation, null); |
143 TextView explanation = (TextView) view | 143 TextView explanation = (TextView) view |
144 .findViewById(R.id.password_generation_explanation); | 144 .findViewById(R.id.password_generation_explanation); |
145 SpannableString explanationSpan = new SpannableString(mExplanati onText); | 145 SpannableString explanationSpan = new SpannableString(mExplanati onText); |
146 explanationSpan.setSpan( | 146 explanationSpan.setSpan( |
147 new ClickableSpan() { | 147 new NoUnderlineClickableSpan() { |
148 @Override | 148 @Override |
149 public void onClick(View view) { | 149 public void onClick(View view) { |
150 mDelegate.onSavedPasswordsLinkClicked(); | 150 mDelegate.onSavedPasswordsLinkClicked(); |
151 } | 151 } |
152 | 152 |
153 @Override | 153 @Override |
154 public void updateDrawState(TextPaint textPaint) { | 154 public void updateDrawState(TextPaint textPaint) { |
newt (away)
2016/03/10 02:45:13
Let's remove this method and delete password_gener
juncai
2016/03/11 23:53:05
Done.
| |
155 textPaint.setUnderlineText(false); | 155 super.updateDrawState(textPaint); |
156 textPaint.setColor(ApiCompatibilityUtils.getColo r( | 156 textPaint.setColor(ApiCompatibilityUtils.getColo r( |
157 mContext.getResources(), | 157 mContext.getResources(), |
158 R.color.password_generation_link_text_co lor)); | 158 R.color.password_generation_link_text_co lor)); |
159 } | 159 } |
160 }, mExplanationTextLinkRangeStart, mExplanationTextLinkR angeEnd, | 160 }, |
161 mExplanationTextLinkRangeStart, mExplanationTextLinkRang eEnd, | |
161 Spanned.SPAN_INCLUSIVE_INCLUSIVE); | 162 Spanned.SPAN_INCLUSIVE_INCLUSIVE); |
162 explanation.setText(explanationSpan); | 163 explanation.setText(explanationSpan); |
163 explanation.setMovementMethod(LinkMovementMethod.getInstance()); | 164 explanation.setMovementMethod(LinkMovementMethod.getInstance()); |
164 explanation.setLayoutParams(new LayoutParams(mSuggestionMeasured Width, | 165 explanation.setLayoutParams(new LayoutParams(mSuggestionMeasured Width, |
165 LayoutParams.WRAP_CONTENT)); | 166 LayoutParams.WRAP_CONTENT)); |
166 break; | 167 break; |
167 | 168 |
168 default: | 169 default: |
169 assert false : "Unknown view type"; | 170 assert false : "Unknown view type"; |
170 break; | 171 break; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 /** | 235 /** |
235 * Used by list popup window to check if the element at this position is ena bled. Only the | 236 * Used by list popup window to check if the element at this position is ena bled. Only the |
236 * suggestion element is enabled. | 237 * suggestion element is enabled. |
237 * @return boolean True if the view at position is a suggestion. | 238 * @return boolean True if the view at position is a suggestion. |
238 */ | 239 */ |
239 @Override | 240 @Override |
240 public boolean isEnabled(int position) { | 241 public boolean isEnabled(int position) { |
241 return mViewTypes.get(position) == SUGGESTION; | 242 return mViewTypes.get(position) == SUGGESTION; |
242 } | 243 } |
243 } | 244 } |
OLD | NEW |