• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.app.ActionBar;
20 import android.content.Context;
21 import android.os.Bundle;
22 import android.view.LayoutInflater;
23 import android.view.View;
24 import android.view.ViewGroup;
25 import android.widget.ListView;
26 
27 import com.android.contacts.common.ContactPhotoManager;
28 
29 import java.util.List;
30 
31 /**
32  * Fragment for call control buttons
33  */
34 public class ConferenceManagerFragment
35         extends BaseFragment<ConferenceManagerPresenter,
36                 ConferenceManagerPresenter.ConferenceManagerUi>
37         implements ConferenceManagerPresenter.ConferenceManagerUi {
38 
39     private ListView mConferenceParticipantList;
40     private int mActionBarElevation;
41     private ContactPhotoManager mContactPhotoManager;
42     private LayoutInflater mInflater;
43     private ConferenceParticipantListAdapter mConferenceParticipantListAdapter;
44 
45     @Override
createPresenter()46     ConferenceManagerPresenter createPresenter() {
47         // having a singleton instance.
48         return new ConferenceManagerPresenter();
49     }
50 
51     @Override
getUi()52     ConferenceManagerPresenter.ConferenceManagerUi getUi() {
53         return this;
54     }
55 
56     @Override
onCreate(Bundle savedInstanceState)57     public void onCreate(Bundle savedInstanceState) {
58         super.onCreate(savedInstanceState);
59     }
60 
61     @Override
onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)62     public View onCreateView(LayoutInflater inflater, ViewGroup container,
63             Bundle savedInstanceState) {
64         final View parent =
65                 inflater.inflate(R.layout.conference_manager_fragment, container, false);
66 
67         mConferenceParticipantList = (ListView) parent.findViewById(R.id.participantList);
68         mContactPhotoManager =
69                 ContactPhotoManager.getInstance(getActivity().getApplicationContext());
70         mActionBarElevation =
71                 (int) getResources().getDimension(R.dimen.incall_action_bar_elevation);
72         mInflater = LayoutInflater.from(getActivity().getApplicationContext());
73 
74         return parent;
75     }
76 
77     @Override
onActivityCreated(Bundle savedInstanceState)78     public void onActivityCreated(Bundle savedInstanceState) {
79         super.onActivityCreated(savedInstanceState);
80     }
81 
82     @Override
setVisible(boolean on)83     public void setVisible(boolean on) {
84         ActionBar actionBar = getActivity().getActionBar();
85 
86         if (on) {
87             actionBar.setTitle(R.string.manageConferenceLabel);
88             actionBar.setElevation(mActionBarElevation);
89             actionBar.setHideOffset(0);
90             actionBar.show();
91 
92             final CallList calls = CallList.getInstance();
93             getPresenter().init(getActivity(), calls);
94             getView().setVisibility(View.VISIBLE);
95             // Request focus on the list of participants for accessibility purposes.  This ensures
96             // that once the list of participants is shown, the first participant is announced.
97             mConferenceParticipantList.requestFocus();
98         } else {
99             getView().setVisibility(View.GONE);
100 
101             actionBar.setElevation(0);
102             actionBar.setHideOffset(actionBar.getHeight());
103         }
104     }
105 
106     @Override
isFragmentVisible()107     public boolean isFragmentVisible() {
108         return isVisible();
109     }
110 
111     @Override
update(Context context, List<Call> participants, boolean parentCanSeparate)112     public void update(Context context, List<Call> participants, boolean parentCanSeparate) {
113         if (mConferenceParticipantListAdapter == null) {
114             mConferenceParticipantListAdapter = new ConferenceParticipantListAdapter(
115                     mConferenceParticipantList, context, mInflater, mContactPhotoManager);
116 
117             mConferenceParticipantList.setAdapter(mConferenceParticipantListAdapter);
118         }
119         mConferenceParticipantListAdapter.updateParticipants(participants, parentCanSeparate);
120     }
121 
122     @Override
refreshCall(Call call)123     public void refreshCall(Call call) {
124         mConferenceParticipantListAdapter.refreshCall(call);
125     }
126 }
127