much better reaction to opening/ closing details for a message after zooming
when the user taps show / hide details, scroll the webview up (show) or down (hide)
enough to compensate for the difference in header height.
fixes b/6319197 After pinch zooming, expanding the message details causes the message headers to jump
Change-Id: I64ced1b9a1d411fa0fa34a179f2ae629fc993088
diff --git a/src/com/android/mail/ui/ConversationViewFragment.java b/src/com/android/mail/ui/ConversationViewFragment.java
index f2a4009..fd35d78 100644
--- a/src/com/android/mail/ui/ConversationViewFragment.java
+++ b/src/com/android/mail/ui/ConversationViewFragment.java
@@ -93,6 +93,11 @@
public static final String LAYOUT_TAG = "ConvLayout";
/**
+ * Difference in the height of the message header whose details have been expanded/collapsed
+ */
+ private int mDiff = 0;
+
+ /**
* Default value for {@link #mLoadWaitReason}. Conversation load will happen immediately.
*/
private final int LOAD_NOW = 0;
@@ -872,15 +877,23 @@
public void onWebContentGeometryChange(final String[] overlayBottomStrs) {
try {
getHandler().post(new Runnable() {
+
@Override
public void run() {
if (!mViewsCreated) {
- LogUtils.d(LOG_TAG, "ignoring webContentGeometryChange because views" +
- " are gone, %s", ConversationViewFragment.this);
+ LogUtils.d(LOG_TAG, "ignoring webContentGeometryChange because views"
+ + " are gone, %s", ConversationViewFragment.this);
return;
}
-
mConversationContainer.onGeometryChange(parseInts(overlayBottomStrs));
+ if (mDiff != 0) {
+ // SCROLL!
+ int scale = (int) (mWebView.getScale() / mWebView.getInitialScale());
+ if (scale > 1) {
+ mWebView.scrollBy(0, (mDiff * (scale - 1)));
+ }
+ mDiff = 0;
+ }
}
});
} catch (Throwable t) {
@@ -1160,4 +1173,10 @@
renderConversation(getMessageCursor());
}
}
+
+ @Override
+ public void setMessageDetailsExpanded(MessageHeaderItem i, boolean expanded,
+ int heightBefore) {
+ mDiff = (expanded ? 1 : -1) * Math.abs(i.getHeight() - heightBefore);
+ }
}