blob: 5472ad6718dd73a5137833379f0edfde56aeab93 [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;
Jaewan Kim21e04212016-03-21 14:22:33 +090020import android.app.ActivityOptions;
21import android.content.Context;
22import android.content.Intent;
Youngsang Chof1647922015-12-17 13:39:39 -080023import android.os.Bundle;
24import android.os.Handler;
Wale Ogunwale480dca02016-02-06 13:58:29 -080025import android.view.View;
Jaewan Kim8f584b82016-03-22 22:16:59 +090026import android.widget.ImageView;
Jaewan Kimedd02dc2016-02-23 06:16:57 -080027
Youngsang Chof1647922015-12-17 13:39:39 -080028import com.android.systemui.R;
29
Jaewan Kim21e04212016-03-21 14:22:33 +090030import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
31
Youngsang Chof1647922015-12-17 13:39:39 -080032/**
33 * Activity to show an overlay on top of PIP activity to show how to pop up PIP menu.
34 */
35public class PipOverlayActivity extends Activity implements PipManager.Listener {
Wale Ogunwale480dca02016-02-06 13:58:29 -080036 private static final long SHOW_GUIDE_OVERLAY_VIEW_DURATION_MS = 4000;
Youngsang Chof1647922015-12-17 13:39:39 -080037
38 private final PipManager mPipManager = PipManager.getInstance();
39 private final Handler mHandler = new Handler();
Wale Ogunwale480dca02016-02-06 13:58:29 -080040 private View mGuideOverlayView;
Jaewan Kimc92a7d12016-02-15 17:33:25 -080041 private View mGuideButtonsView;
Jaewan Kim8f584b82016-03-22 22:16:59 +090042 private ImageView mGuideButtonPlayPauseImageView;
Wale Ogunwale480dca02016-02-06 13:58:29 -080043 private final Runnable mHideGuideOverlayRunnable = new Runnable() {
44 public void run() {
Jaewan Kim8f584b82016-03-22 22:16:59 +090045 mGuideOverlayView.setVisibility(View.GONE);
Wale Ogunwale480dca02016-02-06 13:58:29 -080046 }
47 };
Youngsang Chof1647922015-12-17 13:39:39 -080048
49 @Override
50 protected void onCreate(Bundle bundle) {
51 super.onCreate(bundle);
52 setContentView(R.layout.tv_pip_overlay);
Wale Ogunwale480dca02016-02-06 13:58:29 -080053 mGuideOverlayView = findViewById(R.id.guide_overlay);
Youngsang Chof1647922015-12-17 13:39:39 -080054 mPipManager.addListener(this);
Wale Ogunwale480dca02016-02-06 13:58:29 -080055 }
56
57 @Override
Wale Ogunwaleed0f7e22016-02-17 16:04:58 -080058 protected void onResume() {
59 super.onResume();
Wale Ogunwale480dca02016-02-06 13:58:29 -080060 mHandler.removeCallbacks(mHideGuideOverlayRunnable);
61 mHandler.postDelayed(mHideGuideOverlayRunnable, SHOW_GUIDE_OVERLAY_VIEW_DURATION_MS);
62 }
63
64 @Override
65 protected void onStop() {
66 super.onStop();
67 mHandler.removeCallbacks(mHideGuideOverlayRunnable);
68 finish();
Youngsang Chof1647922015-12-17 13:39:39 -080069 }
70
71 @Override
72 protected void onDestroy() {
73 super.onDestroy();
74 mHandler.removeCallbacksAndMessages(null);
75 mPipManager.removeListener(this);
Wale Ogunwale480dca02016-02-06 13:58:29 -080076 mPipManager.resumePipResizing(
77 PipManager.SUSPEND_PIP_RESIZE_REASON_WAITING_FOR_OVERLAY_ACTIVITY_FINISH);
Youngsang Chof1647922015-12-17 13:39:39 -080078 }
79
80 @Override
Jaewan Kim82ac50d2016-03-21 17:34:28 +090081 public void onPipEntered() { }
82
83 @Override
Youngsang Chof1647922015-12-17 13:39:39 -080084 public void onPipActivityClosed() {
85 finish();
86 }
87
88 @Override
89 public void onShowPipMenu() {
90 finish();
91 }
92
93 @Override
94 public void onMoveToFullscreen() {
95 finish();
96 }
Wale Ogunwale480dca02016-02-06 13:58:29 -080097
98 @Override
99 public void onPipResizeAboutToStart() {
100 finish();
101 mPipManager.suspendPipResizing(
102 PipManager.SUSPEND_PIP_RESIZE_REASON_WAITING_FOR_OVERLAY_ACTIVITY_FINISH);
103 }
Youngsang Chof1647922015-12-17 13:39:39 -0800104}