Commit 4ee19dd3 authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

Add extra Y offset to toasts for duet

This patch adds a static member to chrome's toast wrapper that allows
extra padding to be applied to all toasts. The setter is only allowed
to be called once to prevent abuse of the system.

Bug: 914107
Change-Id: Iaaa036526a13a1b3759ec417cb401efd02a171f7
Reviewed-on: https://chromium-review.googlesource.com/c/1457463
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630540}
parent 12dbe9bf
...@@ -114,6 +114,7 @@ import org.chromium.content_public.browser.WebContents; ...@@ -114,6 +114,7 @@ import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.AsyncViewProvider; import org.chromium.ui.AsyncViewProvider;
import org.chromium.ui.base.DeviceFormFactor; import org.chromium.ui.base.DeviceFormFactor;
import org.chromium.ui.base.PageTransition; import org.chromium.ui.base.PageTransition;
import org.chromium.ui.widget.Toast;
import org.chromium.ui.widget.ViewRectProvider; import org.chromium.ui.widget.ViewRectProvider;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
...@@ -779,6 +780,8 @@ public class ToolbarManager ...@@ -779,6 +780,8 @@ public class ToolbarManager
mActivity.getActivityTabProvider(), homeButtonListener, searchAcceleratorListener, mActivity.getActivityTabProvider(), homeButtonListener, searchAcceleratorListener,
shareButtonListener); shareButtonListener);
if (mAppMenuButtonHelper != null) mAppMenuButtonHelper.setMenuShowsFromBottom(true); if (mAppMenuButtonHelper != null) mAppMenuButtonHelper.setMenuShowsFromBottom(true);
Toast.setGlobalExtraYOffset(
mActivity.getResources().getDimensionPixelSize(R.dimen.bottom_toolbar_height));
} }
/** Record that homepage button was used for IPH reasons */ /** Record that homepage button was used for IPH reasons */
......
...@@ -29,6 +29,8 @@ public class Toast { ...@@ -29,6 +29,8 @@ public class Toast {
public static final int LENGTH_SHORT = android.widget.Toast.LENGTH_SHORT; public static final int LENGTH_SHORT = android.widget.Toast.LENGTH_SHORT;
public static final int LENGTH_LONG = android.widget.Toast.LENGTH_LONG; public static final int LENGTH_LONG = android.widget.Toast.LENGTH_LONG;
private static int sExtraYOffset;
private android.widget.Toast mToast; private android.widget.Toast mToast;
private ViewGroup mSWLayout; private ViewGroup mSWLayout;
...@@ -61,6 +63,8 @@ public class Toast { ...@@ -61,6 +63,8 @@ public class Toast {
setView(toast.getView()); setView(toast.getView());
} }
mToast.setGravity(
mToast.getGravity(), mToast.getXOffset(), mToast.getYOffset() + sExtraYOffset);
} }
public android.widget.Toast getAndroidToast() { public android.widget.Toast getAndroidToast() {
...@@ -155,4 +159,13 @@ public class Toast { ...@@ -155,4 +159,13 @@ public class Toast {
throws Resources.NotFoundException { throws Resources.NotFoundException {
return makeText(context, context.getResources().getText(resId), duration); return makeText(context, context.getResources().getText(resId), duration);
} }
/**
* Set extra Y offset for toasts all toasts created with this class. This can be overridden by
* calling {@link Toast#setGravity(int, int, int)} on an individual toast.
* @param yOffsetPx The Y offset from the normal toast position in px.
*/
public static void setGlobalExtraYOffset(int yOffsetPx) {
sExtraYOffset = yOffsetPx;
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment