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
3 // found in the LICENSE file.
4 package org.chromium.chrome.browser.infobar;
6 import android.content.Context;
7 import android.widget.CheckBox;
8 import android.widget.CompoundButton;
11 import org.chromium.chrome.browser.infobar.InfoBar;
12 import org.chromium.chrome.browser.infobar.InfoBarLayout;
13 import org.chromium.chrome.R;
16 * A check box used to determine if a page should always be translated.
18 public class TranslateCheckBox {
19 private final SubPanelListener mListener;
20 private final TranslateOptions mOptions;
22 public TranslateCheckBox(TranslateOptions options, SubPanelListener listener) {
27 public void createContent(Context context, InfoBarLayout layout) {
28 CheckBox checkBox = new CheckBox(context);
29 checkBox.setId(R.id.infobar_extra_check);
30 checkBox.setText(context.getString(R.string.translate_always_text,
31 mOptions.sourceLanguage()));
32 checkBox.setChecked(mOptions.alwaysTranslateLanguageState());
33 checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
35 public void onCheckedChanged(CompoundButton view, boolean isChecked) {
36 mOptions.toggleAlwaysTranslateLanguageState(isChecked);
38 mListener.onPanelClosed(InfoBar.ACTION_TYPE_NONE);
40 mListener.onOptionsChanged();
44 layout.addGroup(checkBox);