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.calllog.ui.menu; 18 19 import android.content.Context; 20 import android.provider.CallLog.Calls; 21 import android.view.View; 22 import com.android.dialer.calllog.CallLogComponent; 23 import com.android.dialer.calllog.model.CoalescedRow; 24 import com.android.dialer.common.concurrent.DefaultFutureCallback; 25 import com.android.dialer.glidephotomanager.GlidePhotoManager; 26 import com.android.dialer.historyitemactions.HistoryItemActionBottomSheet; 27 import com.google.common.util.concurrent.Futures; 28 import com.google.common.util.concurrent.MoreExecutors; 29 30 /** Handles configuration of the bottom sheet menus for call log entries. */ 31 public final class NewCallLogMenu { 32 33 /** Creates and returns the OnClickListener which opens the menu for the provided row. */ createOnClickListener( Context context, CoalescedRow row, GlidePhotoManager glidePhotoManager)34 public static View.OnClickListener createOnClickListener( 35 Context context, CoalescedRow row, GlidePhotoManager glidePhotoManager) { 36 return view -> { 37 HistoryItemActionBottomSheet.show( 38 context, 39 PrimaryAction.fromRow(context, row), 40 Modules.fromRow(context, row), 41 glidePhotoManager); 42 43 // If the user opens the bottom sheet for a new call, clear the notifications and make the row 44 // not bold immediately. To do this, mark all of the calls in group as not new. 45 if (row.isNew() && row.callType() == Calls.MISSED_TYPE) { 46 Futures.addCallback( 47 CallLogComponent.get(context) 48 .getClearMissedCalls() 49 .clearBySystemCallLogId(row.coalescedIds().getCoalescedIdList()), 50 new DefaultFutureCallback<>(), 51 MoreExecutors.directExecutor()); 52 } 53 }; 54 } 55 } 56