diff options
author | Yuzhou <jiayuzhou@google.com> | 2018-04-21 17:20:47 -0700 |
---|---|---|
committer | Yuzhou Jia <jiayuzhou@google.com> | 2018-04-25 20:28:03 +0000 |
commit | 186357b18efe58929d910d6e699492db1f2d13cb (patch) | |
tree | 65c6df1883f61e34efd782cd555a51982c663b7f | |
parent | 9101760369ab89da6f42544b62948f54e33c5cc7 (diff) | |
download | platform_packages_apps_Car_Dialer-186357b18efe58929d910d6e699492db1f2d13cb.tar.gz platform_packages_apps_Car_Dialer-186357b18efe58929d910d6e699492db1f2d13cb.tar.bz2 platform_packages_apps_Car_Dialer-186357b18efe58929d910d6e699492db1f2d13cb.zip |
DO NOT MERGE Fix the regression that clicking on a call log won't have any action.
Bug: 78404733.
Test: build and load the app.
Change-Id: I9905e172b527f497a7176f7b114c7b05a204d3a0
-rw-r--r-- | src/com/android/car/dialer/ui/CallHistoryListItemProvider.java | 11 | ||||
-rw-r--r-- | src/com/android/car/dialer/ui/listitem/CallLogListItem.java | 53 |
2 files changed, 56 insertions, 8 deletions
diff --git a/src/com/android/car/dialer/ui/CallHistoryListItemProvider.java b/src/com/android/car/dialer/ui/CallHistoryListItemProvider.java index bff1c22e..2b905efa 100644 --- a/src/com/android/car/dialer/ui/CallHistoryListItemProvider.java +++ b/src/com/android/car/dialer/ui/CallHistoryListItemProvider.java @@ -22,24 +22,19 @@ import androidx.car.widget.ListItem; import androidx.car.widget.ListItemProvider; import androidx.car.widget.TextListItem; +import com.android.car.dialer.ui.listitem.CallLogListItem; + import java.util.ArrayList; import java.util.List; public class CallHistoryListItemProvider extends ListItemProvider { - private List<TextListItem> mItems = new ArrayList<>(); public void setCallHistoryListItems(Context context, List<CallLogListingTask.CallLogItem> items) { - for (CallLogListingTask.CallLogItem callLogItem : items) { - TextListItem textListItem = new TextListItem(context); - textListItem.setPrimaryActionIcon( - new BitmapDrawable(context.getResources(), callLogItem.mIcon), true); - textListItem.setTitle(callLogItem.mTitle); - textListItem.setBody(callLogItem.mText); - mItems.add(textListItem); + mItems.add(new CallLogListItem(context, callLogItem)); } } diff --git a/src/com/android/car/dialer/ui/listitem/CallLogListItem.java b/src/com/android/car/dialer/ui/listitem/CallLogListItem.java new file mode 100644 index 00000000..c0cb4143 --- /dev/null +++ b/src/com/android/car/dialer/ui/listitem/CallLogListItem.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.car.dialer.ui.listitem; + +import android.content.Context; +import android.graphics.drawable.BitmapDrawable; + +import androidx.car.widget.TextListItem; + +import com.android.car.dialer.telecom.UiCallManager; +import com.android.car.dialer.ui.CallHistoryListItemProvider; +import com.android.car.dialer.ui.CallLogListingTask; + +/** + * List item which is created by {@link CallHistoryListItemProvider} binds a call list item to a + * list view item. + */ +public class CallLogListItem extends TextListItem { + private final CallLogListingTask.CallLogItem mCallLogItem; + private final Context mContext; + + public CallLogListItem(Context context, CallLogListingTask.CallLogItem callLog) { + super(context); + mCallLogItem = callLog; + mContext = context; + } + + @Override + public void onBind(ViewHolder viewHolder) { + super.onBind(viewHolder); + setPrimaryActionIcon( + new BitmapDrawable(mContext.getResources(), mCallLogItem.mIcon), true); + setTitle(mCallLogItem.mTitle); + setBody(mCallLogItem.mText); + + viewHolder.itemView.setOnClickListener((v) -> { + UiCallManager.get().safePlaceCall(mCallLogItem.mNumber, false); + }); + } +} |