OSDN Git Service

set correct bounds in ActionBar based on visibility of ActionBarView
authorChet Haase <chet@google.com>
Sat, 13 Sep 2014 01:03:55 +0000 (18:03 -0700)
committerChet Haase <chet@google.com>
Sun, 14 Sep 2014 20:53:10 +0000 (13:53 -0700)
ActionBarContainer was setting the bounds of its background assuming the
visibility of the ActionBarView. But that view becomes GONE when the
ActionBarContextView is visible, causing artifacts such as wrong shadows
when resized (as in custom configuration changes).

Issue #17280341 Quantum: drop shadow on CAB has wrong width after rotation on L, when configuration change is handled by the app

Change-Id: I07e57f00e27b41d5370cb9440b35734a8ec10f3a

core/java/com/android/internal/widget/ActionBarContainer.java

index 8111e63..0105f51 100644 (file)
@@ -39,6 +39,7 @@ public class ActionBarContainer extends FrameLayout {
     private boolean mIsTransitioning;
     private View mTabContainer;
     private View mActionBarView;
+    private View mActionContextView;
 
     private Drawable mBackground;
     private Drawable mStackedBackground;
@@ -79,6 +80,7 @@ public class ActionBarContainer extends FrameLayout {
     public void onFinishInflate() {
         super.onFinishInflate();
         mActionBarView = findViewById(com.android.internal.R.id.action_bar);
+        mActionContextView = findViewById(com.android.internal.R.id.action_context_bar);
     }
 
     public void setPrimaryBackground(Drawable bg) {
@@ -312,8 +314,16 @@ public class ActionBarContainer extends FrameLayout {
             }
         } else {
             if (mBackground != null) {
-                mBackground.setBounds(mActionBarView.getLeft(), mActionBarView.getTop(),
-                        mActionBarView.getRight(), mActionBarView.getBottom());
+                if (mActionBarView.getVisibility() == View.VISIBLE) {
+                    mBackground.setBounds(mActionBarView.getLeft(), mActionBarView.getTop(),
+                            mActionBarView.getRight(), mActionBarView.getBottom());
+                } else if (mActionContextView != null &&
+                        mActionContextView.getVisibility() == View.VISIBLE) {
+                    mBackground.setBounds(mActionContextView.getLeft(), mActionContextView.getTop(),
+                            mActionContextView.getRight(), mActionContextView.getBottom());
+                } else {
+                    mBackground.setBounds(0, 0, 0, 0);
+                }
                 needsInvalidate = true;
             }
             mIsStacked = hasTabs;