Search in sources :

Example 1 with SearchFragment

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

the class DialtactsActivity method onAttachFragment.

@Override
public void onAttachFragment(Fragment 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);
    }
}
Also used : DialpadFragment(com.android.dialer.dialpad.DialpadFragment) FragmentTransaction(android.app.FragmentTransaction) ListsFragment(com.android.dialer.list.ListsFragment) SmartDialSearchFragment(com.android.dialer.list.SmartDialSearchFragment) RegularSearchFragment(com.android.dialer.list.RegularSearchFragment) SmartDialSearchFragment(com.android.dialer.list.SmartDialSearchFragment) SearchFragment(com.android.dialer.list.SearchFragment)

Example 2 with SearchFragment

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

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) {
        Log.d(TAG, "Entering search UI - 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;
    if (smartDialSearch) {
        tag = TAG_SMARTDIAL_SEARCH_FRAGMENT;
    } else {
        tag = TAG_REGULAR_SEARCH_FRAGMENT;
    }
    mInDialpadSearch = smartDialSearch;
    mInRegularSearch = !smartDialSearch;
    mFloatingActionButtonController.scaleOut();
    SearchFragment fragment = (SearchFragment) getFragmentManager().findFragmentByTag(tag);
    if (animate) {
        transaction.setCustomAnimations(android.R.animator.fade_in, 0);
    } else {
        transaction.setTransition(FragmentTransaction.TRANSIT_NONE);
    }
    if (fragment == null) {
        if (smartDialSearch) {
            fragment = new SmartDialSearchFragment();
        } else {
            fragment = ObjectFactory.newRegularSearchFragment();
            fragment.setOnTouchListener(new View.OnTouchListener() {

                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    // Show the FAB when the user touches the lists fragment and the soft
                    // keyboard is hidden.
                    hideDialpadFragment(true, false);
                    showFabInSearchUi();
                    return false;
                }
            });
        }
        transaction.add(R.id.dialtacts_frame, fragment, tag);
    } else {
        transaction.show(fragment);
    }
    // DialtactsActivity will provide the options menu
    fragment.setHasOptionsMenu(false);
    fragment.setShowEmptyListForNullQuery(true);
    if (!smartDialSearch) {
        fragment.setQueryString(query, false);
    }
    transaction.commit();
    if (animate) {
        mListsFragment.getView().animate().alpha(0).withLayer();
    }
    mListsFragment.setUserVisibleHint(false);
    if (smartDialSearch) {
        Logger.logScreenView(ScreenEvent.SMART_DIAL_SEARCH, this);
    } else {
        Logger.logScreenView(ScreenEvent.REGULAR_SEARCH, this);
    }
}
Also used : FragmentTransaction(android.app.FragmentTransaction) SmartDialSearchFragment(com.android.dialer.list.SmartDialSearchFragment) RegularSearchFragment(com.android.dialer.list.RegularSearchFragment) SmartDialSearchFragment(com.android.dialer.list.SmartDialSearchFragment) SearchFragment(com.android.dialer.list.SearchFragment) View(android.view.View) TextView(android.widget.TextView) PhoneFavoriteSquareTileView(com.android.dialer.list.PhoneFavoriteSquareTileView) MotionEvent(android.view.MotionEvent)

Aggregations

FragmentTransaction (android.app.FragmentTransaction)2 RegularSearchFragment (com.android.dialer.list.RegularSearchFragment)2 SearchFragment (com.android.dialer.list.SearchFragment)2 SmartDialSearchFragment (com.android.dialer.list.SmartDialSearchFragment)2 MotionEvent (android.view.MotionEvent)1 View (android.view.View)1 TextView (android.widget.TextView)1 DialpadFragment (com.android.dialer.dialpad.DialpadFragment)1 ListsFragment (com.android.dialer.list.ListsFragment)1 PhoneFavoriteSquareTileView (com.android.dialer.list.PhoneFavoriteSquareTileView)1