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

Commit 0ef9b71f authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Fix loading of toast app icons" into main

parents 3a74114a 5a5818f2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1429,7 +1429,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi
    void makeOverlayToast(int stringId) {
        final Resources res = mContext.getResources();

        final SystemUIToast systemUIToast = mToastFactory.createToast(mContext,
        final SystemUIToast systemUIToast = mToastFactory.createToast(mContext, mContext,
                res.getString(stringId), mContext.getPackageName(), UserHandle.myUserId(),
                res.getConfiguration().orientation);
        if (systemUIToast == null) {
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ constructor(
        // Show the brightness warning toast with passing the toast inflation required context,
        // userId and resId from SystemUI package.
        val systemUIToast = toastFactory.createToast(
            viewContext,
            viewContext, viewContext,
            res.getString(resId), viewContext.packageName, viewContext.getUserId(),
            res.configuration.orientation
        )
+11 −9
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import com.android.systemui.plugins.ToastPlugin;
public class SystemUIToast implements ToastPlugin.Toast {
    static final String TAG = "SystemUIToast";
    final Context mContext;
    final Context mDisplayContext;
    final CharSequence mText;
    final ToastPlugin.Toast mPluginToast;

@@ -68,17 +69,18 @@ public class SystemUIToast implements ToastPlugin.Toast {
    @Nullable private final Animator mInAnimator;
    @Nullable private final Animator mOutAnimator;

    SystemUIToast(LayoutInflater layoutInflater, Context context, CharSequence text,
            String packageName, int userId, int orientation) {
        this(layoutInflater, context, text, null, packageName, userId,
    SystemUIToast(LayoutInflater layoutInflater, Context applicationContext, Context displayContext,
            CharSequence text, String packageName, int userId, int orientation) {
        this(layoutInflater, applicationContext, displayContext, text, null, packageName, userId,
                orientation);
    }

    SystemUIToast(LayoutInflater layoutInflater, Context context, CharSequence text,
            ToastPlugin.Toast pluginToast, String packageName, @UserIdInt int userId,
            int orientation) {
    SystemUIToast(LayoutInflater layoutInflater, Context applicationContext, Context displayContext,
            CharSequence text, ToastPlugin.Toast pluginToast, String packageName,
            @UserIdInt int userId, int orientation) {
        mLayoutInflater = layoutInflater;
        mContext = context;
        mContext = applicationContext;
        mDisplayContext = displayContext;
        mText = text;
        mPluginToast = pluginToast;
        mPackageName = packageName;
@@ -221,9 +223,9 @@ public class SystemUIToast implements ToastPlugin.Toast {
            mPluginToast.onOrientationChange(orientation);
        }

        mDefaultY = mContext.getResources().getDimensionPixelSize(R.dimen.toast_y_offset);
        mDefaultY = mDisplayContext.getResources().getDimensionPixelSize(R.dimen.toast_y_offset);
        mDefaultGravity =
                mContext.getResources().getInteger(R.integer.config_toastDefaultGravity);
                mDisplayContext.getResources().getInteger(R.integer.config_toastDefaultGravity);
    }

    private Animator createInAnimator() {
+8 −7
Original line number Diff line number Diff line
@@ -65,16 +65,17 @@ public class ToastFactory implements Dumpable {
    /**
     * Create a toast to be shown by ToastUI.
     */
    public SystemUIToast createToast(Context context, CharSequence text, String packageName,
            int userId, int orientation) {
        LayoutInflater layoutInflater = LayoutInflater.from(context);
    public SystemUIToast createToast(Context applicationContext, Context displayContext,
            CharSequence text, String packageName, int userId, int orientation) {
        LayoutInflater layoutInflater = LayoutInflater.from(displayContext);
        if (isPluginAvailable()) {
            return new SystemUIToast(layoutInflater, context, text, mPlugin.createToast(text,
                    packageName, userId), packageName, userId, orientation);
        }
        return new SystemUIToast(layoutInflater, context, text, packageName, userId,
            return new SystemUIToast(layoutInflater, applicationContext, displayContext, text,
                    mPlugin.createToast(text, packageName, userId), packageName, userId,
                    orientation);
        }
        return new SystemUIToast(layoutInflater, applicationContext, displayContext, text,
                packageName, userId, orientation);
    }

    private boolean isPluginAvailable() {
        return mPlugin != null;
+2 −2
Original line number Diff line number Diff line
@@ -135,8 +135,8 @@ public class ToastUI implements
                return;
            }
            Context displayContext = context.createDisplayContext(display);
            mToast = mToastFactory.createToast(displayContext /* sysuiContext */, text, packageName,
                    userHandle.getIdentifier(), mOrientation);
            mToast = mToastFactory.createToast(mContext, displayContext /* sysuiContext */, text,
                    packageName, userHandle.getIdentifier(), mOrientation);

            if (mToast.getInAnimation() != null) {
                mToast.getInAnimation().start();
Loading