OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 package org.chromium.chrome.browser.infobar; | 4 package org.chromium.chrome.browser.infobar; |
5 | 5 |
6 import android.content.Context; | 6 import android.content.Context; |
7 import android.widget.TextView; | |
8 | 7 |
9 import org.chromium.chrome.R; | 8 import org.chromium.chrome.R; |
10 | 9 |
11 /** | 10 /** |
12 * Options panel shown in the after translate infobar. | 11 * Options panel shown in the after translate infobar. |
13 */ | 12 */ |
14 public class TranslateAlwaysPanel implements TranslateSubPanel { | 13 public class TranslateAlwaysPanel implements TranslateSubPanel { |
15 | 14 |
16 private final TranslateOptions mOptions; | 15 private final TranslateOptions mOptions; |
17 private final SubPanelListener mListener; | 16 private final SubPanelListener mListener; |
18 | 17 |
19 TranslateAlwaysPanel(SubPanelListener listener, TranslateOptions options) { | 18 TranslateAlwaysPanel(SubPanelListener listener, TranslateOptions options) { |
20 mOptions = options; | 19 mOptions = options; |
21 mListener = listener; | 20 mListener = listener; |
22 } | 21 } |
23 | 22 |
24 @Override | 23 @Override |
25 public void createContent(Context context, InfoBarLayout layout) { | 24 public void createContent(Context context, InfoBarLayout layout) { |
26 TextView panelMessage = (TextView) layout.findViewById(R.id.infobar_mess
age); | 25 layout.setMessage(context.getString( |
27 panelMessage.setText(context.getString( | |
28 R.string.translate_infobar_translation_done, mOptions.targetLang
uage())); | 26 R.string.translate_infobar_translation_done, mOptions.targetLang
uage())); |
29 | 27 |
30 if (!mOptions.triggeredFromMenu()) { | 28 if (!mOptions.triggeredFromMenu()) { |
31 TranslateCheckBox checkBox = new TranslateCheckBox(mOptions, mListen
er); | 29 TranslateCheckBox checkBox = new TranslateCheckBox(context, mOptions
, mListener); |
32 checkBox.createContent(context, layout); | 30 layout.setCustomContent(checkBox); |
33 } | 31 } |
34 | 32 |
35 layout.addButtons(context.getString(R.string.translate_button_done), | 33 layout.setButtons(context.getString(R.string.translate_button_done), |
36 context.getString(R.string.translate_show_original)); | 34 context.getString(R.string.translate_show_original)); |
37 } | 35 } |
38 | 36 |
39 @Override | 37 @Override |
40 public void onButtonClicked(boolean primary) { | 38 public void onButtonClicked(boolean primary) { |
41 if (primary) { | 39 if (primary) { |
42 mListener.onPanelClosed(InfoBar.ACTION_TYPE_NONE); | 40 mListener.onPanelClosed(InfoBar.ACTION_TYPE_NONE); |
43 } else { | 41 } else { |
44 mListener.onPanelClosed(InfoBar.ACTION_TYPE_TRANSLATE_SHOW_ORIGINAL)
; | 42 mListener.onPanelClosed(InfoBar.ACTION_TYPE_TRANSLATE_SHOW_ORIGINAL)
; |
45 } | 43 } |
46 } | 44 } |
47 } | 45 } |
OLD | NEW |