Fix toggle button clickability in app restrictions
Also fix side padding Bug: 17159406 Change-Id: Ic1d61d9a4a7ae6f3f7c451405a6e127791edbdaf
This commit is contained in:
@@ -19,7 +19,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:paddingStart="@*android:dimen/preference_item_padding_side">
|
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||||
|
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" >
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@@ -159,34 +159,17 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
|
|||||||
private boolean panelOpen;
|
private boolean panelOpen;
|
||||||
private boolean immutable;
|
private boolean immutable;
|
||||||
private List<Preference> mChildren = new ArrayList<Preference>();
|
private List<Preference> mChildren = new ArrayList<Preference>();
|
||||||
private final ColorFilter grayscaleFilter;
|
|
||||||
|
|
||||||
AppRestrictionsPreference(Context context, OnClickListener listener) {
|
AppRestrictionsPreference(Context context, OnClickListener listener) {
|
||||||
super(context);
|
super(context);
|
||||||
setLayoutResource(R.layout.preference_app_restrictions);
|
setLayoutResource(R.layout.preference_app_restrictions);
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
|
||||||
ColorMatrix colorMatrix = new ColorMatrix();
|
|
||||||
colorMatrix.setSaturation(0f);
|
|
||||||
float[] matrix = colorMatrix.getArray();
|
|
||||||
matrix[18] = 0.5f;
|
|
||||||
grayscaleFilter = new ColorMatrixColorFilter(colorMatrix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSettingsEnabled(boolean enable) {
|
private void setSettingsEnabled(boolean enable) {
|
||||||
hasSettings = enable;
|
hasSettings = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setChecked(boolean checked) {
|
|
||||||
if (checked) {
|
|
||||||
getIcon().setColorFilter(null);
|
|
||||||
} else {
|
|
||||||
getIcon().setColorFilter(grayscaleFilter);
|
|
||||||
}
|
|
||||||
super.setChecked(checked);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setRestrictions(ArrayList<RestrictionEntry> restrictions) {
|
void setRestrictions(ArrayList<RestrictionEntry> restrictions) {
|
||||||
this.restrictions = restrictions;
|
this.restrictions = restrictions;
|
||||||
}
|
}
|
||||||
@@ -246,6 +229,8 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
|
|||||||
final Switch toggle = (Switch) widget.getChildAt(0);
|
final Switch toggle = (Switch) widget.getChildAt(0);
|
||||||
toggle.setEnabled(!isImmutable());
|
toggle.setEnabled(!isImmutable());
|
||||||
toggle.setTag(this);
|
toggle.setTag(this);
|
||||||
|
toggle.setClickable(true);
|
||||||
|
toggle.setFocusable(true);
|
||||||
toggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
toggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
Reference in New Issue
Block a user