diff options
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/views')
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/views/IconSwitchEntry.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/views/IconSwitchEntry.java b/app/src/main/java/se/leap/bitmaskclient/views/IconSwitchEntry.java index 02347b05..b41f3a50 100644 --- a/app/src/main/java/se/leap/bitmaskclient/views/IconSwitchEntry.java +++ b/app/src/main/java/se/leap/bitmaskclient/views/IconSwitchEntry.java @@ -7,6 +7,7 @@ import android.graphics.drawable.Drawable; import android.support.annotation.DrawableRes; import android.support.annotation.Nullable; import android.support.annotation.StringRes; +import android.support.v7.widget.AppCompatImageView; import android.support.v7.widget.SwitchCompat; import android.util.AttributeSet; import android.view.LayoutInflater; @@ -22,7 +23,7 @@ public class IconSwitchEntry extends LinearLayout { private TextView textView; private TextView subtitleView; - private ImageView iconView; + private AppCompatImageView iconView; private SwitchCompat switchView; private CompoundButton.OnCheckedChangeListener checkedChangeListener; @@ -88,6 +89,10 @@ public class IconSwitchEntry extends LinearLayout { textView.setText(id); } + public void showSubtitle(boolean show) { + subtitleView.setVisibility(show ? VISIBLE : GONE); + } + public void setIcon(@DrawableRes int id) { iconView.setImageResource(id); } @@ -101,4 +106,12 @@ public class IconSwitchEntry extends LinearLayout { switchView.setChecked(isChecked); switchView.setOnCheckedChangeListener(checkedChangeListener); } + + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + switchView.setVisibility(enabled ? VISIBLE : GONE); + textView.setTextColor(getResources().getColor(enabled ? android.R.color.black : R.color.colorDisabled)); + iconView.setImageAlpha(enabled ? 255 : 128); + } } |