diff options
Diffstat (limited to 'app/src/main/java/net/lacolaco/smileessence/view/ThreeStateButton.java')
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/ThreeStateButton.java | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/app/src/main/java/net/lacolaco/smileessence/view/ThreeStateButton.java b/app/src/main/java/net/lacolaco/smileessence/view/ThreeStateButton.java deleted file mode 100644 index d5358db5..00000000 --- a/app/src/main/java/net/lacolaco/smileessence/view/ThreeStateButton.java +++ /dev/null @@ -1,56 +0,0 @@ -package net.lacolaco.smileessence.view; - -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.drawable.Drawable; -import android.util.AttributeSet; -import android.widget.Button; -import net.lacolaco.smileessence.R; - -public class ThreeStateButton extends Button { - public static final int STATE_OFF = 0; - public static final int STATE_ON = 1; - public static final int STATE_LOCKED = 2; - - private int state = STATE_OFF; - private String texts[] = new String[3]; - private Drawable backgrounds[] = new Drawable[3]; - - public ThreeStateButton(Context context) { - this(context, null); - } - - public ThreeStateButton(Context context, AttributeSet attrs) { - this(context, attrs, android.R.attr.buttonStyle); - } - - public ThreeStateButton(Context context, AttributeSet attrs, int defStyleAttr) { - this(context, attrs, defStyleAttr, 0); - } - - public ThreeStateButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); - - TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ThreeStateButton); - texts[STATE_OFF] = ta.getString(R.styleable.ThreeStateButton_off_text); - texts[STATE_ON] = ta.getString(R.styleable.ThreeStateButton_on_text); - texts[STATE_LOCKED] = ta.getString(R.styleable.ThreeStateButton_locked_text); - backgrounds[STATE_OFF] = ta.getDrawable(R.styleable.ThreeStateButton_off_background); - backgrounds[STATE_ON] = ta.getDrawable(R.styleable.ThreeStateButton_on_background); - backgrounds[STATE_LOCKED] = ta.getDrawable(R.styleable.ThreeStateButton_locked_background); - ta.recycle(); - - setState(STATE_OFF); - } - - public int getState() { - return state; - } - - public void setState(int s) { - state = s; - setText(texts[state]); - setBackground(backgrounds[state]); - setEnabled(state != STATE_LOCKED); - } -} |