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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchOptOutPromo.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, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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.compositor.bottombar.contextualsearch; 5 package org.chromium.chrome.browser.compositor.bottombar.contextualsearch;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.text.method.LinkMovementMethod; 8 import android.text.method.LinkMovementMethod;
9 import android.text.style.ClickableSpan;
10 import android.util.AttributeSet; 9 import android.util.AttributeSet;
11 import android.view.View; 10 import android.view.View;
12 import android.widget.Button; 11 import android.widget.Button;
13 import android.widget.RelativeLayout; 12 import android.widget.RelativeLayout;
14 import android.widget.TextView; 13 import android.widget.TextView;
15 14
16 import org.chromium.chrome.R; 15 import org.chromium.chrome.R;
17 import org.chromium.ui.resources.dynamics.ViewResourceAdapter; 16 import org.chromium.ui.resources.dynamics.ViewResourceAdapter;
17 import org.chromium.ui.text.NoUnderlineClickableSpan;
18 import org.chromium.ui.text.SpanApplier; 18 import org.chromium.ui.text.SpanApplier;
19 import org.chromium.ui.text.SpanApplier.SpanInfo; 19 import org.chromium.ui.text.SpanApplier.SpanInfo;
20 20
21 /** 21 /**
22 */ 22 */
23 public class ContextualSearchOptOutPromo extends RelativeLayout { 23 public class ContextualSearchOptOutPromo extends RelativeLayout {
24 /** 24 /**
25 * The {@link ViewResourceAdapter} instance. 25 * The {@link ViewResourceAdapter} instance.
26 */ 26 */
27 private ViewResourceAdapter mResourceAdapter; 27 private ViewResourceAdapter mResourceAdapter;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 @Override 78 @Override
79 public void onFinishInflate() { 79 public void onFinishInflate() {
80 super.onFinishInflate(); 80 super.onFinishInflate();
81 81
82 mResourceAdapter = 82 mResourceAdapter =
83 new ViewResourceAdapter(findViewById(R.id.contextual_search_opt_ out_promo)); 83 new ViewResourceAdapter(findViewById(R.id.contextual_search_opt_ out_promo));
84 84
85 // Fill in text with link to Settings. 85 // Fill in text with link to Settings.
86 TextView optOutText = (TextView) findViewById(R.id.contextual_search_opt _out_text); 86 TextView optOutText = (TextView) findViewById(R.id.contextual_search_opt _out_text);
87 87
88 ClickableSpan settingsLink = new ClickableSpan() { 88 NoUnderlineClickableSpan settingsLink = new NoUnderlineClickableSpan() {
89 @Override 89 @Override
90 public void onClick(View view) { 90 public void onClick(View view) {
91 mHost.onPromoPreferenceClick(); 91 mHost.onPromoPreferenceClick();
92 } 92 }
93
94 // Disable underline on the link text.
95 @Override
96 public void updateDrawState(android.text.TextPaint textPaint) {
97 super.updateDrawState(textPaint);
98 textPaint.setUnderlineText(false);
99 }
100 }; 93 };
101 94
102 optOutText.setText(SpanApplier.applySpans( 95 optOutText.setText(SpanApplier.applySpans(
103 getResources().getString(R.string.contextual_search_short_descri ption), 96 getResources().getString(R.string.contextual_search_short_descri ption),
104 new SpanInfo("<link>", "</link>", settingsLink))); 97 new SpanInfo("<link>", "</link>", settingsLink)));
105 optOutText.setMovementMethod(LinkMovementMethod.getInstance()); 98 optOutText.setMovementMethod(LinkMovementMethod.getInstance());
106 99
107 // "No thanks" button. 100 // "No thanks" button.
108 Button noThanksButton = (Button) findViewById(R.id.contextual_search_no_ thanks_button); 101 Button noThanksButton = (Button) findViewById(R.id.contextual_search_no_ thanks_button);
109 noThanksButton.setOnClickListener(new View.OnClickListener() { 102 noThanksButton.setOnClickListener(new View.OnClickListener() {
(...skipping 25 matching lines...) Expand all
135 // The Promo will be as wide as possible (same width as the Panel). 128 // The Promo will be as wide as possible (same width as the Panel).
136 int widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EX ACTLY); 129 int widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EX ACTLY);
137 // But the height will depend on how big is the Promo text. 130 // But the height will depend on how big is the Promo text.
138 int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPE CIFIED); 131 int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPE CIFIED);
139 // Calculates the height. 132 // Calculates the height.
140 measure(widthMeasureSpec, heightMeasureSpec); 133 measure(widthMeasureSpec, heightMeasureSpec);
141 134
142 return getMeasuredHeight(); 135 return getMeasuredHeight();
143 } 136 }
144 } 137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698