summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.txt3
-rw-r--r--api/system-current.txt3
-rw-r--r--api/test-current.txt3
-rw-r--r--core/java/android/preference/Preference.java28
-rw-r--r--core/res/res/values/attrs.xml3
-rw-r--r--core/res/res/values/public.xml1
6 files changed, 41 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt
index 6880c0ba18e6..8f2360fa908f 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -1179,6 +1179,7 @@ package android {
field public static final deprecated int shownWeekCount = 16843585; // 0x1010341
field public static final int shrinkColumns = 16843082; // 0x101014a
field public static final deprecated int singleLine = 16843101; // 0x101015d
+ field public static final int singleLineTitle = 16844127; // 0x101055f
field public static final int singleUser = 16843711; // 0x10103bf
field public static final int slideEdge = 16843824; // 0x1010430
field public static final int smallIcon = 16843422; // 0x101029e
@@ -32000,6 +32001,7 @@ package android.preference {
method public boolean isPersistent();
method public boolean isRecycleEnabled();
method public boolean isSelectable();
+ method public boolean isSingleLineTitle();
method protected void notifyChanged();
method public void notifyDependencyChange(boolean);
method protected void notifyHierarchyChanged();
@@ -32041,6 +32043,7 @@ package android.preference {
method public void setRecycleEnabled(boolean);
method public void setSelectable(boolean);
method public void setShouldDisableView(boolean);
+ method public void setSingleLineTitle(boolean);
method public void setSummary(java.lang.CharSequence);
method public void setSummary(int);
method public void setTitle(java.lang.CharSequence);
diff --git a/api/system-current.txt b/api/system-current.txt
index 3dac882e2d04..65f443a65bf7 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -1296,6 +1296,7 @@ package android {
field public static final deprecated int shownWeekCount = 16843585; // 0x1010341
field public static final int shrinkColumns = 16843082; // 0x101014a
field public static final deprecated int singleLine = 16843101; // 0x101015d
+ field public static final int singleLineTitle = 16844127; // 0x101055f
field public static final int singleUser = 16843711; // 0x10103bf
field public static final int slideEdge = 16843824; // 0x1010430
field public static final int smallIcon = 16843422; // 0x101029e
@@ -34852,6 +34853,7 @@ package android.preference {
method public boolean isPersistent();
method public boolean isRecycleEnabled();
method public boolean isSelectable();
+ method public boolean isSingleLineTitle();
method protected void notifyChanged();
method public void notifyDependencyChange(boolean);
method protected void notifyHierarchyChanged();
@@ -34893,6 +34895,7 @@ package android.preference {
method public void setRecycleEnabled(boolean);
method public void setSelectable(boolean);
method public void setShouldDisableView(boolean);
+ method public void setSingleLineTitle(boolean);
method public void setSummary(java.lang.CharSequence);
method public void setSummary(int);
method public void setTitle(java.lang.CharSequence);
diff --git a/api/test-current.txt b/api/test-current.txt
index a891fde573b2..7d6f5eee1e59 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -1179,6 +1179,7 @@ package android {
field public static final deprecated int shownWeekCount = 16843585; // 0x1010341
field public static final int shrinkColumns = 16843082; // 0x101014a
field public static final deprecated int singleLine = 16843101; // 0x101015d
+ field public static final int singleLineTitle = 16844127; // 0x101055f
field public static final int singleUser = 16843711; // 0x10103bf
field public static final int slideEdge = 16843824; // 0x1010430
field public static final int smallIcon = 16843422; // 0x101029e
@@ -32125,6 +32126,7 @@ package android.preference {
method public boolean isPersistent();
method public boolean isRecycleEnabled();
method public boolean isSelectable();
+ method public boolean isSingleLineTitle();
method protected void notifyChanged();
method public void notifyDependencyChange(boolean);
method protected void notifyHierarchyChanged();
@@ -32166,6 +32168,7 @@ package android.preference {
method public void setRecycleEnabled(boolean);
method public void setSelectable(boolean);
method public void setShouldDisableView(boolean);
+ method public void setSingleLineTitle(boolean);
method public void setSummary(java.lang.CharSequence);
method public void setSummary(int);
method public void setTitle(java.lang.CharSequence);
diff --git a/core/java/android/preference/Preference.java b/core/java/android/preference/Preference.java
index d9c749a65d0f..4d14277be9c1 100644
--- a/core/java/android/preference/Preference.java
+++ b/core/java/android/preference/Preference.java
@@ -82,6 +82,7 @@ import java.util.Set;
* @attr ref android.R.styleable#Preference_defaultValue
* @attr ref android.R.styleable#Preference_shouldDisableView
* @attr ref android.R.styleable#Preference_recycleEnabled
+ * @attr ref android.R.styleable#Preference_singleLineTitle
*/
public class Preference implements Comparable<Preference> {
/**
@@ -133,6 +134,7 @@ public class Preference implements Comparable<Preference> {
private boolean mDependencyMet = true;
private boolean mParentDependencyMet = true;
private boolean mRecycleEnabled = true;
+ private boolean mSingleLineTitle = true;
/**
* @see #setShouldDisableView(boolean)
@@ -296,6 +298,10 @@ public class Preference implements Comparable<Preference> {
case com.android.internal.R.styleable.Preference_recycleEnabled:
mRecycleEnabled = a.getBoolean(attr, mRecycleEnabled);
break;
+
+ case com.android.internal.R.styleable.Preference_singleLineTitle:
+ mSingleLineTitle = a.getBoolean(attr, mSingleLineTitle);
+ break;
}
}
a.recycle();
@@ -597,6 +603,7 @@ public class Preference implements Comparable<Preference> {
if (!TextUtils.isEmpty(title)) {
titleView.setText(title);
titleView.setVisibility(View.VISIBLE);
+ titleView.setSingleLine(mSingleLineTitle);
} else {
titleView.setVisibility(View.GONE);
}
@@ -903,6 +910,27 @@ public class Preference implements Comparable<Preference> {
}
/**
+ * Sets whether to constrain the title of this Preference to a single line instead of
+ * letting it wrap onto multiple lines.
+ *
+ * @param singleLineTitle set {@code true} if the title should be constrained to one line
+ */
+ public void setSingleLineTitle(boolean singleLineTitle) {
+ mSingleLineTitle = singleLineTitle;
+ notifyChanged();
+ }
+
+ /**
+ * Gets whether the title of this preference is constrained to a single line.
+ *
+ * @see #setSingleLineTitle(boolean)
+ * @return {@code true} if the title of this preference is constrained to a single line
+ */
+ public boolean isSingleLineTitle() {
+ return mSingleLineTitle;
+ }
+
+ /**
* Returns a unique ID for this Preference. This ID should be unique across all
* Preference objects in a hierarchy.
*
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 4432e3c90f1a..9401f0e174d8 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -7198,6 +7198,9 @@
<!-- Whether the preference has enabled to have its view recycled when used in the list
view. This is true by default. -->
<attr name="recycleEnabled" format="boolean" />
+ <!-- Whether to use single line for the preference title text. By default, preference title
+ will be constrained to one line, so the default value of this attribute is true. -->
+ <attr name="singleLineTitle" format="boolean" />
</declare-styleable>
<!-- Base attributes available to CheckBoxPreference. -->
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index f965c6954948..8b1b9d39a471 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2808,6 +2808,7 @@
<public name="recycleEnabled"/>
<public name="isStatic" />
<public name="isFeatureSplit" />
+ <public name="singleLineTitle" />
</public-group>
<public-group type="style" first-id="0x010302e0">