jenkins-bot has submitted this change and it was merged.
Change subject: Fix lead image click area in 2.3
......................................................................
Fix lead image click area in 2.3
The problem was that, even though the ViewHelper library (nineoldandroids)
correctly slides the lead image component, it does not successfully slide
the logical click area that corresponds to the visual position of the
component! So, the lead image remains "clickable" even after sliding away.
The solution is to stop using the ViewHelper library, and shift the
position of the lead image component using standard margins.
There was another slight issue, however: in Android 2.3, using negative
margins is only possible for a component that has a LinearLayout as a
parent. So, I had to put the lead image container into a dummy
LinearLayout, just to achieve negative margins.
Thanks again, 2.3!
NOTE: The same issue is currently present in the Search bar at the top,
which slides away in a similar fashion. This will be the subject of a
subsequent patch.
Bug: T84998
Change-Id: I79120601b156e151a8b9ddabcfef2952c1555de5
---
M wikipedia/res/layout/fragment_page.xml
M wikipedia/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java
2 files changed, 72 insertions(+), 50 deletions(-)
Approvals:
BearND: Looks good to me, approved
jenkins-bot: Verified
diff --git a/wikipedia/res/layout/fragment_page.xml
b/wikipedia/res/layout/fragment_page.xml
index 997e356..aa472a1 100644
--- a/wikipedia/res/layout/fragment_page.xml
+++ b/wikipedia/res/layout/fragment_page.xml
@@ -29,52 +29,63 @@
android:layout_height="match_parent"
/>
- <FrameLayout
- android:id="@+id/page_images_container"
+ <!-- dummy LinearLayout container for 2.3 support.
+ Remove when we drop support for 2.3. -->
+ <LinearLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingTop="?attr/actionBarSize">
- <org.wikipedia.page.leadimages.ImageViewWithFace
- android:id="@+id/page_image_1"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:scaleType="centerCrop"
- android:visibility="invisible"/>
- <ImageView
- android:id="@+id/page_image_placeholder"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:scaleType="centerCrop"
- android:contentDescription="@null"/>
+ android:layout_height="wrap_content">
<FrameLayout
- android:id="@+id/page_title_container"
+ android:id="@+id/page_images_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:layout_gravity="bottom">
- <TextView
- android:id="@+id/page_title_text"
+ android:paddingTop="?attr/actionBarSize">
+ <!-- dummy LinearLayout container for 2.3 support.
+ Remove when we drop support for 2.3. -->
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <org.wikipedia.page.leadimages.ImageViewWithFace
+ android:id="@+id/page_image_1"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="centerCrop"
+ android:visibility="invisible"/>
+ </LinearLayout>
+ <ImageView
+ android:id="@+id/page_image_placeholder"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="centerCrop"
+ android:contentDescription="@null"/>
+ <FrameLayout
+ android:id="@+id/page_title_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:fontFamily="serif"
- android:paddingTop="16dp"
- android:paddingBottom="16dp"
-
android:paddingRight="@dimen/activity_horizontal_margin"
-
android:paddingLeft="@dimen/activity_horizontal_margin"/>
- <TextView
- android:id="@+id/page_description_text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- android:visibility="invisible"
- android:fontFamily="serif"
- android:textSize="@dimen/descriptionTextSize"
- android:paddingBottom="16dp"
-
android:paddingRight="@dimen/activity_horizontal_margin"
-
android:paddingLeft="@dimen/activity_horizontal_margin"/>
+ android:orientation="vertical"
+ android:layout_gravity="bottom">
+ <TextView
+ android:id="@+id/page_title_text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:fontFamily="serif"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+
android:paddingRight="@dimen/activity_horizontal_margin"
+
android:paddingLeft="@dimen/activity_horizontal_margin"/>
+ <TextView
+ android:id="@+id/page_description_text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom"
+ android:visibility="invisible"
+ android:fontFamily="serif"
+ android:textSize="@dimen/descriptionTextSize"
+ android:paddingBottom="16dp"
+
android:paddingRight="@dimen/activity_horizontal_margin"
+
android:paddingLeft="@dimen/activity_horizontal_margin"/>
+ </FrameLayout>
</FrameLayout>
- </FrameLayout>
+ </LinearLayout>
<LinearLayout
android:id="@+id/bottom_content_container"
diff --git
a/wikipedia/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java
b/wikipedia/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java
index 263d04b..def891c 100644
---
a/wikipedia/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java
+++
b/wikipedia/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java
@@ -15,9 +15,9 @@
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.TextView;
-import com.nineoldandroids.view.ViewHelper;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Target;
@@ -159,12 +159,21 @@
@Override
public void onScrollChanged(int oldScrollY, int scrollY) {
+ LinearLayout.LayoutParams contParams = (LinearLayout.LayoutParams)
imageContainer
+ .getLayoutParams();
+ LinearLayout.LayoutParams imgParams = (LinearLayout.LayoutParams)
image1.getLayoutParams();
if (scrollY > imageContainer.getHeight()) {
- ViewHelper.setTranslationY(imageContainer,
-imageContainer.getHeight());
- ViewHelper.setTranslationY(image1, 0);
+ if (contParams.topMargin != -imageContainer.getHeight()) {
+ contParams.topMargin = -imageContainer.getHeight();
+ imgParams.topMargin = 0;
+ imageContainer.setLayoutParams(contParams);
+ image1.setLayoutParams(imgParams);
+ }
} else {
- ViewHelper.setTranslationY(imageContainer, -scrollY);
- ViewHelper.setTranslationY(image1, imageBaseYOffset + scrollY /
2); //parallax, baby
+ contParams.topMargin = -scrollY;
+ imgParams.topMargin = imageBaseYOffset + scrollY / 2; //parallax,
baby
+ imageContainer.setLayoutParams(contParams);
+ image1.setLayoutParams(imgParams);
}
}
@@ -218,12 +227,14 @@
if (newHeight < imagePlaceholder.getHeight()) {
// if the height of the image is less than the container,
then just
// make it fill-parent
- image1.setLayoutParams(new
FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
- FrameLayout.LayoutParams.MATCH_PARENT));
+ image1.setLayoutParams(
+ new
LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
+
LinearLayout.LayoutParams.MATCH_PARENT));
imageBaseYOffset = 0;
} else {
- image1.setLayoutParams(new
FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
- newHeight));
+ image1.setLayoutParams(
+ new
LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
+ newHeight));
}
// and force a refresh of its position within the container
view.
@@ -381,7 +392,7 @@
// make the WebView padding be just the height of the title text,
plus a fixed offset
titleContainerHeight = (int) ((pageTitleContainer.getHeight() /
displayDensity))
+ DISABLED_OFFSET_DP;
- imageContainer.setLayoutParams(new
FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
+ imageContainer.setLayoutParams(new
LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
(int) ((titleContainerHeight) * displayDensity)));
// hide the lead image
image1.setVisibility(View.GONE);
@@ -409,7 +420,7 @@
// layout, in case we were previously not showing it:
// make the WebView padding be a proportion of the total screen
height
titleContainerHeight = (int) (displayHeight *
IMAGES_CONTAINER_RATIO);
- imageContainer.setLayoutParams(new
FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
+ imageContainer.setLayoutParams(new
LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
(int) (titleContainerHeight * displayDensity)));
// prepare the lead image to be populated
image1.setVisibility(View.INVISIBLE);
--
To view, visit https://gerrit.wikimedia.org/r/181065
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I79120601b156e151a8b9ddabcfef2952c1555de5
Gerrit-PatchSet: 2
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <[email protected]>
Gerrit-Reviewer: BearND <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits