Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dismissability issues with tooltips that have custom View. #2169

Merged
merged 5 commits into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/main/java/org/wikipedia/main/MainFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ private void maybeShowWatchlistTooltip() {
}
new WatchlistFunnel().logShowTooltipMore();
Prefs.setWatchlistMainOnboardingTooltipShown(true);
FeedbackUtil.showTooltip(requireActivity(), moreContainer, R.layout.view_watchlist_main_tooltip, 0, 0, true);
FeedbackUtil.showTooltip(requireActivity(), moreContainer, R.layout.view_watchlist_main_tooltip, 0, 0, true, false);
}, 500);
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/wikipedia/page/PageActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ private void maybeShowWatchlistTooltip() {
}
watchlistFunnel.logShowTooltip();
Prefs.setWatchlistPageOnboardingTooltipShown(true);
FeedbackUtil.showTooltip(this, overflowButton, R.layout.view_watchlist_page_tooltip, -32, -8, false);
FeedbackUtil.showTooltip(this, overflowButton, R.layout.view_watchlist_page_tooltip, -32, -8, false, false);
}, 500);
}
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/org/wikipedia/util/FeedbackUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ object FeedbackUtil {

@JvmStatic
fun showTooltip(activity: Activity, anchor: View, @LayoutRes layoutRes: Int,
arrowAnchorPadding: Int, topOrBottomMargin: Int, aboveOrBelow: Boolean): Balloon {
return showTooltip(activity, getTooltip(anchor.context, layoutRes, arrowAnchorPadding, topOrBottomMargin, aboveOrBelow), anchor, aboveOrBelow, false)
arrowAnchorPadding: Int, topOrBottomMargin: Int, aboveOrBelow: Boolean, autoDismiss: Boolean): Balloon {
return showTooltip(activity, getTooltip(anchor.context, layoutRes, arrowAnchorPadding, topOrBottomMargin, aboveOrBelow, autoDismiss), anchor, aboveOrBelow, autoDismiss)
}

private fun showTooltip(activity: Activity, balloon: Balloon, anchor: View, aboveOrBelow: Boolean, autoDismiss: Boolean): Balloon {
Expand Down Expand Up @@ -215,7 +215,7 @@ object FeedbackUtil {
}

private fun getTooltip(context: Context, @LayoutRes layoutRes: Int, arrowAnchorPadding: Int,
topOrBottomMargin: Int, aboveOrBelow: Boolean): Balloon {
topOrBottomMargin: Int, aboveOrBelow: Boolean, autoDismiss: Boolean): Balloon {
return createBalloon(context) {
setArrowDrawableResource(R.drawable.ic_tooltip_arrow_up)
setArrowPositionRules(ArrowPositionRules.ALIGN_ANCHOR)
Expand All @@ -226,7 +226,7 @@ object FeedbackUtil {
setMarginTop(if (aboveOrBelow) 0 else topOrBottomMargin)
setMarginBottom(if (aboveOrBelow) topOrBottomMargin else 0)
setBackgroundColorResource(ResourceUtil.getThemedAttributeId(context, R.attr.colorAccent))
setDismissWhenTouchOutside(true)
setDismissWhenTouchOutside(autoDismiss)
setLayout(layoutRes)
setWidthRatio(if (isLandscape(context)) 0.4f else 0.8f)
setArrowAlignAnchorPadding(arrowAnchorPadding)
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/view_watchlist_main_tooltip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
android:orientation="vertical"
android:paddingStart="16dp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
Copy link
Collaborator

@cooltey cooltey Mar 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding 16dp will show too much space on the bottom (on Samsung S9). Would it be possible to change it to 8dp?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's how it looks on my Pixel 2:

image

Are we sure the Balloon updates are ready for prime time?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what's happening there.
The library uses the width instead of height to adjust the tooltip's height.

My Pixel 3 XL also has a similar issue you have on Pixel 2 (with android:paddingBottom="16dp" changes)

It would be better to change android:padding='16dp' for a proper fix.

Copy link
Collaborator

@cooltey cooltey Mar 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add the ScrollView back to the tooltip custom views? I will report this issue to the author. 🆘

bab1c7b#diff-b973be46f02dbcc9ce6123253a46d143a264dd1713a7f15bc7eac15fbb80eaa3

android:paddingEnd="8dp">

<com.google.android.material.textview.MaterialTextView
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/view_watchlist_page_tooltip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
android:orientation="vertical"
android:paddingStart="16dp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingEnd="8dp">

<com.google.android.material.textview.MaterialTextView
Expand Down