1 /*
2  * Copyright (C) 2013 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;
18 
19 import android.os.Bundle;
20 import android.view.LayoutInflater;
21 import android.view.View;
22 import android.view.ViewGroup;
23 import android.widget.ListView;
24 import com.android.contacts.common.ContactPhotoManager;
25 import com.android.dialer.logging.Logger;
26 import com.android.dialer.logging.ScreenEvent;
27 import com.android.incallui.ConferenceManagerPresenter.ConferenceManagerUi;
28 import com.android.incallui.baseui.BaseFragment;
29 import com.android.incallui.call.CallList;
30 import com.android.incallui.call.DialerCall;
31 import java.util.List;
32 
33 /** Fragment that allows the user to manage a conference call. */
34 public class ConferenceManagerFragment
35     extends BaseFragment<ConferenceManagerPresenter, ConferenceManagerUi>
36     implements ConferenceManagerPresenter.ConferenceManagerUi {
37 
38   private ListView mConferenceParticipantList;
39   private ContactPhotoManager mContactPhotoManager;
40   private ConferenceParticipantListAdapter mConferenceParticipantListAdapter;
41 
42   @Override
createPresenter()43   public ConferenceManagerPresenter createPresenter() {
44     return new ConferenceManagerPresenter();
45   }
46 
47   @Override
getUi()48   public ConferenceManagerPresenter.ConferenceManagerUi getUi() {
49     return this;
50   }
51 
52   @Override
onCreate(Bundle savedInstanceState)53   public void onCreate(Bundle savedInstanceState) {
54     super.onCreate(savedInstanceState);
55     if (savedInstanceState != null) {
56       Logger.get(getContext()).logScreenView(ScreenEvent.Type.CONFERENCE_MANAGEMENT, getActivity());
57     }
58   }
59 
60   @Override
onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)61   public View onCreateView(
62       LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
63     final View parent = inflater.inflate(R.layout.conference_manager_fragment, container, false);
64 
65     mConferenceParticipantList = (ListView) parent.findViewById(R.id.participantList);
66     mContactPhotoManager = ContactPhotoManager.getInstance(getActivity().getApplicationContext());
67 
68     return parent;
69   }
70 
71   @Override
onResume()72   public void onResume() {
73     super.onResume();
74     final CallList calls = CallList.getInstance();
75     getPresenter().init(calls);
76     // Request focus on the list of participants for accessibility purposes.  This ensures
77     // that once the list of participants is shown, the first participant is announced.
78     mConferenceParticipantList.requestFocus();
79   }
80 
81   @Override
onSaveInstanceState(Bundle outState)82   public void onSaveInstanceState(Bundle outState) {
83     super.onSaveInstanceState(outState);
84   }
85 
86   @Override
isFragmentVisible()87   public boolean isFragmentVisible() {
88     return isVisible();
89   }
90 
91   @Override
update(List<DialerCall> participants, boolean parentCanSeparate)92   public void update(List<DialerCall> participants, boolean parentCanSeparate) {
93     if (mConferenceParticipantListAdapter == null) {
94       mConferenceParticipantListAdapter =
95           new ConferenceParticipantListAdapter(mConferenceParticipantList, mContactPhotoManager);
96 
97       mConferenceParticipantList.setAdapter(mConferenceParticipantListAdapter);
98     }
99     mConferenceParticipantListAdapter.updateParticipants(participants, parentCanSeparate);
100   }
101 
102   @Override
refreshCall(DialerCall call)103   public void refreshCall(DialerCall call) {
104     mConferenceParticipantListAdapter.refreshCall(call);
105   }
106 }
107