Loading java/com/android/dialer/databasepopulator/ContactsPopulator.java +1 −0 Original line number Diff line number Diff line Loading @@ -152,6 +152,7 @@ public final class ContactsPopulator { Assert.isWorkerThread(); ArrayList<ContentProviderOperation> operations = new ArrayList<>(); addContact(SIMPLE_CONTACTS[0], operations); addContact(SIMPLE_CONTACTS[3], operations); addContact(SIMPLE_CONTACTS[5], operations); try { context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, operations); Loading java/com/android/dialer/speeddial/SpeedDialFragment.java +64 −25 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import android.os.Bundle; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.helper.ItemTouchHelper; Loading Loading @@ -62,16 +64,12 @@ import com.google.common.collect.ImmutableList; public class SpeedDialFragment extends Fragment { private final SpeedDialHeaderListener headerListener = new SpeedDialFragmentHeaderListener(); private final FavoriteContactsListener favoritesListener = new SpeedDialFavoritesListener(); private final SuggestedContactsListener suggestedListener = new SpeedDialSuggestedListener(); private View rootLayout; private ContextMenu contextMenu; private FrameLayout contextMenuBackground; private ContextMenuItemListener contextMenuItemListener; private SpeedDialAdapter adapter; private SpeedDialLayoutManager layoutManager; private SupportUiListener<ImmutableList<SpeedDialUiItem>> speedDialLoaderListener; /** Loading @@ -80,6 +78,8 @@ public class SpeedDialFragment extends Fragment { */ private boolean updateSpeedDialItemsOnResume = true; private FavoriteContactsListener favoritesListener; public static SpeedDialFragment newInstance() { return new SpeedDialFragment(); } Loading @@ -89,14 +89,33 @@ public class SpeedDialFragment extends Fragment { public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LogUtil.enterBlock("SpeedDialFragment.onCreateView"); rootLayout = inflater.inflate(R.layout.fragment_speed_dial, container, false); View rootLayout = inflater.inflate(R.layout.fragment_speed_dial, container, false); // Setup favorite contact context menu 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); }); // Setup our RecyclerView RecyclerView recyclerView = rootLayout.findViewById(R.id.speed_dial_recycler_view); SpeedDialLayoutManager layoutManager = new SpeedDialLayoutManager(getContext(), 3 /* spanCount */); favoritesListener = new SpeedDialFavoritesListener( getActivity(), getChildFragmentManager(), rootLayout, contextMenu, contextMenuBackground, new SpeedDialContextMenuItemListener(), layoutManager); adapter = new SpeedDialAdapter(getContext(), favoritesListener, suggestedListener, headerListener); layoutManager = new SpeedDialLayoutManager(getContext(), 3 /* spanCount */); layoutManager.setSpanSizeLookup(adapter.getSpanSizeLookup()); RecyclerView recyclerView = rootLayout.findViewById(R.id.speed_dial_recycler_view); recyclerView.setLayoutManager(layoutManager); recyclerView.setAdapter(adapter); Loading @@ -106,16 +125,6 @@ public class SpeedDialFragment extends Fragment { touchHelper.attachToRecyclerView(recyclerView); adapter.setItemTouchHelper(touchHelper); // Setup favorite contact context menu 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"); Loading Loading @@ -181,26 +190,56 @@ public class SpeedDialFragment extends Fragment { } } private final class SpeedDialFavoritesListener implements FavoriteContactsListener { private static final class SpeedDialFavoritesListener implements FavoriteContactsListener { private final FragmentActivity activity; private final FragmentManager childFragmentManager; private final View rootLayout; private final ContextMenu contextMenu; private final View contextMenuBackground; private final ContextMenuItemListener contextMenuListener; private final SpeedDialLayoutManager layoutManager; SpeedDialFavoritesListener( FragmentActivity activity, FragmentManager childFragmentManager, View rootLayout, ContextMenu contextMenu, View contextMenuBackground, ContextMenuItemListener contextMenuListener, SpeedDialLayoutManager layoutManager) { this.activity = activity; this.childFragmentManager = childFragmentManager; this.rootLayout = rootLayout; this.contextMenu = contextMenu; this.contextMenuBackground = contextMenuBackground; this.contextMenuListener = contextMenuListener; this.layoutManager = layoutManager; } @Override public void onAmbiguousContactClicked(SpeedDialUiItem speedDialUiItem) { DisambigDialog.show(speedDialUiItem, getChildFragmentManager()); // If there is only one channel, skip the menu and place a call directly if (speedDialUiItem.channels().size() == 1) { onClick(speedDialUiItem.channels().get(0)); return; } DisambigDialog.show(speedDialUiItem, childFragmentManager); } @Override public void onClick(Channel channel) { if (channel.technology() == Channel.DUO) { Logger.get(getContext()) Logger.get(activity) .logImpression(DialerImpression.Type.LIGHTBRINGER_VIDEO_REQUESTED_FOR_FAVORITE_CONTACT); Intent intent = DuoComponent.get(getContext()).getDuo().getIntent(getContext(), channel.number()); getActivity().startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_DUO); Intent intent = DuoComponent.get(activity).getDuo().getIntent(activity, channel.number()); activity.startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_DUO); return; } PreCall.start( getContext(), activity, new CallIntentBuilder(channel.number(), CallInitiationType.Type.SPEED_DIAL) .setIsVideoCall(channel.isVideoTechnology())); } Loading @@ -208,7 +247,7 @@ public class SpeedDialFragment extends Fragment { @Override public void showContextMenu(View view, SpeedDialUiItem speedDialUiItem) { layoutManager.setScrollEnabled(false); contextMenu.showMenu(rootLayout, view, speedDialUiItem, contextMenuItemListener); contextMenu.showMenu(rootLayout, view, speedDialUiItem, contextMenuListener); } @Override Loading Loading
java/com/android/dialer/databasepopulator/ContactsPopulator.java +1 −0 Original line number Diff line number Diff line Loading @@ -152,6 +152,7 @@ public final class ContactsPopulator { Assert.isWorkerThread(); ArrayList<ContentProviderOperation> operations = new ArrayList<>(); addContact(SIMPLE_CONTACTS[0], operations); addContact(SIMPLE_CONTACTS[3], operations); addContact(SIMPLE_CONTACTS[5], operations); try { context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, operations); Loading
java/com/android/dialer/speeddial/SpeedDialFragment.java +64 −25 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import android.os.Bundle; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.helper.ItemTouchHelper; Loading Loading @@ -62,16 +64,12 @@ import com.google.common.collect.ImmutableList; public class SpeedDialFragment extends Fragment { private final SpeedDialHeaderListener headerListener = new SpeedDialFragmentHeaderListener(); private final FavoriteContactsListener favoritesListener = new SpeedDialFavoritesListener(); private final SuggestedContactsListener suggestedListener = new SpeedDialSuggestedListener(); private View rootLayout; private ContextMenu contextMenu; private FrameLayout contextMenuBackground; private ContextMenuItemListener contextMenuItemListener; private SpeedDialAdapter adapter; private SpeedDialLayoutManager layoutManager; private SupportUiListener<ImmutableList<SpeedDialUiItem>> speedDialLoaderListener; /** Loading @@ -80,6 +78,8 @@ public class SpeedDialFragment extends Fragment { */ private boolean updateSpeedDialItemsOnResume = true; private FavoriteContactsListener favoritesListener; public static SpeedDialFragment newInstance() { return new SpeedDialFragment(); } Loading @@ -89,14 +89,33 @@ public class SpeedDialFragment extends Fragment { public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LogUtil.enterBlock("SpeedDialFragment.onCreateView"); rootLayout = inflater.inflate(R.layout.fragment_speed_dial, container, false); View rootLayout = inflater.inflate(R.layout.fragment_speed_dial, container, false); // Setup favorite contact context menu 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); }); // Setup our RecyclerView RecyclerView recyclerView = rootLayout.findViewById(R.id.speed_dial_recycler_view); SpeedDialLayoutManager layoutManager = new SpeedDialLayoutManager(getContext(), 3 /* spanCount */); favoritesListener = new SpeedDialFavoritesListener( getActivity(), getChildFragmentManager(), rootLayout, contextMenu, contextMenuBackground, new SpeedDialContextMenuItemListener(), layoutManager); adapter = new SpeedDialAdapter(getContext(), favoritesListener, suggestedListener, headerListener); layoutManager = new SpeedDialLayoutManager(getContext(), 3 /* spanCount */); layoutManager.setSpanSizeLookup(adapter.getSpanSizeLookup()); RecyclerView recyclerView = rootLayout.findViewById(R.id.speed_dial_recycler_view); recyclerView.setLayoutManager(layoutManager); recyclerView.setAdapter(adapter); Loading @@ -106,16 +125,6 @@ public class SpeedDialFragment extends Fragment { touchHelper.attachToRecyclerView(recyclerView); adapter.setItemTouchHelper(touchHelper); // Setup favorite contact context menu 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"); Loading Loading @@ -181,26 +190,56 @@ public class SpeedDialFragment extends Fragment { } } private final class SpeedDialFavoritesListener implements FavoriteContactsListener { private static final class SpeedDialFavoritesListener implements FavoriteContactsListener { private final FragmentActivity activity; private final FragmentManager childFragmentManager; private final View rootLayout; private final ContextMenu contextMenu; private final View contextMenuBackground; private final ContextMenuItemListener contextMenuListener; private final SpeedDialLayoutManager layoutManager; SpeedDialFavoritesListener( FragmentActivity activity, FragmentManager childFragmentManager, View rootLayout, ContextMenu contextMenu, View contextMenuBackground, ContextMenuItemListener contextMenuListener, SpeedDialLayoutManager layoutManager) { this.activity = activity; this.childFragmentManager = childFragmentManager; this.rootLayout = rootLayout; this.contextMenu = contextMenu; this.contextMenuBackground = contextMenuBackground; this.contextMenuListener = contextMenuListener; this.layoutManager = layoutManager; } @Override public void onAmbiguousContactClicked(SpeedDialUiItem speedDialUiItem) { DisambigDialog.show(speedDialUiItem, getChildFragmentManager()); // If there is only one channel, skip the menu and place a call directly if (speedDialUiItem.channels().size() == 1) { onClick(speedDialUiItem.channels().get(0)); return; } DisambigDialog.show(speedDialUiItem, childFragmentManager); } @Override public void onClick(Channel channel) { if (channel.technology() == Channel.DUO) { Logger.get(getContext()) Logger.get(activity) .logImpression(DialerImpression.Type.LIGHTBRINGER_VIDEO_REQUESTED_FOR_FAVORITE_CONTACT); Intent intent = DuoComponent.get(getContext()).getDuo().getIntent(getContext(), channel.number()); getActivity().startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_DUO); Intent intent = DuoComponent.get(activity).getDuo().getIntent(activity, channel.number()); activity.startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_DUO); return; } PreCall.start( getContext(), activity, new CallIntentBuilder(channel.number(), CallInitiationType.Type.SPEED_DIAL) .setIsVideoCall(channel.isVideoTechnology())); } Loading @@ -208,7 +247,7 @@ public class SpeedDialFragment extends Fragment { @Override public void showContextMenu(View view, SpeedDialUiItem speedDialUiItem) { layoutManager.setScrollEnabled(false); contextMenu.showMenu(rootLayout, view, speedDialUiItem, contextMenuItemListener); contextMenu.showMenu(rootLayout, view, speedDialUiItem, contextMenuListener); } @Override Loading