1 /* 2 * Copyright (C) 2017 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.dialer.calldetails; 18 19 import android.content.Context; 20 import android.content.Intent; 21 import com.android.dialer.calldetails.CallDetailsEntryViewHolder.CallDetailsEntryListener; 22 import com.android.dialer.calldetails.CallDetailsFooterViewHolder.DeleteCallDetailsListener; 23 import com.android.dialer.calldetails.CallDetailsFooterViewHolder.ReportCallIdListener; 24 import com.android.dialer.calldetails.CallDetailsHeaderViewHolder.CallDetailsHeaderListener; 25 import com.android.dialer.common.Assert; 26 import com.android.dialer.dialercontact.DialerContact; 27 import com.android.dialer.protos.ProtoParsers; 28 29 /** 30 * Displays the details of a specific call log entry. 31 * 32 * <p>This activity is for the old call log. 33 * 34 * <p>See {@link CallDetailsAdapterCommon} for logic shared between this activity and the one for 35 * the new call log. 36 */ 37 public final class OldCallDetailsActivity extends CallDetailsActivityCommon { 38 public static final String EXTRA_CALL_DETAILS_ENTRIES = "call_details_entries"; 39 public static final String EXTRA_CONTACT = "contact"; 40 41 /** Contains info to be shown in the header. */ 42 private DialerContact contact; 43 isLaunchIntent(Intent intent)44 public static boolean isLaunchIntent(Intent intent) { 45 return intent.getComponent() != null 46 && OldCallDetailsActivity.class.getName().equals(intent.getComponent().getClassName()); 47 } 48 49 /** Returns an {@link Intent} to launch this activity. */ newInstance( Context context, CallDetailsEntries details, DialerContact contact, boolean canReportCallerId, boolean canSupportAssistedDialing)50 public static Intent newInstance( 51 Context context, 52 CallDetailsEntries details, 53 DialerContact contact, 54 boolean canReportCallerId, 55 boolean canSupportAssistedDialing) { 56 Intent intent = new Intent(context, OldCallDetailsActivity.class); 57 ProtoParsers.put(intent, EXTRA_CONTACT, Assert.isNotNull(contact)); 58 ProtoParsers.put(intent, EXTRA_CALL_DETAILS_ENTRIES, Assert.isNotNull(details)); 59 intent.putExtra(EXTRA_CAN_REPORT_CALLER_ID, canReportCallerId); 60 intent.putExtra(EXTRA_CAN_SUPPORT_ASSISTED_DIALING, canSupportAssistedDialing); 61 return intent; 62 } 63 64 @Override handleIntent(Intent intent)65 protected void handleIntent(Intent intent) { 66 Assert.checkArgument(intent.hasExtra(EXTRA_CONTACT)); 67 Assert.checkArgument(intent.hasExtra(EXTRA_CALL_DETAILS_ENTRIES)); 68 Assert.checkArgument(intent.hasExtra(EXTRA_CAN_REPORT_CALLER_ID)); 69 Assert.checkArgument(intent.hasExtra(EXTRA_CAN_SUPPORT_ASSISTED_DIALING)); 70 71 contact = ProtoParsers.getTrusted(intent, EXTRA_CONTACT, DialerContact.getDefaultInstance()); 72 setCallDetailsEntries( 73 ProtoParsers.getTrusted( 74 intent, EXTRA_CALL_DETAILS_ENTRIES, CallDetailsEntries.getDefaultInstance())); 75 loadRttTranscriptAvailability(); 76 } 77 78 @Override createAdapter( CallDetailsEntryListener callDetailsEntryListener, CallDetailsHeaderListener callDetailsHeaderListener, ReportCallIdListener reportCallIdListener, DeleteCallDetailsListener deleteCallDetailsListener)79 protected CallDetailsAdapterCommon createAdapter( 80 CallDetailsEntryListener callDetailsEntryListener, 81 CallDetailsHeaderListener callDetailsHeaderListener, 82 ReportCallIdListener reportCallIdListener, 83 DeleteCallDetailsListener deleteCallDetailsListener) { 84 return new OldCallDetailsAdapter( 85 /* context = */ this, 86 contact, 87 getCallDetailsEntries(), 88 callDetailsEntryListener, 89 callDetailsHeaderListener, 90 reportCallIdListener, 91 deleteCallDetailsListener); 92 } 93 94 @Override getNumber()95 protected String getNumber() { 96 return contact.getNumber(); 97 } 98 } 99