Loading core/java/android/preference/PreferenceFrameLayout.java +86 −27 Original line number Diff line number Diff line Loading @@ -20,16 +20,22 @@ import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup.MarginLayoutParams; import android.widget.FrameLayout; import android.widget.FrameLayout.LayoutParams; /** * @hide */ public class PreferenceFrameLayout extends FrameLayout { private static final int DEFAULT_TOP_PADDING = 0; private static final int DEFAULT_BOTTOM_PADDING = 0; private final int mTopPadding; private final int mBottomPadding; private static final int DEFAULT_BORDER_TOP = 0; private static final int DEFAULT_BORDER_BOTTOM = 0; private static final int DEFAULT_BORDER_LEFT = 0; private static final int DEFAULT_BORDER_RIGHT = 0; private final int mBorderTop; private final int mBorderBottom; private final int mBorderLeft; private final int mBorderRight; private boolean mPaddingApplied = false; public PreferenceFrameLayout(Context context) { Loading @@ -46,45 +52,98 @@ public class PreferenceFrameLayout extends FrameLayout { com.android.internal.R.styleable.PreferenceFrameLayout, defStyle, 0); float density = context.getResources().getDisplayMetrics().density; int defaultTopPadding = (int) (density * DEFAULT_TOP_PADDING + 0.5f); int defaultBottomPadding = (int) (density * DEFAULT_BOTTOM_PADDING + 0.5f); mTopPadding = a.getDimensionPixelSize( com.android.internal.R.styleable.PreferenceFrameLayout_topPadding, defaultTopPadding); mBottomPadding = a.getDimensionPixelSize( com.android.internal.R.styleable.PreferenceFrameLayout_bottomPadding, defaultBottomPadding); int defaultBorderTop = (int) (density * DEFAULT_BORDER_TOP + 0.5f); int defaultBottomPadding = (int) (density * DEFAULT_BORDER_BOTTOM + 0.5f); int defaultLeftPadding = (int) (density * DEFAULT_BORDER_LEFT + 0.5f); int defaultRightPadding = (int) (density * DEFAULT_BORDER_RIGHT + 0.5f); mBorderTop = a.getDimensionPixelSize( com.android.internal.R.styleable.PreferenceFrameLayout_borderTop, defaultBorderTop); mBorderBottom = a.getDimensionPixelSize( com.android.internal.R.styleable.PreferenceFrameLayout_borderBottom, defaultBottomPadding); mBorderLeft = a.getDimensionPixelSize( com.android.internal.R.styleable.PreferenceFrameLayout_borderLeft, defaultLeftPadding); mBorderRight = a.getDimensionPixelSize( com.android.internal.R.styleable.PreferenceFrameLayout_borderRight, defaultRightPadding); a.recycle(); } /** * {@inheritDoc} */ @Override public LayoutParams generateLayoutParams(AttributeSet attrs) { return new LayoutParams(getContext(), attrs); } @Override public void addView(View child) { int topPadding = getPaddingTop(); int bottomPadding = getPaddingBottom(); int borderTop = getPaddingTop(); int borderBottom = getPaddingBottom(); int borderLeft = getPaddingLeft(); int borderRight = getPaddingRight(); LayoutParams layoutParams = (PreferenceFrameLayout.LayoutParams) child.getLayoutParams(); // Check on the id of the child before adding it. if (child != null && child.getId() != com.android.internal.R.id.default_preference_layout) { // Add the padding to the view group after determining if the padding already exists. if (!mPaddingApplied) { topPadding += mTopPadding; bottomPadding += mBottomPadding; mPaddingApplied = true; } } else { if (layoutParams != null && layoutParams.removeBorders) { if (mPaddingApplied) { topPadding -= mTopPadding; bottomPadding -= mBottomPadding; borderTop -= mBorderTop; borderBottom -= mBorderBottom; borderLeft -= mBorderLeft; borderRight -= mBorderRight; mPaddingApplied = false; } } else { // Add the padding to the view group after determining if the // padding already exists. if (!mPaddingApplied) { borderTop += mBorderTop; borderBottom += mBorderBottom; borderLeft += mBorderLeft; borderRight += mBorderRight; mPaddingApplied = true; } } int previousTop = getPaddingTop(); int previousBottom = getPaddingBottom(); if (previousTop != topPadding || previousBottom != bottomPadding) { setPadding(getPaddingLeft(), topPadding, getPaddingRight(), bottomPadding); int previousLeft = getPaddingLeft(); int previousRight = getPaddingRight(); if (previousTop != borderTop || previousBottom != borderBottom || previousLeft != borderLeft || previousRight != borderRight) { setPadding(borderLeft, borderTop, borderRight, borderBottom); } super.addView(child); } public static class LayoutParams extends FrameLayout.LayoutParams { public boolean removeBorders = false; /** * {@inheritDoc} */ public LayoutParams(Context c, AttributeSet attrs) { super(c, attrs); TypedArray a = c.obtainStyledAttributes(attrs, com.android.internal.R.styleable.PreferenceFrameLayout_Layout); removeBorders = a.getBoolean( com.android.internal.R.styleable.PreferenceFrameLayout_Layout_layout_removeBorders, false); a.recycle(); } /** * {@inheritDoc} */ public LayoutParams(int width, int height) { super(width, height); } } } No newline at end of file core/res/res/layout/preference_list_content.xml +0 −2 Original line number Diff line number Diff line Loading @@ -64,8 +64,6 @@ android:layout_marginRight="@dimen/preference_screen_side_margin" android:layout_marginTop="16dp" android:layout_marginBottom="16dp" android:paddingLeft="32dip" android:paddingRight="32dip" android:background="?attr/preferencePanelBackground" android:visibility="gone" /> </LinearLayout> Loading core/res/res/layout/preference_list_fragment.xml +4 −2 Original line number Diff line number Diff line Loading @@ -18,11 +18,11 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/default_preference_layout" android:orientation="vertical" android:layout_height="match_parent" android:layout_width="match_parent" android:background="@android:color/transparent"> android:background="@android:color/transparent" android:layout_removeBorders="true"> <ListView android:id="@android:id/list" android:layout_width="match_parent" Loading @@ -30,6 +30,8 @@ android:layout_weight="1" android:paddingTop="48dip" android:paddingBottom="48dip" android:paddingLeft="32dip" android:paddingRight="32dip" android:clipToPadding="false" android:drawSelectorOnTop="false" android:cacheColorHint="@android:color/transparent" Loading core/res/res/values/attrs.xml +10 −2 Original line number Diff line number Diff line Loading @@ -2201,9 +2201,17 @@ </declare-styleable> <declare-styleable name="PreferenceFrameLayout"> <!-- Padding to use at the top of the prefs content. --> <attr name="topPadding" format="dimension" /> <attr name="borderTop" format="dimension" /> <!-- Padding to use at the bottom of the prefs content. --> <attr name="bottomPadding" format="dimension" /> <attr name="borderBottom" format="dimension" /> <!-- Padding to use at the left of the prefs content. --> <attr name="borderLeft" format="dimension" /> <!-- Padding to use at the right of the prefs content. --> <attr name="borderRight" format="dimension" /> </declare-styleable> <declare-styleable name="PreferenceFrameLayout_Layout"> <!-- Padding to use at the top of the prefs content. --> <attr name="layout_removeBorders" format="boolean" /> </declare-styleable> <declare-styleable name="MenuView"> <!-- Default appearance of menu item text. --> Loading core/res/res/values/styles.xml +8 −4 Original line number Diff line number Diff line Loading @@ -50,8 +50,10 @@ </style> <style name="Widget.PreferenceFrameLayout"> <item name="android:topPadding">0dip</item> <item name="android:bottomPadding">0dip</item> <item name="android:borderTop">0dip</item> <item name="android:borderBottom">0dip</item> <item name="android:borderLeft">0dip</item> <item name="android:borderRight">0dip</item> </style> <!-- Base style for animations. This style specifies no animations. --> Loading Loading @@ -1962,7 +1964,9 @@ </style> <style name="Widget.Holo.PreferenceFrameLayout"> <item name="android:topPadding">48dip</item> <item name="android:bottomPadding">48dip</item> <item name="android:borderTop">48dip</item> <item name="android:borderBottom">48dip</item> <item name="android:borderLeft">32dip</item> <item name="android:borderRight">32dip</item> </style> </resources> Loading
core/java/android/preference/PreferenceFrameLayout.java +86 −27 Original line number Diff line number Diff line Loading @@ -20,16 +20,22 @@ import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup.MarginLayoutParams; import android.widget.FrameLayout; import android.widget.FrameLayout.LayoutParams; /** * @hide */ public class PreferenceFrameLayout extends FrameLayout { private static final int DEFAULT_TOP_PADDING = 0; private static final int DEFAULT_BOTTOM_PADDING = 0; private final int mTopPadding; private final int mBottomPadding; private static final int DEFAULT_BORDER_TOP = 0; private static final int DEFAULT_BORDER_BOTTOM = 0; private static final int DEFAULT_BORDER_LEFT = 0; private static final int DEFAULT_BORDER_RIGHT = 0; private final int mBorderTop; private final int mBorderBottom; private final int mBorderLeft; private final int mBorderRight; private boolean mPaddingApplied = false; public PreferenceFrameLayout(Context context) { Loading @@ -46,45 +52,98 @@ public class PreferenceFrameLayout extends FrameLayout { com.android.internal.R.styleable.PreferenceFrameLayout, defStyle, 0); float density = context.getResources().getDisplayMetrics().density; int defaultTopPadding = (int) (density * DEFAULT_TOP_PADDING + 0.5f); int defaultBottomPadding = (int) (density * DEFAULT_BOTTOM_PADDING + 0.5f); mTopPadding = a.getDimensionPixelSize( com.android.internal.R.styleable.PreferenceFrameLayout_topPadding, defaultTopPadding); mBottomPadding = a.getDimensionPixelSize( com.android.internal.R.styleable.PreferenceFrameLayout_bottomPadding, defaultBottomPadding); int defaultBorderTop = (int) (density * DEFAULT_BORDER_TOP + 0.5f); int defaultBottomPadding = (int) (density * DEFAULT_BORDER_BOTTOM + 0.5f); int defaultLeftPadding = (int) (density * DEFAULT_BORDER_LEFT + 0.5f); int defaultRightPadding = (int) (density * DEFAULT_BORDER_RIGHT + 0.5f); mBorderTop = a.getDimensionPixelSize( com.android.internal.R.styleable.PreferenceFrameLayout_borderTop, defaultBorderTop); mBorderBottom = a.getDimensionPixelSize( com.android.internal.R.styleable.PreferenceFrameLayout_borderBottom, defaultBottomPadding); mBorderLeft = a.getDimensionPixelSize( com.android.internal.R.styleable.PreferenceFrameLayout_borderLeft, defaultLeftPadding); mBorderRight = a.getDimensionPixelSize( com.android.internal.R.styleable.PreferenceFrameLayout_borderRight, defaultRightPadding); a.recycle(); } /** * {@inheritDoc} */ @Override public LayoutParams generateLayoutParams(AttributeSet attrs) { return new LayoutParams(getContext(), attrs); } @Override public void addView(View child) { int topPadding = getPaddingTop(); int bottomPadding = getPaddingBottom(); int borderTop = getPaddingTop(); int borderBottom = getPaddingBottom(); int borderLeft = getPaddingLeft(); int borderRight = getPaddingRight(); LayoutParams layoutParams = (PreferenceFrameLayout.LayoutParams) child.getLayoutParams(); // Check on the id of the child before adding it. if (child != null && child.getId() != com.android.internal.R.id.default_preference_layout) { // Add the padding to the view group after determining if the padding already exists. if (!mPaddingApplied) { topPadding += mTopPadding; bottomPadding += mBottomPadding; mPaddingApplied = true; } } else { if (layoutParams != null && layoutParams.removeBorders) { if (mPaddingApplied) { topPadding -= mTopPadding; bottomPadding -= mBottomPadding; borderTop -= mBorderTop; borderBottom -= mBorderBottom; borderLeft -= mBorderLeft; borderRight -= mBorderRight; mPaddingApplied = false; } } else { // Add the padding to the view group after determining if the // padding already exists. if (!mPaddingApplied) { borderTop += mBorderTop; borderBottom += mBorderBottom; borderLeft += mBorderLeft; borderRight += mBorderRight; mPaddingApplied = true; } } int previousTop = getPaddingTop(); int previousBottom = getPaddingBottom(); if (previousTop != topPadding || previousBottom != bottomPadding) { setPadding(getPaddingLeft(), topPadding, getPaddingRight(), bottomPadding); int previousLeft = getPaddingLeft(); int previousRight = getPaddingRight(); if (previousTop != borderTop || previousBottom != borderBottom || previousLeft != borderLeft || previousRight != borderRight) { setPadding(borderLeft, borderTop, borderRight, borderBottom); } super.addView(child); } public static class LayoutParams extends FrameLayout.LayoutParams { public boolean removeBorders = false; /** * {@inheritDoc} */ public LayoutParams(Context c, AttributeSet attrs) { super(c, attrs); TypedArray a = c.obtainStyledAttributes(attrs, com.android.internal.R.styleable.PreferenceFrameLayout_Layout); removeBorders = a.getBoolean( com.android.internal.R.styleable.PreferenceFrameLayout_Layout_layout_removeBorders, false); a.recycle(); } /** * {@inheritDoc} */ public LayoutParams(int width, int height) { super(width, height); } } } No newline at end of file
core/res/res/layout/preference_list_content.xml +0 −2 Original line number Diff line number Diff line Loading @@ -64,8 +64,6 @@ android:layout_marginRight="@dimen/preference_screen_side_margin" android:layout_marginTop="16dp" android:layout_marginBottom="16dp" android:paddingLeft="32dip" android:paddingRight="32dip" android:background="?attr/preferencePanelBackground" android:visibility="gone" /> </LinearLayout> Loading
core/res/res/layout/preference_list_fragment.xml +4 −2 Original line number Diff line number Diff line Loading @@ -18,11 +18,11 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/default_preference_layout" android:orientation="vertical" android:layout_height="match_parent" android:layout_width="match_parent" android:background="@android:color/transparent"> android:background="@android:color/transparent" android:layout_removeBorders="true"> <ListView android:id="@android:id/list" android:layout_width="match_parent" Loading @@ -30,6 +30,8 @@ android:layout_weight="1" android:paddingTop="48dip" android:paddingBottom="48dip" android:paddingLeft="32dip" android:paddingRight="32dip" android:clipToPadding="false" android:drawSelectorOnTop="false" android:cacheColorHint="@android:color/transparent" Loading
core/res/res/values/attrs.xml +10 −2 Original line number Diff line number Diff line Loading @@ -2201,9 +2201,17 @@ </declare-styleable> <declare-styleable name="PreferenceFrameLayout"> <!-- Padding to use at the top of the prefs content. --> <attr name="topPadding" format="dimension" /> <attr name="borderTop" format="dimension" /> <!-- Padding to use at the bottom of the prefs content. --> <attr name="bottomPadding" format="dimension" /> <attr name="borderBottom" format="dimension" /> <!-- Padding to use at the left of the prefs content. --> <attr name="borderLeft" format="dimension" /> <!-- Padding to use at the right of the prefs content. --> <attr name="borderRight" format="dimension" /> </declare-styleable> <declare-styleable name="PreferenceFrameLayout_Layout"> <!-- Padding to use at the top of the prefs content. --> <attr name="layout_removeBorders" format="boolean" /> </declare-styleable> <declare-styleable name="MenuView"> <!-- Default appearance of menu item text. --> Loading
core/res/res/values/styles.xml +8 −4 Original line number Diff line number Diff line Loading @@ -50,8 +50,10 @@ </style> <style name="Widget.PreferenceFrameLayout"> <item name="android:topPadding">0dip</item> <item name="android:bottomPadding">0dip</item> <item name="android:borderTop">0dip</item> <item name="android:borderBottom">0dip</item> <item name="android:borderLeft">0dip</item> <item name="android:borderRight">0dip</item> </style> <!-- Base style for animations. This style specifies no animations. --> Loading Loading @@ -1962,7 +1964,9 @@ </style> <style name="Widget.Holo.PreferenceFrameLayout"> <item name="android:topPadding">48dip</item> <item name="android:bottomPadding">48dip</item> <item name="android:borderTop">48dip</item> <item name="android:borderBottom">48dip</item> <item name="android:borderLeft">32dip</item> <item name="android:borderRight">32dip</item> </style> </resources>