1 /*
2  * Copyright (C) 2015 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.server.telecom.testapps;
18 
19 import android.app.Activity;
20 import android.graphics.Color;
21 import android.os.Bundle;
22 import android.telecom.Call;
23 import android.util.Log;
24 import android.view.View;
25 import android.view.View.OnClickListener;
26 import android.widget.ListView;
27 
28 public class TestInCallUI extends Activity {
29 
30     private ListView mListView;
31     private TestCallList mCallList;
32 
33     /** ${inheritDoc} */
34     @Override
onCreate(Bundle savedInstanceState)35     protected void onCreate(Bundle savedInstanceState) {
36         super.onCreate(savedInstanceState);
37 
38         setContentView(R.layout.incall_screen);
39 
40         mListView = (ListView) findViewById(R.id.callListView);
41         mListView.setAdapter(new CallListAdapter(this));
42         mListView.setVisibility(View.VISIBLE);
43 
44         mCallList = TestCallList.getInstance();
45         mCallList.addListener(new TestCallList.Listener() {
46             @Override
47             public void onCallRemoved(Call call) {
48                 if (mCallList.size() == 0) {
49                     Log.i("Santos", "Ending the incall UI");
50                     finish();
51                 }
52             }
53         });
54 
55         View endCallButton = findViewById(R.id.end_call_button);
56         View holdButton = findViewById(R.id.hold_button);
57         View muteButton = findViewById(R.id.mute_button);
58 
59         endCallButton.setOnClickListener(new OnClickListener() {
60             @Override
61             public void onClick(View view) {
62                 Call call = mCallList.getCall(0);
63                 if (call != null) {
64                     call.disconnect();
65                 }
66             }
67         });
68         holdButton.setOnClickListener(new OnClickListener() {
69             @Override
70             public void onClick(View view) {
71                 Call call = mCallList.getCall(0);
72                 if (call != null) {
73                     if (call.getState() == Call.STATE_HOLDING) {
74                         call.unhold();
75                     } else {
76                         call.hold();
77                     }
78                 }
79             }
80         });
81         muteButton.setOnClickListener(new OnClickListener() {
82             @Override
83             public void onClick(View view) {
84                 Call call = mCallList.getCall(0);
85                 if (call != null) {
86                 }
87             }
88         });
89     }
90 
91     /** ${inheritDoc} */
92     @Override
onDestroy()93     protected void onDestroy() {
94         super.onDestroy();
95     }
96 
97     @Override
onPause()98     protected void onPause() {
99         super.onPause();
100     }
101 
102     @Override
onStart()103     protected void onStart() {
104         super.onStart();
105     }
106 
107     @Override
onResume()108     protected void onResume() {
109         super.onResume();
110     }
111 }
112