Allow settings preference title to span over multiple lines.

- add singleLineTitle=false to SettingsPreference style, so that it will
not confined the title to a single line.
- remove the custom multi line title from DividerPreference and
MasterSwitchPreference.

Change-Id: I5a78d2cd6ac00c4482e252b0789fd2d265bd9adf
Fix: 34886787
Test: manual
This commit is contained in:
Doris Ling
2017-04-11 13:17:38 -07:00
parent f84c8d3480
commit aa805e70ed
6 changed files with 21 additions and 68 deletions

View File

@@ -136,7 +136,6 @@
<declare-styleable name="DividerPreference"> <declare-styleable name="DividerPreference">
<attr name="allowDividerAbove" format="boolean" /> <attr name="allowDividerAbove" format="boolean" />
<attr name="allowDividerBelow" format="boolean" /> <attr name="allowDividerBelow" format="boolean" />
<attr name="multiLine" format="boolean" />
</declare-styleable> </declare-styleable>
<!-- For GesturePreference --> <!-- For GesturePreference -->

View File

@@ -31,6 +31,7 @@
<style name="SettingsPreference"> <style name="SettingsPreference">
<item name="allowDividerAbove">false</item> <item name="allowDividerAbove">false</item>
<item name="allowDividerBelow">true</item> <item name="allowDividerBelow">true</item>
<item name="singleLineTitle">false</item>
<item name="android:layout">@layout/preference_material_settings</item> <item name="android:layout">@layout/preference_material_settings</item>
</style> </style>

View File

@@ -28,84 +28,64 @@
<PreferenceCategory android:title="@string/enterprise_privacy_exposure_category"> <PreferenceCategory android:title="@string/enterprise_privacy_exposure_category">
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:title="@string/enterprise_privacy_enterprise_data" android:title="@string/enterprise_privacy_enterprise_data"/>
settings:multiLine="true"/>
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:title="@string/enterprise_privacy_installed_packages" android:title="@string/enterprise_privacy_installed_packages"/>
settings:multiLine="true"/>
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:title="@string/enterprise_privacy_usage_stats" android:title="@string/enterprise_privacy_usage_stats"/>
settings:multiLine="true"/>
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:key="network_logs" android:key="network_logs"
android:title="@string/enterprise_privacy_network_logs" android:title="@string/enterprise_privacy_network_logs"/>
settings:multiLine="true"/>
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:key="bug_reports" android:key="bug_reports"
android:title="@string/enterprise_privacy_bug_reports" android:title="@string/enterprise_privacy_bug_reports"/>
settings:multiLine="true"/>
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:key="security_logs" android:key="security_logs"
android:title="@string/enterprise_privacy_security_logs" android:title="@string/enterprise_privacy_security_logs"/>
settings:multiLine="true"/>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/enterprise_privacy_exposure_changes_category"> <PreferenceCategory android:title="@string/enterprise_privacy_exposure_changes_category">
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:key="number_enterprise_installed_packages" android:key="number_enterprise_installed_packages"
android:title="@string/enterprise_privacy_enterprise_installed_packages" android:title="@string/enterprise_privacy_enterprise_installed_packages"/>
settings:multiLine="true"/>
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:key="enterprise_privacy_number_location_access_packages" android:key="enterprise_privacy_number_location_access_packages"
android:title="@string/enterprise_privacy_location_access" android:title="@string/enterprise_privacy_location_access"/>
settings:multiLine="true"/>
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:key="enterprise_privacy_number_microphone_access_packages" android:key="enterprise_privacy_number_microphone_access_packages"
android:title="@string/enterprise_privacy_microphone_access" android:title="@string/enterprise_privacy_microphone_access"/>
settings:multiLine="true"/>
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:key="enterprise_privacy_number_camera_access_packages" android:key="enterprise_privacy_number_camera_access_packages"
android:title="@string/enterprise_privacy_camera_access" android:title="@string/enterprise_privacy_camera_access"/>
settings:multiLine="true"/>
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:key="number_enterprise_set_default_apps" android:key="number_enterprise_set_default_apps"
android:title="@string/enterprise_privacy_enterprise_set_default_apps" android:title="@string/enterprise_privacy_enterprise_set_default_apps"/>
settings:multiLine="true"/>
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:key="always_on_vpn_primary_user" android:key="always_on_vpn_primary_user"/>
settings:multiLine="true"/>
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:key="always_on_vpn_managed_profile" android:key="always_on_vpn_managed_profile"
android:title="@string/enterprise_privacy_always_on_vpn_work" android:title="@string/enterprise_privacy_always_on_vpn_work"/>
settings:multiLine="true"/>
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:key="input_method" android:key="input_method"
android:title="@string/enterprise_privacy_input_method" android:title="@string/enterprise_privacy_input_method"/>
settings:multiLine="true"/>
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:key="global_http_proxy" android:key="global_http_proxy"
android:title="@string/enterprise_privacy_global_http_proxy" android:title="@string/enterprise_privacy_global_http_proxy"/>
settings:multiLine="true"/>
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:key="ca_certs" android:key="ca_certs"
android:title="@string/enterprise_privacy_ca_certs" android:title="@string/enterprise_privacy_ca_certs"/>
settings:multiLine="true"/>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/enterprise_privacy_device_access_category"> <PreferenceCategory android:title="@string/enterprise_privacy_device_access_category">
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:title="@string/enterprise_privacy_lock_device" android:title="@string/enterprise_privacy_lock_device"/>
settings:multiLine="true"/>
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:title="@string/enterprise_privacy_wipe_device" android:title="@string/enterprise_privacy_wipe_device"/>
settings:multiLine="true"/>
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:key="failed_password_wipe_current_user" android:key="failed_password_wipe_current_user"
android:title="@string/enterprise_privacy_failed_password_wipe_device" android:title="@string/enterprise_privacy_failed_password_wipe_device"/>
settings:multiLine="true"/>
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:key="failed_password_wipe_managed_profile" android:key="failed_password_wipe_managed_profile"
android:title="@string/enterprise_privacy_failed_password_wipe_work" android:title="@string/enterprise_privacy_failed_password_wipe_work"/>
settings:multiLine="true"/>
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View File

@@ -25,7 +25,6 @@ public class DividerPreference extends Preference {
private Boolean mAllowAbove; private Boolean mAllowAbove;
private Boolean mAllowBelow; private Boolean mAllowBelow;
private Boolean mMultiLine;
public DividerPreference(Context context, AttributeSet attrs) { public DividerPreference(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
@@ -36,9 +35,6 @@ public class DividerPreference extends Preference {
if (a.hasValue(R.styleable.DividerPreference_allowDividerBelow)) { if (a.hasValue(R.styleable.DividerPreference_allowDividerBelow)) {
mAllowBelow = a.getBoolean(R.styleable.DividerPreference_allowDividerBelow, false); mAllowBelow = a.getBoolean(R.styleable.DividerPreference_allowDividerBelow, false);
} }
if (a.hasValue(R.styleable.DividerPreference_multiLine)) {
mMultiLine = a.getBoolean(R.styleable.DividerPreference_multiLine, false);
}
} }
public DividerPreference(Context context) { public DividerPreference(Context context) {
@@ -64,12 +60,5 @@ public class DividerPreference extends Preference {
if (mAllowBelow != null) { if (mAllowBelow != null) {
holder.setDividerAllowedBelow(mAllowBelow); holder.setDividerAllowedBelow(mAllowBelow);
} }
if (mMultiLine != null && mMultiLine) {
TextView textView = (TextView)holder.findViewById(android.R.id.title);
if (textView != null) {
textView.setSingleLine(false);
}
}
} }
} }

View File

@@ -165,7 +165,6 @@ 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);
channelPref.setSummary(getImportanceSummary(channel.getImportance())); channelPref.setSummary(getImportanceSummary(channel.getImportance()));
Bundle channelArgs = new Bundle(); Bundle channelArgs = new Bundle();
channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mUid); channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mUid);

View File

@@ -36,7 +36,6 @@ public class MasterSwitchPreference extends TwoTargetPreference {
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) {
@@ -81,12 +80,6 @@ public class MasterSwitchPreference extends TwoTargetPreference {
if (mSwitch != null) { if (mSwitch != null) {
mSwitch.setChecked(mChecked); mSwitch.setChecked(mChecked);
} }
if (mMultiLine) {
TextView textView = (TextView) holder.findViewById(android.R.id.title);
if (textView != null) {
textView.setSingleLine(false);
}
}
} }
public boolean isChecked() { public boolean isChecked() {
@@ -106,14 +99,6 @@ public class MasterSwitchPreference extends TwoTargetPreference {
} }
} }
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.