Search in sources :

Example 1 with ListsFragment

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

the class DialtactsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    Trace.beginSection(TAG + " onCreate");
    super.onCreate(savedInstanceState);
    mFirstLaunch = true;
    isLastTabEnabled = ConfigProviderBindings.get(this).getBoolean("last_tab_enabled", false);
    final Resources resources = getResources();
    mActionBarHeight = resources.getDimensionPixelSize(R.dimen.action_bar_height_large);
    Trace.beginSection(TAG + " setContentView");
    setContentView(R.layout.dialtacts_activity);
    Trace.endSection();
    getWindow().setBackgroundDrawable(null);
    Trace.beginSection(TAG + " setup Views");
    final ActionBar actionBar = getActionBarSafely();
    actionBar.setCustomView(R.layout.search_edittext);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setBackgroundDrawable(null);
    SearchEditTextLayout searchEditTextLayout = (SearchEditTextLayout) actionBar.getCustomView().findViewById(R.id.search_view_container);
    searchEditTextLayout.setPreImeKeyListener(mSearchEditTextLayoutListener);
    mActionBarController = new ActionBarController(this, searchEditTextLayout);
    mSearchView = (EditText) searchEditTextLayout.findViewById(R.id.search_view);
    mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener);
    mVoiceSearchButton = searchEditTextLayout.findViewById(R.id.voice_search_button);
    searchEditTextLayout.findViewById(R.id.search_box_collapsed).setOnClickListener(mSearchViewOnClickListener);
    searchEditTextLayout.setCallback(new SearchEditTextLayout.Callback() {

        @Override
        public void onBackButtonClicked() {
            onBackPressed();
        }

        @Override
        public void onSearchViewClicked() {
            // Hide FAB, as the keyboard is shown.
            mFloatingActionButtonController.scaleOut();
        }
    });
    mIsLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    mPreviouslySelectedTabIndex = DialtactsPagerAdapter.TAB_INDEX_SPEED_DIAL;
    FloatingActionButton floatingActionButton = (FloatingActionButton) findViewById(R.id.floating_action_button);
    floatingActionButton.setOnClickListener(this);
    mFloatingActionButtonController = new FloatingActionButtonController(this, floatingActionButton);
    ImageButton optionsMenuButton = (ImageButton) searchEditTextLayout.findViewById(R.id.dialtacts_options_menu_button);
    optionsMenuButton.setOnClickListener(this);
    mOverflowMenu = buildOptionsMenu(optionsMenuButton);
    optionsMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener());
    // fragment manager is responsible for recreating it.
    if (savedInstanceState == null) {
        getFragmentManager().beginTransaction().add(R.id.dialtacts_frame, new ListsFragment(), TAG_FAVORITES_FRAGMENT).commit();
    } else {
        mSearchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY);
        mInRegularSearch = savedInstanceState.getBoolean(KEY_IN_REGULAR_SEARCH_UI);
        mInDialpadSearch = savedInstanceState.getBoolean(KEY_IN_DIALPAD_SEARCH_UI);
        mFirstLaunch = savedInstanceState.getBoolean(KEY_FIRST_LAUNCH);
        mWasConfigurationChange = savedInstanceState.getBoolean(KEY_WAS_CONFIGURATION_CHANGE);
        mShowDialpadOnResume = savedInstanceState.getBoolean(KEY_IS_DIALPAD_SHOWN);
        mActionBarController.restoreInstanceState(savedInstanceState);
    }
    final boolean isLayoutRtl = ViewUtil.isRtl();
    if (mIsLandscape) {
        mSlideIn = AnimationUtils.loadAnimation(this, isLayoutRtl ? R.anim.dialpad_slide_in_left : R.anim.dialpad_slide_in_right);
        mSlideOut = AnimationUtils.loadAnimation(this, isLayoutRtl ? R.anim.dialpad_slide_out_left : R.anim.dialpad_slide_out_right);
    } else {
        mSlideIn = AnimationUtils.loadAnimation(this, R.anim.dialpad_slide_in_bottom);
        mSlideOut = AnimationUtils.loadAnimation(this, R.anim.dialpad_slide_out_bottom);
    }
    mSlideIn.setInterpolator(AnimUtils.EASE_IN);
    mSlideOut.setInterpolator(AnimUtils.EASE_OUT);
    mSlideIn.setAnimationListener(mSlideInListener);
    mSlideOut.setAnimationListener(mSlideOutListener);
    mParentLayout = (CoordinatorLayout) findViewById(R.id.dialtacts_mainlayout);
    mParentLayout.setOnDragListener(new LayoutOnDragListener());
    ViewUtil.doOnGlobalLayout(floatingActionButton, view -> {
        int screenWidth = mParentLayout.getWidth();
        mFloatingActionButtonController.setScreenWidth(screenWidth);
        mFloatingActionButtonController.align(getFabAlignment(), false);
    });
    Trace.endSection();
    Trace.beginSection(TAG + " initialize smart dialing");
    mDialerDatabaseHelper = Database.get(this).getDatabaseHelper(this);
    SmartDialPrefix.initializeNanpSettings(this);
    Trace.endSection();
    mP13nLogger = P13nLogging.get(getApplicationContext());
    mP13nRanker = P13nRanking.get(getApplicationContext());
    Trace.endSection();
}
Also used : ListsFragment(com.android.dialer.app.list.ListsFragment) ActionBarController(com.android.dialer.app.widget.ActionBarController) FloatingActionButtonController(com.android.contacts.common.widget.FloatingActionButtonController) ImageButton(android.widget.ImageButton) FloatingActionButton(android.support.design.widget.FloatingActionButton) Resources(android.content.res.Resources) SearchEditTextLayout(com.android.dialer.app.widget.SearchEditTextLayout) ActionBar(android.support.v7.app.ActionBar)

Example 2 with ListsFragment

use of com.android.dialer.app.list.ListsFragment 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

ListsFragment (com.android.dialer.app.list.ListsFragment)2 FragmentTransaction (android.app.FragmentTransaction)1 Resources (android.content.res.Resources)1 Cursor (android.database.Cursor)1 MainThread (android.support.annotation.MainThread)1 FloatingActionButton (android.support.design.widget.FloatingActionButton)1 ActionBar (android.support.v7.app.ActionBar)1 ImageButton (android.widget.ImageButton)1 PhoneNumberListAdapter (com.android.contacts.common.list.PhoneNumberListAdapter)1 CursorReranker (com.android.contacts.common.list.PhoneNumberPickerFragment.CursorReranker)1 OnLoadFinishedListener (com.android.contacts.common.list.PhoneNumberPickerFragment.OnLoadFinishedListener)1 FloatingActionButtonController (com.android.contacts.common.widget.FloatingActionButtonController)1 DialpadFragment (com.android.dialer.app.dialpad.DialpadFragment)1 RegularSearchFragment (com.android.dialer.app.list.RegularSearchFragment)1 SearchFragment (com.android.dialer.app.list.SearchFragment)1 SmartDialSearchFragment (com.android.dialer.app.list.SmartDialSearchFragment)1 ActionBarController (com.android.dialer.app.widget.ActionBarController)1 SearchEditTextLayout (com.android.dialer.app.widget.SearchEditTextLayout)1 NewSearchFragment (com.android.dialer.searchfragment.list.NewSearchFragment)1