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

Commit 762a733a authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Allow switch preferences to span lines.

Test: manual
Change-Id: Ifcc801873ed143c4d9ceb6fb928c276808a95f81
parent 92033fdb
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -184,6 +184,7 @@ public class AppNotificationSettings extends NotificationSettingsBase {
                    channelPref.setKey(channel.getId());
                    channelPref.setKey(channel.getId());
                    channelPref.setTitle(channel.getName());
                    channelPref.setTitle(channel.getName());
                    channelPref.setChecked(channel.getImportance() != IMPORTANCE_NONE);
                    channelPref.setChecked(channel.getImportance() != IMPORTANCE_NONE);
                    channelPref.setMultiLine(true);


                    if (channel.isDeleted()) {
                    if (channel.isDeleted()) {
                        channelPref.setTitle(
                        channelPref.setTitle(
+16 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.widget.CompoundButton;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.Switch;
import android.widget.TextView;


import com.android.settings.R;
import com.android.settings.R;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
@@ -34,6 +35,7 @@ public class MasterSwitchPreference extends Preference {


    private Switch mSwitch;
    private Switch mSwitch;
    private boolean mChecked;
    private boolean mChecked;
    private boolean mMultiLine;


    public MasterSwitchPreference(Context context, AttributeSet attrs,
    public MasterSwitchPreference(Context context, AttributeSet attrs,
            int defStyleAttr, int defStyleRes) {
            int defStyleAttr, int defStyleRes) {
@@ -74,6 +76,12 @@ public class MasterSwitchPreference extends Preference {
                }
                }
            });
            });
        }
        }
        if (mMultiLine) {
            TextView textView = (TextView)holder.findViewById(android.R.id.title);
            if (textView != null) {
                textView.setSingleLine(false);
            }
        }
    }
    }


    public boolean isChecked() {
    public boolean isChecked() {
@@ -97,6 +105,14 @@ public class MasterSwitchPreference extends Preference {
        }
        }
    }
    }


    public boolean isMultiLine() {
        return mMultiLine;
    }

    public void setMultiLine(boolean multiLine) {
        mMultiLine = multiLine;
    }

    /**
    /**
     * If admin is not null, disables the switch.
     * If admin is not null, disables the switch.
     * Otherwise, keep it enabled.
     * Otherwise, keep it enabled.