blob: 95d655c2f320048b707f2651c677969ba6eefdd5 [file] [log] [blame]
Youngsang Chof1647922015-12-17 13:39:39 -08001/*
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;
20import android.os.Bundle;
21import android.os.Handler;
Wale Ogunwale480dca02016-02-06 13:58:29 -080022import android.view.View;
Jaewan Kimedd02dc2016-02-23 06:16:57 -080023
Youngsang Chof1647922015-12-17 13:39:39 -080024import com.android.systemui.R;
25
26/**
27 * Activity to show an overlay on top of PIP activity to show how to pop up PIP menu.
28 */
29public class PipOverlayActivity extends Activity implements PipManager.Listener {
30 private static final String TAG = "PipOverlayActivity";
31 private static final boolean DEBUG = false;
32
Wale Ogunwale480dca02016-02-06 13:58:29 -080033 private static final long SHOW_GUIDE_OVERLAY_VIEW_DURATION_MS = 4000;
Youngsang Chof1647922015-12-17 13:39:39 -080034
35 private final PipManager mPipManager = PipManager.getInstance();
36 private final Handler mHandler = new Handler();
Wale Ogunwale480dca02016-02-06 13:58:29 -080037 private View mGuideOverlayView;
Jaewan Kimc92a7d12016-02-15 17:33:25 -080038 private View mGuideButtonsView;
Wale Ogunwale480dca02016-02-06 13:58:29 -080039 private final Runnable mHideGuideOverlayRunnable = new Runnable() {
40 public void run() {
Jaewan Kim36a165d2016-02-24 18:50:28 -080041 mGuideOverlayView.setVisibility(View.INVISIBLE);
Wale Ogunwale480dca02016-02-06 13:58:29 -080042 }
43 };
Youngsang Chof1647922015-12-17 13:39:39 -080044
45 @Override
46 protected void onCreate(Bundle bundle) {
47 super.onCreate(bundle);
48 setContentView(R.layout.tv_pip_overlay);
Wale Ogunwale480dca02016-02-06 13:58:29 -080049 mGuideOverlayView = findViewById(R.id.guide_overlay);
Jaewan Kimc92a7d12016-02-15 17:33:25 -080050 mGuideButtonsView = findViewById(R.id.guide_buttons);
Youngsang Chof1647922015-12-17 13:39:39 -080051 mPipManager.addListener(this);
Wale Ogunwale480dca02016-02-06 13:58:29 -080052 }
53
54 @Override
Wale Ogunwaleed0f7e22016-02-17 16:04:58 -080055 protected void onResume() {
56 super.onResume();
Jaewan Kimc92a7d12016-02-15 17:33:25 -080057 // TODO: Implement animation for this
58 if (!mPipManager.isRecentsShown()) {
59 mGuideOverlayView.setVisibility(View.VISIBLE);
60 mGuideButtonsView.setVisibility(View.INVISIBLE);
61 } else {
62 mGuideOverlayView.setVisibility(View.INVISIBLE);
63 mGuideButtonsView.setVisibility(View.VISIBLE);
64 }
Wale Ogunwale480dca02016-02-06 13:58:29 -080065 mHandler.removeCallbacks(mHideGuideOverlayRunnable);
66 mHandler.postDelayed(mHideGuideOverlayRunnable, SHOW_GUIDE_OVERLAY_VIEW_DURATION_MS);
67 }
68
69 @Override
70 protected void onStop() {
71 super.onStop();
72 mHandler.removeCallbacks(mHideGuideOverlayRunnable);
73 finish();
Youngsang Chof1647922015-12-17 13:39:39 -080074 }
75
76 @Override
77 protected void onDestroy() {
78 super.onDestroy();
79 mHandler.removeCallbacksAndMessages(null);
80 mPipManager.removeListener(this);
Wale Ogunwale480dca02016-02-06 13:58:29 -080081 mPipManager.resumePipResizing(
82 PipManager.SUSPEND_PIP_RESIZE_REASON_WAITING_FOR_OVERLAY_ACTIVITY_FINISH);
Youngsang Chof1647922015-12-17 13:39:39 -080083 }
84
85 @Override
86 public void onPipActivityClosed() {
87 finish();
88 }
89
90 @Override
91 public void onShowPipMenu() {
92 finish();
93 }
94
95 @Override
96 public void onMoveToFullscreen() {
97 finish();
98 }
Wale Ogunwale480dca02016-02-06 13:58:29 -080099
100 @Override
101 public void onPipResizeAboutToStart() {
102 finish();
103 mPipManager.suspendPipResizing(
104 PipManager.SUSPEND_PIP_RESIZE_REASON_WAITING_FOR_OVERLAY_ACTIVITY_FINISH);
105 }
Jaewan Kim62338192016-02-25 10:00:05 -0800106
107 @Override
108 public void onMediaControllerChanged() {
109 }
Youngsang Chof1647922015-12-17 13:39:39 -0800110}