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.ntp.NewTabPageView.NewTabPageManager; |
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 SingleItemGroup { | 21 public class Footer extends Leaf { |
22 @Override | 22 @Override |
23 public int getType() { | 23 @ItemViewType |
24 return NewTabPageItem.VIEW_TYPE_FOOTER; | 24 protected int getItemViewType() { |
| 25 return ItemViewType.FOOTER; |
25 } | 26 } |
26 | 27 |
27 @Override | 28 @Override |
28 public void onBindViewHolder(NewTabPageViewHolder holder) { | 29 protected void onBindViewHolder(NewTabPageViewHolder holder) { |
29 // Nothing to do (the footer view is static). | 30 // Nothing to do (the footer view is static). |
30 } | 31 } |
31 | 32 |
32 /** | 33 /** |
33 * The {@code ViewHolder} for the {@link Footer}. | 34 * The {@code ViewHolder} for the {@link Footer}. |
34 */ | 35 */ |
35 public static class ViewHolder extends NewTabPageViewHolder { | 36 public static class ViewHolder extends NewTabPageViewHolder { |
36 public ViewHolder(ViewGroup root, final NewTabPageManager manager) { | 37 public ViewHolder(ViewGroup root, final NewTabPageManager manager) { |
37 super(LayoutInflater.from(root.getContext()) | 38 super(LayoutInflater.from(root.getContext()) |
38 .inflate(R.layout.new_tab_page_footer, root, false))
; | 39 .inflate(R.layout.new_tab_page_footer, root, false))
; |
39 | 40 |
40 NoUnderlineClickableSpan link = new NoUnderlineClickableSpan() { | 41 NoUnderlineClickableSpan link = new NoUnderlineClickableSpan() { |
41 @Override | 42 @Override |
42 public void onClick(View view) { | 43 public void onClick(View view) { |
43 // TODO(mvanouwerkerk): Ensure this can be activated when us
ing TalkBack. | 44 // TODO(mvanouwerkerk): Ensure this can be activated when us
ing TalkBack. |
44 manager.onLearnMoreClicked(); | 45 manager.onLearnMoreClicked(); |
45 } | 46 } |
46 }; | 47 }; |
47 | 48 |
48 TextView textView = (TextView) itemView; | 49 TextView textView = (TextView) itemView; |
49 textView.setText(SpanApplier.applySpans( | 50 textView.setText(SpanApplier.applySpans( |
50 root.getResources().getString(R.string.ntp_learn_more_about_
suggested_content), | 51 root.getResources().getString(R.string.ntp_learn_more_about_
suggested_content), |
51 new SpanApplier.SpanInfo("<link>", "</link>", link))); | 52 new SpanApplier.SpanInfo("<link>", "</link>", link))); |
52 textView.setMovementMethod(LinkMovementMethod.getInstance()); | 53 textView.setMovementMethod(LinkMovementMethod.getInstance()); |
53 } | 54 } |
54 } | 55 } |
55 } | 56 } |
OLD | NEW |