Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4cd323f2 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes Ib035855d,I15bc2c45,I079aca18,I9b90aaa0,I452ca635, ...

* changes:
  Don't override contactExists if there is no update from Cequint Caller ID.
  Make default lastModified timestamp configurable
  Added old call log to NUI.
  Add old speed dial fragment to NUI.
  Added badge count feature to bottom nav.
  Allow delete of Restricted number entries
  Update FragUtils to encourage better readability in Activities.
parents a6b96247 d6b91d1f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1508,6 +1508,11 @@ public class DialtactsActivity extends TransactionSafeActivity
  @Override
  public void onDroppedOnRemove() {}

  @Override
  public ImageView getDragShadowOverlay() {
    return findViewById(R.id.contact_tile_drag_shadow_overlay);
  }

  /**
   * Allows the SpeedDialFragment to attach the drag controller to mRemoveViewContainer once it has
   * been attached to the activity.
+23 −8
Original line number Diff line number Diff line
@@ -53,10 +53,10 @@ import com.android.dialer.app.calllog.calllogcache.CallLogCache;
import com.android.dialer.app.contactinfo.ContactInfoCache;
import com.android.dialer.app.contactinfo.ContactInfoCache.OnContactInfoChangedListener;
import com.android.dialer.app.contactinfo.ExpirableCacheHeadlessFragment;
import com.android.dialer.app.list.ListsFragment;
import com.android.dialer.app.voicemail.VoicemailPlaybackPresenter;
import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler;
import com.android.dialer.common.Assert;
import com.android.dialer.common.FragmentUtils;
import com.android.dialer.common.LogUtil;
import com.android.dialer.database.CallLogQueryHandler;
import com.android.dialer.database.CallLogQueryHandler.Listener;
@@ -344,9 +344,10 @@ public class CallLogFragment extends Fragment
                recyclerView,
                this,
                this,
                activityType == CallLogAdapter.ACTIVITY_TYPE_DIALTACTS
                    ? (CallLogAdapter.OnActionModeStateChangedListener) getActivity()
                    : null,
                // We aren't calling getParentUnsafe because CallLogActivity doesn't need to
                // implement this listener
                FragmentUtils.getParent(
                    this, CallLogAdapter.OnActionModeStateChangedListener.class),
                new CallLogCache(getActivity()),
                contactInfoCache,
                getVoicemailPlaybackPresenter(),
@@ -479,7 +480,7 @@ public class CallLogFragment extends Fragment
  public void fetchCalls() {
    callLogQueryHandler.fetchCalls(callTypeFilter, dateLimit);
    if (!isCallLogActivity) {
      ((ListsFragment) getParentFragment()).updateTabUnreadCounts();
      FragmentUtils.getParentUnsafe(this, CallLogFragmentListener.class).updateTabUnreadCounts();
    }
  }

@@ -616,7 +617,8 @@ public class CallLogFragment extends Fragment
  public void onVisible() {
    LogUtil.enterBlock("CallLogFragment.onPageSelected");
    if (getActivity() != null && getActivity() instanceof HostInterface) {
      ((HostInterface) getActivity()).enableFloatingButton(!isModalAlertVisible());
      FragmentUtils.getParentUnsafe(this, HostInterface.class)
          .enableFloatingButton(!isModalAlertVisible());
    }
  }

@@ -638,7 +640,7 @@ public class CallLogFragment extends Fragment
        this,
        getUserVisibleHint());
    getAdapter().notifyDataSetChanged();
    HostInterface hostInterface = (HostInterface) getActivity();
    HostInterface hostInterface = FragmentUtils.getParent(this, HostInterface.class);
    if (show) {
      recyclerView.setVisibility(View.GONE);
      modalAlertView.setVisibility(View.VISIBLE);
@@ -659,7 +661,8 @@ public class CallLogFragment extends Fragment
    multiSelectUnSelectAllViewContent.setVisibility(show ? View.VISIBLE : View.GONE);
    multiSelectUnSelectAllViewContent.setAlpha(show ? 0 : 1);
    multiSelectUnSelectAllViewContent.animate().alpha(show ? 1 : 0).start();
    ((ListsFragment) getParentFragment()).showMultiSelectRemoveView(show);
    FragmentUtils.getParentUnsafe(this, CallLogFragmentListener.class)
        .showMultiSelectRemoveView(show);
  }

  @Override
@@ -717,4 +720,16 @@ public class CallLogFragment extends Fragment
      refreshDataRequired = true;
    }
  }

  /** Useful callback for ListsFragment children to use to call into ListsFragment. */
  public interface CallLogFragmentListener {

    /**
     * External method to update unread count because the unread count changes when the user expands
     * a voicemail in the call log or when the user expands an unread call in the call history tab.
     */
    void updateTabUnreadCounts();

    void showMultiSelectRemoveView(boolean show);
  }
}
+5 −5
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.view.ViewGroup;
import com.android.contacts.common.list.ViewPagerTabs;
import com.android.dialer.app.R;
import com.android.dialer.app.calllog.CallLogFragment;
import com.android.dialer.app.calllog.CallLogFragment.CallLogFragmentListener;
import com.android.dialer.app.calllog.CallLogNotificationsService;
import com.android.dialer.app.calllog.VisualVoicemailCallLogFragment;
import com.android.dialer.common.LogUtil;
@@ -59,7 +60,8 @@ import java.util.ArrayList;
 * Contacts list. This will also eventually contain the logic that allows sliding the ViewPager
 * containing the lists up above the search bar and pin it against the top of the screen.
 */
public class ListsFragment extends Fragment implements OnPageChangeListener, Listener {
public class ListsFragment extends Fragment
    implements OnPageChangeListener, Listener, CallLogFragmentListener {

  private static final String TAG = "ListsFragment";

@@ -423,10 +425,7 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis
    return true;
  }

  /**
   * External method to update unread count because the unread count changes when the user expands a
   * voicemail in the call log or when the user expands an unread call in the call history tab.
   */
  @Override
  public void updateTabUnreadCounts() {
    if (callLogQueryHandler != null) {
      callLogQueryHandler.fetchMissedCallsUnreadCount();
@@ -450,6 +449,7 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis
    removeView.animate().alpha(show ? 1 : 0).start();
  }

  @Override
  public void showMultiSelectRemoveView(boolean show) {
    viewPagerTabs.setVisibility(show ? View.GONE : View.VISIBLE);
    viewPager.setEnableSwipingPages(!show);
+64 −110
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import static android.Manifest.permission.READ_CONTACTS;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.app.Fragment;
import android.app.LoaderManager;
import android.content.CursorLoader;
@@ -50,6 +49,7 @@ import com.android.contacts.common.list.ContactTileView;
import com.android.contacts.common.list.OnPhoneNumberPickerActionListener;
import com.android.dialer.app.R;
import com.android.dialer.callintent.CallSpecificAppData;
import com.android.dialer.common.FragmentUtils;
import com.android.dialer.common.LogUtil;
import com.android.dialer.contactphoto.ContactPhotoManager;
import com.android.dialer.util.PermissionsUtil;
@@ -77,22 +77,17 @@ public class OldSpeedDialFragment extends Fragment
  private static final long KEY_REMOVED_ITEM_HEIGHT = Long.MAX_VALUE;

  private static final String TAG = "OldSpeedDialFragment";
  private static final boolean DEBUG = false;
  /** Used with LoaderManager. */
  private static final int LOADER_ID_CONTACT_TILE = 1;

  private final LongSparseArray<Integer> itemIdTopMap = new LongSparseArray<>();
  private final LongSparseArray<Integer> itemIdLeftMap = new LongSparseArray<>();
  private final ContactTileView.Listener contactTileAdapterListener =
      new ContactTileAdapterListener();
  private final LoaderManager.LoaderCallbacks<Cursor> contactTileLoaderListener =
      new ContactTileLoaderListener();
  private final ScrollListener scrollListener = new ScrollListener();
      new ContactTileAdapterListener(this);
  private final ScrollListener scrollListener = new ScrollListener(this);
  private LoaderManager.LoaderCallbacks<Cursor> contactTileLoaderListener;
  private int animationDuration;
  private OnPhoneNumberPickerActionListener phoneNumberPickerActionListener;
  private OnListFragmentScrolledListener activityScrollListener;
  private PhoneFavoritesTileAdapter contactTileAdapter;
  private View parentView;
  private PhoneFavoriteListView listView;
  private View contactTileFrame;
  /** Layout used when there are no favorites. */
@@ -100,9 +95,6 @@ public class OldSpeedDialFragment extends Fragment

  @Override
  public void onCreate(Bundle savedState) {
    if (DEBUG) {
      LogUtil.d("OldSpeedDialFragment.onCreate", null);
    }
    Trace.beginSection(TAG + " onCreate");
    super.onCreate(savedState);

@@ -110,8 +102,9 @@ public class OldSpeedDialFragment extends Fragment
    // We don't construct the resultant adapter at this moment since it requires LayoutInflater
    // that will be available on onCreateView().
    contactTileAdapter =
        new PhoneFavoritesTileAdapter(getActivity(), contactTileAdapterListener, this);
    contactTileAdapter.setPhotoLoader(ContactPhotoManager.getInstance(getActivity()));
        new PhoneFavoritesTileAdapter(getContext(), contactTileAdapterListener, this);
    contactTileAdapter.setPhotoLoader(ContactPhotoManager.getInstance(getContext()));
    contactTileLoaderListener = new ContactTileLoaderListener(this, contactTileAdapter);
    animationDuration = getResources().getInteger(R.integer.fade_duration);
    Trace.endSection();
  }
@@ -123,7 +116,7 @@ public class OldSpeedDialFragment extends Fragment
    if (contactTileAdapter != null) {
      contactTileAdapter.refreshContactsPreferences();
    }
    if (PermissionsUtil.hasContactsReadPermissions(getActivity())) {
    if (PermissionsUtil.hasContactsReadPermissions(getContext())) {
      if (getLoaderManager().getLoader(LOADER_ID_CONTACT_TILE) == null) {
        getLoaderManager().initLoader(LOADER_ID_CONTACT_TILE, null, contactTileLoaderListener);

@@ -144,7 +137,7 @@ public class OldSpeedDialFragment extends Fragment
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Trace.beginSection(TAG + " onCreateView");
    parentView = inflater.inflate(R.layout.speed_dial_fragment, container, false);
    View parentView = inflater.inflate(R.layout.speed_dial_fragment, container, false);

    listView = (PhoneFavoriteListView) parentView.findViewById(R.id.contact_tile_list);
    listView.setOnItemClickListener(this);
@@ -152,10 +145,8 @@ public class OldSpeedDialFragment extends Fragment
    listView.setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_RIGHT);
    listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
    listView.getDragDropController().addOnDragDropListener(contactTileAdapter);

    final ImageView dragShadowOverlay =
        (ImageView) getActivity().findViewById(R.id.contact_tile_drag_shadow_overlay);
    listView.setDragShadowOverlay(dragShadowOverlay);
    listView.setDragShadowOverlay(
        FragmentUtils.getParentUnsafe(this, HostInterface.class).getDragShadowOverlay());

    emptyView = (EmptyContentView) parentView.findViewById(R.id.empty_list_view);
    emptyView.setImage(R.drawable.empty_speed_dial);
@@ -165,7 +156,7 @@ public class OldSpeedDialFragment extends Fragment

    final LayoutAnimationController controller =
        new LayoutAnimationController(
            AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
            AnimationUtils.loadAnimation(getContext(), android.R.anim.fade_in));
    controller.setDelay(0);
    listView.setLayoutAnimation(controller);
    listView.setAdapter(contactTileAdapter);
@@ -206,36 +197,16 @@ public class OldSpeedDialFragment extends Fragment
  @Override
  public void onStart() {
    super.onStart();

    final Activity activity = getActivity();

    try {
      activityScrollListener = (OnListFragmentScrolledListener) activity;
    } catch (ClassCastException e) {
      throw new ClassCastException(
          activity.toString() + " must implement OnListFragmentScrolledListener");
    }

    try {
      OnDragDropListener listener = (OnDragDropListener) activity;
      listView.getDragDropController().addOnDragDropListener(listener);
      ((HostInterface) activity).setDragDropController(listView.getDragDropController());
    } catch (ClassCastException e) {
      throw new ClassCastException(
          activity.toString() + " must implement OnDragDropListener and HostInterface");
    }

    try {
      phoneNumberPickerActionListener = (OnPhoneNumberPickerActionListener) activity;
    } catch (ClassCastException e) {
      throw new ClassCastException(
          activity.toString() + " must implement PhoneFavoritesFragment.listener");
    }
    listView
        .getDragDropController()
        .addOnDragDropListener(FragmentUtils.getParentUnsafe(this, OnDragDropListener.class));
    FragmentUtils.getParentUnsafe(this, HostInterface.class)
        .setDragDropController(listView.getDragDropController());

    // Use initLoader() instead of restartLoader() to refraining unnecessary reload.
    // This method call implicitly assures ContactTileLoaderListener's onLoadFinished() will
    // be called, on which we'll check if "all" contacts should be reloaded again or not.
    if (PermissionsUtil.hasContactsReadPermissions(activity)) {
    if (PermissionsUtil.hasContactsReadPermissions(getContext())) {
      getLoaderManager().initLoader(LOADER_ID_CONTACT_TILE, null, contactTileLoaderListener);
    } else {
      setEmptyViewVisibility(true);
@@ -268,9 +239,6 @@ public class OldSpeedDialFragment extends Fragment
   */
  private void saveOffsets(int removedItemHeight) {
    final int firstVisiblePosition = listView.getFirstVisiblePosition();
    if (DEBUG) {
      LogUtil.d("OldSpeedDialFragment.saveOffsets", "Child count : " + listView.getChildCount());
    }
    for (int i = 0; i < listView.getChildCount(); i++) {
      final View child = listView.getChildAt(i);
      final int position = firstVisiblePosition + i;
@@ -281,11 +249,6 @@ public class OldSpeedDialFragment extends Fragment
        continue;
      }
      final long itemId = contactTileAdapter.getItemId(position);
      if (DEBUG) {
        LogUtil.d(
            "OldSpeedDialFragment.saveOffsets",
            "Saving itemId: " + itemId + " for listview child " + i + " Top: " + child.getTop());
      }
      itemIdTopMap.put(itemId, child.getTop());
      itemIdLeftMap.put(itemId, child.getLeft());
    }
@@ -350,19 +313,6 @@ public class OldSpeedDialFragment extends Fragment
                    animators.add(ObjectAnimator.ofFloat(child, "translationY", deltaY, 0.0f));
                  }
                }

                if (DEBUG) {
                  LogUtil.d(
                      "OldSpeedDialFragment.onPreDraw",
                      "Found itemId: "
                          + itemId
                          + " for listview child "
                          + i
                          + " Top: "
                          + top
                          + " Delta: "
                          + deltaY);
                }
              }
            }

@@ -399,11 +349,6 @@ public class OldSpeedDialFragment extends Fragment

  @Override
  public void onEmptyViewActionButtonClicked() {
    final Activity activity = getActivity();
    if (activity == null) {
      return;
    }

    String[] deniedPermissions =
        PermissionsUtil.getPermissionsCurrentlyDenied(
            getContext(), PermissionsUtil.allContactsGroupPermissionsUsedInDialer);
@@ -415,7 +360,7 @@ public class OldSpeedDialFragment extends Fragment
          this, deniedPermissions, READ_CONTACTS_PERMISSION_REQUEST_CODE);
    } else {
      // Switch tabs
      ((HostInterface) activity).showAllContactsTab();
      FragmentUtils.getParentUnsafe(this, HostInterface.class).showAllContactsTab();
    }
  }

@@ -424,79 +369,88 @@ public class OldSpeedDialFragment extends Fragment
      int requestCode, String[] permissions, int[] grantResults) {
    if (requestCode == READ_CONTACTS_PERMISSION_REQUEST_CODE) {
      if (grantResults.length == 1 && PackageManager.PERMISSION_GRANTED == grantResults[0]) {
        PermissionsUtil.notifyPermissionGranted(getActivity(), READ_CONTACTS);
        PermissionsUtil.notifyPermissionGranted(getContext(), READ_CONTACTS);
      }
    }
  }

  public interface HostInterface {
  private static final class ContactTileLoaderListener
      implements LoaderManager.LoaderCallbacks<Cursor> {

    void setDragDropController(DragDropController controller);
    private final OldSpeedDialFragment fragment;
    private final PhoneFavoritesTileAdapter adapter;

    void showAllContactsTab();
    ContactTileLoaderListener(OldSpeedDialFragment fragment, PhoneFavoritesTileAdapter adapter) {
      this.fragment = fragment;
      this.adapter = adapter;
    }

  class ContactTileLoaderListener implements LoaderManager.LoaderCallbacks<Cursor> {

    @Override
    public CursorLoader onCreateLoader(int id, Bundle args) {
      if (DEBUG) {
        LogUtil.d("ContactTileLoaderListener.onCreateLoader", null);
      }
      return ContactTileLoaderFactory.createStrequentPhoneOnlyLoader(getActivity());
      return ContactTileLoaderFactory.createStrequentPhoneOnlyLoader(fragment.getContext());
    }

    @Override
    public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
      if (DEBUG) {
        LogUtil.d("ContactTileLoaderListener.onLoadFinished", null);
      }
      contactTileAdapter.setContactCursor(data);
      setEmptyViewVisibility(contactTileAdapter.getCount() == 0);
      adapter.setContactCursor(data);
      fragment.setEmptyViewVisibility(adapter.getCount() == 0);
    }

    @Override
    public void onLoaderReset(Loader<Cursor> loader) {
      if (DEBUG) {
        LogUtil.d("ContactTileLoaderListener.onLoaderReset", null);
      }
    }
    public void onLoaderReset(Loader<Cursor> loader) {}
  }

  private class ContactTileAdapterListener implements ContactTileView.Listener {
  private static final class ContactTileAdapterListener implements ContactTileView.Listener {

    private final OldSpeedDialFragment fragment;

    ContactTileAdapterListener(OldSpeedDialFragment fragment) {
      this.fragment = fragment;
    }

    @Override
    public void onContactSelected(
        Uri contactUri, Rect targetRect, CallSpecificAppData callSpecificAppData) {
      if (phoneNumberPickerActionListener != null) {
        phoneNumberPickerActionListener.onPickDataUri(
            contactUri, false /* isVideoCall */, callSpecificAppData);
      }
      FragmentUtils.getParentUnsafe(fragment, OnPhoneNumberPickerActionListener.class)
          .onPickDataUri(contactUri, false /* isVideoCall */, callSpecificAppData);
    }

    @Override
    public void onCallNumberDirectly(String phoneNumber, CallSpecificAppData callSpecificAppData) {
      if (phoneNumberPickerActionListener != null) {
        phoneNumberPickerActionListener.onPickPhoneNumber(
            phoneNumber, false /* isVideoCall */, callSpecificAppData);
      }
      FragmentUtils.getParentUnsafe(fragment, OnPhoneNumberPickerActionListener.class)
          .onPickPhoneNumber(phoneNumber, false /* isVideoCall */, callSpecificAppData);
    }
  }

  private class ScrollListener implements ListView.OnScrollListener {
  private static class ScrollListener implements ListView.OnScrollListener {

    private final OldSpeedDialFragment fragment;

    ScrollListener(OldSpeedDialFragment fragment) {
      this.fragment = fragment;
    }

    @Override
    public void onScroll(
        AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
      if (activityScrollListener != null) {
        activityScrollListener.onListFragmentScroll(
            firstVisibleItem, visibleItemCount, totalItemCount);
      }
      FragmentUtils.getParentUnsafe(fragment, OnListFragmentScrolledListener.class)
          .onListFragmentScroll(firstVisibleItem, visibleItemCount, totalItemCount);
    }

    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {
      activityScrollListener.onListFragmentScrollStateChange(scrollState);
      FragmentUtils.getParentUnsafe(fragment, OnListFragmentScrolledListener.class)
          .onListFragmentScrollStateChange(scrollState);
    }
  }

  /** Interface for parents of OldSpeedDialFragment to implement. */
  public interface HostInterface {

    void setDragDropController(DragDropController controller);

    void showAllContactsTab();

    ImageView getDragShadowOverlay();
  }
}
+2 −3
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ final class CallDetailsFooterViewHolder extends RecyclerView.ViewHolder implemen

  private final ReportCallIdListener reportCallIdListener;
  private final DeleteCallDetailsListener deleteCallDetailsListener;
  private final View container;
  private final View copy;
  private final View edit;
  private final View reportCallerId;
@@ -51,7 +50,6 @@ final class CallDetailsFooterViewHolder extends RecyclerView.ViewHolder implemen
    super(view);
    this.reportCallIdListener = reportCallIdListener;
    this.deleteCallDetailsListener = deleteCallDetailsListener;
    container = view.findViewById(R.id.footer_container);
    copy = view.findViewById(R.id.call_detail_action_copy);
    edit = view.findViewById(R.id.call_detail_action_edit_before_call);
    reportCallerId = view.findViewById(R.id.call_detail_action_report_caller_id);
@@ -65,7 +63,8 @@ final class CallDetailsFooterViewHolder extends RecyclerView.ViewHolder implemen
  public void setPhoneNumber(String number) {
    this.number = number;
    if (TextUtils.isEmpty(number)) {
      container.setVisibility(View.GONE);
      copy.setVisibility(View.GONE);
      edit.setVisibility(View.GONE);
    } else if (reportCallIdListener.canReportCallerId(number)) {
      reportCallerId.setVisibility(View.VISIBLE);
    }
Loading