blob: ad45625b0f9cfcc92231fa954a16fdba4a305f44 [file] [log] [blame]
Jaewan Kim977dcdc2016-01-20 19:21:08 +09001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.systemui.tv.pip;
18
19import android.app.Activity;
Jaewan Kimedd02dc2016-02-23 06:16:57 -080020import android.graphics.Rect;
Jaewan Kim977dcdc2016-01-20 19:21:08 +090021import android.os.Bundle;
22import android.util.Log;
23import android.view.View;
Jaewan Kimedd02dc2016-02-23 06:16:57 -080024import android.view.ViewGroup.LayoutParams;
Jaewan Kim977dcdc2016-01-20 19:21:08 +090025
26import com.android.systemui.R;
27
28/**
29 * Activity to show an overlay on top of PIP activity to show how to pop up PIP menu.
30 */
31public class PipOnboardingActivity extends Activity implements PipManager.Listener {
32 private final PipManager mPipManager = PipManager.getInstance();
33
34 @Override
35 protected void onCreate(Bundle bundle) {
36 super.onCreate(bundle);
37 setContentView(R.layout.tv_pip_onboarding);
Jaewan Kimedd02dc2016-02-23 06:16:57 -080038 View pipOnboardingView = findViewById(R.id.pip_onboarding);
39 View pipOutlineView = findViewById(R.id.pip_outline);
Jaewan Kim977dcdc2016-01-20 19:21:08 +090040 mPipManager.addListener(this);
41 findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
42 @Override
43 public void onClick(View v) {
44 finish();
45 }
46 });
Jaewan Kimedd02dc2016-02-23 06:16:57 -080047
48 int pipOutlineSpace = getResources().getDimensionPixelSize(R.dimen.tv_pip_bounds_space);
49 int screenWidth = getResources().getDisplayMetrics().widthPixels;
50 Rect pipBounds = mPipManager.getPipBounds();
51 pipOnboardingView.setPadding(
52 pipBounds.left - pipOutlineSpace,
53 pipBounds.top - pipOutlineSpace,
54 screenWidth - pipBounds.right - pipOutlineSpace, 0);
55
56 // Set width and height for outline view to enclose the PIP.
57 LayoutParams lp = pipOutlineView.getLayoutParams();
58 lp.width = pipBounds.width() + pipOutlineSpace * 2;
59 lp.height = pipBounds.height() + pipOutlineSpace * 2;
60 pipOutlineView.setLayoutParams(lp);
Jaewan Kim977dcdc2016-01-20 19:21:08 +090061 }
62
63 @Override
64 protected void onDestroy() {
65 super.onDestroy();
66 mPipManager.removeListener(this);
67 }
68
69 @Override
70 public void onPipActivityClosed() {
71 finish();
72 }
73
74 @Override
75 public void onShowPipMenu() {
76 finish();
77 }
78
79 @Override
80 public void onMoveToFullscreen() {
81 finish();
82 }
Wale Ogunwale480dca02016-02-06 13:58:29 -080083
84 @Override
Jaewan Kim62338192016-02-25 10:00:05 -080085 public void onPipResizeAboutToStart() { }
86
87 @Override
88 public void onMediaControllerChanged() { }
Jaewan Kim977dcdc2016-01-20 19:21:08 +090089}