From dacbb746c99bd80bd618f1ba14eaa5a969e3b148 Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Thu, 19 May 2011 15:02:50 -0700 Subject: [PATCH] DO NOT MERGE Action bar config changes Handle action bar padding on configuration changes when the app handles these changes itself. Change-Id: I044da9253a0be6b4bbabdc12891b6d4786725afa --- .../internal/widget/ActionBarView.java | 17 +++++++++ .../res/res/layout-w720dp/action_bar_home.xml | 36 ------------------- core/res/res/layout/action_bar_home.xml | 6 ++-- core/res/res/values-w720dp/dimens.xml | 24 +++++++++++++ core/res/res/values/dimens.xml | 8 +++++ 5 files changed, 52 insertions(+), 39 deletions(-) delete mode 100644 core/res/res/layout-w720dp/action_bar_home.xml create mode 100644 core/res/res/values-w720dp/dimens.xml diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java index cc51911501a42..891557df3f6e8 100644 --- a/core/java/com/android/internal/widget/ActionBarView.java +++ b/core/java/com/android/internal/widget/ActionBarView.java @@ -28,6 +28,8 @@ import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; +import android.content.res.Configuration; +import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.text.TextUtils; @@ -979,6 +981,21 @@ public class ActionBarView extends ViewGroup { mIconView = (ImageView) findViewById(com.android.internal.R.id.home); } + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + + // Make sure we reload positioning elements that may change with configuration. + Resources res = getContext().getResources(); + final int imagePadding = res.getDimensionPixelSize( + com.android.internal.R.dimen.action_bar_home_image_padding); + final int upMargin = res.getDimensionPixelSize( + com.android.internal.R.dimen.action_bar_home_up_margin); + mIconView.setPadding(imagePadding, getPaddingTop(), imagePadding, getPaddingBottom()); + ((LayoutParams) mUpView.getLayoutParams()).rightMargin = upMargin; + mUpView.requestLayout(); + } + @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { measureChildWithMargins(mUpView, widthMeasureSpec, 0, heightMeasureSpec, 0); diff --git a/core/res/res/layout-w720dp/action_bar_home.xml b/core/res/res/layout-w720dp/action_bar_home.xml deleted file mode 100644 index ece1a34ab13ae..0000000000000 --- a/core/res/res/layout-w720dp/action_bar_home.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - diff --git a/core/res/res/layout/action_bar_home.xml b/core/res/res/layout/action_bar_home.xml index a45432a3105fb..a4c09627ca6ea 100644 --- a/core/res/res/layout/action_bar_home.xml +++ b/core/res/res/layout/action_bar_home.xml @@ -25,12 +25,12 @@ android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginRight="-4dip" /> + android:layout_marginRight="@dimen/action_bar_home_up_margin" /> diff --git a/core/res/res/values-w720dp/dimens.xml b/core/res/res/values-w720dp/dimens.xml new file mode 100644 index 0000000000000..a74c41c2b0aaa --- /dev/null +++ b/core/res/res/values-w720dp/dimens.xml @@ -0,0 +1,24 @@ + + + + + + -12dip + + 16dip + diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index 05840a4f13b1c..02193c3ad49d2 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -81,4 +81,12 @@ 48dip 48dip + + + -4dip + + 8dip +