diff options
author | Andrew Lee <anwlee@google.com> | 2015-10-03 00:09:50 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-10-03 00:09:50 +0000 |
commit | aebebba874a0137ff8fdb280f87b047e49c0707b (patch) | |
tree | 0b22de3483f54dc0ddf2056845a6b0b1eb0903f5 | |
parent | f375d2a8d7b22b2d404170cb7687b1c69359583c (diff) | |
parent | 7b127d43de0de29c27a9db19f0a7e792ac678c05 (diff) |
am 7b127d43: Prepatory CallDetailActivity tweaks.
* commit '7b127d43de0de29c27a9db19f0a7e792ac678c05':
Prepatory CallDetailActivity tweaks.
-rw-r--r-- | res/layout/call_detail.xml | 3 | ||||
-rw-r--r-- | res/layout/call_detail_history_header.xml | 30 | ||||
-rw-r--r-- | res/menu/call_details_options.xml | 10 | ||||
-rw-r--r-- | res/values/dimens.xml | 6 | ||||
-rw-r--r-- | res/values/ids.xml | 1 | ||||
-rw-r--r-- | res/values/strings.xml | 3 | ||||
-rw-r--r-- | src/com/android/dialer/CallDetailActivity.java | 52 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/CallDetailHistoryAdapter.java | 28 | ||||
-rw-r--r-- | tests/src/com/android/dialer/CallDetailActivityTest.java | 18 |
9 files changed, 51 insertions, 100 deletions
diff --git a/res/layout/call_detail.xml b/res/layout/call_detail.xml index fde1de5c1..591ba5c45 100644 --- a/res/layout/call_detail.xml +++ b/res/layout/call_detail.xml @@ -60,7 +60,8 @@ android:textColor="?attr/call_log_primary_text_color" android:textSize="@dimen/call_log_primary_text_size" android:includeFontPadding="false" - android:layout_marginBottom="5dp" + android:layout_marginTop="2dp" + android:layout_marginBottom="3dp" android:singleLine="true" /> <TextView diff --git a/res/layout/call_detail_history_header.xml b/res/layout/call_detail_history_header.xml deleted file mode 100644 index def1fd805..000000000 --- a/res/layout/call_detail_history_header.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2009 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. ---> - -<TextView - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:ex="http://schemas.android.com/apk/res-auto" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:paddingTop="@dimen/call_detail_header_top_margin" - android:paddingBottom="@dimen/call_detail_header_bottom_margin" - android:paddingStart="@dimen/call_detail_horizontal_margin" - android:textColor="?attr/call_log_secondary_text_color" - android:textSize="@dimen/call_log_secondary_text_size" - android:fontFamily="sans-serif-medium" - android:singleLine="true" - android:text="@string/call_detail_list_header" - /> diff --git a/res/menu/call_details_options.xml b/res/menu/call_details_options.xml index 0e9e5c9d0..414b6711a 100644 --- a/res/menu/call_details_options.xml +++ b/res/menu/call_details_options.xml @@ -16,16 +16,6 @@ <menu xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/call_details_menu"> - <item android:id="@+id/menu_trash" - android:icon="@drawable/ic_delete_24dp" - android:showAsAction="ifRoom" - android:title="@string/call_log_trash_voicemail" /> - - <item android:id="@+id/menu_remove_from_call_log" - android:icon="@drawable/ic_delete_24dp" - android:showAsAction="ifRoom" - android:title="@string/call_log_remove_from_call_log" /> - <item android:id="@+id/menu_edit_number_before_call" android:title="@string/call_log_edit_number_before_call" /> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 0a330d8a4..d35a78d12 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -39,9 +39,9 @@ <!-- Size of contact photos in the call log and call details. --> <dimen name="contact_photo_size">40dp</dimen> <dimen name="call_detail_button_spacing">2dip</dimen> - <dimen name="call_detail_horizontal_margin">16dp</dimen> - <dimen name="call_detail_top_margin">36dp</dimen> - <dimen name="call_detail_bottom_margin">32dp</dimen> + <dimen name="call_detail_horizontal_margin">20dp</dimen> + <dimen name="call_detail_top_margin">16dp</dimen> + <dimen name="call_detail_bottom_margin">16dp</dimen> <dimen name="call_detail_header_top_margin">20dp</dimen> <dimen name="call_detail_header_bottom_margin">9dp</dimen> <dimen name="call_detail_translation_z">0.5dp</dimen> diff --git a/res/values/ids.xml b/res/values/ids.xml index f96761a81..f850327ea 100644 --- a/res/values/ids.xml +++ b/res/values/ids.xml @@ -15,6 +15,7 @@ --> <resources> + <item type="id" name="call_detail_delete_menu_item" /> <item type="id" name="context_menu_copy_to_clipboard" /> <item type="id" name="context_menu_copy_transcript_to_clipboard" /> <item type="id" name="context_menu_edit_before_call" /> diff --git a/res/values/strings.xml b/res/values/strings.xml index d51ff6d72..b2621cd9e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -70,6 +70,9 @@ <!-- Text for undo button in snackbar for blocking/unblocking number. [CHAR LIMIT=10] --> <string name="block_number_undo">UNDO</string> + <!-- Menu item in call details used to remove a call or voicemail from the call log. --> + <string name="call_details_delete">Delete</string> + <!-- Menu item used to copy a number from the call log to the dialer so it can be edited before calling it --> <string name="call_log_edit_number_before_call">Edit number before call</string> 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); diff --git a/tests/src/com/android/dialer/CallDetailActivityTest.java b/tests/src/com/android/dialer/CallDetailActivityTest.java index 27fbc304e..eda74742b 100644 --- a/tests/src/com/android/dialer/CallDetailActivityTest.java +++ b/tests/src/com/android/dialer/CallDetailActivityTest.java @@ -84,11 +84,9 @@ public class CallDetailActivityTest extends ActivityInstrumentationTestCase2<Cal } /** - * Test for bug where voicemails should not have remove-from-call-log entry. - * <p> - * See http://b/5054103. + * Verifies the trash menu item is present and a voicemail URI is set. */ - public void testVoicemailDoesNotHaveRemoveFromCallLog() throws Throwable { + public void testVoicemailDeleteButton() throws Throwable { setActivityIntentForTestVoicemailEntry(); startActivityUnderTest(); mFakeAsyncTaskExecutor.runTask(GET_CALL_DETAILS); @@ -96,12 +94,13 @@ public class CallDetailActivityTest extends ActivityInstrumentationTestCase2<Cal Menu optionsMenu = (new PopupMenu(mActivityUnderTest, null)).getMenu(); mActivityUnderTest.onCreateOptionsMenu(optionsMenu); mActivityUnderTest.onPrepareOptionsMenu(optionsMenu); - assertFalse(optionsMenu.findItem(R.id.menu_remove_from_call_log).isVisible()); - assertTrue(optionsMenu.findItem(R.id.menu_trash).isVisible()); + + assertTrue(optionsMenu.findItem(R.id.call_detail_delete_menu_item).isVisible()); + assertTrue(mActivityUnderTest.hasVoicemail()); } /** - * Test to check that I haven't broken the remove-from-call-log entry from regular calls. + * Verifies the trash menu item is present and a voicemail URI is not set. */ public void testRegularCallDoesHaveRemoveFromCallLog() throws Throwable { setActivityIntentForTestCallEntry(); @@ -111,8 +110,9 @@ public class CallDetailActivityTest extends ActivityInstrumentationTestCase2<Cal Menu optionsMenu = (new PopupMenu(mActivityUnderTest, null)).getMenu(); mActivityUnderTest.onCreateOptionsMenu(optionsMenu); mActivityUnderTest.onPrepareOptionsMenu(optionsMenu); - assertTrue(optionsMenu.findItem(R.id.menu_remove_from_call_log).isVisible()); - assertFalse(optionsMenu.findItem(R.id.menu_trash).isVisible()); + + assertTrue(optionsMenu.findItem(R.id.call_detail_delete_menu_item).isVisible()); + assertFalse(mActivityUnderTest.hasVoicemail()); } private void setActivityIntentForTestCallEntry() { |