• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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.incallui.rtt.impl;
18 
19 import android.content.Context;
20 import android.telecom.CallAudioState;
21 import android.view.View;
22 import android.widget.PopupWindow;
23 import com.android.incallui.incall.protocol.InCallButtonUiDelegate;
24 import com.android.incallui.rtt.impl.RttCheckableButton.OnCheckedChangeListener;
25 import com.android.incallui.speakerbuttonlogic.SpeakerButtonInfo;
26 import com.android.incallui.speakerbuttonlogic.SpeakerButtonInfo.IconSize;
27 
28 /** Overflow menu for RTT call. */
29 public class RttOverflowMenu extends PopupWindow implements OnCheckedChangeListener {
30 
31   private final RttCheckableButton muteButton;
32   private final RttCheckableButton speakerButton;
33   private final RttCheckableButton dialpadButton;
34   private final RttCheckableButton addCallButton;
35   private final InCallButtonUiDelegate inCallButtonUiDelegate;
36 
RttOverflowMenu(Context context, InCallButtonUiDelegate inCallButtonUiDelegate)37   RttOverflowMenu(Context context, InCallButtonUiDelegate inCallButtonUiDelegate) {
38     super(context);
39     this.inCallButtonUiDelegate = inCallButtonUiDelegate;
40     View view = View.inflate(context, R.layout.overflow_menu, null);
41     setContentView(view);
42     setOnDismissListener(this::dismiss);
43     setFocusable(true);
44     setWidth(context.getResources().getDimensionPixelSize(R.dimen.rtt_overflow_menu_width));
45     muteButton = view.findViewById(R.id.menu_mute);
46     muteButton.setOnCheckedChangeListener(this);
47     speakerButton = view.findViewById(R.id.menu_speaker);
48     speakerButton.setOnCheckedChangeListener(this);
49     dialpadButton = view.findViewById(R.id.menu_keypad);
50     dialpadButton.setOnCheckedChangeListener(this);
51     addCallButton = view.findViewById(R.id.menu_add_call);
52     addCallButton.setOnCheckedChangeListener(this);
53   }
54 
55   @Override
onCheckedChanged(RttCheckableButton button, boolean isChecked)56   public void onCheckedChanged(RttCheckableButton button, boolean isChecked) {
57     if (button == muteButton) {
58       inCallButtonUiDelegate.muteClicked(isChecked, true);
59     } else if (button == speakerButton) {
60       inCallButtonUiDelegate.toggleSpeakerphone();
61     } else if (button == dialpadButton) {
62       inCallButtonUiDelegate.showDialpadClicked(isChecked);
63     } else if (button == addCallButton) {
64       inCallButtonUiDelegate.addCallClicked();
65     }
66   }
67 
setMuteButtonChecked(boolean isChecked)68   void setMuteButtonChecked(boolean isChecked) {
69     muteButton.setChecked(isChecked);
70   }
71 
setAudioState(CallAudioState audioState)72   void setAudioState(CallAudioState audioState) {
73     SpeakerButtonInfo info = new SpeakerButtonInfo(audioState, IconSize.SIZE_24_DP);
74     if (info.checkable) {
75       speakerButton.setChecked(info.isChecked);
76     }
77   }
78 }
79