Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc714a35 authored by Adam Powell's avatar Adam Powell Committed by Android (Google) Code Review
Browse files

Merge "Fix bug 5205275 - SwitchPreference doesn't allow Switch to slide back and forth."

parents f33bc2df 94f67e2a
Loading
Loading
Loading
Loading
+8 −12
Original line number Diff line number Diff line
@@ -41,14 +41,16 @@ public class SwitchPreference extends TwoStatePreference {
    private CharSequence mSwitchOff;
    private final Listener mListener = new Listener();

    private class Listener implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
    private class Listener implements CompoundButton.OnCheckedChangeListener {
        @Override
        public void onClick(View v) {
            SwitchPreference.this.onClick();
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (!callChangeListener(isChecked)) {
                // Listener didn't like it, change it back.
                // CompoundButton will make sure we don't recurse.
                buttonView.setChecked(!isChecked);
                return;
            }

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            SwitchPreference.this.setChecked(isChecked);
        }
    }
@@ -111,12 +113,6 @@ public class SwitchPreference extends TwoStatePreference {
                switchView.setTextOff(mSwitchOff);
                switchView.setOnCheckedChangeListener(mListener);
            }

            if (checkableView.hasFocusable()) {
                // This is a focusable list item. Attach a click handler to toggle the button
                // for the rest of the item.
                view.setOnClickListener(mListener);
            }
        }

        syncSummaryView(view);
+1 −2
Original line number Diff line number Diff line
@@ -22,5 +22,4 @@
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:padding="16dip"
    android:focusable="false"
    android:clickable="false" />
    android:focusable="false" />