diff options
10 files changed, 222 insertions, 10 deletions
diff --git a/java/com/android/dialer/app/res/values/colors.xml b/java/com/android/dialer/app/res/values/colors.xml index 84a381f21..bb3662cda 100644 --- a/java/com/android/dialer/app/res/values/colors.xml +++ b/java/com/android/dialer/app/res/values/colors.xml @@ -68,7 +68,6 @@ <color name="dialer_dialpad_touch_tint">@color/dialer_theme_color_20pct</color> <color name="call_log_action_divider">#eeeeee</color> - <color name="divider_line_color">#D8D8D8</color> <!-- Colors for blocked numbers list --> <color name="blocked_number_primary_text_color">@color/dialer_primary_text_color</color> diff --git a/java/com/android/dialer/speeddial/FavoritesViewHolder.java b/java/com/android/dialer/speeddial/FavoritesViewHolder.java index f9eec8e79..4e8d4ad07 100644 --- a/java/com/android/dialer/speeddial/FavoritesViewHolder.java +++ b/java/com/android/dialer/speeddial/FavoritesViewHolder.java @@ -22,12 +22,16 @@ import android.database.Cursor; import android.net.Uri; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.Contacts; +import android.support.annotation.VisibleForTesting; import android.support.v7.widget.RecyclerView; import android.text.TextUtils; +import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnLongClickListener; import android.widget.FrameLayout; +import android.widget.LinearLayout.LayoutParams; +import android.widget.PopupWindow; import android.widget.QuickContactBadge; import android.widget.TextView; import com.android.dialer.common.Assert; @@ -44,6 +48,9 @@ public class FavoritesViewHolder extends RecyclerView.ViewHolder private final TextView nameView; private final TextView phoneType; private final FrameLayout videoCallIcon; + private final View contextMenuAnchor; + + private PopupWindow contextMenu; private boolean hasDefaultNumber; private boolean isVideoCall; @@ -56,6 +63,7 @@ public class FavoritesViewHolder extends RecyclerView.ViewHolder nameView = view.findViewById(R.id.name); phoneType = view.findViewById(R.id.phone_type); videoCallIcon = view.findViewById(R.id.video_call_container); + contextMenuAnchor = view.findViewById(R.id.avatar_container); view.setOnClickListener(this); view.setOnLongClickListener(this); photoView.setClickable(false); @@ -112,12 +120,44 @@ public class FavoritesViewHolder extends RecyclerView.ViewHolder } @Override - public boolean onLongClick(View v) { - // TODO(calderwoodra): implement drag and drop logic - listener.onLongClick(number); + public boolean onLongClick(View view) { + Context context = itemView.getContext(); + View contentView = LayoutInflater.from(context).inflate(R.layout.favorite_context_menu, null); + contentView + .findViewById(R.id.voice_call_container) + .setOnClickListener(v -> listener.onClick(Assert.isNotNull(number), false)); + contentView + .findViewById(R.id.video_call_container) + .setOnClickListener(v -> listener.onClick(Assert.isNotNull(number), true)); + contentView + .findViewById(R.id.send_message_container) + .setOnClickListener(v -> listener.openSmsConversation(Assert.isNotNull(number))); + contentView + .findViewById(R.id.remove_container) + .setOnClickListener(v -> listener.removeFavoriteContact()); + contentView + .findViewById(R.id.contact_info_container) + .setOnClickListener(v -> listener.openContactInfo()); + + int offset = + context.getResources().getDimensionPixelSize(R.dimen.speed_dial_context_menu_x_offset); + int padding = + context.getResources().getDimensionPixelSize(R.dimen.speed_dial_context_menu_extra_width); + int width = padding + itemView.getWidth(); + int elevation = context.getResources().getDimensionPixelSize(R.dimen.context_menu_elevation); + contextMenu = new PopupWindow(contentView, width, LayoutParams.WRAP_CONTENT, true); + contextMenu.setBackgroundDrawable(context.getDrawable(R.drawable.context_menu_background)); + contextMenu.setElevation(elevation); + contextMenu.setOnDismissListener(() -> contextMenu = null); + contextMenu.showAsDropDown(contextMenuAnchor, offset, 0); return true; } + @VisibleForTesting + public PopupWindow getContextMenu() { + return contextMenu; + } + /** Listener/callback for {@link FavoritesViewHolder} actions. */ public interface FavoriteContactsListener { @@ -127,7 +167,13 @@ public class FavoritesViewHolder extends RecyclerView.ViewHolder /** Called when the user clicks on a favorite contact. */ void onClick(String number, boolean isVideoCall); - /** Called when the user long clicks on a favorite contact. */ - void onLongClick(String number); + /** Called when the user selects send message from the context menu. */ + void openSmsConversation(String number); + + /** Called when the user selects remove from the context menu. */ + void removeFavoriteContact(); + + /** Called when the user selects contact info from the context menu. */ + void openContactInfo(); } } diff --git a/java/com/android/dialer/speeddial/SpeedDialFragment.java b/java/com/android/dialer/speeddial/SpeedDialFragment.java index 979c894fe..a75c5ddbd 100644 --- a/java/com/android/dialer/speeddial/SpeedDialFragment.java +++ b/java/com/android/dialer/speeddial/SpeedDialFragment.java @@ -112,8 +112,18 @@ public class SpeedDialFragment extends Fragment { } @Override - public void onLongClick(String number) { - // TODO(calderwoodra): show favorite contact floating context menu + public void openSmsConversation(String number) { + // TODO(calderwoodra): open sms conversation + } + + @Override + public void removeFavoriteContact() { + // TODO(calderwoodra): remove contact from favorites + } + + @Override + public void openContactInfo() { + // TODO(calderwoodra): open quick contact info } } diff --git a/java/com/android/dialer/speeddial/res/drawable/context_menu_background.xml b/java/com/android/dialer/speeddial/res/drawable/context_menu_background.xml new file mode 100644 index 000000000..fd60757b5 --- /dev/null +++ b/java/com/android/dialer/speeddial/res/drawable/context_menu_background.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2017 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 + --> + +<shape xmlns:android="http://schemas.android.com/apk/res/android"> + <corners + android:bottomRightRadius="@dimen/speed_dial_context_menu_corner_radius" + android:topRightRadius="@dimen/speed_dial_context_menu_corner_radius" + android:bottomLeftRadius="@dimen/speed_dial_context_menu_corner_radius" + android:topLeftRadius="@dimen/speed_dial_context_menu_corner_radius"/> + <solid android:color="@android:color/white"/> +</shape> diff --git a/java/com/android/dialer/speeddial/res/layout/favorite_context_menu.xml b/java/com/android/dialer/speeddial/res/layout/favorite_context_menu.xml new file mode 100644 index 000000000..04d0139e0 --- /dev/null +++ b/java/com/android/dialer/speeddial/res/layout/favorite_context_menu.xml @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2017 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 + --> +<!-- TODO(calderwoodra): fix elevation --> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/contact_menu_container" + android:orientation="vertical" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:background="@drawable/context_menu_background"> + + <TextView + android:id="@+id/voice_call_container" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/contact_menu_voice_call" + android:drawableStart="@drawable/quantum_ic_phone_vd_theme_24" + style="@style/SpeedDialContextMenuItem"/> + + <TextView + android:id="@+id/video_call_container" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/contact_menu_video_call" + android:drawableStart="@drawable/quantum_ic_videocam_vd_theme_24" + style="@style/SpeedDialContextMenuItem"/> + + <TextView + android:id="@+id/send_message_container" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingBottom="4dp" + android:text="@string/contact_menu_message" + android:drawableStart="@drawable/quantum_ic_message_vd_theme_24" + style="@style/SpeedDialContextMenuItem"/> + + <View + android:layout_width="match_parent" + android:layout_height="1dp" + android:background="@color/divider_line_color"/> + + <TextView + android:id="@+id/remove_container" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="4dp" + android:text="@string/contact_menu_remove" + android:drawableStart="@drawable/quantum_ic_close_vd_theme_24" + style="@style/SpeedDialContextMenuItem"/> + + <TextView + android:id="@+id/contact_info_container" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/contact_menu_contact_info" + android:drawableStart="@drawable/quantum_ic_call_vd_theme_24" + style="@style/SpeedDialContextMenuItem"/> +</LinearLayout>
\ No newline at end of file diff --git a/java/com/android/dialer/speeddial/res/layout/fragment_speed_dial.xml b/java/com/android/dialer/speeddial/res/layout/fragment_speed_dial.xml index d432f097b..b4fc9c08d 100644 --- a/java/com/android/dialer/speeddial/res/layout/fragment_speed_dial.xml +++ b/java/com/android/dialer/speeddial/res/layout/fragment_speed_dial.xml @@ -19,6 +19,6 @@ android:id="@+id/speed_dial_recycler_view" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingStart="16dp" - android:paddingEnd="16dp" + android:paddingStart="@dimen/speed_dial_recyclerview_horizontal_padding" + android:paddingEnd="@dimen/speed_dial_recyclerview_horizontal_padding" android:clipToPadding="false"/> diff --git a/java/com/android/dialer/speeddial/res/values/dimens.xml b/java/com/android/dialer/speeddial/res/values/dimens.xml index 74b509b73..ce2de9dcc 100644 --- a/java/com/android/dialer/speeddial/res/values/dimens.xml +++ b/java/com/android/dialer/speeddial/res/values/dimens.xml @@ -16,4 +16,19 @@ --> <resources> <dimen name="scrollview_max_height">280dp</dimen> + <dimen name="speed_dial_context_menu_width">200dp</dimen> + <dimen name="context_menu_elevation">4dp</dimen> + <dimen name="speed_dial_recyclerview_horizontal_padding">16dp</dimen> + + <!-- + ~ This value expands the context menu to allow space for more text w/o being flush with the edge + ~ of the screen. Calculated with 2 * (speed_dial_recyclerview_horizontal_padding - 2dp) + --> + <dimen name="speed_dial_context_menu_extra_width">28dp</dimen> + <!-- + ~ This value centers the context menu with the favorite item layout. + ~ Calculated with -1 * (speed_dial_context_menu_extra_width * 1.75) + --> + <dimen name="speed_dial_context_menu_x_offset">-24dp</dimen> + <dimen name="speed_dial_context_menu_corner_radius">16dp</dimen> </resources>
\ No newline at end of file diff --git a/java/com/android/dialer/speeddial/res/values/strings.xml b/java/com/android/dialer/speeddial/res/values/strings.xml index 677f772c5..666eedea9 100644 --- a/java/com/android/dialer/speeddial/res/values/strings.xml +++ b/java/com/android/dialer/speeddial/res/values/strings.xml @@ -38,6 +38,21 @@ <!-- Text for a button that places a phone/voice call [CHAR LIMIT=15]--> <string name="disambig_option_voice_call">Call</string> + <!-- Text for a button that places a phone/voice call [CHAR LIMIT=15]--> + <string name="contact_menu_voice_call">Voice Call</string> + + <!-- Text for a button that places a video call [CHAR LIMIT=15]--> + <string name="contact_menu_video_call">Video Call</string> + + <!-- Text for a button that opens the contact in the SMS app [CHAR LIMIT=15]--> + <string name="contact_menu_message">Message</string> + + <!-- Text for a button that removes the item from the list [CHAR LIMIT=15]--> + <string name="contact_menu_remove">Remove</string> + + <!-- Text for a button that opens the contact's info [CHAR LIMIT=15]--> + <string name="contact_menu_contact_info">Contact info</string> + <!-- Title for screen prompting the user to select a contact to mark as a favorite. [CHAR LIMIT=NONE] --> <string name="add_favorite_activity_title">Add Favorite</string> </resources>
\ No newline at end of file diff --git a/java/com/android/dialer/speeddial/res/values/styles.xml b/java/com/android/dialer/speeddial/res/values/styles.xml new file mode 100644 index 000000000..83bbd09e5 --- /dev/null +++ b/java/com/android/dialer/speeddial/res/values/styles.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2017 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 + --> +<resources> + <style name="SpeedDialContextMenuItem" parent="SecondaryText"> + <item name="android:paddingStart">12dp</item> + <item name="android:minHeight">48dp</item> + <item name="android:gravity">center_vertical</item> + <item name="android:drawableTint">@color/secondary_text_color</item> + <item name="android:drawablePadding">12dp</item> + <item name="android:clickable">true</item> + <item name="android:background">?android:attr/selectableItemBackground</item> + </style> +</resources>
\ No newline at end of file diff --git a/java/com/android/dialer/theme/res/values/dimens.xml b/java/com/android/dialer/theme/res/values/dimens.xml index 2b5243ebd..52a7560b3 100644 --- a/java/com/android/dialer/theme/res/values/dimens.xml +++ b/java/com/android/dialer/theme/res/values/dimens.xml @@ -50,4 +50,7 @@ <!-- Minimum width for material compliant buttons. --> <dimen name="dialer_button_min_width">72dp</dimen> + + <!-- Color for list dividers --> + <color name="divider_line_color">#D8D8D8</color> </resources> |