diff options
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/dialer/CallDetailActivity.java | 52 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/CallDetailHistoryAdapter.java | 28 |
2 files changed, 33 insertions, 47 deletions
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java index d95b55ecb..c8a5356a6 100644 --- a/src/com/android/dialer/CallDetailActivity.java +++ b/src/com/android/dialer/CallDetailActivity.java @@ -38,11 +38,12 @@ import android.widget.QuickContactBadge; import android.widget.TextView; import android.widget.Toast; -import com.android.contacts.common.ContactPhotoManager; +import com.android.contacts.common.CallUtil; import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; -import com.android.contacts.common.interactions.TouchPointManager; +import com.android.contacts.common.ContactPhotoManager; import com.android.contacts.common.GeoUtil; -import com.android.contacts.common.CallUtil; +import com.android.contacts.common.interactions.TouchPointManager; +import com.android.contacts.common.testing.NeededForTesting; import com.android.contacts.common.util.UriUtils; import com.android.dialer.calllog.CallDetailHistoryAdapter; import com.android.dialer.calllog.CallLogAsyncTaskUtil.CallLogAsyncTaskListener; @@ -276,7 +277,8 @@ public class CallDetailActivity extends AppCompatActivity CallLogAsyncTaskUtil.getCallDetails(this, getCallLogEntryUris(), mCallLogAsyncTaskListener); } - private boolean hasVoicemail() { + @NeededForTesting + public boolean hasVoicemail() { return mVoicemailUri != null; } @@ -321,23 +323,24 @@ public class CallDetailActivity extends AppCompatActivity @Override public boolean onCreateOptionsMenu(Menu menu) { + final MenuItem deleteMenuItem = menu.add( + Menu.NONE, + R.id.call_detail_delete_menu_item, + Menu.NONE, + R.string.call_details_delete); + deleteMenuItem.setIcon(R.drawable.ic_delete_24dp); + deleteMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); + deleteMenuItem.setOnMenuItemClickListener(this); + getMenuInflater().inflate(R.menu.call_details_options, menu); return super.onCreateOptionsMenu(menu); } @Override public boolean onPrepareOptionsMenu(Menu menu) { - // This action deletes all elements in the group from the call log. - // We don't have this action for voicemails, because you can just use the trash button. - menu.findItem(R.id.menu_remove_from_call_log) - .setVisible(!hasVoicemail()) - .setOnMenuItemClickListener(this); menu.findItem(R.id.menu_edit_number_before_call) .setVisible(mHasEditNumberBeforeCallOption) .setOnMenuItemClickListener(this); - menu.findItem(R.id.menu_trash) - .setVisible(hasVoicemail()) - .setOnMenuItemClickListener(this); menu.findItem(R.id.menu_report) .setVisible(mHasReportMenuOption) .setOnMenuItemClickListener(this); @@ -347,24 +350,25 @@ public class CallDetailActivity extends AppCompatActivity @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { - case R.id.menu_remove_from_call_log: - final StringBuilder callIds = new StringBuilder(); - for (Uri callUri : getCallLogEntryUris()) { - if (callIds.length() != 0) { - callIds.append(","); + case R.id.call_detail_delete_menu_item: + if (hasVoicemail()) { + CallLogAsyncTaskUtil.deleteVoicemail( + this, mVoicemailUri, mCallLogAsyncTaskListener); + } else { + final StringBuilder callIds = new StringBuilder(); + for (Uri callUri : getCallLogEntryUris()) { + if (callIds.length() != 0) { + callIds.append(","); + } + callIds.append(ContentUris.parseId(callUri)); } - callIds.append(ContentUris.parseId(callUri)); + CallLogAsyncTaskUtil.deleteCalls( + this, callIds.toString(), mCallLogAsyncTaskListener); } - CallLogAsyncTaskUtil.deleteCalls( - this, callIds.toString(), mCallLogAsyncTaskListener); break; case R.id.menu_edit_number_before_call: startActivity(new Intent(Intent.ACTION_DIAL, CallUtil.getCallUri(mNumber))); break; - case R.id.menu_trash: - CallLogAsyncTaskUtil.deleteVoicemail( - this, mVoicemailUri, mCallLogAsyncTaskListener); - break; } return true; } diff --git a/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java b/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java index 3b488a8ae..ac56332ce 100644 --- a/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java +++ b/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java @@ -38,8 +38,6 @@ import java.util.ArrayList; * Adapter for a ListView containing history items from the details of a call. */ public class CallDetailHistoryAdapter extends BaseAdapter { - /** The top element is a blank header, which is hidden under the rest of the UI. */ - private static final int VIEW_TYPE_HEADER = 0; /** Each history item shows the detail of a call. */ private static final int VIEW_TYPE_HISTORY_ITEM = 1; @@ -69,53 +67,37 @@ public class CallDetailHistoryAdapter extends BaseAdapter { @Override public int getCount() { - return mPhoneCallDetails.length + 1; + return mPhoneCallDetails.length; } @Override public Object getItem(int position) { - if (position == 0) { - return null; - } - return mPhoneCallDetails[position - 1]; + return mPhoneCallDetails[position]; } @Override public long getItemId(int position) { - if (position == 0) { - return -1; - } - return position - 1; + return position; } @Override public int getViewTypeCount() { - return 2; + return 1; } @Override public int getItemViewType(int position) { - if (position == 0) { - return VIEW_TYPE_HEADER; - } return VIEW_TYPE_HISTORY_ITEM; } @Override public View getView(int position, View convertView, ViewGroup parent) { - if (position == 0) { - final View header = convertView == null - ? mLayoutInflater.inflate(R.layout.call_detail_history_header, parent, false) - : convertView; - return header; - } - // Make sure we have a valid convertView to start with final View result = convertView == null ? mLayoutInflater.inflate(R.layout.call_detail_history_item, parent, false) : convertView; - PhoneCallDetails details = mPhoneCallDetails[position - 1]; + PhoneCallDetails details = mPhoneCallDetails[position]; CallTypeIconsView callTypeIconView = (CallTypeIconsView) result.findViewById(R.id.call_type_icon); TextView callTypeTextView = (TextView) result.findViewById(R.id.call_type_text); |