ActivityContentVideoViewClient.java revision f2477e01787aa58f445919b809d89e252beef54f
1// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package org.chromium.content.browser;
6
7import android.app.Activity;
8import android.view.Gravity;
9import android.view.View;
10import android.view.ViewGroup;
11import android.view.WindowManager;
12import android.widget.FrameLayout;
13
14/**
15 * Uses an existing Activity to handle displaying video in full screen.
16 */
17public class ActivityContentVideoViewClient implements ContentVideoViewClient {
18    private final Activity mActivity;
19    private View mView;
20
21    public ActivityContentVideoViewClient(Activity activity)  {
22        this.mActivity = activity;
23    }
24
25    @Override
26    public void onShowCustomView(View view) {
27        mActivity.getWindow().setFlags(
28                WindowManager.LayoutParams.FLAG_FULLSCREEN,
29                WindowManager.LayoutParams.FLAG_FULLSCREEN);
30
31        mActivity.getWindow().addContentView(view,
32                new FrameLayout.LayoutParams(
33                        ViewGroup.LayoutParams.MATCH_PARENT,
34                        ViewGroup.LayoutParams.MATCH_PARENT,
35                        Gravity.CENTER));
36        mView = view;
37    }
38
39    @Override
40    public void onDestroyContentVideoView() {
41        mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
42        FrameLayout decor = (FrameLayout) mActivity.getWindow().getDecorView();
43        decor.removeView(mView);
44        mView = null;
45    }
46
47    @Override
48    public View getVideoLoadingProgressView() {
49        return null;
50    }
51
52    @Override
53    public ContentVideoViewControls createControls() {
54        return null;
55    }
56}
57