Loading res/layout/call_detail.xml +14 −16 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone" android:background="@android:color/black" > <!-- The list view is under everything. Loading @@ -32,7 +33,6 @@ android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:background="@android:color/black" /> <!-- All the controls which are part of the pinned header are in this layout. --> Loading Loading @@ -128,35 +128,34 @@ android:layout_height="wrap_content" android:paddingBottom="@dimen/call_detail_button_spacing" android:layout_below="@id/blue_separator" android:background="@android:color/black" > <!-- The voicemail fragment will be put here. --> </LinearLayout> <FrameLayout android:id="@+id/call_and_sms_container" <FrameLayout android:id="@+id/call_and_sms" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="@dimen/call_log_list_item_height" android:layout_marginBottom="@dimen/call_detail_button_spacing" android:layout_below="@id/voicemail_container" android:background="@android:color/black" android:gravity="center_vertical" android:background="@drawable/dialpad_background" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/call_and_sms" <LinearLayout android:id="@+id/call_and_sms_main_action" android:layout_width="match_parent" android:layout_height="@dimen/call_log_list_item_height" android:layout_height="match_parent" android:orientation="horizontal" android:gravity="center_vertical" android:background="@drawable/dialpad_background" android:focusable="true" android:background="?android:attr/selectableItemBackground" > <LinearLayout android:id="@+id/call_and_sms_main_action" <LinearLayout android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="1" android:paddingLeft="@dimen/call_log_indent_margin" android:orientation="vertical" android:gravity="center_vertical" android:focusable="true" android:background="?android:attr/selectableItemBackground" > <TextView android:id="@+id/call_and_sms_text" Loading @@ -179,7 +178,6 @@ android:singleLine="true" android:ellipsize="end" /> </LinearLayout> <View android:id="@+id/call_and_sms_divider" Loading Loading @@ -213,7 +211,7 @@ android:layout_height="match_parent" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:background="#000000" android:background="@android:color/black" android:visibility="gone" android:clickable="true" /> Loading res/menu/call_details_cab.xml 0 → 100644 +22 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2012 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. --> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/copy_phone_number" android:icon="?android:attr/actionModeCopyDrawable" android:title="@string/menu_copy" /> </menu> res/values/colors.xml +4 −0 Original line number Diff line number Diff line Loading @@ -75,4 +75,8 @@ <!-- Color of image view placeholder. --> <color name="image_placeholder">#DDDDDD</color> <!-- Standard color for selected items. --> <color name="item_selected">#660099cc</color> </resources> res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -115,6 +115,9 @@ <!-- Menu item used to delete a specific contact --> <string name="menu_deleteContact">Delete</string> <!-- Menu item to copy something [CHAR_LIMIT=10] --> <string name="menu_copy">Copy</string> <!-- Menu item used to create a contact shortcut when viewing contact details. [CHAR LIMIT=30] --> <string name="menu_create_contact_shortcut">Place on Home screen</string> Loading src/com/android/contacts/CallDetailActivity.java +95 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.contacts.calllog.PhoneNumberHelper; import com.android.contacts.format.FormatUtils; import com.android.contacts.util.AsyncTaskExecutor; import com.android.contacts.util.AsyncTaskExecutors; import com.android.contacts.util.ClipboardUtils; import com.android.contacts.util.Constants; import com.android.contacts.voicemail.VoicemailPlaybackFragment; import com.android.contacts.voicemail.VoicemailStatusHelper; Loading @@ -40,6 +41,7 @@ import android.content.Context; import android.content.Intent; import android.content.res.Resources; import android.database.Cursor; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; Loading @@ -53,6 +55,7 @@ import android.telephony.PhoneNumberUtils; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; import android.view.ActionMode; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.Menu; Loading Loading @@ -132,6 +135,15 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware private ProximitySensorManager mProximitySensorManager; private final ProximitySensorListener mProximitySensorListener = new ProximitySensorListener(); /** * The action mode used when the phone number is selected. This will be non-null only when the * phone number is selected. */ private ActionMode mPhoneNumberActionMode; private CharSequence mPhoneNumberLabelToCopy; private CharSequence mPhoneNumberToCopy; /** Listener to changes in the proximity sensor state. */ private class ProximitySensorListener implements ProximitySensorManager.Listener { /** Used to show a blank view and hide the action bar. */ Loading Loading @@ -202,6 +214,9 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware private final View.OnClickListener mPrimaryActionListener = new View.OnClickListener() { @Override public void onClick(View view) { if (finishPhoneNumerSelectedActionModeIfShown()) { return; } startActivity(((ViewEntry) view.getTag()).primaryIntent); } }; Loading @@ -209,10 +224,25 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware private final View.OnClickListener mSecondaryActionListener = new View.OnClickListener() { @Override public void onClick(View view) { if (finishPhoneNumerSelectedActionModeIfShown()) { return; } startActivity(((ViewEntry) view.getTag()).secondaryIntent); } }; private final View.OnLongClickListener mPrimaryLongClickListener = new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (finishPhoneNumerSelectedActionModeIfShown()) { return true; } startPhoneNumberSelectedActionMode(v); return true; } }; @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); Loading Loading @@ -497,8 +527,12 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware } configureCallButton(entry); mPhoneNumberToCopy = displayNumber; mPhoneNumberLabelToCopy = entry.label; } else { disableCallButton(); mPhoneNumberToCopy = null; mPhoneNumberLabelToCopy = null; } mHasEditNumberBeforeCallOption = Loading Loading @@ -656,6 +690,7 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware mainAction.setOnClickListener(mPrimaryActionListener); mainAction.setTag(entry); mainAction.setContentDescription(entry.primaryDescription); mainAction.setOnLongClickListener(mPrimaryLongClickListener); if (entry.secondaryIntent != null) { icon.setOnClickListener(mSecondaryActionListener); Loading Loading @@ -829,4 +864,64 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware public void disableProximitySensor(boolean waitForFarState) { mProximitySensorManager.disable(waitForFarState); } /** * If the phone number is selected, unselect it and return {@code true}. * Otherwise, just {@code false}. */ private boolean finishPhoneNumerSelectedActionModeIfShown() { if (mPhoneNumberActionMode == null) return false; mPhoneNumberActionMode.finish(); return true; } private void startPhoneNumberSelectedActionMode(View targetView) { mPhoneNumberActionMode = startActionMode(new PhoneNumberActionModeCallback(targetView)); } private class PhoneNumberActionModeCallback implements ActionMode.Callback { private final View mTargetView; private final Drawable mOriginalViewBackground; public PhoneNumberActionModeCallback(View targetView) { mTargetView = targetView; // Highlight the phone number view. Remember the old background, and put a new one. mOriginalViewBackground = mTargetView.getBackground(); mTargetView.setBackgroundColor(getResources().getColor(R.color.item_selected)); } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { if (TextUtils.isEmpty(mPhoneNumberToCopy)) return false; getMenuInflater().inflate(R.menu.call_details_cab, menu); return true; } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return true; } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.copy_phone_number: ClipboardUtils.copyText(CallDetailActivity.this, mPhoneNumberLabelToCopy, mPhoneNumberToCopy, true); mode.finish(); // Close the CAB return true; } return false; } @Override public void onDestroyActionMode(ActionMode mode) { mPhoneNumberActionMode = null; // Restore the view background. mTargetView.setBackground(mOriginalViewBackground); } } } Loading
res/layout/call_detail.xml +14 −16 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone" android:background="@android:color/black" > <!-- The list view is under everything. Loading @@ -32,7 +33,6 @@ android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:background="@android:color/black" /> <!-- All the controls which are part of the pinned header are in this layout. --> Loading Loading @@ -128,35 +128,34 @@ android:layout_height="wrap_content" android:paddingBottom="@dimen/call_detail_button_spacing" android:layout_below="@id/blue_separator" android:background="@android:color/black" > <!-- The voicemail fragment will be put here. --> </LinearLayout> <FrameLayout android:id="@+id/call_and_sms_container" <FrameLayout android:id="@+id/call_and_sms" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="@dimen/call_log_list_item_height" android:layout_marginBottom="@dimen/call_detail_button_spacing" android:layout_below="@id/voicemail_container" android:background="@android:color/black" android:gravity="center_vertical" android:background="@drawable/dialpad_background" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/call_and_sms" <LinearLayout android:id="@+id/call_and_sms_main_action" android:layout_width="match_parent" android:layout_height="@dimen/call_log_list_item_height" android:layout_height="match_parent" android:orientation="horizontal" android:gravity="center_vertical" android:background="@drawable/dialpad_background" android:focusable="true" android:background="?android:attr/selectableItemBackground" > <LinearLayout android:id="@+id/call_and_sms_main_action" <LinearLayout android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="1" android:paddingLeft="@dimen/call_log_indent_margin" android:orientation="vertical" android:gravity="center_vertical" android:focusable="true" android:background="?android:attr/selectableItemBackground" > <TextView android:id="@+id/call_and_sms_text" Loading @@ -179,7 +178,6 @@ android:singleLine="true" android:ellipsize="end" /> </LinearLayout> <View android:id="@+id/call_and_sms_divider" Loading Loading @@ -213,7 +211,7 @@ android:layout_height="match_parent" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:background="#000000" android:background="@android:color/black" android:visibility="gone" android:clickable="true" /> Loading
res/menu/call_details_cab.xml 0 → 100644 +22 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2012 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. --> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/copy_phone_number" android:icon="?android:attr/actionModeCopyDrawable" android:title="@string/menu_copy" /> </menu>
res/values/colors.xml +4 −0 Original line number Diff line number Diff line Loading @@ -75,4 +75,8 @@ <!-- Color of image view placeholder. --> <color name="image_placeholder">#DDDDDD</color> <!-- Standard color for selected items. --> <color name="item_selected">#660099cc</color> </resources>
res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -115,6 +115,9 @@ <!-- Menu item used to delete a specific contact --> <string name="menu_deleteContact">Delete</string> <!-- Menu item to copy something [CHAR_LIMIT=10] --> <string name="menu_copy">Copy</string> <!-- Menu item used to create a contact shortcut when viewing contact details. [CHAR LIMIT=30] --> <string name="menu_create_contact_shortcut">Place on Home screen</string> Loading
src/com/android/contacts/CallDetailActivity.java +95 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.contacts.calllog.PhoneNumberHelper; import com.android.contacts.format.FormatUtils; import com.android.contacts.util.AsyncTaskExecutor; import com.android.contacts.util.AsyncTaskExecutors; import com.android.contacts.util.ClipboardUtils; import com.android.contacts.util.Constants; import com.android.contacts.voicemail.VoicemailPlaybackFragment; import com.android.contacts.voicemail.VoicemailStatusHelper; Loading @@ -40,6 +41,7 @@ import android.content.Context; import android.content.Intent; import android.content.res.Resources; import android.database.Cursor; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; Loading @@ -53,6 +55,7 @@ import android.telephony.PhoneNumberUtils; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; import android.view.ActionMode; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.Menu; Loading Loading @@ -132,6 +135,15 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware private ProximitySensorManager mProximitySensorManager; private final ProximitySensorListener mProximitySensorListener = new ProximitySensorListener(); /** * The action mode used when the phone number is selected. This will be non-null only when the * phone number is selected. */ private ActionMode mPhoneNumberActionMode; private CharSequence mPhoneNumberLabelToCopy; private CharSequence mPhoneNumberToCopy; /** Listener to changes in the proximity sensor state. */ private class ProximitySensorListener implements ProximitySensorManager.Listener { /** Used to show a blank view and hide the action bar. */ Loading Loading @@ -202,6 +214,9 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware private final View.OnClickListener mPrimaryActionListener = new View.OnClickListener() { @Override public void onClick(View view) { if (finishPhoneNumerSelectedActionModeIfShown()) { return; } startActivity(((ViewEntry) view.getTag()).primaryIntent); } }; Loading @@ -209,10 +224,25 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware private final View.OnClickListener mSecondaryActionListener = new View.OnClickListener() { @Override public void onClick(View view) { if (finishPhoneNumerSelectedActionModeIfShown()) { return; } startActivity(((ViewEntry) view.getTag()).secondaryIntent); } }; private final View.OnLongClickListener mPrimaryLongClickListener = new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (finishPhoneNumerSelectedActionModeIfShown()) { return true; } startPhoneNumberSelectedActionMode(v); return true; } }; @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); Loading Loading @@ -497,8 +527,12 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware } configureCallButton(entry); mPhoneNumberToCopy = displayNumber; mPhoneNumberLabelToCopy = entry.label; } else { disableCallButton(); mPhoneNumberToCopy = null; mPhoneNumberLabelToCopy = null; } mHasEditNumberBeforeCallOption = Loading Loading @@ -656,6 +690,7 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware mainAction.setOnClickListener(mPrimaryActionListener); mainAction.setTag(entry); mainAction.setContentDescription(entry.primaryDescription); mainAction.setOnLongClickListener(mPrimaryLongClickListener); if (entry.secondaryIntent != null) { icon.setOnClickListener(mSecondaryActionListener); Loading Loading @@ -829,4 +864,64 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware public void disableProximitySensor(boolean waitForFarState) { mProximitySensorManager.disable(waitForFarState); } /** * If the phone number is selected, unselect it and return {@code true}. * Otherwise, just {@code false}. */ private boolean finishPhoneNumerSelectedActionModeIfShown() { if (mPhoneNumberActionMode == null) return false; mPhoneNumberActionMode.finish(); return true; } private void startPhoneNumberSelectedActionMode(View targetView) { mPhoneNumberActionMode = startActionMode(new PhoneNumberActionModeCallback(targetView)); } private class PhoneNumberActionModeCallback implements ActionMode.Callback { private final View mTargetView; private final Drawable mOriginalViewBackground; public PhoneNumberActionModeCallback(View targetView) { mTargetView = targetView; // Highlight the phone number view. Remember the old background, and put a new one. mOriginalViewBackground = mTargetView.getBackground(); mTargetView.setBackgroundColor(getResources().getColor(R.color.item_selected)); } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { if (TextUtils.isEmpty(mPhoneNumberToCopy)) return false; getMenuInflater().inflate(R.menu.call_details_cab, menu); return true; } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return true; } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.copy_phone_number: ClipboardUtils.copyText(CallDetailActivity.this, mPhoneNumberLabelToCopy, mPhoneNumberToCopy, true); mode.finish(); // Close the CAB return true; } return false; } @Override public void onDestroyActionMode(ActionMode mode) { mPhoneNumberActionMode = null; // Restore the view background. mTargetView.setBackground(mOriginalViewBackground); } } }