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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/autofill/PasswordGenerationAdapter.java

Issue 1774243003: Re-use NoUnderlineClickableSpan which shows a clickable link with underlines turned off (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webusb_android_chooser
Patch Set: rebase Created 4 years, 9 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
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.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;
11 import android.text.method.LinkMovementMethod; 10 import android.text.method.LinkMovementMethod;
12 import android.text.style.ClickableSpan;
13 import android.view.LayoutInflater; 11 import android.view.LayoutInflater;
14 import android.view.View; 12 import android.view.View;
15 import android.view.View.MeasureSpec; 13 import android.view.View.MeasureSpec;
16 import android.view.ViewGroup; 14 import android.view.ViewGroup;
17 import android.widget.BaseAdapter; 15 import android.widget.BaseAdapter;
18 import android.widget.RelativeLayout.LayoutParams; 16 import android.widget.RelativeLayout.LayoutParams;
19 import android.widget.TextView; 17 import android.widget.TextView;
20 18
21 import org.chromium.base.ApiCompatibilityUtils;
22 import org.chromium.chrome.R; 19 import org.chromium.chrome.R;
20 import org.chromium.ui.text.NoUnderlineClickableSpan;
23 21
24 import java.util.Arrays; 22 import java.util.Arrays;
25 import java.util.List; 23 import java.util.List;
26 24
27 /** 25 /**
28 * The adapter that populates the list popup for password generation with data. If the constructor 26 * 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 27 * 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 28 * 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. 29 * the passwordDisplayed parameter is false, then the adapter shows only the exp lanation item.
32 */ 30 */
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 ((TextView) view.findViewById(R.id.password_generation_password) ) 135 ((TextView) view.findViewById(R.id.password_generation_password) )
138 .setText(mPassword); 136 .setText(mPassword);
139 break; 137 break;
140 138
141 case EXPLANATION: 139 case EXPLANATION:
142 view = inflater.inflate(R.layout.password_generation_popup_expla nation, null); 140 view = inflater.inflate(R.layout.password_generation_popup_expla nation, null);
143 TextView explanation = (TextView) view 141 TextView explanation = (TextView) view
144 .findViewById(R.id.password_generation_explanation); 142 .findViewById(R.id.password_generation_explanation);
145 SpannableString explanationSpan = new SpannableString(mExplanati onText); 143 SpannableString explanationSpan = new SpannableString(mExplanati onText);
146 explanationSpan.setSpan( 144 explanationSpan.setSpan(
147 new ClickableSpan() { 145 new NoUnderlineClickableSpan() {
148 @Override 146 @Override
149 public void onClick(View view) { 147 public void onClick(View view) {
150 mDelegate.onSavedPasswordsLinkClicked(); 148 mDelegate.onSavedPasswordsLinkClicked();
151 } 149 }
152 150 },
153 @Override 151 mExplanationTextLinkRangeStart, mExplanationTextLinkRang eEnd,
154 public void updateDrawState(TextPaint textPaint) {
155 textPaint.setUnderlineText(false);
156 textPaint.setColor(ApiCompatibilityUtils.getColo r(
157 mContext.getResources(),
158 R.color.password_generation_link_text_co lor));
159 }
160 }, mExplanationTextLinkRangeStart, mExplanationTextLinkR angeEnd,
161 Spanned.SPAN_INCLUSIVE_INCLUSIVE); 152 Spanned.SPAN_INCLUSIVE_INCLUSIVE);
162 explanation.setText(explanationSpan); 153 explanation.setText(explanationSpan);
163 explanation.setMovementMethod(LinkMovementMethod.getInstance()); 154 explanation.setMovementMethod(LinkMovementMethod.getInstance());
164 explanation.setLayoutParams(new LayoutParams(mSuggestionMeasured Width, 155 explanation.setLayoutParams(new LayoutParams(mSuggestionMeasured Width,
165 LayoutParams.WRAP_CONTENT)); 156 LayoutParams.WRAP_CONTENT));
166 break; 157 break;
167 158
168 default: 159 default:
169 assert false : "Unknown view type"; 160 assert false : "Unknown view type";
170 break; 161 break;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 /** 225 /**
235 * Used by list popup window to check if the element at this position is ena bled. Only the 226 * Used by list popup window to check if the element at this position is ena bled. Only the
236 * suggestion element is enabled. 227 * suggestion element is enabled.
237 * @return boolean True if the view at position is a suggestion. 228 * @return boolean True if the view at position is a suggestion.
238 */ 229 */
239 @Override 230 @Override
240 public boolean isEnabled(int position) { 231 public boolean isEnabled(int position) {
241 return mViewTypes.get(position) == SUGGESTION; 232 return mViewTypes.get(position) == SUGGESTION;
242 } 233 }
243 } 234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698