| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.ntp.cards; | 5 package org.chromium.chrome.browser.ntp.cards; |
| 6 | 6 |
| 7 import android.text.method.LinkMovementMethod; | 7 import android.text.method.LinkMovementMethod; |
| 8 import android.view.LayoutInflater; | 8 import android.view.LayoutInflater; |
| 9 import android.view.View; | 9 import android.view.View; |
| 10 import android.view.ViewGroup; | 10 import android.view.ViewGroup; |
| 11 import android.widget.TextView; | 11 import android.widget.TextView; |
| 12 | 12 |
| 13 import org.chromium.chrome.R; | 13 import org.chromium.chrome.R; |
| 14 import org.chromium.chrome.browser.ntp.NewTabPageView.NewTabPageManager; | 14 import org.chromium.chrome.browser.suggestions.SuggestionsNavigationDelegate; |
| 15 import org.chromium.ui.text.NoUnderlineClickableSpan; | 15 import org.chromium.ui.text.NoUnderlineClickableSpan; |
| 16 import org.chromium.ui.text.SpanApplier; | 16 import org.chromium.ui.text.SpanApplier; |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * A footer to show some text and a link to learn more. | 19 * A footer to show some text and a link to learn more. |
| 20 */ | 20 */ |
| 21 public class Footer extends OptionalLeaf { | 21 public class Footer extends OptionalLeaf { |
| 22 | 22 |
| 23 @Override | 23 @Override |
| 24 @ItemViewType | 24 @ItemViewType |
| 25 protected int getItemViewType() { | 25 protected int getItemViewType() { |
| 26 return ItemViewType.FOOTER; | 26 return ItemViewType.FOOTER; |
| 27 } | 27 } |
| 28 | 28 |
| 29 @Override | 29 @Override |
| 30 protected void onBindViewHolder(NewTabPageViewHolder holder) { | 30 protected void onBindViewHolder(NewTabPageViewHolder holder) { |
| 31 // Nothing to do (the footer view is static). | 31 // Nothing to do (the footer view is static). |
| 32 } | 32 } |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * The {@code ViewHolder} for the {@link Footer}. | 35 * The {@code ViewHolder} for the {@link Footer}. |
| 36 */ | 36 */ |
| 37 public static class ViewHolder extends NewTabPageViewHolder { | 37 public static class ViewHolder extends NewTabPageViewHolder { |
| 38 public ViewHolder(ViewGroup root, final NewTabPageManager manager) { | 38 public ViewHolder(ViewGroup root, final SuggestionsNavigationDelegate na
vigationDelegate) { |
| 39 super(LayoutInflater.from(root.getContext()) | 39 super(LayoutInflater.from(root.getContext()) |
| 40 .inflate(R.layout.new_tab_page_footer, root, false))
; | 40 .inflate(R.layout.new_tab_page_footer, root, false))
; |
| 41 | 41 |
| 42 NoUnderlineClickableSpan link = new NoUnderlineClickableSpan() { | 42 NoUnderlineClickableSpan link = new NoUnderlineClickableSpan() { |
| 43 @Override | 43 @Override |
| 44 public void onClick(View view) { | 44 public void onClick(View view) { |
| 45 // TODO(mvanouwerkerk): Ensure this can be activated when us
ing TalkBack. | 45 // TODO(mvanouwerkerk): Ensure this can be activated when us
ing TalkBack. |
| 46 manager.onLearnMoreClicked(); | 46 navigationDelegate.navigateToHelpPage(); |
| 47 } | 47 } |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 TextView textView = (TextView) itemView.findViewById(R.id.text); | 50 TextView textView = (TextView) itemView.findViewById(R.id.text); |
| 51 textView.setText(SpanApplier.applySpans( | 51 textView.setText(SpanApplier.applySpans( |
| 52 root.getResources().getString(R.string.ntp_learn_more_about_
suggested_content), | 52 root.getResources().getString(R.string.ntp_learn_more_about_
suggested_content), |
| 53 new SpanApplier.SpanInfo("<link>", "</link>", link))); | 53 new SpanApplier.SpanInfo("<link>", "</link>", link))); |
| 54 textView.setMovementMethod(LinkMovementMethod.getInstance()); | 54 textView.setMovementMethod(LinkMovementMethod.getInstance()); |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 } | 57 } |
| OLD | NEW |