Manual merge. Preference activity changes to work on smaller tablet screens and phones.
Padding around fragments and to the left of preference items
adjusted for different display sizes.
Change-Id: I2d29e5525c381092a3f1d2fb1265ce07db893d78
diff --git a/core/java/android/preference/Preference.java b/core/java/android/preference/Preference.java
index 5e1be21..b6d1594 100644
--- a/core/java/android/preference/Preference.java
+++ b/core/java/android/preference/Preference.java
@@ -472,11 +472,15 @@
final View layout = layoutInflater.inflate(mLayoutResId, parent, false);
- if (mWidgetLayoutResId != 0) {
- final ViewGroup widgetFrame = (ViewGroup)layout.findViewById(com.android.internal.R.id.widget_frame);
- layoutInflater.inflate(mWidgetLayoutResId, widgetFrame);
+ final ViewGroup widgetFrame = (ViewGroup) layout
+ .findViewById(com.android.internal.R.id.widget_frame);
+ if (widgetFrame != null) {
+ if (mWidgetLayoutResId != 0) {
+ layoutInflater.inflate(mWidgetLayoutResId, widgetFrame);
+ } else {
+ widgetFrame.setVisibility(View.GONE);
+ }
}
-
return layout;
}
@@ -514,14 +518,18 @@
}
ImageView imageView = (ImageView) view.findViewById(com.android.internal.R.id.icon);
- if (imageView != null && (mIconResId != 0 || mIcon != null)) {
- if (mIcon == null) {
- mIcon = getContext().getResources().getDrawable(mIconResId);
+ if (imageView != null) {
+ if (mIconResId != 0 || mIcon != null) {
+ if (mIcon == null) {
+ mIcon = getContext().getResources().getDrawable(mIconResId);
+ }
+ if (mIcon != null) {
+ imageView.setImageDrawable(mIcon);
+ }
}
- if (mIcon != null) {
- imageView.setImageDrawable(mIcon);
- }
+ imageView.setVisibility(mIcon != null ? View.VISIBLE : View.GONE);
}
+
if (mShouldDisableView) {
setEnabledStateOnViews(view, isEnabled());
}
@@ -633,6 +641,7 @@
public void setIcon(Drawable icon) {
if ((icon == null && mIcon != null) || (icon != null && mIcon != icon)) {
mIcon = icon;
+
notifyChanged();
}
}