1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mobile/android/base/widget/CheckableLinearLayout.java Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,50 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +package org.mozilla.gecko.widget; 1.9 + 1.10 +import org.mozilla.gecko.R; 1.11 + 1.12 +import android.content.Context; 1.13 +import android.util.AttributeSet; 1.14 +import android.widget.CheckBox; 1.15 +import android.widget.Checkable; 1.16 +import android.widget.LinearLayout; 1.17 + 1.18 + 1.19 +public class CheckableLinearLayout extends LinearLayout implements Checkable { 1.20 + 1.21 + private CheckBox mCheckBox; 1.22 + 1.23 + public CheckableLinearLayout(Context context, AttributeSet attrs) { 1.24 + super(context, attrs); 1.25 + } 1.26 + 1.27 + @Override 1.28 + public boolean isChecked() { 1.29 + return mCheckBox != null ? mCheckBox.isChecked() : false; 1.30 + } 1.31 + 1.32 + @Override 1.33 + public void setChecked(boolean isChecked) { 1.34 + if (mCheckBox != null) 1.35 + mCheckBox.setChecked(isChecked); 1.36 + } 1.37 + 1.38 + @Override 1.39 + public void toggle() { 1.40 + if (mCheckBox != null) 1.41 + mCheckBox.toggle(); 1.42 + } 1.43 + 1.44 + @Override 1.45 + protected void onFinishInflate() { 1.46 + super.onFinishInflate(); 1.47 + 1.48 + mCheckBox = (CheckBox) findViewById(R.id.checkbox); 1.49 + mCheckBox.setClickable(false); 1.50 + } 1.51 +} 1.52 + 1.53 +