Loading res/layout/call_log_list_item_extra.xml +40 −35 Original line number Diff line number Diff line Loading @@ -18,9 +18,9 @@ <!-- Can't use merge here because this is referenced via a ViewStub --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/badge_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/badge_container"> android:layout_height="wrap_content"> <View android:layout_width="match_parent" android:layout_height="1px" Loading @@ -31,22 +31,25 @@ android:layout_height="wrap_content" android:paddingStart="@dimen/call_log_outer_margin" android:paddingEnd="@dimen/call_log_outer_margin" android:paddingTop="0dip" android:paddingBottom="0dip" android:paddingTop="@dimen/call_log_item_extra_padding_vertical" android:paddingBottom="@dimen/call_log_item_extra_padding_vertical" android:background="?android:attr/selectableItemBackground" android:clickable="true"> <ImageView android:layout_width="wrap_content" <ImageView android:id="@+id/badge_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/badge_image" android:tint="@color/dialpad_primary_text_color" android:padding="@dimen/call_log_outer_margin" /> <TextView android:layout_width="wrap_content" <TextView android:id="@+id/badge_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingStart="@dimen/call_log_start_margin" android:id="@+id/badge_text" android:textColor="@color/dialpad_primary_text_color" android:layout_gravity="center_vertical" android:layout_weight="1" /> <ImageView android:id="@+id/dismiss_button" android:layout_width="wrap_content" android:layout_height="wrap_content" Loading @@ -58,5 +61,7 @@ android:background="?android:attr/selectableItemBackground" android:visibility="gone" android:contentDescription="@string/description_dismiss" /> </LinearLayout> </FrameLayout> No newline at end of file res/values/dimens.xml +3 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,9 @@ <dimen name="recent_call_log_item_padding_top">12dp</dimen> <dimen name="recent_call_log_item_padding_bottom">11dp</dimen> <dimen name="call_log_item_extra_padding_vertical">4dp</dimen> <!-- Size of the star icon on the favorites tile. --> <dimen name="favorites_star_icon_size">12dp</dimen> Loading src/com/android/dialer/calllog/CallLogAdapter.java +14 −79 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import com.android.common.widget.GroupingListAdapter; import com.android.contacts.common.ContactPhotoManager; import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; import com.android.contacts.common.util.UriUtils; import com.android.dialer.DialtactsActivity; import com.android.dialer.PhoneCallDetails; import com.android.dialer.PhoneCallDetailsHelper; import com.android.dialer.R; Loading Loading @@ -255,8 +256,6 @@ public class CallLogAdapter extends GroupingListAdapter private volatile boolean mRequestProcessingDisabled = false; private boolean mIsCallLog = true; private int mNumMissedCalls = 0; private int mNumMissedCallsShown = 0; private View mBadgeContainer; private ImageView mBadgeImageView; Loading Loading @@ -1032,21 +1031,13 @@ public class CallLogAdapter extends GroupingListAdapter mCallLogViewsHelper.setActionContentDescriptions(views); } protected void bindBadge(View view, ContactInfo info, PhoneCallDetails details, int callType) { protected void bindBadge( View view, ContactInfo info, final PhoneCallDetails details, int callType) { // Do not show badge in call log. if (!mIsCallLog) { final int numMissed = getNumMissedCalls(callType); final ViewStub stub = (ViewStub) view.findViewById(R.id.link_stub); if (shouldShowBadge(numMissed, info, details)) { // Do not process if the data has not changed (optimization since bind view is // called multiple times due to contact lookup). if (numMissed == mNumMissedCallsShown) { return; } // stub will be null if it was already inflated. if (TextUtils.isEmpty(info.lookupKey)) { if (stub != null) { final View inflated = stub.inflate(); inflated.setVisibility(View.VISIBLE); Loading @@ -1055,11 +1046,16 @@ public class CallLogAdapter extends GroupingListAdapter mBadgeText = (TextView) inflated.findViewById(R.id.badge_text); } mBadgeContainer.setOnClickListener(getBadgeClickListener()); mBadgeImageView.setImageResource(getBadgeImageResId()); mBadgeText.setText(getBadgeText(numMissed)); mNumMissedCallsShown = numMissed; mBadgeContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Intent intent = DialtactsActivity.getAddNumberToContactIntent(details.number); mContext.startActivity(intent); } }); mBadgeImageView.setImageResource(R.drawable.ic_person_add_24dp); mBadgeText.setText(R.string.recentCalls_addToContact); } else { // Hide badge if it was previously shown. if (stub == null) { Loading @@ -1072,67 +1068,6 @@ public class CallLogAdapter extends GroupingListAdapter } } public void setMissedCalls(Cursor data) { final int missed; if (data == null) { missed = 0; } else { missed = data.getCount(); } // Only need to update if the number of calls changed. if (missed != mNumMissedCalls) { mNumMissedCalls = missed; notifyDataSetChanged(); } } protected View.OnClickListener getBadgeClickListener() { return new View.OnClickListener() { @Override public void onClick(View v) { final Intent intent = new Intent(mContext, CallLogActivity.class); mContext.startActivity(intent); } }; } /** * Get the resource id for the image to be shown for the badge. */ protected int getBadgeImageResId() { return R.drawable.ic_call_log_blue; } /** * Get the text to be shown for the badge. * * @param numMissed The number of missed calls. */ protected String getBadgeText(int numMissed) { return mContext.getResources().getString(R.string.num_missed_calls, numMissed); } /** * Whether to show the badge. * * @param numMissedCalls The number of missed calls. * @param info The contact info. * @param details The call detail. * @return {@literal true} if badge should be shown. {@literal false} otherwise. */ protected boolean shouldShowBadge(int numMissedCalls, ContactInfo info, PhoneCallDetails details) { return numMissedCalls > 0; } private int getNumMissedCalls(int callType) { if (callType == Calls.MISSED_TYPE) { // Exclude the current missed call shown in the shortcut. return mNumMissedCalls - 1; } return mNumMissedCalls; } /** Checks whether the contact info from the call log matches the one from the contacts db. */ private boolean callLogInfoMatches(ContactInfo callLogInfo, ContactInfo info) { // The call log only contains a subset of the fields in the contacts db. Loading src/com/android/dialer/list/ListsFragment.java +0 −25 Original line number Diff line number Diff line Loading @@ -70,9 +70,6 @@ public class ListsFragment extends AnalyticsFragment implements CallLogQueryHand public static final float REMOVE_VIEW_SHOWN_ALPHA = 0.5f; public static final float REMOVE_VIEW_HIDDEN_ALPHA = 1; // Used with LoaderManager private static int MISSED_CALL_LOADER = 1; public interface HostInterface { public void showCallHistory(); public int getActionBarHeight(); Loading Loading @@ -111,27 +108,6 @@ public class ListsFragment extends AnalyticsFragment implements CallLogQueryHand */ private long mCurrentCallShortcutDate = 0; private class MissedCallLogLoaderListener implements LoaderManager.LoaderCallbacks<Cursor> { @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { final Uri uri = CallLog.Calls.CONTENT_URI; final String[] projection = new String[] {CallLog.Calls.TYPE}; final String selection = CallLog.Calls.TYPE + " = " + CallLog.Calls.MISSED_TYPE + " AND " + CallLog.Calls.IS_READ + " = 0"; return new CursorLoader(getActivity(), uri, projection, selection, null, null); } @Override public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor data) { mCallLogAdapter.setMissedCalls(data); } @Override public void onLoaderReset(Loader<Cursor> cursorLoader) { } } private PanelSlideListener mPanelSlideListener = new PanelSlideListener() { @Override public void onPanelSlide(View panel, float slideOffset) { Loading Loading @@ -229,7 +205,6 @@ public class ListsFragment extends AnalyticsFragment implements CallLogQueryHand @Override public void onStart() { super.onStart(); getLoaderManager().initLoader(MISSED_CALL_LOADER, null, new MissedCallLogLoaderListener()); } @Override Loading Loading
res/layout/call_log_list_item_extra.xml +40 −35 Original line number Diff line number Diff line Loading @@ -18,9 +18,9 @@ <!-- Can't use merge here because this is referenced via a ViewStub --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/badge_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/badge_container"> android:layout_height="wrap_content"> <View android:layout_width="match_parent" android:layout_height="1px" Loading @@ -31,22 +31,25 @@ android:layout_height="wrap_content" android:paddingStart="@dimen/call_log_outer_margin" android:paddingEnd="@dimen/call_log_outer_margin" android:paddingTop="0dip" android:paddingBottom="0dip" android:paddingTop="@dimen/call_log_item_extra_padding_vertical" android:paddingBottom="@dimen/call_log_item_extra_padding_vertical" android:background="?android:attr/selectableItemBackground" android:clickable="true"> <ImageView android:layout_width="wrap_content" <ImageView android:id="@+id/badge_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/badge_image" android:tint="@color/dialpad_primary_text_color" android:padding="@dimen/call_log_outer_margin" /> <TextView android:layout_width="wrap_content" <TextView android:id="@+id/badge_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingStart="@dimen/call_log_start_margin" android:id="@+id/badge_text" android:textColor="@color/dialpad_primary_text_color" android:layout_gravity="center_vertical" android:layout_weight="1" /> <ImageView android:id="@+id/dismiss_button" android:layout_width="wrap_content" android:layout_height="wrap_content" Loading @@ -58,5 +61,7 @@ android:background="?android:attr/selectableItemBackground" android:visibility="gone" android:contentDescription="@string/description_dismiss" /> </LinearLayout> </FrameLayout> No newline at end of file
res/values/dimens.xml +3 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,9 @@ <dimen name="recent_call_log_item_padding_top">12dp</dimen> <dimen name="recent_call_log_item_padding_bottom">11dp</dimen> <dimen name="call_log_item_extra_padding_vertical">4dp</dimen> <!-- Size of the star icon on the favorites tile. --> <dimen name="favorites_star_icon_size">12dp</dimen> Loading
src/com/android/dialer/calllog/CallLogAdapter.java +14 −79 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import com.android.common.widget.GroupingListAdapter; import com.android.contacts.common.ContactPhotoManager; import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; import com.android.contacts.common.util.UriUtils; import com.android.dialer.DialtactsActivity; import com.android.dialer.PhoneCallDetails; import com.android.dialer.PhoneCallDetailsHelper; import com.android.dialer.R; Loading Loading @@ -255,8 +256,6 @@ public class CallLogAdapter extends GroupingListAdapter private volatile boolean mRequestProcessingDisabled = false; private boolean mIsCallLog = true; private int mNumMissedCalls = 0; private int mNumMissedCallsShown = 0; private View mBadgeContainer; private ImageView mBadgeImageView; Loading Loading @@ -1032,21 +1031,13 @@ public class CallLogAdapter extends GroupingListAdapter mCallLogViewsHelper.setActionContentDescriptions(views); } protected void bindBadge(View view, ContactInfo info, PhoneCallDetails details, int callType) { protected void bindBadge( View view, ContactInfo info, final PhoneCallDetails details, int callType) { // Do not show badge in call log. if (!mIsCallLog) { final int numMissed = getNumMissedCalls(callType); final ViewStub stub = (ViewStub) view.findViewById(R.id.link_stub); if (shouldShowBadge(numMissed, info, details)) { // Do not process if the data has not changed (optimization since bind view is // called multiple times due to contact lookup). if (numMissed == mNumMissedCallsShown) { return; } // stub will be null if it was already inflated. if (TextUtils.isEmpty(info.lookupKey)) { if (stub != null) { final View inflated = stub.inflate(); inflated.setVisibility(View.VISIBLE); Loading @@ -1055,11 +1046,16 @@ public class CallLogAdapter extends GroupingListAdapter mBadgeText = (TextView) inflated.findViewById(R.id.badge_text); } mBadgeContainer.setOnClickListener(getBadgeClickListener()); mBadgeImageView.setImageResource(getBadgeImageResId()); mBadgeText.setText(getBadgeText(numMissed)); mNumMissedCallsShown = numMissed; mBadgeContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Intent intent = DialtactsActivity.getAddNumberToContactIntent(details.number); mContext.startActivity(intent); } }); mBadgeImageView.setImageResource(R.drawable.ic_person_add_24dp); mBadgeText.setText(R.string.recentCalls_addToContact); } else { // Hide badge if it was previously shown. if (stub == null) { Loading @@ -1072,67 +1068,6 @@ public class CallLogAdapter extends GroupingListAdapter } } public void setMissedCalls(Cursor data) { final int missed; if (data == null) { missed = 0; } else { missed = data.getCount(); } // Only need to update if the number of calls changed. if (missed != mNumMissedCalls) { mNumMissedCalls = missed; notifyDataSetChanged(); } } protected View.OnClickListener getBadgeClickListener() { return new View.OnClickListener() { @Override public void onClick(View v) { final Intent intent = new Intent(mContext, CallLogActivity.class); mContext.startActivity(intent); } }; } /** * Get the resource id for the image to be shown for the badge. */ protected int getBadgeImageResId() { return R.drawable.ic_call_log_blue; } /** * Get the text to be shown for the badge. * * @param numMissed The number of missed calls. */ protected String getBadgeText(int numMissed) { return mContext.getResources().getString(R.string.num_missed_calls, numMissed); } /** * Whether to show the badge. * * @param numMissedCalls The number of missed calls. * @param info The contact info. * @param details The call detail. * @return {@literal true} if badge should be shown. {@literal false} otherwise. */ protected boolean shouldShowBadge(int numMissedCalls, ContactInfo info, PhoneCallDetails details) { return numMissedCalls > 0; } private int getNumMissedCalls(int callType) { if (callType == Calls.MISSED_TYPE) { // Exclude the current missed call shown in the shortcut. return mNumMissedCalls - 1; } return mNumMissedCalls; } /** Checks whether the contact info from the call log matches the one from the contacts db. */ private boolean callLogInfoMatches(ContactInfo callLogInfo, ContactInfo info) { // The call log only contains a subset of the fields in the contacts db. Loading
src/com/android/dialer/list/ListsFragment.java +0 −25 Original line number Diff line number Diff line Loading @@ -70,9 +70,6 @@ public class ListsFragment extends AnalyticsFragment implements CallLogQueryHand public static final float REMOVE_VIEW_SHOWN_ALPHA = 0.5f; public static final float REMOVE_VIEW_HIDDEN_ALPHA = 1; // Used with LoaderManager private static int MISSED_CALL_LOADER = 1; public interface HostInterface { public void showCallHistory(); public int getActionBarHeight(); Loading Loading @@ -111,27 +108,6 @@ public class ListsFragment extends AnalyticsFragment implements CallLogQueryHand */ private long mCurrentCallShortcutDate = 0; private class MissedCallLogLoaderListener implements LoaderManager.LoaderCallbacks<Cursor> { @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { final Uri uri = CallLog.Calls.CONTENT_URI; final String[] projection = new String[] {CallLog.Calls.TYPE}; final String selection = CallLog.Calls.TYPE + " = " + CallLog.Calls.MISSED_TYPE + " AND " + CallLog.Calls.IS_READ + " = 0"; return new CursorLoader(getActivity(), uri, projection, selection, null, null); } @Override public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor data) { mCallLogAdapter.setMissedCalls(data); } @Override public void onLoaderReset(Loader<Cursor> cursorLoader) { } } private PanelSlideListener mPanelSlideListener = new PanelSlideListener() { @Override public void onPanelSlide(View panel, float slideOffset) { Loading Loading @@ -229,7 +205,6 @@ public class ListsFragment extends AnalyticsFragment implements CallLogQueryHand @Override public void onStart() { super.onStart(); getLoaderManager().initLoader(MISSED_CALL_LOADER, null, new MissedCallLogLoaderListener()); } @Override Loading