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 | |
5 | package org.chromium.content.browser; |
6 | |
7 | import android.app.Activity; |
8 | import android.view.Gravity; |
9 | import android.view.View; |
10 | import android.view.ViewGroup; |
11 | import android.view.WindowManager; |
12 | import android.widget.FrameLayout; |
13 | |
14 | import org.chromium.content.browser.ContentVideoViewClient; |
15 | |
16 | /** |
17 | * Uses an existing Activity to handle displaying video in full screen. |
18 | */ |
19 | public class ActivityContentVideoViewClient implements ContentVideoViewClient { |
20 | private Activity mActivity; |
21 | private View mView; |
22 | |
23 | public ActivityContentVideoViewClient(Activity activity) { |
24 | this.mActivity = activity; |
25 | } |
26 | |
27 | @Override |
28 | public void onShowCustomView(View view) { |
29 | mActivity.getWindow().setFlags( |
30 | WindowManager.LayoutParams.FLAG_FULLSCREEN, |
31 | WindowManager.LayoutParams.FLAG_FULLSCREEN); |
32 | |
33 | mActivity.getWindow().addContentView(view, |
34 | new FrameLayout.LayoutParams( |
35 | ViewGroup.LayoutParams.MATCH_PARENT, |
36 | ViewGroup.LayoutParams.MATCH_PARENT, |
37 | Gravity.CENTER)); |
38 | mView = view; |
39 | } |
40 | |
41 | @Override |
42 | public void onDestroyContentVideoView() { |
43 | mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); |
44 | FrameLayout decor = (FrameLayout) mActivity.getWindow().getDecorView(); |
45 | decor.removeView(mView); |
46 | mView = null; |
47 | } |
48 | |
49 | @Override |
50 | public View getVideoLoadingProgressView() { |
51 | return null; |
52 | } |
53 | |
54 | @Override |
55 | public ContentVideoViewControls createControls() { |
56 | return null; |
57 | } |
58 | } |