summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/speeddial/SpeedDialFragment.java
diff options
context:
space:
mode:
authorcalderwoodra <calderwoodra@google.com>2018-04-11 21:43:49 -0700
committerCopybara-Service <copybara-piper@google.com>2018-04-11 21:44:39 -0700
commit7be061ae13582b0c64251d99a206589a6901bf20 (patch)
tree352e4063bb756866db3e878dbb1bec933c71af5c /java/com/android/dialer/speeddial/SpeedDialFragment.java
parentd0c86ba608484d8e9307417d2546220b38ab6f10 (diff)
Added context menu for favorite contacts in new speed dial.
Bug: 36841782,77761023 Test: WIP PiperOrigin-RevId: 192556602 Change-Id: I50c0baef7ef6c8ae533545567ec797283a9a870f
Diffstat (limited to 'java/com/android/dialer/speeddial/SpeedDialFragment.java')
-rw-r--r--java/com/android/dialer/speeddial/SpeedDialFragment.java66
1 files changed, 56 insertions, 10 deletions
diff --git a/java/com/android/dialer/speeddial/SpeedDialFragment.java b/java/com/android/dialer/speeddial/SpeedDialFragment.java
index aca4886a4..d323b1bb4 100644
--- a/java/com/android/dialer/speeddial/SpeedDialFragment.java
+++ b/java/com/android/dialer/speeddial/SpeedDialFragment.java
@@ -24,11 +24,14 @@ import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.FrameLayout;
import com.android.dialer.callintent.CallInitiationType;
import com.android.dialer.callintent.CallIntentBuilder;
+import com.android.dialer.common.LogUtil;
import com.android.dialer.common.concurrent.DialerExecutorComponent;
import com.android.dialer.common.concurrent.SupportUiListener;
import com.android.dialer.precall.PreCall;
+import com.android.dialer.speeddial.ContextMenu.ContextMenuItemListener;
import com.android.dialer.speeddial.FavoritesViewHolder.FavoriteContactsListener;
import com.android.dialer.speeddial.HeaderViewHolder.SpeedDialHeaderListener;
import com.android.dialer.speeddial.SuggestionViewHolder.SuggestedContactsListener;
@@ -54,7 +57,11 @@ public class SpeedDialFragment extends Fragment {
private final FavoriteContactsListener favoritesListener = new SpeedDialFavoritesListener();
private final SuggestedContactsListener suggestedListener = new SpeedDialSuggestedListener();
+ private View rootLayout;
+ private ContextMenu contextMenu;
+ private FrameLayout contextMenuBackground;
private SpeedDialAdapter adapter;
+ private ContextMenuItemListener contextMenuItemListener;
private SupportUiListener<ImmutableList<SpeedDialUiItem>> speedDialLoaderListener;
public static SpeedDialFragment newInstance() {
@@ -65,18 +72,28 @@ public class SpeedDialFragment extends Fragment {
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_speed_dial, container, false);
- RecyclerView recyclerView = view.findViewById(R.id.speed_dial_recycler_view);
+ LogUtil.enterBlock("SpeedDialFragment.onCreateView");
+ rootLayout = inflater.inflate(R.layout.fragment_speed_dial, container, false);
+ RecyclerView recyclerView = rootLayout.findViewById(R.id.speed_dial_recycler_view);
adapter =
new SpeedDialAdapter(getContext(), favoritesListener, suggestedListener, headerListener);
recyclerView.setLayoutManager(adapter.getLayoutManager(getContext()));
recyclerView.setAdapter(adapter);
+ contextMenu = rootLayout.findViewById(R.id.favorite_contact_context_menu);
+ contextMenuBackground = rootLayout.findViewById(R.id.context_menu_background);
+ contextMenuBackground.setOnClickListener(
+ v -> {
+ contextMenu.hideMenu();
+ contextMenuBackground.setVisibility(View.GONE);
+ });
+ contextMenuItemListener = new SpeedDialContextMenuItemListener();
+
speedDialLoaderListener =
DialerExecutorComponent.get(getContext())
.createUiListener(getChildFragmentManager(), "speed_dial_loader_listener");
- return view;
+ return rootLayout;
}
public boolean hasFrequents() {
@@ -107,7 +124,7 @@ public class SpeedDialFragment extends Fragment {
}
}
- private class SpeedDialFavoritesListener implements FavoriteContactsListener {
+ private final class SpeedDialFavoritesListener implements FavoriteContactsListener {
@Override
public void onAmbiguousContactClicked(List<Channel> channels) {
@@ -115,21 +132,22 @@ public class SpeedDialFragment extends Fragment {
}
@Override
- public void onClick(String number, boolean isVideoCall) {
+ public void onClick(Channel channel) {
// TODO(calderwoodra): add logic for duo video calls
PreCall.start(
getContext(),
- new CallIntentBuilder(number, CallInitiationType.Type.SPEED_DIAL)
- .setIsVideoCall(isVideoCall));
+ new CallIntentBuilder(channel.number(), CallInitiationType.Type.SPEED_DIAL)
+ .setIsVideoCall(channel.isVideoTechnology()));
}
@Override
- public void onLongClick(String number) {
- // TODO(calderwoodra): show favorite contact floating context menu
+ public void onLongClick(View view, SpeedDialUiItem speedDialUiItem) {
+ contextMenuBackground.setVisibility(View.VISIBLE);
+ contextMenu.showMenu(rootLayout, view, speedDialUiItem, contextMenuItemListener);
}
}
- private class SpeedDialSuggestedListener implements SuggestedContactsListener {
+ private final class SpeedDialSuggestedListener implements SuggestedContactsListener {
@Override
public void onOverFlowMenuClicked(String number) {
@@ -142,4 +160,32 @@ public class SpeedDialFragment extends Fragment {
getContext(), new CallIntentBuilder(number, CallInitiationType.Type.SPEED_DIAL));
}
}
+
+ private static final class SpeedDialContextMenuItemListener implements ContextMenuItemListener {
+
+ @Override
+ public void placeVoiceCall(SpeedDialUiItem speedDialUiItem) {
+ // TODO(calderwoodra)
+ }
+
+ @Override
+ public void placeVideoCall(SpeedDialUiItem speedDialUiItem) {
+ // TODO(calderwoodra)
+ }
+
+ @Override
+ public void openSmsConversation(SpeedDialUiItem speedDialUiItem) {
+ // TODO(calderwoodra)
+ }
+
+ @Override
+ public void removeFavoriteContact(SpeedDialUiItem speedDialUiItem) {
+ // TODO(calderwoodra)
+ }
+
+ @Override
+ public void openContactInfo(SpeedDialUiItem speedDialUiItem) {
+ // TODO(calderwoodra)
+ }
+ }
}