Jaewan Kim | 977dcdc | 2016-01-20 19:21:08 +0900 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.systemui.tv.pip; |
| 18 | |
| 19 | import android.app.Activity; |
Jaewan Kim | edd02dc | 2016-02-23 06:16:57 -0800 | [diff] [blame] | 20 | import android.graphics.Rect; |
Jaewan Kim | 977dcdc | 2016-01-20 19:21:08 +0900 | [diff] [blame] | 21 | import android.os.Bundle; |
| 22 | import android.util.Log; |
| 23 | import android.view.View; |
Jaewan Kim | edd02dc | 2016-02-23 06:16:57 -0800 | [diff] [blame] | 24 | import android.view.ViewGroup.LayoutParams; |
Jaewan Kim | 977dcdc | 2016-01-20 19:21:08 +0900 | [diff] [blame] | 25 | |
| 26 | import 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 | */ |
| 31 | public 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 Kim | edd02dc | 2016-02-23 06:16:57 -0800 | [diff] [blame] | 38 | View pipOnboardingView = findViewById(R.id.pip_onboarding); |
| 39 | View pipOutlineView = findViewById(R.id.pip_outline); |
Jaewan Kim | 977dcdc | 2016-01-20 19:21:08 +0900 | [diff] [blame] | 40 | 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 Kim | edd02dc | 2016-02-23 06:16:57 -0800 | [diff] [blame] | 47 | |
| 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 Kim | 977dcdc | 2016-01-20 19:21:08 +0900 | [diff] [blame] | 61 | } |
| 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 Ogunwale | 480dca0 | 2016-02-06 13:58:29 -0800 | [diff] [blame] | 83 | |
| 84 | @Override |
Jaewan Kim | 6233819 | 2016-02-25 10:00:05 -0800 | [diff] [blame] | 85 | public void onPipResizeAboutToStart() { } |
| 86 | |
| 87 | @Override |
| 88 | public void onMediaControllerChanged() { } |
Jaewan Kim | 977dcdc | 2016-01-20 19:21:08 +0900 | [diff] [blame] | 89 | } |