diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-02-27 23:07:40 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-02-27 23:07:40 +0000 |
commit | ffdd9c7513dfe72e02722889baaaab241d244d8c (patch) | |
tree | 84597a3d9385d3a43de68cb6fe7041c6b9c9fdc1 /java | |
parent | 82393b8382b39fbbf94cb2fcc7fc61b1cb62588d (diff) | |
parent | 5e5172c41d6f246bf216a68b3625dd9553af74d5 (diff) |
Merge "Implement contacts promo in NUI."
Diffstat (limited to 'java')
-rw-r--r-- | java/com/android/dialer/contactsfragment/ContactsFragment.java | 20 | ||||
-rw-r--r-- | java/com/android/dialer/main/impl/MainSearchController.java | 36 |
2 files changed, 56 insertions, 0 deletions
diff --git a/java/com/android/dialer/contactsfragment/ContactsFragment.java b/java/com/android/dialer/contactsfragment/ContactsFragment.java index ae2bd746a..794a5b91c 100644 --- a/java/com/android/dialer/contactsfragment/ContactsFragment.java +++ b/java/com/android/dialer/contactsfragment/ContactsFragment.java @@ -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); + } } diff --git a/java/com/android/dialer/main/impl/MainSearchController.java b/java/com/android/dialer/main/impl/MainSearchController.java index 33e0981dd..4f3ee6032 100644 --- a/java/com/android/dialer/main/impl/MainSearchController.java +++ b/java/com/android/dialer/main/impl/MainSearchController.java @@ -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(); + } } |