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

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

Merge "Implement contacts promo in NUI."

parents 82393b83 5e5172c4
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -158,6 +158,11 @@ public class ContactsFragment extends Fragment
    contactsPrefs.registerChangeListener(this);
    header = getArguments().getInt(EXTRA_HEADER);
    hasPhoneNumbers = getArguments().getBoolean(EXTRA_HAS_PHONE_NUMBERS);
    if (savedInstanceState == null) {
      // The onHiddenChanged callback does not get called the first time the fragment is
      // attached, so call it ourselves here.
      onHiddenChanged(false);
    }
  }

  @Override
@@ -354,6 +359,16 @@ public class ContactsFragment extends Fragment
    }
  }

  @Override
  public void onHiddenChanged(boolean hidden) {
    super.onHiddenChanged(hidden);
    OnContactsFragmentHiddenChangedListener listener =
        FragmentUtils.getParent(this, OnContactsFragmentHiddenChangedListener.class);
    if (listener != null) {
      listener.onContactsFragmentHiddenChanged(hidden);
    }
  }

  private void loadContacts() {
    getLoaderManager().initLoader(0, null, this);
    recyclerView.setVisibility(View.VISIBLE);
@@ -371,4 +386,9 @@ public class ContactsFragment extends Fragment
    /** Called when a contact is selected in {@link ContactsFragment}. */
    void onContactSelected(ImageView photo, Uri contactUri, long contactId);
  }

  /** Listener for contacts fragment hidden state */
  public interface OnContactsFragmentHiddenChangedListener {
    void onContactsFragmentHiddenChanged(boolean hidden);
  }
}
+36 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import com.android.dialer.searchfragment.list.NewSearchFragment.SearchFragmentLi
import com.android.dialer.smartdial.util.SmartDialNameMatcher;
import com.google.common.base.Optional;
import java.util.ArrayList;
import java.util.List;

/**
 * Search controller for handling all the logic related to entering and exiting the search UI.
@@ -83,6 +84,8 @@ public class MainSearchController implements SearchBarListener {
  private final MainToolbar toolbar;
  private final View toolbarShadow;

  private final List<OnSearchShowListener> onSearchShowListenerList = new ArrayList<>();

  public MainSearchController(
      MainActivity mainActivity,
      BottomNavBar bottomNav,
@@ -142,6 +145,8 @@ public class MainSearchController implements SearchBarListener {
      transaction.show(dialpadFragment);
    }
    transaction.commit();

    notifyListenersOnSearchOpen();
  }

  /**
@@ -288,6 +293,8 @@ public class MainSearchController implements SearchBarListener {
    if (getDialpadFragment() != null) {
      getDialpadFragment().clearDialpad();
    }

    notifyListenersOnSearchClose();
  }

  @Nullable
@@ -356,6 +363,8 @@ public class MainSearchController implements SearchBarListener {
    searchFragment.setQuery(
        query.isPresent() ? query.get() : "", CallInitiationType.Type.REGULAR_SEARCH);
    transaction.commit();

    notifyListenersOnSearchOpen();
  }

  @Override
@@ -455,4 +464,31 @@ public class MainSearchController implements SearchBarListener {
      toolbar.slideUp(false);
    }
  }

  public void addOnSearchShowListener(OnSearchShowListener listener) {
    onSearchShowListenerList.add(listener);
  }

  public void removeOnSearchShowListener(OnSearchShowListener listener) {
    onSearchShowListenerList.remove(listener);
  }

  private void notifyListenersOnSearchOpen() {
    for (OnSearchShowListener listener : onSearchShowListenerList) {
      listener.onSearchOpen();
    }
  }

  private void notifyListenersOnSearchClose() {
    for (OnSearchShowListener listener : onSearchShowListenerList) {
      listener.onSearchClose();
    }
  }

  /** Listener for search fragment show states change */
  public interface OnSearchShowListener {
    void onSearchOpen();

    void onSearchClose();
  }
}