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.historyitemactions.HistoryItemActionBottomSheet; 26 import com.google.common.util.concurrent.Futures; 27 import com.google.common.util.concurrent.MoreExecutors; 28 29 /** Handles configuration of the bottom sheet menus for call log entries. */ 30 public final class NewCallLogMenu { 31 32 /** Creates and returns the OnClickListener which opens the menu for the provided row. */ createOnClickListener(Context context, CoalescedRow row)33 public static View.OnClickListener createOnClickListener(Context context, CoalescedRow row) { 34 return view -> { 35 HistoryItemActionBottomSheet.show( 36 context, BottomSheetHeader.fromRow(context, row), Modules.fromRow(context, row)); 37 38 // If the user opens the bottom sheet for an unread call, clear the notifications and make the 39 // row not bold immediately. To do this, mark all of the calls in group as read. 40 if (!row.getIsRead() && row.getCallType() == Calls.MISSED_TYPE) { 41 Futures.addCallback( 42 CallLogComponent.get(context) 43 .getClearMissedCalls() 44 .clearBySystemCallLogId(row.getCoalescedIds().getCoalescedIdList()), 45 new DefaultFutureCallback<>(), 46 MoreExecutors.directExecutor()); 47 } 48 }; 49 } 50 } 51