Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 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; |
Eric Erfanian | fc0eb8c | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 24 | import com.android.dialer.contactphoto.ContactPhotoManager; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 25 | import com.android.dialer.logging.Logger; |
Eric Erfanian | 8369df0 | 2017-05-03 10:27:13 -0700 | [diff] [blame] | 26 | import com.android.dialer.logging.ScreenEvent; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 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 | |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 38 | private ListView conferenceParticipantList; |
| 39 | private ContactPhotoManager contactPhotoManager; |
| 40 | private ConferenceParticipantListAdapter conferenceParticipantListAdapter; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 41 | |
| 42 | @Override |
| 43 | public ConferenceManagerPresenter createPresenter() { |
| 44 | return new ConferenceManagerPresenter(); |
| 45 | } |
| 46 | |
| 47 | @Override |
| 48 | public ConferenceManagerPresenter.ConferenceManagerUi getUi() { |
| 49 | return this; |
| 50 | } |
| 51 | |
| 52 | @Override |
| 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 |
| 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 | |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 65 | conferenceParticipantList = (ListView) parent.findViewById(R.id.participantList); |
| 66 | contactPhotoManager = ContactPhotoManager.getInstance(getActivity().getApplicationContext()); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 67 | |
| 68 | return parent; |
| 69 | } |
| 70 | |
| 71 | @Override |
| 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. |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 78 | conferenceParticipantList.requestFocus(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | @Override |
| 82 | public void onSaveInstanceState(Bundle outState) { |
| 83 | super.onSaveInstanceState(outState); |
| 84 | } |
| 85 | |
| 86 | @Override |
| 87 | public boolean isFragmentVisible() { |
| 88 | return isVisible(); |
| 89 | } |
| 90 | |
| 91 | @Override |
| 92 | public void update(List<DialerCall> participants, boolean parentCanSeparate) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 93 | if (conferenceParticipantListAdapter == null) { |
| 94 | conferenceParticipantListAdapter = |
| 95 | new ConferenceParticipantListAdapter(conferenceParticipantList, contactPhotoManager); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 96 | |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 97 | conferenceParticipantList.setAdapter(conferenceParticipantListAdapter); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 98 | } |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 99 | conferenceParticipantListAdapter.updateParticipants(participants, parentCanSeparate); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | @Override |
| 103 | public void refreshCall(DialerCall call) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 104 | conferenceParticipantListAdapter.refreshCall(call); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 105 | } |
| 106 | } |