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

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

Merge "MediaControlView2: Inflate layout from MediaConponents"

parents 5efd03b8 6766e9d3
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -16,8 +16,13 @@

package com.android.media.update;

import android.content.Context;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.content.res.XmlResourceParser;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;

public class ApiHelper {
    private static ApiHelper sInstance;
@@ -46,4 +51,17 @@ public class ApiHelper {
    public static Resources.Theme getLibTheme() {
        return sInstance.mLibTheme;
    }

    public static LayoutInflater getLayoutInflater(Context context) {
        LayoutInflater layoutInflater = LayoutInflater.from(context).cloneInContext(
                new ContextThemeWrapper(context, getLibTheme()));
        // TODO: call layoutInflater.setFactory2()
        return layoutInflater;
    }

    public static View inflateLibLayout(Context context, int libResId) {
        try (XmlResourceParser parser = getLibResources().getLayout(libResId)) {
            return getLayoutInflater(context).inflate(parser, null);
        }
    }
}
+1 −4
Original line number Diff line number Diff line
@@ -348,11 +348,8 @@ public class MediaControlView2Impl implements MediaControlView2Provider {
     * @hide This doesn't work as advertised
     */
    protected View makeControllerView() {
        View root = LayoutInflater.from(mInstance.getContext()).inflate(
                R.layout.media_controller, null);

        View root = ApiHelper.inflateLibLayout(mInstance.getContext(), R.layout.media_controller);
        initControllerView(root);

        return root;
    }