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;
9 import android.widget.CompoundButton.OnCheckedChangeListener;
11 import org.chromium.chrome.R;
14 * A check box used to determine if a page should always be translated.
16 public class TranslateCheckBox extends CheckBox implements OnCheckedChangeListener {
17 private static final int TEXT_SIZE_SP = 13;
19 private final SubPanelListener mListener;
20 private final TranslateOptions mOptions;
22 public TranslateCheckBox(Context context, TranslateOptions options, SubPanelListener listener) {
27 setId(R.id.infobar_extra_check);
28 setText(context.getString(R.string.translate_always_text, mOptions.sourceLanguage()));
29 setTextColor(context.getResources().getColor(R.color.default_text_color));
30 setTextSize(TEXT_SIZE_SP);
31 setChecked(mOptions.alwaysTranslateLanguageState());
32 setOnCheckedChangeListener(this);
36 public void onCheckedChanged(CompoundButton view, boolean isChecked) {
37 mOptions.toggleAlwaysTranslateLanguageState(isChecked);
39 mListener.onPanelClosed(InfoBar.ACTION_TYPE_NONE);
41 mListener.onOptionsChanged();