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

Commit 912963cc authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Removing mApplyTheme parameter in RemoteViews as it changes the...

Merge "Removing mApplyTheme parameter in RemoteViews as it changes the internal state of RemoteView without parcelling the new state"
parents 743ad8a7 40f589c6
Loading
Loading
Loading
Loading
+16 −16
Original line number Diff line number Diff line
@@ -195,12 +195,6 @@ public class RemoteViews implements Parcelable, Filter {
     */
    private boolean mIsRoot = true;

    /**
     * Optional theme resource id applied in inflateView(). When 0, Theme.DeviceDefault will be
     * used.
     */
    private int mApplyThemeResId;

    /**
     * Whether reapply is disallowed on this remoteview. This maybe be true if some actions modify
     * the layout in a way that isn't recoverable, since views are being removed.
@@ -3261,14 +3255,6 @@ public class RemoteViews implements Parcelable, Filter {
        return this;
    }

    /**
     * Set the theme used in apply() and applyASync().
     * @hide
     */
    public void setApplyTheme(@StyleRes int themeResId) {
        mApplyThemeResId = themeResId;
    }

    /**
     * Inflates the view hierarchy represented by this object and applies
     * all of the actions.
@@ -3290,11 +3276,25 @@ public class RemoteViews implements Parcelable, Filter {

        View result = inflateView(context, rvToApply, parent);
        rvToApply.performApply(result, parent, handler);
        return result;
    }

    /** @hide */
    public View applyWithTheme(Context context, ViewGroup parent, OnClickHandler handler,
            @StyleRes int applyThemeResId) {
        RemoteViews rvToApply = getRemoteViewsToApply(context);

        View result = inflateView(context, rvToApply, parent, applyThemeResId);
        rvToApply.performApply(result, parent, handler);
        return result;
    }

    private View inflateView(Context context, RemoteViews rv, ViewGroup parent) {
        return inflateView(context, rv, parent, 0);
    }

    private View inflateView(Context context, RemoteViews rv, ViewGroup parent,
            @StyleRes int applyThemeResId) {
        // RemoteViews may be built by an application installed in another
        // user. So build a context that loads resources from that user but
        // still returns the current users userId so settings like data / time formats
@@ -3303,8 +3303,8 @@ public class RemoteViews implements Parcelable, Filter {
        Context inflationContext = new RemoteViewsContextWrapper(context, contextForResources);

        // If mApplyThemeResId is not given, Theme.DeviceDefault will be used.
        if (mApplyThemeResId != 0) {
            inflationContext = new ContextThemeWrapper(inflationContext, mApplyThemeResId);
        if (applyThemeResId != 0) {
            inflationContext = new ContextThemeWrapper(inflationContext, applyThemeResId);
        }
        LayoutInflater inflater = (LayoutInflater)
                context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+7 −8
Original line number Diff line number Diff line
@@ -218,8 +218,8 @@ final class FillUi {
            ViewGroup container = decor.findViewById(R.id.autofill_dataset_picker);
            final View content;
            try {
                response.getPresentation().setApplyTheme(mThemeId);
                content = response.getPresentation().apply(mContext, decor, interceptionHandler);
                content = response.getPresentation().applyWithTheme(
                        mContext, decor, interceptionHandler, mThemeId);
                container.addView(content);
            } catch (RuntimeException e) {
                callback.onCanceled();
@@ -259,8 +259,7 @@ final class FillUi {
            RemoteViews.OnClickHandler clickBlocker = null;
            if (headerPresentation != null) {
                clickBlocker = newClickBlocker();
                headerPresentation.setApplyTheme(mThemeId);
                mHeader = headerPresentation.apply(mContext, null, clickBlocker);
                mHeader = headerPresentation.applyWithTheme(mContext, null, clickBlocker, mThemeId);
                final LinearLayout headerContainer =
                        decor.findViewById(R.id.autofill_dataset_header);
                if (sVerbose) Slog.v(TAG, "adding header");
@@ -277,8 +276,8 @@ final class FillUi {
                    if (clickBlocker == null) { // already set for header
                        clickBlocker = newClickBlocker();
                    }
                    footerPresentation.setApplyTheme(mThemeId);
                    mFooter = footerPresentation.apply(mContext, null, clickBlocker);
                    mFooter = footerPresentation.applyWithTheme(
                            mContext, null, clickBlocker, mThemeId);
                    // Footer not supported on some platform e.g. TV
                    if (sVerbose) Slog.v(TAG, "adding footer");
                    footerContainer.addView(mFooter);
@@ -304,8 +303,8 @@ final class FillUi {
                    final View view;
                    try {
                        if (sVerbose) Slog.v(TAG, "setting remote view for " + focusedViewId);
                        presentation.setApplyTheme(mThemeId);
                        view = presentation.apply(mContext, null, interceptionHandler);
                        view = presentation.applyWithTheme(
                                mContext, null, interceptionHandler, mThemeId);
                    } catch (RuntimeException e) {
                        Slog.e(TAG, "Error inflating remote views", e);
                        continue;
+2 −2
Original line number Diff line number Diff line
@@ -339,8 +339,8 @@ final class SaveUi {

        try {
            // Create the remote view peer.
            template.setApplyTheme(mThemeId);
            final View customSubtitleView = template.apply(context, null, handler);
            final View customSubtitleView = template.applyWithTheme(
                    context, null, handler, mThemeId);

            // Apply batch updates (if any).
            final ArrayList<Pair<InternalValidator, BatchUpdates>> updates =