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

Commit 6766e9d3 authored by Sungsoo Lim's avatar Sungsoo Lim
Browse files

MediaControlView2: Inflate layout from MediaConponents

Test: manually using VideoViewTest
Change-Id: I8f777c306184ea250a7dfd2fe0e4a5f850f6366e
parent bd1f9987
Loading
Loading
Loading
Loading
+18 −0
Original line number Original line Diff line number Diff line
@@ -16,8 +16,13 @@


package com.android.media.update;
package com.android.media.update;


import android.content.Context;
import android.content.res.Resources;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
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 {
public class ApiHelper {
    private static ApiHelper sInstance;
    private static ApiHelper sInstance;
@@ -46,4 +51,17 @@ public class ApiHelper {
    public static Resources.Theme getLibTheme() {
    public static Resources.Theme getLibTheme() {
        return sInstance.mLibTheme;
        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 Original line Diff line number Diff line
@@ -339,11 +339,8 @@ public class MediaControlView2Impl implements MediaControlView2Provider {
     * @hide This doesn't work as advertised
     * @hide This doesn't work as advertised
     */
     */
    protected View makeControllerView() {
    protected View makeControllerView() {
        View root = LayoutInflater.from(mInstance.getContext()).inflate(
        View root = ApiHelper.inflateLibLayout(mInstance.getContext(), R.layout.media_controller);
                R.layout.media_controller, null);

        initControllerView(root);
        initControllerView(root);

        return root;
        return root;
    }
    }