Search in sources :

Example 1 with SearchFragment

use of com.android.dialer.app.list.SearchFragment 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);
    }
}
Also used : Arrays(java.util.Arrays) Bundle(android.os.Bundle) AnimUtils(com.android.dialer.animation.AnimUtils) RegularSearchFragment(com.android.dialer.app.list.RegularSearchFragment) CallIntentBuilder(com.android.dialer.callintent.CallIntentBuilder) Uri(android.net.Uri) DialerSettingsActivity(com.android.dialer.app.settings.DialerSettingsActivity) OldSpeedDialFragment(com.android.dialer.app.list.OldSpeedDialFragment) DialtactsPagerAdapter(com.android.dialer.app.list.DialtactsPagerAdapter) ActionBarController(com.android.dialer.app.widget.ActionBarController) Simulator(com.android.dialer.simulator.Simulator) PhoneNumberInteraction(com.android.dialer.interactions.PhoneNumberInteraction) PopupMenu(android.widget.PopupMenu) MainThread(android.support.annotation.MainThread) TabIndex(com.android.dialer.app.list.DialtactsPagerAdapter.TabIndex) Database(com.android.dialer.database.Database) FloatingActionButton(android.support.design.widget.FloatingActionButton) DragEvent(android.view.DragEvent) ScreenEvent(com.android.dialer.logging.ScreenEvent) PhoneFavoriteSquareTileView(com.android.dialer.app.list.PhoneFavoriteSquareTileView) ActivityCompat(android.support.v4.app.ActivityCompat) PhoneNumberListAdapter(com.android.contacts.common.list.PhoneNumberListAdapter) CallSpecificAppData(com.android.dialer.callintent.CallSpecificAppData) OnLoadFinishedListener(com.android.contacts.common.list.PhoneNumberPickerFragment.OnLoadFinishedListener) NewSearchFragment(com.android.dialer.searchfragment.list.NewSearchFragment) Snackbar(android.support.design.widget.Snackbar) TextWatcher(android.text.TextWatcher) Assert(com.android.dialer.common.Assert) OnListFragmentScrolledListener(com.android.dialer.app.list.OnListFragmentScrolledListener) SystemClock(android.os.SystemClock) CallLogFragment(com.android.dialer.app.calllog.CallLogFragment) FragmentTransaction(android.app.FragmentTransaction) NonNull(android.support.annotation.NonNull) ViewUtil(com.android.dialer.util.ViewUtil) Editable(android.text.Editable) ArrayList(java.util.ArrayList) IntentProvider(com.android.dialer.app.calllog.IntentProvider) InteractionErrorCode(com.android.dialer.interactions.PhoneNumberInteraction.InteractionErrorCode) SearchFragment(com.android.dialer.app.list.SearchFragment) P13nLogging(com.android.dialer.p13n.logging.P13nLogging) Toast(android.widget.Toast) Menu(android.view.Menu) ConfigProviderBindings(com.android.dialer.configprovider.ConfigProviderBindings) SmartDialSearchFragment(com.android.dialer.app.list.SmartDialSearchFragment) Fragment(android.app.Fragment) OnPhoneNumberPickerActionListener(com.android.contacts.common.list.OnPhoneNumberPickerActionListener) DialpadFragment(com.android.dialer.app.dialpad.DialpadFragment) SmartDialPrefix(com.android.dialer.smartdial.SmartDialPrefix) TextUtils(android.text.TextUtils) CallDetailsActivity(com.android.dialer.calldetails.CallDetailsActivity) P13nRefreshCompleteListener(com.android.dialer.p13n.inference.protocol.P13nRanker.P13nRefreshCompleteListener) Gravity(android.view.Gravity) P13nLogger(com.android.dialer.p13n.logging.P13nLogger) PhoneAccount(android.telecom.PhoneAccount) CallComposerActivity(com.android.dialer.callcomposer.CallComposerActivity) Configuration(android.content.res.Configuration) Calls(android.provider.CallLog.Calls) Main(com.android.dialer.main.Main) EditText(android.widget.EditText) KeyguardManager(android.app.KeyguardManager) Trace(android.os.Trace) ImageButton(android.widget.ImageButton) P13nRanker(com.android.dialer.p13n.inference.protocol.P13nRanker) CallLogNotificationsService(com.android.dialer.app.calllog.CallLogNotificationsService) PackageManager(android.content.pm.PackageManager) OnDragDropListener(com.android.dialer.app.list.OnDragDropListener) OnDragListener(android.view.View.OnDragListener) VisibleForTesting(android.support.annotation.VisibleForTesting) CallLogAdapter(com.android.dialer.app.calllog.CallLogAdapter) ListsFragment(com.android.dialer.app.list.ListsFragment) Locale(java.util.Locale) TransactionSafeActivity(com.android.dialer.util.TransactionSafeActivity) PermissionsUtil(com.android.dialer.util.PermissionsUtil) View(android.view.View) Animation(android.view.animation.Animation) CursorReranker(com.android.contacts.common.list.PhoneNumberPickerFragment.CursorReranker) SmartDialNameMatcher(com.android.dialer.smartdial.SmartDialNameMatcher) SearchEditTextLayout(com.android.dialer.app.widget.SearchEditTextLayout) CallLogActivity(com.android.dialer.app.calllog.CallLogActivity) DialerImpression(com.android.dialer.logging.DialerImpression) TouchPointManager(com.android.dialer.util.TouchPointManager) ClearFrequentsDialog(com.android.contacts.common.dialog.ClearFrequentsDialog) DragDropController(com.android.dialer.app.list.DragDropController) AnimationListenerAdapter(com.android.dialer.animation.AnimationListenerAdapter) PerformanceReport(com.android.dialer.performancereport.PerformanceReport) OnScrollListener(android.widget.AbsListView.OnScrollListener) List(java.util.List) TextView(android.widget.TextView) ActivityNotFoundException(android.content.ActivityNotFoundException) UiAction(com.android.dialer.logging.UiAction) TelecomUtil(com.android.dialer.telecom.TelecomUtil) Context(android.content.Context) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) LogUtil(com.android.dialer.common.LogUtil) KeyEvent(android.view.KeyEvent) ViewPager(android.support.v4.view.ViewPager) DialerDatabaseHelper(com.android.dialer.database.DialerDatabaseHelper) Intent(android.content.Intent) MainComponent(com.android.dialer.main.MainComponent) MenuItem(android.view.MenuItem) AnimationUtils(android.view.animation.AnimationUtils) MotionEvent(android.view.MotionEvent) RecognizerIntent(android.speech.RecognizerIntent) Logger(com.android.dialer.logging.Logger) ActionBar(android.support.v7.app.ActionBar) Cursor(android.database.Cursor) SimulatorComponent(com.android.dialer.simulator.SimulatorComponent) PostCall(com.android.dialer.postcall.PostCall) UsedByReflection(com.android.dialer.proguard.UsedByReflection) FloatingActionButtonController(com.android.contacts.common.widget.FloatingActionButtonController) ResolveInfo(android.content.pm.ResolveInfo) TimeUnit(java.util.concurrent.TimeUnit) DialerUtils(com.android.dialer.util.DialerUtils) Resources(android.content.res.Resources) P13nRanking(com.android.dialer.p13n.inference.P13nRanking) FragmentTransaction(android.app.FragmentTransaction) SmartDialSearchFragment(com.android.dialer.app.list.SmartDialSearchFragment) NewSearchFragment(com.android.dialer.searchfragment.list.NewSearchFragment) RegularSearchFragment(com.android.dialer.app.list.RegularSearchFragment) NewSearchFragment(com.android.dialer.searchfragment.list.NewSearchFragment) SearchFragment(com.android.dialer.app.list.SearchFragment) SmartDialSearchFragment(com.android.dialer.app.list.SmartDialSearchFragment) RegularSearchFragment(com.android.dialer.app.list.RegularSearchFragment) OldSpeedDialFragment(com.android.dialer.app.list.OldSpeedDialFragment) NewSearchFragment(com.android.dialer.searchfragment.list.NewSearchFragment) CallLogFragment(com.android.dialer.app.calllog.CallLogFragment) SearchFragment(com.android.dialer.app.list.SearchFragment) SmartDialSearchFragment(com.android.dialer.app.list.SmartDialSearchFragment) Fragment(android.app.Fragment) DialpadFragment(com.android.dialer.app.dialpad.DialpadFragment) ListsFragment(com.android.dialer.app.list.ListsFragment)

Example 2 with SearchFragment

use of com.android.dialer.app.list.SearchFragment in project android_packages_apps_Dialer by LineageOS.

the class DialtactsActivity method updateSearchFragmentPosition.

private void updateSearchFragmentPosition() {
    SearchFragment fragment = null;
    if (mSmartDialSearchFragment != null) {
        fragment = mSmartDialSearchFragment;
    } else if (mRegularSearchFragment != null) {
        fragment = mRegularSearchFragment;
    }
    LogUtil.d("DialtactsActivity.updateSearchFragmentPosition", "fragment: %s, isVisible: %b", fragment, fragment != null && fragment.isVisible());
    if (fragment != null) {
        // We need to force animation here even when fragment is not visible since it might not be
        // visible immediately after screen orientation change and dialpad height would not be
        // available immediately which is required to update position. By forcing an animation,
        // position will be updated after a delay by when the dialpad height would be available.
        fragment.updatePosition(true);
    }
}
Also used : RegularSearchFragment(com.android.dialer.app.list.RegularSearchFragment) NewSearchFragment(com.android.dialer.searchfragment.list.NewSearchFragment) SearchFragment(com.android.dialer.app.list.SearchFragment) SmartDialSearchFragment(com.android.dialer.app.list.SmartDialSearchFragment)

Example 3 with SearchFragment

use of com.android.dialer.app.list.SearchFragment 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());
            }
        });
    }
}
Also used : PhoneNumberListAdapter(com.android.contacts.common.list.PhoneNumberListAdapter) DialpadFragment(com.android.dialer.app.dialpad.DialpadFragment) ListsFragment(com.android.dialer.app.list.ListsFragment) SmartDialSearchFragment(com.android.dialer.app.list.SmartDialSearchFragment) NewSearchFragment(com.android.dialer.searchfragment.list.NewSearchFragment) RegularSearchFragment(com.android.dialer.app.list.RegularSearchFragment) NewSearchFragment(com.android.dialer.searchfragment.list.NewSearchFragment) SearchFragment(com.android.dialer.app.list.SearchFragment) SmartDialSearchFragment(com.android.dialer.app.list.SmartDialSearchFragment) Cursor(android.database.Cursor) MainThread(android.support.annotation.MainThread) OnLoadFinishedListener(com.android.contacts.common.list.PhoneNumberPickerFragment.OnLoadFinishedListener) FragmentTransaction(android.app.FragmentTransaction) CursorReranker(com.android.contacts.common.list.PhoneNumberPickerFragment.CursorReranker)

Aggregations

FragmentTransaction (android.app.FragmentTransaction)2 Cursor (android.database.Cursor)2 MainThread (android.support.annotation.MainThread)2 RegularSearchFragment (com.android.dialer.app.list.RegularSearchFragment)2 SearchFragment (com.android.dialer.app.list.SearchFragment)2 SmartDialSearchFragment (com.android.dialer.app.list.SmartDialSearchFragment)2 NewSearchFragment (com.android.dialer.searchfragment.list.NewSearchFragment)2 Fragment (android.app.Fragment)1 KeyguardManager (android.app.KeyguardManager)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Context (android.content.Context)1 Intent (android.content.Intent)1 PackageManager (android.content.pm.PackageManager)1 ResolveInfo (android.content.pm.ResolveInfo)1 Configuration (android.content.res.Configuration)1 Resources (android.content.res.Resources)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 SystemClock (android.os.SystemClock)1 Trace (android.os.Trace)1