Allow switch preferences to span lines.

Test: manual
Change-Id: Ifcc801873ed143c4d9ceb6fb928c276808a95f81
This commit is contained in:
Julia Reynolds
2017-02-28 16:30:48 -05:00
parent 92033fdb6f
commit 762a733afa
2 changed files with 17 additions and 0 deletions

View File

@@ -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(

View File

@@ -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.