summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2012-10-19 11:33:00 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-10-19 11:33:01 -0700
commit398a6713c355cf59af071e944268aec7c0096b5a (patch)
tree19c57689e7738fe9cac071f86951b5b92ff41502 /core/java
parentba0372db366e63fa928ba83f3ad8c064c51ac8e0 (diff)
parentb003e28c1d65d06fcb5690ff2955d007d8f7a626 (diff)
downloadframeworks_base-398a6713c355cf59af071e944268aec7c0096b5a.zip
frameworks_base-398a6713c355cf59af071e944268aec7c0096b5a.tar.gz
frameworks_base-398a6713c355cf59af071e944268aec7c0096b5a.tar.bz2
Merge "Fix bug #7367429 Popup window should get its direction from it Anchor View if it can" into jb-mr1-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/view/ViewRootImpl.java11
-rw-r--r--core/java/android/widget/PopupWindow.java20
2 files changed, 27 insertions, 4 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 67452ec..8a82a54 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -317,6 +317,8 @@ public final class ViewRootImpl implements ViewParent,
private final int mDensity;
private final int mNoncompatDensity;
+ private int mViewLayoutDirectionInitial;
+
/**
* Consistency verifier for debugging purposes.
*/
@@ -465,6 +467,7 @@ public final class ViewRootImpl implements ViewParent,
synchronized (this) {
if (mView == null) {
mView = view;
+ mViewLayoutDirectionInitial = mView.getRawLayoutDirection();
mFallbackEventHandler.setView(view);
mWindowAttributes.copyFrom(attrs);
attrs = mWindowAttributes;
@@ -1186,7 +1189,10 @@ public final class ViewRootImpl implements ViewParent,
viewVisibilityChanged = false;
mLastConfiguration.setTo(host.getResources().getConfiguration());
mLastSystemUiVisibility = mAttachInfo.mSystemUiVisibility;
- host.setLayoutDirection(mLastConfiguration.getLayoutDirection());
+ // Set the layout direction if it has not been set before (inherit is the default)
+ if (mViewLayoutDirectionInitial == View.LAYOUT_DIRECTION_INHERIT) {
+ host.setLayoutDirection(mLastConfiguration.getLayoutDirection());
+ }
host.dispatchAttachedToWindow(attachInfo, 0);
mFitSystemWindowsInsets.set(mAttachInfo.mContentInsets);
host.fitSystemWindows(mFitSystemWindowsInsets);
@@ -2682,7 +2688,8 @@ public final class ViewRootImpl implements ViewParent,
final int lastLayoutDirection = mLastConfiguration.getLayoutDirection();
final int currentLayoutDirection = config.getLayoutDirection();
mLastConfiguration.setTo(config);
- if (lastLayoutDirection != currentLayoutDirection) {
+ if (lastLayoutDirection != currentLayoutDirection &&
+ mViewLayoutDirectionInitial == View.LAYOUT_DIRECTION_INHERIT) {
mView.setLayoutDirection(currentLayoutDirection);
}
mView.dispatchConfigurationChanged(config);
diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java
index af3365e..b71649a 100644
--- a/core/java/android/widget/PopupWindow.java
+++ b/core/java/android/widget/PopupWindow.java
@@ -142,6 +142,8 @@ public class PopupWindow {
};
private int mAnchorXoff, mAnchorYoff;
+ private boolean mPopupViewInitialLayoutDirectionInherited;
+
/**
* <p>Create a new empty, non focusable popup window of dimension (0,0).</p>
*
@@ -968,6 +970,8 @@ public class PopupWindow {
} else {
mPopupView = mContentView;
}
+ mPopupViewInitialLayoutDirectionInherited =
+ (mPopupView.getRawLayoutDirection() == View.LAYOUT_DIRECTION_INHERIT);
mPopupWidth = p.width;
mPopupHeight = p.height;
}
@@ -985,9 +989,19 @@ public class PopupWindow {
p.packageName = mContext.getPackageName();
}
mPopupView.setFitsSystemWindows(mLayoutInsetDecor);
+ setLayoutDirectionFromAnchor();
mWindowManager.addView(mPopupView, p);
}
+ private void setLayoutDirectionFromAnchor() {
+ if (mAnchor != null) {
+ View anchor = mAnchor.get();
+ if (anchor != null && mPopupViewInitialLayoutDirectionInherited) {
+ mPopupView.setLayoutDirection(anchor.getLayoutDirection());
+ }
+ }
+ }
+
/**
* <p>Generate the layout parameters for the popup window.</p>
*
@@ -1304,8 +1318,9 @@ public class PopupWindow {
p.flags = newFlags;
update = true;
}
-
+
if (update) {
+ setLayoutDirectionFromAnchor();
mWindowManager.updateViewLayout(mPopupView, p);
}
}
@@ -1406,6 +1421,7 @@ public class PopupWindow {
}
if (update) {
+ setLayoutDirectionFromAnchor();
mWindowManager.updateViewLayout(mPopupView, p);
}
}
@@ -1482,7 +1498,7 @@ public class PopupWindow {
} else {
updateAboveAnchor(findDropDownPosition(anchor, p, mAnchorXoff, mAnchorYoff));
}
-
+
update(p.x, p.y, width, height, x != p.x || y != p.y);
}