diff options
author | Andrew Lee <anwlee@google.com> | 2015-05-04 17:24:01 -0700 |
---|---|---|
committer | Andrew Lee <anwlee@google.com> | 2015-05-04 17:43:36 -0700 |
commit | 69705be50fc4c84b35df88c879dd9a4b4de655b3 (patch) | |
tree | 08967f96cfc5f9070ec287efb1fd5a53cf36a393 | |
parent | d10eef28fc67aea0e4f4f49813b802ce1df5f7c7 (diff) |
Add "show call history" list item.
+ Add new VIEW_TYPE to the CallLogAdapter.
+ Reintroduce boolean on CallLogAdapter to specify if a call history
list item should be shown.
+ Add new ViewHolder and layout for footer.
+ Some minor styling tweaks and cleanups.
Bug: 20108202
Change-Id: Ie4a86bff9e53cfd69ef8b061af048f40f4358579
-rw-r--r-- | res/layout/call_log_list_item.xml | 4 | ||||
-rw-r--r-- | res/layout/show_call_history_list_item.xml | 30 | ||||
-rw-r--r-- | res/values/dimens.xml | 10 | ||||
-rw-r--r-- | res/values/strings.xml | 4 | ||||
-rw-r--r-- | res/values/styles.xml | 2 | ||||
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 13 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/CallLogAdapter.java | 28 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/CallLogFragment.java | 18 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/ShowCallHistoryViewHolder.java | 46 | ||||
-rw-r--r-- | src/com/android/dialer/list/ListsFragment.java | 1 |
10 files changed, 132 insertions, 24 deletions
diff --git a/res/layout/call_log_list_item.xml b/res/layout/call_log_list_item.xml index a0ed5c799..5928183f8 100644 --- a/res/layout/call_log_list_item.xml +++ b/res/layout/call_log_list_item.xml @@ -49,8 +49,8 @@ android:layout_height="wrap_content" android:paddingStart="@dimen/call_log_start_margin" android:paddingEnd="@dimen/call_log_outer_margin" - android:paddingTop="@dimen/call_log_outer_margin" - android:paddingBottom="@dimen/call_log_outer_margin" + android:paddingTop="@dimen/call_log_vertical_padding" + android:paddingBottom="@dimen/call_log_vertical_padding" android:orientation="horizontal" android:gravity="center_vertical" android:focusable="true" diff --git a/res/layout/show_call_history_list_item.xml b/res/layout/show_call_history_list_item.xml new file mode 100644 index 000000000..1264894a9 --- /dev/null +++ b/res/layout/show_call_history_list_item.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 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. +--> + +<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" + style="@style/CallLogCardStyle" + android:layout_height="40dp" + android:clickable="true" + android:foreground="?android:attr/selectableItemBackground"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:text="@string/show_call_history" /> + +</android.support.v7.widget.CardView> + diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 502b21a59..b9b3aa587 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -22,15 +22,17 @@ <dimen name="remove_text_size">16dp</dimen> <!-- Call Log --> - <dimen name="call_log_call_action_size">32dip</dimen> + <dimen name="call_log_call_action_size">32dp</dimen> <dimen name="call_log_call_action_width">54dp</dimen> - <dimen name="call_log_icon_margin">4dip</dimen> - <dimen name="call_log_inner_margin">13dip</dimen> + <dimen name="call_log_icon_margin">4dp</dimen> + <dimen name="call_log_inner_margin">13dp</dimen> <dimen name="call_log_outer_margin">8dp</dimen> <dimen name="call_log_start_margin">16dp</dimen> - <dimen name="call_log_indent_margin">24dip</dimen> + <dimen name="call_log_indent_margin">24dp</dimen> <dimen name="call_log_name_margin_bottom">2dp</dimen> + <dimen name="call_log_vertical_padding">12dp</dimen> <dimen name="call_log_list_item_height">56dip</dimen> + <dimen name="show_call_history_list_item_height">72dp</dimen> <!-- Size of contact photos in the call log and call details. --> <dimen name="contact_photo_size">40dp</dimen> diff --git a/res/values/strings.xml b/res/values/strings.xml index 4ee5b45c8..7568604af 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -512,8 +512,8 @@ <!-- Shortcut item used to make a video call directly from search. --> <string name="search_shortcut_make_video_call">Make video call</string> - <!-- Title for the recent calls footer that brings users to the full call history when clicked --> - <string name="recents_footer_text">View full call history</string> + <!-- Title for the call log list item that brings users to the full call history when clicked --> + <string name="show_call_history">View full call history</string> <!-- Number of missed calls shown on call card [CHAR LIMIT=40] --> <string name="num_missed_calls"><xliff:g id="number">%s</xliff:g> new missed calls</string> diff --git a/res/values/styles.xml b/res/values/styles.xml index dacf6a47c..2cd4aa3e6 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -198,7 +198,7 @@ <item name="android:layout_height">wrap_content</item> <item name="android:layout_margin">4dp</item> <item name="android:baselineAligned">false</item> - <item name="cardCornerRadius">4dp</item> + <item name="cardCornerRadius">2dp</item> <item name="cardBackgroundColor">@color/background_dialer_call_log_list_item</item> </style> </resources> diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 167c131cb..1e0b7e0f2 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -609,7 +609,10 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.menu_history: - showCallHistory(); + // Use explicit CallLogActivity intent instead of ACTION_VIEW + + // CONTENT_TYPE, so that we always open our call log from our dialer + final Intent intent = new Intent(this, CallLogActivity.class); + startActivity(intent); break; case R.id.menu_add_contact: try { @@ -1101,14 +1104,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O return resolveInfo != null && resolveInfo.size() > 0; } - @Override - public void showCallHistory() { - // Use explicit CallLogActivity intent instead of ACTION_VIEW + - // CONTENT_TYPE, so that we always open our call log from our dialer - final Intent intent = new Intent(this, CallLogActivity.class); - startActivity(intent); - } - /** * Called when the user has long-pressed a contact tile to start a drag operation. */ diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index f2a84c99f..8e22834e5 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -78,6 +78,8 @@ public class CallLogAdapter extends GroupingListAdapter public void onReportButtonClick(String number); } + private static final int VIEW_TYPE_SHOW_CALL_HISTORY_LIST_ITEM = 10; + /** Constant used to indicate no row is expanded. */ private static final long NONE_EXPANDED = -1; @@ -89,6 +91,8 @@ public class CallLogAdapter extends GroupingListAdapter protected ContactInfoCache mContactInfoCache; + private boolean mShowCallHistoryListItem = false; + /** * Tracks the currently expanded call log row. */ @@ -254,6 +258,9 @@ public class CallLogAdapter extends GroupingListAdapter @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + if (viewType == VIEW_TYPE_SHOW_CALL_HISTORY_LIST_ITEM) { + return ShowCallHistoryViewHolder.create(mContext, parent); + } return createCallLogEntryViewHolder(parent); } @@ -287,6 +294,10 @@ public class CallLogAdapter extends GroupingListAdapter * @param count the number of entries in the current item, greater than 1 if it is a group */ public void onBindViewHolder(ViewHolder viewHolder, int position) { + if (getItemViewType(position) == VIEW_TYPE_SHOW_CALL_HISTORY_LIST_ITEM) { + return; + } + Cursor c = (Cursor) getItem(position); if (c == null) { return; @@ -414,6 +425,23 @@ public class CallLogAdapter extends GroupingListAdapter } } + @Override + public int getItemCount() { + return super.getItemCount() + (mShowCallHistoryListItem ? 1 : 0); + } + + @Override + public int getItemViewType(int position) { + if (position == getItemCount() - 1 && mShowCallHistoryListItem) { + return VIEW_TYPE_SHOW_CALL_HISTORY_LIST_ITEM; + } + return super.getItemViewType(position); + } + + public void setShowCallHistoryListItem(boolean show) { + mShowCallHistoryListItem = show; + } + /** * Retrieves the day group of the previous call in the call log. Used to determine if the day * group has changed and to trigger display of the day group text. diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index 4f4fc1b94..85fca9139 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -77,6 +77,11 @@ public class CallLogFragment extends Fragment private static final String KEY_LOG_LIMIT = "log_limit"; private static final String KEY_DATE_LIMIT = "date_limit"; + // No limit specified for the number of logs to show; use the CallLogQueryHandler's default. + private static final int NO_LOG_LIMIT = -1; + // No date-based filtering. + private static final int NO_DATE_LIMIT = 0; + private RecyclerView mRecyclerView; private LinearLayoutManager mLayoutManager; private CallLogAdapter mAdapter; @@ -123,18 +128,18 @@ public class CallLogFragment extends Fragment // Log limit - if no limit is specified, then the default in {@link CallLogQueryHandler} // will be used. - private int mLogLimit = -1; + private int mLogLimit = NO_LOG_LIMIT; // Date limit (in millis since epoch) - when non-zero, only calls which occurred on or after // the date filter are included. If zero, no date-based filtering occurs. - private long mDateLimit = 0; + private long mDateLimit = NO_DATE_LIMIT; public CallLogFragment() { - this(CallLogQueryHandler.CALL_TYPE_ALL, -1); + this(CallLogQueryHandler.CALL_TYPE_ALL, NO_LOG_LIMIT); } public CallLogFragment(int filterType) { - this(filterType, -1); + this(filterType, NO_LOG_LIMIT); } public CallLogFragment(int filterType, int logLimit) { @@ -150,7 +155,7 @@ public class CallLogFragment extends Fragment * @param dateLimit limits results to calls occurring on or after the specified date. */ public CallLogFragment(int filterType, long dateLimit) { - this(filterType, -1, dateLimit); + this(filterType, NO_LOG_LIMIT, dateLimit); } /** @@ -278,6 +283,9 @@ public class CallLogFragment extends Fragment String currentCountryIso = GeoUtil.getCurrentCountryIso(getActivity()); mAdapter = ObjectFactory.newCallLogAdapter(getActivity(), this, new ContactInfoHelper(getActivity(), currentCountryIso), this); + if (mLogLimit != NO_LOG_LIMIT || mDateLimit != NO_DATE_LIMIT) { + mAdapter.setShowCallHistoryListItem(true); + } mRecyclerView.setAdapter(mAdapter); mVoicemailStatusHelper = new VoicemailStatusHelperImpl(); diff --git a/src/com/android/dialer/calllog/ShowCallHistoryViewHolder.java b/src/com/android/dialer/calllog/ShowCallHistoryViewHolder.java new file mode 100644 index 000000000..af36a4d33 --- /dev/null +++ b/src/com/android/dialer/calllog/ShowCallHistoryViewHolder.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2015 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.dialer.calllog; + +import android.content.Context; +import android.content.Intent; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.android.dialer.R; + +public final class ShowCallHistoryViewHolder extends RecyclerView.ViewHolder { + + private ShowCallHistoryViewHolder(final Context context, View view) { + super(view); + view.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + final Intent intent = new Intent(context, CallLogActivity.class); + context.startActivity(intent); + } + }); + } + + public static ShowCallHistoryViewHolder create(Context context, ViewGroup parent) { + LayoutInflater inflater = LayoutInflater.from(context); + View view = inflater.inflate(R.layout.show_call_history_list_item, parent, false); + return new ShowCallHistoryViewHolder(context, view); + } +} diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java index f22a5d19c..4e7e00de6 100644 --- a/src/com/android/dialer/list/ListsFragment.java +++ b/src/com/android/dialer/list/ListsFragment.java @@ -60,7 +60,6 @@ public class ListsFragment extends Fragment implements ViewPager.OnPageChangeLis "key_last_dismissed_call_shortcut_date"; public interface HostInterface { - public void showCallHistory(); public ActionBarController getActionBarController(); } |