use of com.android.dialer.searchfragment.list.NewSearchFragment 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);
}
}
use of com.android.dialer.searchfragment.list.NewSearchFragment in project android_packages_apps_Dialer by LineageOS.
the class DialtactsActivity method onAttachFragment.
@Override
public void onAttachFragment(final Fragment fragment) {
LogUtil.d("DialtactsActivity.onAttachFragment", "fragment: %s", fragment);
if (fragment instanceof DialpadFragment) {
mDialpadFragment = (DialpadFragment) fragment;
if (!mIsDialpadShown && !mShowDialpadOnResume) {
final FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.hide(mDialpadFragment);
transaction.commit();
}
} else if (fragment instanceof SmartDialSearchFragment) {
mSmartDialSearchFragment = (SmartDialSearchFragment) fragment;
mSmartDialSearchFragment.setOnPhoneNumberPickerActionListener(this);
if (!TextUtils.isEmpty(mDialpadQuery)) {
mSmartDialSearchFragment.setAddToContactNumber(mDialpadQuery);
}
} else if (fragment instanceof SearchFragment) {
mRegularSearchFragment = (RegularSearchFragment) fragment;
mRegularSearchFragment.setOnPhoneNumberPickerActionListener(this);
} else if (fragment instanceof ListsFragment) {
mListsFragment = (ListsFragment) fragment;
mListsFragment.addOnPageChangeListener(this);
} else if (fragment instanceof NewSearchFragment) {
mNewSearchFragment = (NewSearchFragment) fragment;
}
if (fragment instanceof SearchFragment) {
final SearchFragment searchFragment = (SearchFragment) fragment;
searchFragment.setReranker(new CursorReranker() {
@Override
@MainThread
public Cursor rerankCursor(Cursor data) {
Assert.isMainThread();
String queryString = searchFragment.getQueryString();
return mP13nRanker.rankCursor(data, queryString == null ? 0 : queryString.length());
}
});
searchFragment.addOnLoadFinishedListener(new OnLoadFinishedListener() {
@Override
public void onLoadFinished() {
mP13nLogger.onSearchQuery(searchFragment.getQueryString(), (PhoneNumberListAdapter) searchFragment.getAdapter());
}
});
}
}
Aggregations