use of com.android.dialer.p13n.inference.protocol.P13nRanker in project android_packages_apps_Dialer by LineageOS.
the class DialtactsActivity method enterSearchUi.
/**
* Shows the search fragment
*/
private void enterSearchUi(boolean smartDialSearch, String query, boolean animate) {
if (mStateSaved || getFragmentManager().isDestroyed()) {
// constructive here.
return;
}
if (DEBUG) {
LogUtil.v("DialtactsActivity.enterSearchUi", "smart dial " + smartDialSearch);
}
final FragmentTransaction transaction = getFragmentManager().beginTransaction();
if (mInDialpadSearch && mSmartDialSearchFragment != null) {
transaction.remove(mSmartDialSearchFragment);
} else if (mInRegularSearch && mRegularSearchFragment != null) {
transaction.remove(mRegularSearchFragment);
}
final String tag;
boolean useNewSearch = ConfigProviderBindings.get(this).getBoolean("enable_new_search_fragment", false);
if (useNewSearch) {
tag = TAG_NEW_SEARCH_FRAGMENT;
} else if (smartDialSearch) {
tag = TAG_SMARTDIAL_SEARCH_FRAGMENT;
} else {
tag = TAG_REGULAR_SEARCH_FRAGMENT;
}
mInDialpadSearch = smartDialSearch;
mInRegularSearch = !smartDialSearch;
mFloatingActionButtonController.scaleOut();
if (animate) {
transaction.setCustomAnimations(android.R.animator.fade_in, 0);
} else {
transaction.setTransition(FragmentTransaction.TRANSIT_NONE);
}
Fragment fragment = getFragmentManager().findFragmentByTag(tag);
if (fragment == null) {
if (useNewSearch) {
fragment = new NewSearchFragment();
} else if (smartDialSearch) {
fragment = new SmartDialSearchFragment();
} else {
fragment = Bindings.getLegacy(this).newRegularSearchFragment();
((SearchFragment) fragment).setOnTouchListener((v, event) -> {
// Show the FAB when the user touches the lists fragment and the soft
// keyboard is hidden.
hideDialpadFragment(true, false);
v.performClick();
return false;
});
}
transaction.add(R.id.dialtacts_frame, fragment, tag);
} else {
// TODO: if this is a transition from dialpad to searchbar, animate fragment
// down, and vice versa. Perhaps just add a coordinator behavior with the search bar.
transaction.show(fragment);
}
// DialtactsActivity will provide the options menu
fragment.setHasOptionsMenu(false);
// Will show empty list if P13nRanker is not enabled. Else, re-ranked list by the ranker.
if (!useNewSearch) {
((SearchFragment) fragment).setShowEmptyListForNullQuery(mP13nRanker.shouldShowEmptyListForNullQuery());
} else {
// TODO: add p13n ranker to new search.
}
if (!smartDialSearch && !useNewSearch) {
((SearchFragment) fragment).setQueryString(query);
} else if (useNewSearch) {
((NewSearchFragment) fragment).setQuery(query);
}
transaction.commit();
if (animate) {
Assert.isNotNull(mListsFragment.getView()).animate().alpha(0).withLayer();
}
mListsFragment.setUserVisibleHint(false);
if (smartDialSearch) {
Logger.get(this).logScreenView(ScreenEvent.Type.SMART_DIAL_SEARCH, this);
} else {
Logger.get(this).logScreenView(ScreenEvent.Type.REGULAR_SEARCH, this);
}
}
Aggregations