Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30eb23ef authored by Biswarup Pal's avatar Biswarup Pal
Browse files

Fix Toast dimensions on non-default displays

LayoutInflater should not be using an application context as this causes
wrong dimensions to be calculated.

Bug: 342316405
Test: manual and showing Toasts on VirtualDevices
Flag: EXEMPT bugfix

Change-Id: I48e948f8801a8cc6363c52ae50a0c5be61e4b636
parent fdf9784b
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -40,14 +40,11 @@ import javax.inject.Inject;
public class ToastFactory implements Dumpable {
    // only one ToastPlugin can be connected at a time.
    private ToastPlugin mPlugin;
    private final LayoutInflater mLayoutInflater;

    @Inject
    public ToastFactory(
            LayoutInflater layoutInflater,
            PluginManager pluginManager,
            DumpManager dumpManager) {
        mLayoutInflater = layoutInflater;
        dumpManager.registerDumpable("ToastFactory", this);
        pluginManager.addPluginListener(
                new PluginListener<ToastPlugin>() {
@@ -70,11 +67,12 @@ public class ToastFactory implements Dumpable {
     */
    public SystemUIToast createToast(Context context, CharSequence text, String packageName,
            int userId, int orientation) {
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        if (isPluginAvailable()) {
            return new SystemUIToast(mLayoutInflater, context, text, mPlugin.createToast(text,
            return new SystemUIToast(layoutInflater, context, text, mPlugin.createToast(text,
                    packageName, userId), packageName, userId, orientation);
        }
        return new SystemUIToast(mLayoutInflater, context, text, packageName, userId,
        return new SystemUIToast(layoutInflater, context, text, packageName, userId,
                orientation);
    }

+1 −1
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ public class ToastUI implements
                return;
            }
            Context displayContext = context.createDisplayContext(display);
            mToast = mToastFactory.createToast(mContext /* sysuiContext */, text, packageName,
            mToast = mToastFactory.createToast(displayContext /* sysuiContext */, text, packageName,
                    userHandle.getIdentifier(), mOrientation);

            if (mToast.getInAnimation() != null) {
+0 −1
Original line number Diff line number Diff line
@@ -134,7 +134,6 @@ public class ToastUITest extends SysuiTestCase {
                mNotificationManager,
                mAccessibilityManager,
                new ToastFactory(
                        mLayoutInflater,
                        mPluginManager,
                        mDumpManager),
                mToastLogger);