blob: 4171dbcc43725ec299aca120fb4195cddc04ebb2 [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.media.session.MediaController;
21import android.os.Bundle;
Youngsang Chof1647922015-12-17 13:39:39 -080022import android.view.View;
23
24import com.android.systemui.R;
25
26/**
27 * Activity to show the PIP menu to control PIP.
28 */
29public class PipMenuActivity extends Activity implements PipManager.Listener {
30 private static final String TAG = "PipMenuActivity";
31 private static final boolean DEBUG = false;
32
33 private final PipManager mPipManager = PipManager.getInstance();
34 private MediaController mMediaController;
35
Jaewan Kim1a9dc562016-02-17 13:41:51 -080036 private View mFullButtonView;
37 private View mFullDescriptionView;
38 private View mPlayPauseButtonView;
39 private View mPlayPauseDescriptionView;
40 private View mCloseButtonView;
41 private View mCloseDescriptionView;
42
Youngsang Chof1647922015-12-17 13:39:39 -080043 @Override
44 protected void onCreate(Bundle bundle) {
45 super.onCreate(bundle);
46 setContentView(R.layout.tv_pip_menu);
47 mPipManager.addListener(this);
Jaewan Kim1a9dc562016-02-17 13:41:51 -080048 mFullButtonView = findViewById(R.id.full);
49 mFullDescriptionView = findViewById(R.id.full_desc);
50 mFullButtonView.setOnClickListener(new View.OnClickListener() {
Youngsang Chof1647922015-12-17 13:39:39 -080051 @Override
52 public void onClick(View v) {
53 mPipManager.movePipToFullscreen();
Jaewan Kim1a9dc562016-02-17 13:41:51 -080054 finish();
Youngsang Chof1647922015-12-17 13:39:39 -080055 }
56 });
Jaewan Kim1a9dc562016-02-17 13:41:51 -080057 mFullButtonView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
58 @Override
59 public void onFocusChange(View v, boolean hasFocus) {
60 mFullDescriptionView.setVisibility(hasFocus ? View.VISIBLE : View.INVISIBLE);
61 }
62 });
63
64 mPlayPauseButtonView = findViewById(R.id.play_pause);
65 mPlayPauseDescriptionView = findViewById(R.id.play_pause_desc);
66 mPlayPauseButtonView.setOnClickListener(new View.OnClickListener() {
67 @Override
68 public void onClick(View v) {
69 // TODO: Implement play/pause.
70 }
71 });
72 mPlayPauseButtonView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
73 @Override
74 public void onFocusChange(View v, boolean hasFocus) {
75 mPlayPauseDescriptionView.setVisibility(hasFocus ? View.VISIBLE : View.INVISIBLE);
76 }
77 });
78
79 mCloseButtonView = findViewById(R.id.close);
80 mCloseDescriptionView = findViewById(R.id.close_desc);
81 mCloseButtonView.setOnClickListener(new View.OnClickListener() {
Youngsang Chof1647922015-12-17 13:39:39 -080082 @Override
83 public void onClick(View v) {
84 mPipManager.closePip();
85 finish();
86 }
87 });
Jaewan Kim1a9dc562016-02-17 13:41:51 -080088 mCloseButtonView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
Youngsang Chof1647922015-12-17 13:39:39 -080089 @Override
Jaewan Kim1a9dc562016-02-17 13:41:51 -080090 public void onFocusChange(View v, boolean hasFocus) {
91 mCloseDescriptionView.setVisibility(hasFocus ? View.VISIBLE : View.INVISIBLE);
Youngsang Chof1647922015-12-17 13:39:39 -080092 }
93 });
94 }
95
96 @Override
97 protected void onDestroy() {
Youngsang Chof1647922015-12-17 13:39:39 -080098 super.onDestroy();
Wale Ogunwale480dca02016-02-06 13:58:29 -080099 mPipManager.removeListener(this);
100 mPipManager.resumePipResizing(
101 PipManager.SUSPEND_PIP_RESIZE_REASON_WAITING_FOR_MENU_ACTIVITY_FINISH);
Youngsang Chof1647922015-12-17 13:39:39 -0800102 }
103
104 @Override
105 public void onBackPressed() {
Wale Ogunwale480dca02016-02-06 13:58:29 -0800106 mPipManager.resizePinnedStack(PipManager.STATE_PIP_OVERLAY);
Youngsang Chof1647922015-12-17 13:39:39 -0800107 finish();
108 }
109
110 @Override
111 public void onPipActivityClosed() {
112 finish();
113 }
114
115 @Override
116 public void onShowPipMenu() { }
117
118 @Override
119 public void onMoveToFullscreen() {
120 finish();
121 }
Wale Ogunwale480dca02016-02-06 13:58:29 -0800122
123 @Override
124 public void onPipResizeAboutToStart() {
125 finish();
126 mPipManager.suspendPipResizing(
127 PipManager.SUSPEND_PIP_RESIZE_REASON_WAITING_FOR_MENU_ACTIVITY_FINISH);
128 }
Youngsang Chof1647922015-12-17 13:39:39 -0800129}