From 58d0b2a7cdd4b988f527f03a7cb4ba2a4b7cd145 Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Wed, 21 Mar 2018 16:57:10 -0700 Subject: Delete old search, old contacts, p13n logger, filtered numbers add number search. These components are safe to delete because: - New Contacts has been in prod for several releases. - New Search has been in in prod for 2 releases. - p13n logger was based on old search and is no longer being implemented in Dialer. - Filtered Number Settings contact search since we no longer support M. Bug: 37208802,73902692 Test: tap PiperOrigin-RevId: 189992017 Change-Id: I2720a252ababd164b5d0fb1011753a3c96a704d1 --- java/com/android/dialer/app/DialtactsActivity.java | 189 +-------- .../app/filterednumber/BlockedNumbersFragment.java | 10 +- .../BlockedNumbersSettingsActivity.java | 47 +-- .../app/legacybindings/DialerLegacyBindings.java | 3 - .../legacybindings/DialerLegacyBindingsStub.java | 6 - .../dialer/app/list/AllContactsFragment.java | 204 ---------- .../dialer/app/list/BlockedListSearchAdapter.java | 84 ---- .../dialer/app/list/BlockedListSearchFragment.java | 248 ------------ .../app/list/DialerPhoneNumberListAdapter.java | 236 ------------ .../dialer/app/list/DialtactsPagerAdapter.java | 19 +- .../dialer/app/list/RegularSearchFragment.java | 199 ---------- .../dialer/app/list/RegularSearchListAdapter.java | 126 ------ .../android/dialer/app/list/SearchFragment.java | 425 --------------------- .../app/list/SmartDialNumberListAdapter.java | 118 ------ .../dialer/app/list/SmartDialSearchFragment.java | 168 -------- .../app/res/layout/all_contacts_fragment.xml | 56 --- .../app/res/layout/blocked_number_header.xml | 40 -- .../android/dialer/p13n/inference/P13nRanking.java | 90 ----- .../dialer/p13n/inference/protocol/P13nRanker.java | 81 ---- .../p13n/inference/protocol/P13nRankerFactory.java | 26 -- .../android/dialer/p13n/logging/P13nLogger.java | 35 -- .../dialer/p13n/logging/P13nLoggerFactory.java | 29 -- .../android/dialer/p13n/logging/P13nLogging.java | 60 --- .../dialer/smartdial/SmartDialCursorLoader.java | 60 ++- 24 files changed, 73 insertions(+), 2486 deletions(-) delete mode 100644 java/com/android/dialer/app/list/AllContactsFragment.java delete mode 100644 java/com/android/dialer/app/list/BlockedListSearchAdapter.java delete mode 100644 java/com/android/dialer/app/list/BlockedListSearchFragment.java delete mode 100644 java/com/android/dialer/app/list/DialerPhoneNumberListAdapter.java delete mode 100644 java/com/android/dialer/app/list/RegularSearchFragment.java delete mode 100644 java/com/android/dialer/app/list/RegularSearchListAdapter.java delete mode 100644 java/com/android/dialer/app/list/SearchFragment.java delete mode 100644 java/com/android/dialer/app/list/SmartDialNumberListAdapter.java delete mode 100644 java/com/android/dialer/app/list/SmartDialSearchFragment.java delete mode 100644 java/com/android/dialer/app/res/layout/all_contacts_fragment.xml delete mode 100644 java/com/android/dialer/p13n/inference/P13nRanking.java delete mode 100644 java/com/android/dialer/p13n/inference/protocol/P13nRanker.java delete mode 100644 java/com/android/dialer/p13n/inference/protocol/P13nRankerFactory.java delete mode 100644 java/com/android/dialer/p13n/logging/P13nLogger.java delete mode 100644 java/com/android/dialer/p13n/logging/P13nLoggerFactory.java delete mode 100644 java/com/android/dialer/p13n/logging/P13nLogging.java (limited to 'java/com/android/dialer') diff --git a/java/com/android/dialer/app/DialtactsActivity.java b/java/com/android/dialer/app/DialtactsActivity.java index 1a8e5cc9c..a9a11e008 100644 --- a/java/com/android/dialer/app/DialtactsActivity.java +++ b/java/com/android/dialer/app/DialtactsActivity.java @@ -26,7 +26,6 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Configuration; import android.content.res.Resources; -import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.os.SystemClock; @@ -34,7 +33,6 @@ import android.os.Trace; import android.provider.CallLog.Calls; import android.provider.ContactsContract.QuickContact; import android.speech.RecognizerIntent; -import android.support.annotation.MainThread; import android.support.annotation.NonNull; import android.support.annotation.VisibleForTesting; import android.support.design.widget.CoordinatorLayout; @@ -66,9 +64,6 @@ import android.widget.TextView; import android.widget.Toast; import com.android.contacts.common.dialog.ClearFrequentsDialog; import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; -import com.android.contacts.common.list.PhoneNumberListAdapter; -import com.android.contacts.common.list.PhoneNumberPickerFragment.CursorReranker; -import com.android.contacts.common.list.PhoneNumberPickerFragment.OnLoadFinishedListener; import com.android.dialer.animation.AnimUtils; import com.android.dialer.animation.AnimationListenerAdapter; import com.android.dialer.app.calllog.CallLogActivity; @@ -84,9 +79,6 @@ import com.android.dialer.app.list.OldSpeedDialFragment; import com.android.dialer.app.list.OnDragDropListener; import com.android.dialer.app.list.OnListFragmentScrolledListener; import com.android.dialer.app.list.PhoneFavoriteSquareTileView; -import com.android.dialer.app.list.RegularSearchFragment; -import com.android.dialer.app.list.SearchFragment; -import com.android.dialer.app.list.SmartDialSearchFragment; import com.android.dialer.app.settings.DialerSettingsActivity; import com.android.dialer.app.widget.ActionBarController; import com.android.dialer.app.widget.SearchEditTextLayout; @@ -120,11 +112,6 @@ import com.android.dialer.logging.ScreenEvent; import com.android.dialer.logging.UiAction; import com.android.dialer.metrics.Metrics; import com.android.dialer.metrics.MetricsComponent; -import com.android.dialer.p13n.inference.P13nRanking; -import com.android.dialer.p13n.inference.protocol.P13nRanker; -import com.android.dialer.p13n.inference.protocol.P13nRanker.P13nRefreshCompleteListener; -import com.android.dialer.p13n.logging.P13nLogger; -import com.android.dialer.p13n.logging.P13nLogging; import com.android.dialer.performancereport.PerformanceReport; import com.android.dialer.postcall.PostCall; import com.android.dialer.precall.PreCall; @@ -161,7 +148,6 @@ public class DialtactsActivity extends TransactionSafeActivity ContactsFragment.OnContactsListScrolledListener, DialpadFragment.HostInterface, OldSpeedDialFragment.HostInterface, - SearchFragment.HostInterface, OnDragDropListener, OnPhoneNumberPickerActionListener, PopupMenu.OnMenuItemClickListener, @@ -192,8 +178,6 @@ public class DialtactsActivity extends TransactionSafeActivity private static final String KEY_IS_DIALPAD_SHOWN = "is_dialpad_shown"; private static final String KEY_FAB_VISIBLE = "fab_visible"; private static final String TAG_NEW_SEARCH_FRAGMENT = "new_search"; - private static final String TAG_REGULAR_SEARCH_FRAGMENT = "search"; - private static final String TAG_SMARTDIAL_SEARCH_FRAGMENT = "smartdial"; private static final String TAG_FAVORITES_FRAGMENT = "favorites"; /** Just for backward compatibility. Should behave as same as {@link Intent#ACTION_DIAL}. */ private static final String ACTION_TOUCH_DIALER = "com.android.phone.action.TOUCH_DIALER"; @@ -212,11 +196,6 @@ public class DialtactsActivity extends TransactionSafeActivity /** Root layout of DialtactsActivity */ private CoordinatorLayout parentLayout; - /** Fragment for searching phone numbers using the alphanumeric keyboard. */ - private RegularSearchFragment regularSearchFragment; - - /** Fragment for searching phone numbers using the dialpad. */ - private SmartDialSearchFragment smartDialSearchFragment; /** new Fragment for search phone numbers using the keyboard and the dialpad. */ private NewSearchFragment newSearchFragment; @@ -267,8 +246,6 @@ public class DialtactsActivity extends TransactionSafeActivity private boolean wasConfigurationChange; private long timeTabSelected; - private P13nLogger p13nLogger; - private P13nRanker p13nRanker; public boolean isMultiSelectModeEnabled; private boolean isLastTabEnabled; @@ -312,7 +289,6 @@ public class DialtactsActivity extends TransactionSafeActivity LogUtil.v("DialtactsActivity.onTextChanged", "previous query: " + searchQuery); searchQuery = newText; - // TODO(calderwoodra): show p13n when newText is empty. // Show search fragment only when the query string is changed to non-empty text. if (!TextUtils.isEmpty(newText)) { // Call enterSearchUi only if we are switching search modes, or showing a search @@ -324,11 +300,7 @@ public class DialtactsActivity extends TransactionSafeActivity } } - if (smartDialSearchFragment != null && smartDialSearchFragment.isVisible()) { - smartDialSearchFragment.setQueryString(searchQuery); - } else if (regularSearchFragment != null && regularSearchFragment.isVisible()) { - regularSearchFragment.setQueryString(searchQuery); - } else if (newSearchFragment != null && newSearchFragment.isVisible()) { + if (newSearchFragment != null && newSearchFragment.isVisible()) { newSearchFragment.setQuery(searchQuery, getCallInitiationType()); } } @@ -496,14 +468,9 @@ public class DialtactsActivity extends TransactionSafeActivity SmartDialPrefix.initializeNanpSettings(this); Trace.endSection(); - p13nLogger = P13nLogging.get(getApplicationContext()); - p13nRanker = P13nRanking.get(getApplicationContext()); Trace.endSection(); - // Update the new search fragment to the correct position and the ActionBar's visibility. - if (ConfigProviderBindings.get(this).getBoolean("enable_new_search_fragment", false)) { - updateSearchFragmentPosition(); - } + updateSearchFragmentPosition(); } @NonNull @@ -624,14 +591,6 @@ public class DialtactsActivity extends TransactionSafeActivity setSearchBoxHint(); timeTabSelected = SystemClock.elapsedRealtime(); - p13nLogger.reset(); - p13nRanker.refresh( - new P13nRefreshCompleteListener() { - @Override - public void onP13nRefreshComplete() { - // TODO(strongarm): make zero-query search results visible - } - }); Trace.endSection(); } @@ -696,15 +655,6 @@ public class DialtactsActivity extends TransactionSafeActivity LogUtil.i("DialtactsActivity.onAttachFragment", "fragment: %s", fragment); if (fragment instanceof DialpadFragment) { dialpadFragment = (DialpadFragment) fragment; - } else if (fragment instanceof SmartDialSearchFragment) { - smartDialSearchFragment = (SmartDialSearchFragment) fragment; - smartDialSearchFragment.setOnPhoneNumberPickerActionListener(this); - if (!TextUtils.isEmpty(dialpadQuery)) { - smartDialSearchFragment.setAddToContactNumber(dialpadQuery); - } - } else if (fragment instanceof SearchFragment) { - regularSearchFragment = (RegularSearchFragment) fragment; - regularSearchFragment.setOnPhoneNumberPickerActionListener(this); } else if (fragment instanceof ListsFragment) { listsFragment = (ListsFragment) fragment; listsFragment.addOnPageChangeListener(this); @@ -712,28 +662,6 @@ public class DialtactsActivity extends TransactionSafeActivity newSearchFragment = (NewSearchFragment) fragment; updateSearchFragmentPosition(); } - 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 p13nRanker.rankCursor(data, queryString == null ? 0 : queryString.length()); - } - }); - searchFragment.addOnLoadFinishedListener( - new OnLoadFinishedListener() { - @Override - public void onLoadFinished() { - p13nLogger.onSearchQuery( - searchFragment.getQueryString(), - (PhoneNumberListAdapter) searchFragment.getAdapter()); - } - }); - } } protected void handleMenuSettings() { @@ -1001,24 +929,7 @@ public class DialtactsActivity extends TransactionSafeActivity } private void updateSearchFragmentPosition() { - SearchFragment fragment = null; - if (smartDialSearchFragment != null) { - fragment = smartDialSearchFragment; - } else if (regularSearchFragment != null) { - fragment = regularSearchFragment; - } - 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 /* animate */); - } else if (newSearchFragment != null) { + if (newSearchFragment != null) { int animationDuration = getResources().getInteger(R.integer.dialpad_slide_in_duration); int actionbarHeight = getResources().getDimensionPixelSize(R.dimen.action_bar_height_large); int shadowHeight = getResources().getDrawable(R.drawable.search_shadow).getIntrinsicHeight(); @@ -1208,29 +1119,9 @@ public class DialtactsActivity extends TransactionSafeActivity return; } - final FragmentTransaction transaction = getFragmentManager().beginTransaction(); - if (inDialpadSearch && smartDialSearchFragment != null) { - transaction.remove(smartDialSearchFragment); - } else if (inRegularSearch && regularSearchFragment != null) { - transaction.remove(regularSearchFragment); - } - - final String tag; - inDialpadSearch = false; - inRegularSearch = false; - inNewSearch = false; - boolean useNewSearch = - ConfigProviderBindings.get(this).getBoolean("enable_new_search_fragment", false); - if (useNewSearch) { - tag = TAG_NEW_SEARCH_FRAGMENT; - inNewSearch = true; - } else if (smartDialSearch) { - tag = TAG_SMARTDIAL_SEARCH_FRAGMENT; - inDialpadSearch = true; - } else { - tag = TAG_REGULAR_SEARCH_FRAGMENT; - inRegularSearch = true; - } + FragmentTransaction transaction = getFragmentManager().beginTransaction(); + String tag = TAG_NEW_SEARCH_FRAGMENT; + inNewSearch = true; floatingActionButtonController.scaleOut(); @@ -1240,59 +1131,23 @@ public class DialtactsActivity extends TransactionSafeActivity transaction.setTransition(FragmentTransaction.TRANSIT_NONE); } - Fragment fragment = getFragmentManager().findFragmentByTag(tag); + NewSearchFragment fragment = (NewSearchFragment) getFragmentManager().findFragmentByTag(tag); if (fragment == null) { - if (useNewSearch) { - fragment = NewSearchFragment.newInstance(!isDialpadShown()); - } 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; - }); - } + fragment = NewSearchFragment.newInstance(!isDialpadShown()); transaction.add(R.id.dialtacts_frame, fragment, tag); } else { - // TODO(calderwoodra): 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(p13nRanker.shouldShowEmptyListForNullQuery()); - } else { - // TODO(calderwoodra): add p13n ranker to new search. - } - - if (!smartDialSearch && !useNewSearch) { - ((SearchFragment) fragment).setQueryString(query); - } else if (useNewSearch) { - ((NewSearchFragment) fragment).setQuery(query, getCallInitiationType()); - } + fragment.setQuery(query, getCallInitiationType()); transaction.commit(); if (animate) { Assert.isNotNull(listsFragment.getView()).animate().alpha(0).withLayer(); } listsFragment.setUserVisibleHint(false); - - if (smartDialSearch) { - Logger.get(this).logScreenView(ScreenEvent.Type.SMART_DIAL_SEARCH, this); - } else { - Logger.get(this).logScreenView(ScreenEvent.Type.REGULAR_SEARCH, this); - } } /** Hides the search fragment */ @@ -1336,12 +1191,6 @@ public class DialtactsActivity extends TransactionSafeActivity } final FragmentTransaction transaction = getFragmentManager().beginTransaction(); - if (smartDialSearchFragment != null) { - transaction.remove(smartDialSearchFragment); - } - if (regularSearchFragment != null) { - transaction.remove(regularSearchFragment); - } if (newSearchFragment != null) { transaction.remove(newSearchFragment); } @@ -1405,9 +1254,6 @@ public class DialtactsActivity extends TransactionSafeActivity @Override public void onDialpadQueryChanged(String query) { dialpadQuery = query; - if (smartDialSearchFragment != null) { - smartDialSearchFragment.setAddToContactNumber(query); - } if (newSearchFragment != null) { newSearchFragment.setRawNumber(query); } @@ -1443,13 +1289,6 @@ public class DialtactsActivity extends TransactionSafeActivity @Override public boolean onDialpadSpacerTouchWithEmptyQuery() { - if (inDialpadSearch - && smartDialSearchFragment != null - && !smartDialSearchFragment.isShowingPermissionRequest()) { - PerformanceReport.recordClick(UiAction.Type.CLOSE_DIALPAD); - hideDialpadFragment(true /* animate */, true /* clearDialpad */); - return true; - } return false; } @@ -1625,24 +1464,14 @@ public class DialtactsActivity extends TransactionSafeActivity @Override public void onPageScrollStateChanged(int state) {} - @Override public boolean isActionBarShowing() { return actionBarController.isActionBarShowing(); } - @Override public boolean isDialpadShown() { return isDialpadShown; } - @Override - public int getDialpadHeight() { - if (dialpadFragment != null) { - return dialpadFragment.getDialpadHeight(); - } - return 0; - } - @Override public void setActionBarHideOffset(int offset) { getActionBarSafely().setHideOffset(offset); diff --git a/java/com/android/dialer/app/filterednumber/BlockedNumbersFragment.java b/java/com/android/dialer/app/filterednumber/BlockedNumbersFragment.java index cae35d5b6..270ec6d03 100644 --- a/java/com/android/dialer/app/filterednumber/BlockedNumbersFragment.java +++ b/java/com/android/dialer/app/filterednumber/BlockedNumbersFragment.java @@ -29,7 +29,6 @@ import android.support.v7.app.AppCompatActivity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ImageView; import android.widget.TextView; import com.android.dialer.app.R; import com.android.dialer.blocking.BlockedNumbersMigrator; @@ -73,13 +72,11 @@ public class BlockedNumbersFragment extends ListFragment getListView().addHeaderView(inflater.inflate(R.layout.blocked_number_header, null)); getListView().addFooterView(inflater.inflate(R.layout.blocked_number_footer, null)); //replace the icon for add number with LetterTileDrawable(), so it will have identical style - ImageView addNumberIcon = (ImageView) getActivity().findViewById(R.id.add_number_icon); LetterTileDrawable drawable = new LetterTileDrawable(getResources()); drawable.setLetter(ADD_BLOCKED_NUMBER_ICON_LETTER); drawable.setColor( ActivityCompat.getColor(getActivity(), R.color.add_blocked_number_icon_color)); drawable.setIsCircular(true); - addNumberIcon.setImageDrawable(drawable); if (adapter == null) { adapter = @@ -97,7 +94,6 @@ public class BlockedNumbersFragment extends ListFragment blockedNumberListDivider = getActivity().findViewById(R.id.blocked_number_list_divider); getListView().findViewById(R.id.import_button).setOnClickListener(this); getListView().findViewById(R.id.view_numbers_button).setOnClickListener(this); - getListView().findViewById(R.id.add_number_linear_layout).setOnClickListener(this); footerText = (TextView) getActivity().findViewById(R.id.blocked_number_footer_textview); voicemailEnabledChecker = new VisualVoicemailEnabledChecker(getContext(), this); @@ -137,8 +133,6 @@ public class BlockedNumbersFragment extends ListFragment if (FilteredNumberCompat.canUseNewFiltering()) { migratePromoView.setVisibility(View.VISIBLE); blockedNumbersText.setVisibility(View.GONE); - getListView().findViewById(R.id.add_number_linear_layout).setVisibility(View.GONE); - getListView().findViewById(R.id.add_number_linear_layout).setOnClickListener(null); blockedNumberListDivider.setVisibility(View.GONE); importSettings.setVisibility(View.GONE); getListView().findViewById(R.id.import_button).setOnClickListener(null); @@ -218,9 +212,7 @@ public class BlockedNumbersFragment extends ListFragment } int resId = view.getId(); - if (resId == R.id.add_number_linear_layout) { - activity.showSearchUi(); - } else if (resId == R.id.view_numbers_button) { + if (resId == R.id.view_numbers_button) { activity.showNumbersToImportPreviewUi(); } else if (resId == R.id.import_button) { FilteredNumbersUtil.importSendToVoicemailContacts( diff --git a/java/com/android/dialer/app/filterednumber/BlockedNumbersSettingsActivity.java b/java/com/android/dialer/app/filterednumber/BlockedNumbersSettingsActivity.java index 858d28355..5475b4ea3 100644 --- a/java/com/android/dialer/app/filterednumber/BlockedNumbersSettingsActivity.java +++ b/java/com/android/dialer/app/filterednumber/BlockedNumbersSettingsActivity.java @@ -19,17 +19,13 @@ import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; import com.android.dialer.app.R; -import com.android.dialer.app.list.BlockedListSearchFragment; -import com.android.dialer.app.list.SearchFragment; import com.android.dialer.logging.Logger; import com.android.dialer.logging.ScreenEvent; /** TODO(calderwoodra): documentation */ -public class BlockedNumbersSettingsActivity extends AppCompatActivity - implements SearchFragment.HostInterface { +public class BlockedNumbersSettingsActivity extends AppCompatActivity { private static final String TAG_BLOCKED_MANAGEMENT_FRAGMENT = "blocked_management"; - private static final String TAG_BLOCKED_SEARCH_FRAGMENT = "blocked_search"; private static final String TAG_VIEW_NUMBERS_TO_IMPORT_FRAGMENT = "view_numbers_to_import"; @Override @@ -60,27 +56,6 @@ public class BlockedNumbersSettingsActivity extends AppCompatActivity Logger.get(this).logScreenView(ScreenEvent.Type.BLOCKED_NUMBER_MANAGEMENT, this); } - /** Shows fragment with search UI for browsing/finding numbers to block. */ - public void showSearchUi() { - BlockedListSearchFragment fragment = - (BlockedListSearchFragment) - getFragmentManager().findFragmentByTag(TAG_BLOCKED_SEARCH_FRAGMENT); - if (fragment == null) { - fragment = new BlockedListSearchFragment(); - fragment.setHasOptionsMenu(false); - fragment.setShowEmptyListForNullQuery(true); - fragment.setDirectorySearchEnabled(false); - } - - getFragmentManager() - .beginTransaction() - .replace(R.id.blocked_numbers_activity_container, fragment, TAG_BLOCKED_SEARCH_FRAGMENT) - .addToBackStack(null) - .commit(); - - Logger.get(this).logScreenView(ScreenEvent.Type.BLOCKED_NUMBER_ADD_NUMBER, this); - } - /** * Shows fragment with UI to preview the numbers of contacts currently marked as send-to-voicemail * in Contacts. These numbers can be imported into Dialer's blocked number list. @@ -119,24 +94,4 @@ public class BlockedNumbersSettingsActivity extends AppCompatActivity super.onBackPressed(); } } - - @Override - public boolean isActionBarShowing() { - return false; - } - - @Override - public boolean isDialpadShown() { - return false; - } - - @Override - public int getDialpadHeight() { - return 0; - } - - @Override - public int getActionBarHeight() { - return 0; - } } diff --git a/java/com/android/dialer/app/legacybindings/DialerLegacyBindings.java b/java/com/android/dialer/app/legacybindings/DialerLegacyBindings.java index a483af9e9..6eaa2b6b9 100644 --- a/java/com/android/dialer/app/legacybindings/DialerLegacyBindings.java +++ b/java/com/android/dialer/app/legacybindings/DialerLegacyBindings.java @@ -22,7 +22,6 @@ import android.view.ViewGroup; import com.android.dialer.app.calllog.CallLogAdapter; import com.android.dialer.app.calllog.calllogcache.CallLogCache; import com.android.dialer.app.contactinfo.ContactInfoCache; -import com.android.dialer.app.list.RegularSearchFragment; import com.android.dialer.app.voicemail.VoicemailPlaybackPresenter; import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler; @@ -47,6 +46,4 @@ public interface DialerLegacyBindings { VoicemailPlaybackPresenter voicemailPlaybackPresenter, @NonNull FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler, int activityType); - - RegularSearchFragment newRegularSearchFragment(); } diff --git a/java/com/android/dialer/app/legacybindings/DialerLegacyBindingsStub.java b/java/com/android/dialer/app/legacybindings/DialerLegacyBindingsStub.java index 488fbad68..e95c4709d 100644 --- a/java/com/android/dialer/app/legacybindings/DialerLegacyBindingsStub.java +++ b/java/com/android/dialer/app/legacybindings/DialerLegacyBindingsStub.java @@ -22,7 +22,6 @@ import android.view.ViewGroup; import com.android.dialer.app.calllog.CallLogAdapter; import com.android.dialer.app.calllog.calllogcache.CallLogCache; import com.android.dialer.app.contactinfo.ContactInfoCache; -import com.android.dialer.app.list.RegularSearchFragment; import com.android.dialer.app.voicemail.VoicemailPlaybackPresenter; import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler; @@ -53,9 +52,4 @@ public class DialerLegacyBindingsStub implements DialerLegacyBindings { filteredNumberAsyncQueryHandler, activityType); } - - @Override - public RegularSearchFragment newRegularSearchFragment() { - return new RegularSearchFragment(); - } } diff --git a/java/com/android/dialer/app/list/AllContactsFragment.java b/java/com/android/dialer/app/list/AllContactsFragment.java deleted file mode 100644 index 5076fd9cf..000000000 --- a/java/com/android/dialer/app/list/AllContactsFragment.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dialer.app.list; - -import static android.Manifest.permission.READ_CONTACTS; - -import android.app.Activity; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.Loader; -import android.content.pm.PackageManager; -import android.database.Cursor; -import android.net.Uri; -import android.provider.ContactsContract.CommonDataKinds.Phone; -import android.provider.ContactsContract.QuickContact; -import android.support.v13.app.FragmentCompat; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import com.android.contacts.common.list.ContactEntryListAdapter; -import com.android.contacts.common.list.ContactEntryListFragment; -import com.android.contacts.common.list.ContactListFilter; -import com.android.contacts.common.list.DefaultContactListAdapter; -import com.android.dialer.app.R; -import com.android.dialer.common.LogUtil; -import com.android.dialer.compat.CompatUtils; -import com.android.dialer.logging.InteractionEvent; -import com.android.dialer.logging.Logger; -import com.android.dialer.util.DialerUtils; -import com.android.dialer.util.IntentUtil; -import com.android.dialer.util.PermissionsUtil; -import com.android.dialer.widget.EmptyContentView; -import com.android.dialer.widget.EmptyContentView.OnEmptyViewActionButtonClickedListener; -import java.util.Arrays; - -/** Fragments to show all contacts with phone numbers. */ -public class AllContactsFragment extends ContactEntryListFragment - implements OnEmptyViewActionButtonClickedListener, - FragmentCompat.OnRequestPermissionsResultCallback { - - private static final int READ_CONTACTS_PERMISSION_REQUEST_CODE = 1; - - private EmptyContentView emptyListView; - - /** - * Listen to broadcast events about permissions in order to be notified if the READ_CONTACTS - * permission is granted via the UI in another fragment. - */ - private BroadcastReceiver readContactsPermissionGrantedReceiver = - new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - reloadData(); - } - }; - - public AllContactsFragment() { - setQuickContactEnabled(false); - setAdjustSelectionBoundsEnabled(true); - setPhotoLoaderEnabled(true); - setSectionHeaderDisplayEnabled(true); - setDarkTheme(false); - setVisibleScrollbarEnabled(true); - } - - @Override - public void onViewCreated(View view, android.os.Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - - emptyListView = (EmptyContentView) view.findViewById(R.id.empty_list_view); - emptyListView.setImage(R.drawable.empty_contacts); - emptyListView.setDescription(R.string.all_contacts_empty); - emptyListView.setActionClickedListener(this); - getListView().setEmptyView(emptyListView); - emptyListView.setVisibility(View.GONE); - } - - @Override - public void onStart() { - super.onStart(); - PermissionsUtil.registerPermissionReceiver( - getActivity(), readContactsPermissionGrantedReceiver, READ_CONTACTS); - } - - @Override - public void onStop() { - PermissionsUtil.unregisterPermissionReceiver( - getActivity(), readContactsPermissionGrantedReceiver); - super.onStop(); - } - - @Override - protected void startLoading() { - if (PermissionsUtil.hasPermission(getActivity(), READ_CONTACTS)) { - super.startLoading(); - emptyListView.setDescription(R.string.all_contacts_empty); - emptyListView.setActionLabel(R.string.all_contacts_empty_add_contact_action); - } else { - emptyListView.setDescription(R.string.permission_no_contacts); - emptyListView.setActionLabel(R.string.permission_single_turn_on); - emptyListView.setVisibility(View.VISIBLE); - } - } - - @Override - public void onLoadFinished(Loader loader, Cursor data) { - super.onLoadFinished(loader, data); - - if (data == null || data.getCount() == 0) { - emptyListView.setVisibility(View.VISIBLE); - } - } - - @Override - protected ContactEntryListAdapter createListAdapter() { - final DefaultContactListAdapter adapter = - new DefaultContactListAdapter(getActivity()) { - @Override - protected void bindView(View itemView, int partition, Cursor cursor, int position) { - super.bindView(itemView, partition, cursor, position); - itemView.setTag(this.getContactUri(partition, cursor)); - } - }; - adapter.setDisplayPhotos(true); - adapter.setFilter( - ContactListFilter.createFilterWithType(ContactListFilter.FILTER_TYPE_DEFAULT)); - adapter.setSectionHeaderDisplayEnabled(isSectionHeaderDisplayEnabled()); - return adapter; - } - - @Override - protected View inflateView(LayoutInflater inflater, ViewGroup container) { - return inflater.inflate(R.layout.all_contacts_fragment, null); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - final Uri uri = (Uri) view.getTag(); - if (uri != null) { - Logger.get(getContext()) - .logInteraction(InteractionEvent.Type.OPEN_QUICK_CONTACT_FROM_ALL_CONTACTS_GENERAL); - if (CompatUtils.hasPrioritizedMimeType()) { - QuickContact.showQuickContact(getContext(), view, uri, null, Phone.CONTENT_ITEM_TYPE); - } else { - QuickContact.showQuickContact(getActivity(), view, uri, QuickContact.MODE_LARGE, null); - } - } - } - - @Override - protected void onItemClick(int position, long id) { - // Do nothing. Implemented to satisfy ContactEntryListFragment. - } - - @Override - public void onEmptyViewActionButtonClicked() { - final Activity activity = getActivity(); - if (activity == null) { - return; - } - - String[] deniedPermissions = - PermissionsUtil.getPermissionsCurrentlyDenied( - getContext(), PermissionsUtil.allContactsGroupPermissionsUsedInDialer); - if (deniedPermissions.length > 0) { - LogUtil.i( - "AllContactsFragment.onEmptyViewActionButtonClicked", - "Requesting permissions: " + Arrays.toString(deniedPermissions)); - FragmentCompat.requestPermissions( - this, deniedPermissions, READ_CONTACTS_PERMISSION_REQUEST_CODE); - } else { - // Add new contact - DialerUtils.startActivityWithErrorToast( - activity, IntentUtil.getNewContactIntent(), R.string.add_contact_not_available); - } - } - - @Override - public void onRequestPermissionsResult( - int requestCode, String[] permissions, int[] grantResults) { - if (requestCode == READ_CONTACTS_PERMISSION_REQUEST_CODE) { - if (grantResults.length >= 1 && PackageManager.PERMISSION_GRANTED == grantResults[0]) { - // Force a refresh of the data since we were missing the permission before this. - reloadData(); - } - } - } -} diff --git a/java/com/android/dialer/app/list/BlockedListSearchAdapter.java b/java/com/android/dialer/app/list/BlockedListSearchAdapter.java deleted file mode 100644 index 575d6e63f..000000000 --- a/java/com/android/dialer/app/list/BlockedListSearchAdapter.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.dialer.app.list; - -import android.content.Context; -import android.content.res.Resources; -import android.database.Cursor; -import android.view.View; -import com.android.contacts.common.list.ContactListItemView; -import com.android.dialer.app.R; -import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler; -import com.android.dialer.location.GeoUtil; - -/** List adapter to display search results for adding a blocked number. */ -public class BlockedListSearchAdapter extends RegularSearchListAdapter { - - private Resources resources; - private FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler; - - public BlockedListSearchAdapter(Context context) { - super(context); - resources = context.getResources(); - disableAllShortcuts(); - setShortcutEnabled(SHORTCUT_BLOCK_NUMBER, true); - - filteredNumberAsyncQueryHandler = new FilteredNumberAsyncQueryHandler(context); - } - - @Override - protected boolean isChanged(boolean showNumberShortcuts) { - return setShortcutEnabled(SHORTCUT_BLOCK_NUMBER, showNumberShortcuts || isQuerySipAddress); - } - - public void setViewBlocked(ContactListItemView view, Integer id) { - view.setTag(R.id.block_id, id); - final int textColor = resources.getColor(R.color.blocked_number_block_color); - view.getDataView().setTextColor(textColor); - view.getLabelView().setTextColor(textColor); - //TODO: Add icon - } - - public void setViewUnblocked(ContactListItemView view) { - view.setTag(R.id.block_id, null); - final int textColor = resources.getColor(R.color.dialer_secondary_text_color); - view.getDataView().setTextColor(textColor); - view.getLabelView().setTextColor(textColor); - //TODO: Remove icon - } - - @Override - protected void bindView(View itemView, int partition, Cursor cursor, int position) { - super.bindView(itemView, partition, cursor, position); - - final ContactListItemView view = (ContactListItemView) itemView; - // Reset view state to unblocked. - setViewUnblocked(view); - - final String number = getPhoneNumber(position); - final String countryIso = GeoUtil.getCurrentCountryIso(mContext); - final FilteredNumberAsyncQueryHandler.OnCheckBlockedListener onCheckListener = - new FilteredNumberAsyncQueryHandler.OnCheckBlockedListener() { - @Override - public void onCheckComplete(Integer id) { - if (id != null && id != FilteredNumberAsyncQueryHandler.INVALID_ID) { - setViewBlocked(view, id); - } - } - }; - filteredNumberAsyncQueryHandler.isBlockedNumber(onCheckListener, number, countryIso); - } -} diff --git a/java/com/android/dialer/app/list/BlockedListSearchFragment.java b/java/com/android/dialer/app/list/BlockedListSearchFragment.java deleted file mode 100644 index ce812af6e..000000000 --- a/java/com/android/dialer/app/list/BlockedListSearchFragment.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.dialer.app.list; - -import android.app.Activity; -import android.os.Bundle; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.text.Editable; -import android.text.TextUtils; -import android.text.TextWatcher; -import android.util.TypedValue; -import android.view.View; -import android.widget.AdapterView; -import android.widget.EditText; -import android.widget.Toast; -import com.android.contacts.common.list.ContactEntryListAdapter; -import com.android.contacts.common.util.ContactDisplayUtils; -import com.android.dialer.app.R; -import com.android.dialer.app.widget.SearchEditTextLayout; -import com.android.dialer.blocking.BlockNumberDialogFragment; -import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler; -import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler.OnCheckBlockedListener; -import com.android.dialer.common.LogUtil; -import com.android.dialer.location.GeoUtil; -import com.android.dialer.logging.InteractionEvent; -import com.android.dialer.logging.Logger; -import com.android.dialer.phonenumberutil.PhoneNumberHelper; - -/** TODO(calderwoodra): documentation */ -public class BlockedListSearchFragment extends RegularSearchFragment - implements BlockNumberDialogFragment.Callback { - - private final TextWatcher phoneSearchQueryTextListener = - new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) {} - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - setQueryString(s.toString()); - } - - @Override - public void afterTextChanged(Editable s) {} - }; - private final SearchEditTextLayout.Callback searchLayoutCallback = - new SearchEditTextLayout.Callback() { - @Override - public void onBackButtonClicked() { - getActivity().onBackPressed(); - } - - @Override - public void onSearchViewClicked() {} - }; - private FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler; - private EditText searchView; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setShowEmptyListForNullQuery(true); - /* - * Pass in the empty string here so ContactEntryListFragment#setQueryString interprets it as - * an empty search query, rather than as an uninitalized value. In the latter case, the - * adapter returned by #createListAdapter is used, which populates the view with contacts. - * Passing in the empty string forces ContactEntryListFragment to interpret it as an empty - * query, which results in showing an empty view - */ - setQueryString(getQueryString() == null ? "" : getQueryString()); - filteredNumberAsyncQueryHandler = new FilteredNumberAsyncQueryHandler(getContext()); - } - - @Override - public void onResume() { - super.onResume(); - - ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); - actionBar.setCustomView(R.layout.search_edittext); - actionBar.setDisplayShowCustomEnabled(true); - actionBar.setDisplayHomeAsUpEnabled(false); - actionBar.setDisplayShowHomeEnabled(false); - - final SearchEditTextLayout searchEditTextLayout = - (SearchEditTextLayout) actionBar.getCustomView().findViewById(R.id.search_view_container); - searchEditTextLayout.expand(false, true); - searchEditTextLayout.setCallback(searchLayoutCallback); - searchEditTextLayout.setBackgroundDrawable(null); - - searchView = (EditText) searchEditTextLayout.findViewById(R.id.search_view); - searchView.addTextChangedListener(phoneSearchQueryTextListener); - searchView.setHint(R.string.block_number_search_hint); - - searchEditTextLayout - .findViewById(R.id.search_box_expanded) - .setBackgroundColor(getContext().getResources().getColor(android.R.color.white)); - - if (!TextUtils.isEmpty(getQueryString())) { - searchView.setText(getQueryString()); - } - - // TODO: Don't set custom text size; use default search text size. - searchView.setTextSize( - TypedValue.COMPLEX_UNIT_PX, - getResources().getDimension(R.dimen.blocked_number_search_text_size)); - } - - @Override - protected ContactEntryListAdapter createListAdapter() { - BlockedListSearchAdapter adapter = new BlockedListSearchAdapter(getActivity()); - adapter.setDisplayPhotos(true); - // Don't show SIP addresses. - adapter.setUseCallableUri(false); - // Keep in sync with the queryString set in #onCreate - adapter.setQueryString(getQueryString() == null ? "" : getQueryString()); - return adapter; - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - super.onItemClick(parent, view, position, id); - final int adapterPosition = position - getListView().getHeaderViewsCount(); - final BlockedListSearchAdapter adapter = (BlockedListSearchAdapter) getAdapter(); - final int shortcutType = adapter.getShortcutTypeFromPosition(adapterPosition); - final Integer blockId = (Integer) view.getTag(R.id.block_id); - final String number; - switch (shortcutType) { - case DialerPhoneNumberListAdapter.SHORTCUT_INVALID: - // Handles click on a search result, either contact or nearby places result. - number = adapter.getPhoneNumber(adapterPosition); - blockContactNumber(number, blockId); - break; - case DialerPhoneNumberListAdapter.SHORTCUT_BLOCK_NUMBER: - // Handles click on 'Block number' shortcut to add the user query as a number. - number = adapter.getQueryString(); - blockNumber(number); - break; - default: - LogUtil.w( - "BlockedListSearchFragment.onItemClick", - "ignoring unsupported shortcut type: " + shortcutType); - break; - } - } - - @Override - protected void onItemClick(int position, long id) { - // Prevent SearchFragment.onItemClicked from being called. - } - - private void blockNumber(final String number) { - final String countryIso = GeoUtil.getCurrentCountryIso(getContext()); - final OnCheckBlockedListener onCheckListener = - new OnCheckBlockedListener() { - @Override - public void onCheckComplete(Integer id) { - if (id == null) { - BlockNumberDialogFragment.show( - id, - number, - countryIso, - PhoneNumberHelper.formatNumber(getContext(), number, countryIso), - R.id.blocked_numbers_activity_container, - getFragmentManager(), - BlockedListSearchFragment.this); - } else if (id == FilteredNumberAsyncQueryHandler.INVALID_ID) { - Toast.makeText( - getContext(), - ContactDisplayUtils.getTtsSpannedPhoneNumber( - getResources(), R.string.invalidNumber, number), - Toast.LENGTH_SHORT) - .show(); - } else { - Toast.makeText( - getContext(), - ContactDisplayUtils.getTtsSpannedPhoneNumber( - getResources(), R.string.alreadyBlocked, number), - Toast.LENGTH_SHORT) - .show(); - } - } - }; - filteredNumberAsyncQueryHandler.isBlockedNumber(onCheckListener, number, countryIso); - } - - @Override - public void onFilterNumberSuccess() { - Logger.get(getContext()).logInteraction(InteractionEvent.Type.BLOCK_NUMBER_MANAGEMENT_SCREEN); - goBack(); - } - - @Override - public void onUnfilterNumberSuccess() { - LogUtil.e( - "BlockedListSearchFragment.onUnfilterNumberSuccess", - "unblocked a number from the BlockedListSearchFragment"); - goBack(); - } - - private void goBack() { - Activity activity = getActivity(); - if (activity == null) { - return; - } - activity.onBackPressed(); - } - - @Override - public void onChangeFilteredNumberUndo() { - getAdapter().notifyDataSetChanged(); - } - - private void blockContactNumber(final String number, final Integer blockId) { - if (blockId != null) { - Toast.makeText( - getContext(), - ContactDisplayUtils.getTtsSpannedPhoneNumber( - getResources(), R.string.alreadyBlocked, number), - Toast.LENGTH_SHORT) - .show(); - return; - } - - BlockNumberDialogFragment.show( - blockId, - number, - GeoUtil.getCurrentCountryIso(getContext()), - number, - R.id.blocked_numbers_activity_container, - getFragmentManager(), - this); - } -} diff --git a/java/com/android/dialer/app/list/DialerPhoneNumberListAdapter.java b/java/com/android/dialer/app/list/DialerPhoneNumberListAdapter.java deleted file mode 100644 index d5609b856..000000000 --- a/java/com/android/dialer/app/list/DialerPhoneNumberListAdapter.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dialer.app.list; - -import android.content.Context; -import android.content.res.Resources; -import android.database.Cursor; -import android.graphics.drawable.Drawable; -import android.support.v4.content.ContextCompat; -import android.telephony.PhoneNumberUtils; -import android.text.BidiFormatter; -import android.text.TextDirectionHeuristics; -import android.view.View; -import android.view.ViewGroup; -import com.android.contacts.common.list.ContactListItemView; -import com.android.contacts.common.list.PhoneNumberListAdapter; -import com.android.contacts.common.util.ContactDisplayUtils; -import com.android.dialer.app.R; -import com.android.dialer.location.GeoUtil; -import com.android.dialer.phonenumberutil.PhoneNumberHelper; - -/** - * {@link PhoneNumberListAdapter} with the following added shortcuts, that are displayed as list - * items: 1) Directly calling the phone number query 2) Adding the phone number query to a contact - * - *

These shortcuts can be enabled or disabled to toggle whether or not they show up in the list. - */ -public class DialerPhoneNumberListAdapter extends PhoneNumberListAdapter { - - public static final int SHORTCUT_INVALID = -1; - public static final int SHORTCUT_DIRECT_CALL = 0; - public static final int SHORTCUT_CREATE_NEW_CONTACT = 1; - public static final int SHORTCUT_ADD_TO_EXISTING_CONTACT = 2; - public static final int SHORTCUT_SEND_SMS_MESSAGE = 3; - public static final int SHORTCUT_MAKE_VIDEO_CALL = 4; - public static final int SHORTCUT_BLOCK_NUMBER = 5; - public static final int SHORTCUT_COUNT = 6; - - private final boolean[] shortcutEnabled = new boolean[SHORTCUT_COUNT]; - private final BidiFormatter bidiFormatter = BidiFormatter.getInstance(); - private final String countryIso; - - private String formattedQueryString; - - public DialerPhoneNumberListAdapter(Context context) { - super(context); - - countryIso = GeoUtil.getCurrentCountryIso(context); - } - - @Override - public int getCount() { - return super.getCount() + getShortcutCount(); - } - - /** @return The number of enabled shortcuts. Ranges from 0 to a maximum of SHORTCUT_COUNT */ - public int getShortcutCount() { - int count = 0; - for (int i = 0; i < shortcutEnabled.length; i++) { - if (shortcutEnabled[i]) { - count++; - } - } - return count; - } - - public void disableAllShortcuts() { - for (int i = 0; i < shortcutEnabled.length; i++) { - shortcutEnabled[i] = false; - } - } - - @Override - public int getItemViewType(int position) { - final int shortcut = getShortcutTypeFromPosition(position); - if (shortcut >= 0) { - // shortcutPos should always range from 1 to SHORTCUT_COUNT - return super.getViewTypeCount() + shortcut; - } else { - return super.getItemViewType(position); - } - } - - @Override - public int getViewTypeCount() { - // Number of item view types in the super implementation + 2 for the 2 new shortcuts - return super.getViewTypeCount() + SHORTCUT_COUNT; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - final int shortcutType = getShortcutTypeFromPosition(position); - if (shortcutType >= 0) { - if (convertView != null) { - assignShortcutToView((ContactListItemView) convertView, shortcutType); - return convertView; - } else { - final ContactListItemView v = - new ContactListItemView(getContext(), null, mIsImsVideoEnabled); - assignShortcutToView(v, shortcutType); - return v; - } - } else { - return super.getView(position, convertView, parent); - } - } - - @Override - protected ContactListItemView newView( - Context context, int partition, Cursor cursor, int position, ViewGroup parent) { - final ContactListItemView view = super.newView(context, partition, cursor, position, parent); - - view.setSupportVideoCallIcon(mIsImsVideoEnabled); - return view; - } - - /** - * @param position The position of the item - * @return The enabled shortcut type matching the given position if the item is a shortcut, -1 - * otherwise - */ - public int getShortcutTypeFromPosition(int position) { - int shortcutCount = position - super.getCount(); - if (shortcutCount >= 0) { - // Iterate through the array of shortcuts, looking only for shortcuts where - // mShortcutEnabled[i] is true - for (int i = 0; shortcutCount >= 0 && i < shortcutEnabled.length; i++) { - if (shortcutEnabled[i]) { - shortcutCount--; - if (shortcutCount < 0) { - return i; - } - } - } - throw new IllegalArgumentException( - "Invalid position - greater than cursor count " + " but not a shortcut."); - } - return SHORTCUT_INVALID; - } - - @Override - public boolean isEmpty() { - return getShortcutCount() == 0 && super.isEmpty(); - } - - @Override - public boolean isEnabled(int position) { - final int shortcutType = getShortcutTypeFromPosition(position); - if (shortcutType >= 0) { - return true; - } else { - return super.isEnabled(position); - } - } - - private void assignShortcutToView(ContactListItemView v, int shortcutType) { - final CharSequence text; - final Drawable drawable; - final Resources resources = getContext().getResources(); - final String number = getFormattedQueryString(); - switch (shortcutType) { - case SHORTCUT_DIRECT_CALL: - text = - ContactDisplayUtils.getTtsSpannedPhoneNumber( - resources, - R.string.search_shortcut_call_number, - bidiFormatter.unicodeWrap(number, TextDirectionHeuristics.LTR)); - drawable = ContextCompat.getDrawable(getContext(), R.drawable.quantum_ic_call_vd_theme_24); - break; - case SHORTCUT_CREATE_NEW_CONTACT: - text = resources.getString(R.string.search_shortcut_create_new_contact); - drawable = - ContextCompat.getDrawable(getContext(), R.drawable.quantum_ic_person_add_vd_theme_24); - drawable.setAutoMirrored(true); - break; - case SHORTCUT_ADD_TO_EXISTING_CONTACT: - text = resources.getString(R.string.search_shortcut_add_to_contact); - drawable = - ContextCompat.getDrawable(getContext(), R.drawable.quantum_ic_person_add_vd_theme_24); - break; - case SHORTCUT_SEND_SMS_MESSAGE: - text = resources.getString(R.string.search_shortcut_send_sms_message); - drawable = - ContextCompat.getDrawable(getContext(), R.drawable.quantum_ic_message_vd_theme_24); - break; - case SHORTCUT_MAKE_VIDEO_CALL: - text = resources.getString(R.string.search_shortcut_make_video_call); - drawable = - ContextCompat.getDrawable(getContext(), R.drawable.quantum_ic_videocam_vd_theme_24); - break; - case SHORTCUT_BLOCK_NUMBER: - text = resources.getString(R.string.search_shortcut_block_number); - drawable = - ContextCompat.getDrawable(getContext(), R.drawable.ic_not_interested_googblue_24dp); - break; - default: - throw new IllegalArgumentException("Invalid shortcut type"); - } - v.setDrawable(drawable); - v.setDisplayName(text); - v.setAdjustSelectionBoundsEnabled(false); - } - - /** @return True if the shortcut state (disabled vs enabled) was changed by this operation */ - public boolean setShortcutEnabled(int shortcutType, boolean visible) { - final boolean changed = shortcutEnabled[shortcutType] != visible; - shortcutEnabled[shortcutType] = visible; - return changed; - } - - public String getFormattedQueryString() { - return formattedQueryString; - } - - @Override - public void setQueryString(String queryString) { - formattedQueryString = - PhoneNumberHelper.formatNumber( - getContext(), PhoneNumberUtils.normalizeNumber(queryString), countryIso); - super.setQueryString(queryString); - } -} diff --git a/java/com/android/dialer/app/list/DialtactsPagerAdapter.java b/java/com/android/dialer/app/list/DialtactsPagerAdapter.java index d27293244..364ae6fad 100644 --- a/java/com/android/dialer/app/list/DialtactsPagerAdapter.java +++ b/java/com/android/dialer/app/list/DialtactsPagerAdapter.java @@ -56,11 +56,9 @@ public class DialtactsPagerAdapter extends FragmentPagerAdapter { private final List fragments = new ArrayList<>(); private final String[] tabTitles; private final boolean useNewSpeedDialTab; - private final boolean useNewContactsTab; private OldSpeedDialFragment oldSpeedDialFragment; private SpeedDialFragment speedDialFragment; private CallLogFragment callLogFragment; - private AllContactsFragment oldContactsFragment; private ContactsFragment contactsFragment; private CallLogFragment voicemailFragment; @@ -71,8 +69,6 @@ public class DialtactsPagerAdapter extends FragmentPagerAdapter { super(fm); useNewSpeedDialTab = ConfigProviderBindings.get(context).getBoolean("enable_new_favorites_tab", false); - useNewContactsTab = - ConfigProviderBindings.get(context).getBoolean("enable_new_contacts_tab", true); this.tabTitles = tabTitles; hasActiveVoicemailProvider = hasVoicemailProvider; fragments.addAll(Collections.nCopies(TAB_COUNT_WITH_VOICEMAIL, null)); @@ -105,17 +101,10 @@ public class DialtactsPagerAdapter extends FragmentPagerAdapter { } return callLogFragment; case TAB_INDEX_ALL_CONTACTS: - if (useNewContactsTab) { - if (contactsFragment == null) { - contactsFragment = ContactsFragment.newInstance(Header.ADD_CONTACT); - } - return contactsFragment; - } else { - if (oldContactsFragment == null) { - oldContactsFragment = new AllContactsFragment(); - } - return oldContactsFragment; + if (contactsFragment == null) { + contactsFragment = ContactsFragment.newInstance(Header.ADD_CONTACT); } + return contactsFragment; case TAB_INDEX_VOICEMAIL: if (voicemailFragment == null) { voicemailFragment = new VisualVoicemailCallLogFragment(); @@ -145,8 +134,6 @@ public class DialtactsPagerAdapter extends FragmentPagerAdapter { callLogFragment = (CallLogFragment) fragment; } else if (fragment instanceof ContactsFragment) { contactsFragment = (ContactsFragment) fragment; - } else if (fragment instanceof AllContactsFragment) { - oldContactsFragment = (AllContactsFragment) fragment; } else if (fragment instanceof CallLogFragment && position == TAB_INDEX_VOICEMAIL) { voicemailFragment = (CallLogFragment) fragment; LogUtil.v("ViewPagerAdapter.instantiateItem", voicemailFragment.toString()); diff --git a/java/com/android/dialer/app/list/RegularSearchFragment.java b/java/com/android/dialer/app/list/RegularSearchFragment.java deleted file mode 100644 index d1927f08a..000000000 --- a/java/com/android/dialer/app/list/RegularSearchFragment.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.dialer.app.list; - -import static android.Manifest.permission.READ_CONTACTS; - -import android.app.Activity; -import android.content.Context; -import android.content.pm.PackageManager; -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v13.app.FragmentCompat; -import android.view.LayoutInflater; -import android.view.ViewGroup; -import com.android.contacts.common.list.ContactEntryListAdapter; -import com.android.contacts.common.list.PinnedHeaderListView; -import com.android.dialer.app.R; -import com.android.dialer.callintent.CallInitiationType; -import com.android.dialer.common.LogUtil; -import com.android.dialer.common.concurrent.DialerExecutor; -import com.android.dialer.common.concurrent.DialerExecutor.Worker; -import com.android.dialer.common.concurrent.DialerExecutorComponent; -import com.android.dialer.phonenumbercache.CachedNumberLookupService; -import com.android.dialer.phonenumbercache.CachedNumberLookupService.CachedContactInfo; -import com.android.dialer.phonenumbercache.PhoneNumberCache; -import com.android.dialer.util.PermissionsUtil; -import com.android.dialer.widget.EmptyContentView; -import com.android.dialer.widget.EmptyContentView.OnEmptyViewActionButtonClickedListener; -import java.util.Arrays; - -public class RegularSearchFragment extends SearchFragment - implements OnEmptyViewActionButtonClickedListener, - FragmentCompat.OnRequestPermissionsResultCallback { - - public static final int PERMISSION_REQUEST_CODE = 1; - - private static final int SEARCH_DIRECTORY_RESULT_LIMIT = 5; - protected String permissionToRequest; - - private DialerExecutor addContactTask; - - public RegularSearchFragment() { - configureDirectorySearch(); - } - - public void configureDirectorySearch() { - setDirectorySearchEnabled(true); - setDirectoryResultLimit(SEARCH_DIRECTORY_RESULT_LIMIT); - } - - @Override - public void onCreate(Bundle savedState) { - super.onCreate(savedState); - - addContactTask = - DialerExecutorComponent.get(getContext()) - .dialerExecutorFactory() - .createUiTaskBuilder( - getFragmentManager(), - "RegularSearchFragment.addContact", - new AddContactWorker(getContext().getApplicationContext())) - .build(); - } - - @Override - protected void onCreateView(LayoutInflater inflater, ViewGroup container) { - super.onCreateView(inflater, container); - ((PinnedHeaderListView) getListView()).setScrollToSectionOnHeaderTouch(true); - } - - @Override - protected ContactEntryListAdapter createListAdapter() { - RegularSearchListAdapter adapter = new RegularSearchListAdapter(getActivity()); - adapter.setDisplayPhotos(true); - adapter.setUseCallableUri(usesCallableUri()); - adapter.setListener(this); - return adapter; - } - - @Override - protected void cacheContactInfo(int position) { - CachedNumberLookupService cachedNumberLookupService = - PhoneNumberCache.get(getContext()).getCachedNumberLookupService(); - if (cachedNumberLookupService != null) { - final RegularSearchListAdapter adapter = (RegularSearchListAdapter) getAdapter(); - CachedContactInfo cachedContactInfo = - adapter.getContactInfo(cachedNumberLookupService, position); - addContactTask.executeSerial(cachedContactInfo); - } - } - - @Override - protected void setupEmptyView() { - if (emptyView != null && getActivity() != null) { - final int imageResource; - final int actionLabelResource; - final int descriptionResource; - final OnEmptyViewActionButtonClickedListener listener; - if (!PermissionsUtil.hasPermission(getActivity(), READ_CONTACTS)) { - imageResource = R.drawable.empty_contacts; - actionLabelResource = R.string.permission_single_turn_on; - descriptionResource = R.string.permission_no_search; - listener = this; - permissionToRequest = READ_CONTACTS; - } else { - imageResource = EmptyContentView.NO_IMAGE; - actionLabelResource = EmptyContentView.NO_LABEL; - descriptionResource = EmptyContentView.NO_LABEL; - listener = null; - permissionToRequest = null; - } - - emptyView.setImage(imageResource); - emptyView.setActionLabel(actionLabelResource); - emptyView.setDescription(descriptionResource); - if (listener != null) { - emptyView.setActionClickedListener(listener); - } - } - } - - @Override - public void onEmptyViewActionButtonClicked() { - final Activity activity = getActivity(); - if (activity == null) { - return; - } - - if (READ_CONTACTS.equals(permissionToRequest)) { - String[] deniedPermissions = - PermissionsUtil.getPermissionsCurrentlyDenied( - getContext(), PermissionsUtil.allContactsGroupPermissionsUsedInDialer); - if (deniedPermissions.length > 0) { - LogUtil.i( - "RegularSearchFragment.onEmptyViewActionButtonClicked", - "Requesting permissions: " + Arrays.toString(deniedPermissions)); - FragmentCompat.requestPermissions(this, deniedPermissions, PERMISSION_REQUEST_CODE); - } - } - } - - @Override - public void onRequestPermissionsResult( - int requestCode, String[] permissions, int[] grantResults) { - if (requestCode == PERMISSION_REQUEST_CODE) { - setupEmptyView(); - if (grantResults != null - && grantResults.length == 1 - && PackageManager.PERMISSION_GRANTED == grantResults[0]) { - PermissionsUtil.notifyPermissionGranted(getActivity(), permissions[0]); - } - } - } - - @Override - protected CallInitiationType.Type getCallInitiationType(boolean isRemoteDirectory) { - return isRemoteDirectory - ? CallInitiationType.Type.REMOTE_DIRECTORY - : CallInitiationType.Type.REGULAR_SEARCH; - } - - public interface CapabilityChecker { - - boolean isNearbyPlacesSearchEnabled(); - } - - private static class AddContactWorker implements Worker { - - private final Context appContext; - - private AddContactWorker(Context appContext) { - this.appContext = appContext; - } - - @Nullable - @Override - public Void doInBackground(@Nullable CachedContactInfo contactInfo) throws Throwable { - CachedNumberLookupService cachedNumberLookupService = - PhoneNumberCache.get(appContext).getCachedNumberLookupService(); - if (cachedNumberLookupService != null) { - cachedNumberLookupService.addContact(appContext, contactInfo); - } - return null; - } - } -} diff --git a/java/com/android/dialer/app/list/RegularSearchListAdapter.java b/java/com/android/dialer/app/list/RegularSearchListAdapter.java deleted file mode 100644 index c92f48c8b..000000000 --- a/java/com/android/dialer/app/list/RegularSearchListAdapter.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.dialer.app.list; - -import android.content.Context; -import android.database.Cursor; -import android.net.Uri; -import android.text.TextUtils; -import com.android.contacts.common.ContactsUtils; -import com.android.contacts.common.list.DirectoryPartition; -import com.android.dialer.common.cp2.DirectoryCompat; -import com.android.dialer.phonenumbercache.CachedNumberLookupService; -import com.android.dialer.phonenumbercache.CachedNumberLookupService.CachedContactInfo; -import com.android.dialer.phonenumbercache.ContactInfo; -import com.android.dialer.phonenumberutil.PhoneNumberHelper; -import com.android.dialer.util.CallUtil; - -/** List adapter to display regular search results. */ -public class RegularSearchListAdapter extends DialerPhoneNumberListAdapter { - - protected boolean isQuerySipAddress; - - public RegularSearchListAdapter(Context context) { - super(context); - setShortcutEnabled(SHORTCUT_CREATE_NEW_CONTACT, false); - setShortcutEnabled(SHORTCUT_ADD_TO_EXISTING_CONTACT, false); - } - - public CachedContactInfo getContactInfo(CachedNumberLookupService lookupService, int position) { - ContactInfo info = new ContactInfo(); - CachedContactInfo cacheInfo = lookupService.buildCachedContactInfo(info); - final Cursor item = (Cursor) getItem(position); - if (item != null) { - final DirectoryPartition partition = - (DirectoryPartition) getPartition(getPartitionForPosition(position)); - final long directoryId = partition.getDirectoryId(); - final boolean isExtendedDirectory = isExtendedDirectory(directoryId); - - info.name = item.getString(PhoneQuery.DISPLAY_NAME); - info.type = item.getInt(PhoneQuery.PHONE_TYPE); - info.label = item.getString(PhoneQuery.PHONE_LABEL); - info.number = item.getString(PhoneQuery.PHONE_NUMBER); - final String photoUriStr = item.getString(PhoneQuery.PHOTO_URI); - info.photoUri = photoUriStr == null ? null : Uri.parse(photoUriStr); - /* - * An extended directory is custom directory in the app, but not a directory provided by - * framework. So it can't be USER_TYPE_WORK. - * - * When a search result is selected, RegularSearchFragment calls getContactInfo and - * cache the resulting @{link ContactInfo} into local db. Set usertype to USER_TYPE_WORK - * only if it's NOT extended directory id and is enterprise directory. - */ - info.userType = - !isExtendedDirectory && DirectoryCompat.isEnterpriseDirectoryId(directoryId) - ? ContactsUtils.USER_TYPE_WORK - : ContactsUtils.USER_TYPE_CURRENT; - - cacheInfo.setLookupKey(item.getString(PhoneQuery.LOOKUP_KEY)); - - final String sourceName = partition.getLabel(); - if (isExtendedDirectory) { - cacheInfo.setExtendedSource(sourceName, directoryId); - } else { - cacheInfo.setDirectorySource(sourceName, directoryId); - } - } - return cacheInfo; - } - - @Override - public String getFormattedQueryString() { - if (isQuerySipAddress) { - // Return unnormalized SIP address - return getQueryString(); - } - return super.getFormattedQueryString(); - } - - @Override - public void setQueryString(String queryString) { - // Don't show actions if the query string contains a letter. - final boolean showNumberShortcuts = - !TextUtils.isEmpty(getFormattedQueryString()) && hasDigitsInQueryString(); - isQuerySipAddress = PhoneNumberHelper.isUriNumber(queryString); - - if (isChanged(showNumberShortcuts)) { - notifyDataSetChanged(); - } - super.setQueryString(queryString); - } - - protected boolean isChanged(boolean showNumberShortcuts) { - boolean changed = false; - changed |= setShortcutEnabled(SHORTCUT_DIRECT_CALL, showNumberShortcuts || isQuerySipAddress); - changed |= setShortcutEnabled(SHORTCUT_SEND_SMS_MESSAGE, showNumberShortcuts); - changed |= - setShortcutEnabled( - SHORTCUT_MAKE_VIDEO_CALL, showNumberShortcuts && CallUtil.isVideoEnabled(getContext())); - return changed; - } - - /** Whether there is at least one digit in the query string. */ - private boolean hasDigitsInQueryString() { - String queryString = getQueryString(); - int length = queryString.length(); - for (int i = 0; i < length; i++) { - if (Character.isDigit(queryString.charAt(i))) { - return true; - } - } - return false; - } -} diff --git a/java/com/android/dialer/app/list/SearchFragment.java b/java/com/android/dialer/app/list/SearchFragment.java deleted file mode 100644 index afb678969..000000000 --- a/java/com/android/dialer/app/list/SearchFragment.java +++ /dev/null @@ -1,425 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.dialer.app.list; - -import android.animation.Animator; -import android.animation.AnimatorInflater; -import android.animation.AnimatorListenerAdapter; -import android.app.Activity; -import android.app.DialogFragment; -import android.content.Intent; -import android.content.res.Configuration; -import android.content.res.Resources; -import android.text.TextUtils; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.animation.Interpolator; -import android.widget.AbsListView; -import android.widget.AbsListView.OnScrollListener; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.Space; -import com.android.contacts.common.list.ContactEntryListAdapter; -import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; -import com.android.contacts.common.list.PhoneNumberPickerFragment; -import com.android.dialer.animation.AnimUtils; -import com.android.dialer.app.R; -import com.android.dialer.app.widget.DialpadSearchEmptyContentView; -import com.android.dialer.callintent.CallSpecificAppData; -import com.android.dialer.common.LogUtil; -import com.android.dialer.dialpadview.DialpadFragment.ErrorDialogFragment; -import com.android.dialer.logging.DialerImpression; -import com.android.dialer.logging.Logger; -import com.android.dialer.util.DialerUtils; -import com.android.dialer.util.IntentUtil; -import com.android.dialer.util.PermissionsUtil; -import com.android.dialer.widget.EmptyContentView; - -public class SearchFragment extends PhoneNumberPickerFragment { - - protected EmptyContentView emptyView; - private OnListFragmentScrolledListener activityScrollListener; - private View.OnTouchListener activityOnTouchListener; - /* - * Stores the untouched user-entered string that is used to populate the add to contacts - * intent. - */ - private String addToContactNumber; - private int actionBarHeight; - private int shadowHeight; - private int paddingTop; - private int showDialpadDuration; - private int hideDialpadDuration; - /** - * Used to resize the list view containing search results so that it fits the available space - * above the dialpad. Does not have a user-visible effect in regular touch usage (since the - * dialpad hides that portion of the ListView anyway), but improves usability in accessibility - * mode. - */ - private Space spacer; - - private HostInterface activity; - - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - - setQuickContactEnabled(true); - setAdjustSelectionBoundsEnabled(false); - setDarkTheme(false); - setUseCallableUri(true); - - try { - activityScrollListener = (OnListFragmentScrolledListener) activity; - } catch (ClassCastException e) { - LogUtil.v( - "SearchFragment.onAttach", - activity.toString() - + " doesn't implement OnListFragmentScrolledListener. " - + "Ignoring."); - } - } - - @Override - public void onStart() { - LogUtil.d("SearchFragment.onStart", ""); - super.onStart(); - - activity = (HostInterface) getActivity(); - - final Resources res = getResources(); - actionBarHeight = activity.getActionBarHeight(); - shadowHeight = res.getDrawable(R.drawable.search_shadow).getIntrinsicHeight(); - paddingTop = res.getDimensionPixelSize(R.dimen.search_list_padding_top); - showDialpadDuration = res.getInteger(R.integer.dialpad_slide_in_duration); - hideDialpadDuration = res.getInteger(R.integer.dialpad_slide_out_duration); - - final ListView listView = getListView(); - - if (emptyView == null) { - if (this instanceof SmartDialSearchFragment) { - emptyView = new DialpadSearchEmptyContentView(getActivity()); - } else { - emptyView = new EmptyContentView(getActivity()); - } - ((ViewGroup) getListView().getParent()).addView(emptyView); - getListView().setEmptyView(emptyView); - setupEmptyView(); - } - - listView.setBackgroundColor(res.getColor(R.color.background_dialer_results)); - listView.setClipToPadding(false); - setVisibleScrollbarEnabled(false); - - //Turn of accessibility live region as the list constantly update itself and spam messages. - listView.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_NONE); - ContentChangedFilter.addToParent(listView); - - listView.setOnScrollListener( - new OnScrollListener() { - @Override - public void onScrollStateChanged(AbsListView view, int scrollState) { - if (activityScrollListener != null) { - activityScrollListener.onListFragmentScrollStateChange(scrollState); - } - } - - @Override - public void onScroll( - AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {} - }); - if (activityOnTouchListener != null) { - listView.setOnTouchListener(activityOnTouchListener); - } - - updatePosition(false /* animate */); - } - - @Override - public Animator onCreateAnimator(int transit, boolean enter, int nextAnim) { - Animator animator = null; - if (nextAnim != 0) { - animator = AnimatorInflater.loadAnimator(getActivity(), nextAnim); - } - if (animator != null) { - final View view = getView(); - final int oldLayerType = view.getLayerType(); - animator.addListener( - new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - view.setLayerType(oldLayerType, null); - } - }); - } - return animator; - } - - public void setAddToContactNumber(String addToContactNumber) { - this.addToContactNumber = addToContactNumber; - } - - /** - * Return true if phone number is prohibited by a value - - * (R.string.config_prohibited_phone_number_regexp) in the config files. False otherwise. - */ - public boolean checkForProhibitedPhoneNumber(String number) { - // Regular expression prohibiting manual phone call. Can be empty i.e. "no rule". - String prohibitedPhoneNumberRegexp = - getResources().getString(R.string.config_prohibited_phone_number_regexp); - - // "persist.radio.otaspdial" is a temporary hack needed for one carrier's automated - // test equipment. - if (number != null - && !TextUtils.isEmpty(prohibitedPhoneNumberRegexp) - && number.matches(prohibitedPhoneNumberRegexp)) { - LogUtil.i( - "SearchFragment.checkForProhibitedPhoneNumber", - "the phone number is prohibited explicitly by a rule"); - if (getActivity() != null) { - DialogFragment dialogFragment = - ErrorDialogFragment.newInstance(R.string.dialog_phone_call_prohibited_message); - dialogFragment.show(getFragmentManager(), "phone_prohibited_dialog"); - } - - return true; - } - return false; - } - - @Override - protected ContactEntryListAdapter createListAdapter() { - DialerPhoneNumberListAdapter adapter = new DialerPhoneNumberListAdapter(getActivity()); - adapter.setDisplayPhotos(true); - adapter.setUseCallableUri(super.usesCallableUri()); - adapter.setListener(this); - return adapter; - } - - @Override - protected void onItemClick(int position, long id) { - final DialerPhoneNumberListAdapter adapter = (DialerPhoneNumberListAdapter) getAdapter(); - final int shortcutType = adapter.getShortcutTypeFromPosition(position); - final OnPhoneNumberPickerActionListener listener; - final Intent intent; - final String number; - - LogUtil.i("SearchFragment.onItemClick", "shortcutType: " + shortcutType); - - switch (shortcutType) { - case DialerPhoneNumberListAdapter.SHORTCUT_DIRECT_CALL: - number = adapter.getQueryString(); - listener = getOnPhoneNumberPickerListener(); - if (listener != null && !checkForProhibitedPhoneNumber(number)) { - CallSpecificAppData callSpecificAppData = - CallSpecificAppData.newBuilder() - .setCallInitiationType(getCallInitiationType(false /* isRemoteDirectory */)) - .setPositionOfSelectedSearchResult(position) - .setCharactersInSearchString( - getQueryString() == null ? 0 : getQueryString().length()) - .build(); - listener.onPickPhoneNumber(number, false /* isVideoCall */, callSpecificAppData); - } - break; - case DialerPhoneNumberListAdapter.SHORTCUT_CREATE_NEW_CONTACT: - if (this instanceof SmartDialSearchFragment) { - Logger.get(getContext()) - .logImpression(DialerImpression.Type.CREATE_NEW_CONTACT_FROM_DIALPAD); - } - number = - TextUtils.isEmpty(addToContactNumber) - ? adapter.getFormattedQueryString() - : addToContactNumber; - intent = IntentUtil.getNewContactIntent(number); - DialerUtils.startActivityWithErrorToast(getActivity(), intent); - break; - case DialerPhoneNumberListAdapter.SHORTCUT_ADD_TO_EXISTING_CONTACT: - if (this instanceof SmartDialSearchFragment) { - Logger.get(getContext()) - .logImpression(DialerImpression.Type.ADD_TO_A_CONTACT_FROM_DIALPAD); - } - number = - TextUtils.isEmpty(addToContactNumber) - ? adapter.getFormattedQueryString() - : addToContactNumber; - intent = IntentUtil.getAddToExistingContactIntent(number); - DialerUtils.startActivityWithErrorToast( - getActivity(), intent, R.string.add_contact_not_available); - break; - case DialerPhoneNumberListAdapter.SHORTCUT_SEND_SMS_MESSAGE: - number = - TextUtils.isEmpty(addToContactNumber) - ? adapter.getFormattedQueryString() - : addToContactNumber; - intent = IntentUtil.getSendSmsIntent(number); - DialerUtils.startActivityWithErrorToast(getActivity(), intent); - break; - case DialerPhoneNumberListAdapter.SHORTCUT_MAKE_VIDEO_CALL: - number = - TextUtils.isEmpty(addToContactNumber) ? adapter.getQueryString() : addToContactNumber; - listener = getOnPhoneNumberPickerListener(); - if (listener != null && !checkForProhibitedPhoneNumber(number)) { - CallSpecificAppData callSpecificAppData = - CallSpecificAppData.newBuilder() - .setCallInitiationType(getCallInitiationType(false /* isRemoteDirectory */)) - .setPositionOfSelectedSearchResult(position) - .setCharactersInSearchString( - getQueryString() == null ? 0 : getQueryString().length()) - .build(); - listener.onPickPhoneNumber(number, true /* isVideoCall */, callSpecificAppData); - } - break; - case DialerPhoneNumberListAdapter.SHORTCUT_INVALID: - default: - super.onItemClick(position, id); - break; - } - } - - /** - * Updates the position and padding of the search fragment, depending on whether the dialpad is - * shown. This can be optionally animated. - */ - public void updatePosition(boolean animate) { - LogUtil.d("SearchFragment.updatePosition", "animate: %b", animate); - if (activity == null) { - // Activity will be set in onStart, and this method will be called again - return; - } - - // Use negative shadow height instead of 0 to account for the 9-patch's shadow. - int startTranslationValue = - activity.isDialpadShown() ? actionBarHeight - shadowHeight : -shadowHeight; - int endTranslationValue = 0; - // Prevents ListView from being translated down after a rotation when the ActionBar is up. - if (animate || activity.isActionBarShowing()) { - endTranslationValue = activity.isDialpadShown() ? 0 : actionBarHeight - shadowHeight; - } - if (animate) { - // If the dialpad will be shown, then this animation involves sliding the list up. - final boolean slideUp = activity.isDialpadShown(); - - Interpolator interpolator = slideUp ? AnimUtils.EASE_IN : AnimUtils.EASE_OUT; - int duration = slideUp ? showDialpadDuration : hideDialpadDuration; - getView().setTranslationY(startTranslationValue); - getView() - .animate() - .translationY(endTranslationValue) - .setInterpolator(interpolator) - .setDuration(duration) - .setListener( - new AnimatorListenerAdapter() { - @Override - public void onAnimationStart(Animator animation) { - if (!slideUp) { - resizeListView(); - } - } - - @Override - public void onAnimationEnd(Animator animation) { - if (slideUp) { - resizeListView(); - } - } - }); - - } else { - getView().setTranslationY(endTranslationValue); - resizeListView(); - } - - // There is padding which should only be applied when the dialpad is not shown. - int paddingTop = activity.isDialpadShown() ? 0 : this.paddingTop; - final ListView listView = getListView(); - listView.setPaddingRelative( - listView.getPaddingStart(), - paddingTop, - listView.getPaddingEnd(), - listView.getPaddingBottom()); - } - - public void resizeListView() { - if (spacer == null) { - return; - } - int spacerHeight = activity.isDialpadShown() ? activity.getDialpadHeight() : 0; - LogUtil.d( - "SearchFragment.resizeListView", - "spacerHeight: %d -> %d, isDialpadShown: %b, dialpad height: %d", - spacer.getHeight(), - spacerHeight, - activity.isDialpadShown(), - activity.getDialpadHeight()); - if (spacerHeight != spacer.getHeight()) { - final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) spacer.getLayoutParams(); - lp.height = spacerHeight; - spacer.setLayoutParams(lp); - } - } - - @Override - protected void startLoading() { - if (getActivity() == null) { - return; - } - - if (PermissionsUtil.hasContactsReadPermissions(getActivity())) { - super.startLoading(); - } else if (TextUtils.isEmpty(getQueryString())) { - // Clear out any existing call shortcuts. - final DialerPhoneNumberListAdapter adapter = (DialerPhoneNumberListAdapter) getAdapter(); - adapter.disableAllShortcuts(); - } else { - // The contact list is not going to change (we have no results since permissions are - // denied), but the shortcuts might because of the different query, so update the - // list. - getAdapter().notifyDataSetChanged(); - } - - setupEmptyView(); - } - - public void setOnTouchListener(View.OnTouchListener onTouchListener) { - activityOnTouchListener = onTouchListener; - } - - @Override - protected View inflateView(LayoutInflater inflater, ViewGroup container) { - final LinearLayout parent = (LinearLayout) super.inflateView(inflater, container); - final int orientation = getResources().getConfiguration().orientation; - if (orientation == Configuration.ORIENTATION_PORTRAIT) { - spacer = new Space(getActivity()); - parent.addView( - spacer, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0)); - } - return parent; - } - - protected void setupEmptyView() {} - - public interface HostInterface { - - boolean isActionBarShowing(); - - boolean isDialpadShown(); - - int getDialpadHeight(); - - int getActionBarHeight(); - } -} diff --git a/java/com/android/dialer/app/list/SmartDialNumberListAdapter.java b/java/com/android/dialer/app/list/SmartDialNumberListAdapter.java deleted file mode 100644 index c84bff7fc..000000000 --- a/java/com/android/dialer/app/list/SmartDialNumberListAdapter.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.dialer.app.list; - -import android.content.Context; -import android.database.Cursor; -import android.support.annotation.NonNull; -import android.telephony.PhoneNumberUtils; -import android.text.TextUtils; -import com.android.contacts.common.list.ContactListItemView; -import com.android.dialer.common.LogUtil; -import com.android.dialer.smartdial.SmartDialCursorLoader; -import com.android.dialer.smartdial.util.SmartDialMatchPosition; -import com.android.dialer.smartdial.util.SmartDialNameMatcher; -import com.android.dialer.util.CallUtil; -import java.util.ArrayList; - -/** List adapter to display the SmartDial search results. */ -public class SmartDialNumberListAdapter extends DialerPhoneNumberListAdapter { - - private static final String TAG = SmartDialNumberListAdapter.class.getSimpleName(); - private static final boolean DEBUG = false; - - private final Context context; - @NonNull private final SmartDialNameMatcher nameMatcher; - - public SmartDialNumberListAdapter(Context context) { - super(context); - this.context = context; - nameMatcher = new SmartDialNameMatcher(""); - setShortcutEnabled(SmartDialNumberListAdapter.SHORTCUT_DIRECT_CALL, false); - - if (DEBUG) { - LogUtil.v(TAG, "Constructing List Adapter"); - } - } - - /** Sets query for the SmartDialCursorLoader. */ - public void configureLoader(SmartDialCursorLoader loader) { - if (DEBUG) { - LogUtil.v(TAG, "Configure Loader with query" + getQueryString()); - } - - if (getQueryString() == null) { - loader.configureQuery(""); - nameMatcher.setQuery(""); - } else { - loader.configureQuery(getQueryString()); - nameMatcher.setQuery(PhoneNumberUtils.normalizeNumber(getQueryString())); - } - } - - /** - * Sets highlight options for a List item in the SmartDial search results. - * - * @param view ContactListItemView where the result will be displayed. - * @param cursor Object containing information of the associated List item. - */ - @Override - protected void setHighlight(ContactListItemView view, Cursor cursor) { - view.clearHighlightSequences(); - - if (nameMatcher.matches(context, cursor.getString(PhoneQuery.DISPLAY_NAME))) { - final ArrayList nameMatches = nameMatcher.getMatchPositions(); - for (SmartDialMatchPosition match : nameMatches) { - view.addNameHighlightSequence(match.start, match.end); - if (DEBUG) { - LogUtil.v( - TAG, - cursor.getString(PhoneQuery.DISPLAY_NAME) - + " " - + nameMatcher.getQuery() - + " " - + String.valueOf(match.start)); - } - } - } - - final SmartDialMatchPosition numberMatch = - nameMatcher.matchesNumber(context, cursor.getString(PhoneQuery.PHONE_NUMBER)); - if (numberMatch != null) { - view.addNumberHighlightSequence(numberMatch.start, numberMatch.end); - } - } - - @Override - public void setQueryString(String queryString) { - final boolean showNumberShortcuts = !TextUtils.isEmpty(getFormattedQueryString()); - boolean changed = false; - changed |= setShortcutEnabled(SHORTCUT_CREATE_NEW_CONTACT, showNumberShortcuts); - changed |= setShortcutEnabled(SHORTCUT_ADD_TO_EXISTING_CONTACT, showNumberShortcuts); - changed |= setShortcutEnabled(SHORTCUT_SEND_SMS_MESSAGE, showNumberShortcuts); - changed |= - setShortcutEnabled( - SHORTCUT_MAKE_VIDEO_CALL, showNumberShortcuts && CallUtil.isVideoEnabled(getContext())); - if (changed) { - notifyDataSetChanged(); - } - super.setQueryString(queryString); - } - - public void setShowEmptyListForNullQuery(boolean show) { - nameMatcher.setShouldMatchEmptyQuery(!show); - } -} diff --git a/java/com/android/dialer/app/list/SmartDialSearchFragment.java b/java/com/android/dialer/app/list/SmartDialSearchFragment.java deleted file mode 100644 index fdf0b5a56..000000000 --- a/java/com/android/dialer/app/list/SmartDialSearchFragment.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.dialer.app.list; - -import static android.Manifest.permission.CALL_PHONE; - -import android.app.Activity; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.Loader; -import android.database.Cursor; -import android.os.Bundle; -import android.support.v13.app.FragmentCompat; -import com.android.contacts.common.list.ContactEntryListAdapter; -import com.android.dialer.app.R; -import com.android.dialer.callintent.CallInitiationType; -import com.android.dialer.common.LogUtil; -import com.android.dialer.database.DialerDatabaseHelper; -import com.android.dialer.smartdial.SmartDialCursorLoader; -import com.android.dialer.util.PermissionsUtil; -import com.android.dialer.widget.EmptyContentView; -import java.util.Arrays; - -/** Implements a fragment to load and display SmartDial search results. */ -public class SmartDialSearchFragment extends SearchFragment - implements EmptyContentView.OnEmptyViewActionButtonClickedListener, - FragmentCompat.OnRequestPermissionsResultCallback { - - private static final int CALL_PHONE_PERMISSION_REQUEST_CODE = 1; - - private final BroadcastReceiver smartDialUpdatedReceiver = - new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - LogUtil.i("SmartDialSearchFragment.onReceive", "smart dial update broadcast received"); - reloadData(); - } - }; - - /** Creates a SmartDialListAdapter to display and operate on search results. */ - @Override - protected ContactEntryListAdapter createListAdapter() { - SmartDialNumberListAdapter adapter = new SmartDialNumberListAdapter(getActivity()); - adapter.setUseCallableUri(super.usesCallableUri()); - adapter.setQuickContactEnabled(true); - adapter.setShowEmptyListForNullQuery(getShowEmptyListForNullQuery()); - // Set adapter's query string to restore previous instance state. - adapter.setQueryString(getQueryString()); - adapter.setListener(this); - return adapter; - } - - /** Creates a SmartDialCursorLoader object to load query results. */ - @Override - public Loader onCreateLoader(int id, Bundle args) { - // Smart dialing does not support Directory Load, falls back to normal search instead. - if (id == getDirectoryLoaderId()) { - return super.onCreateLoader(id, args); - } else { - final SmartDialNumberListAdapter adapter = (SmartDialNumberListAdapter) getAdapter(); - SmartDialCursorLoader loader = new SmartDialCursorLoader(super.getContext()); - loader.setShowEmptyListForNullQuery(getShowEmptyListForNullQuery()); - adapter.configureLoader(loader); - return loader; - } - } - - @Override - public boolean getShowEmptyListForNullQuery() { - return true; - } - - @Override - protected void setupEmptyView() { - if (emptyView != null && getActivity() != null) { - if (!PermissionsUtil.hasPermission(getActivity(), CALL_PHONE)) { - emptyView.setImage(R.drawable.empty_contacts); - emptyView.setActionLabel(R.string.permission_single_turn_on); - emptyView.setDescription(R.string.permission_place_call); - emptyView.setActionClickedListener(this); - } else { - emptyView.setImage(EmptyContentView.NO_IMAGE); - emptyView.setActionLabel(EmptyContentView.NO_LABEL); - emptyView.setDescription(EmptyContentView.NO_LABEL); - } - } - } - - @Override - public void onStart() { - super.onStart(); - - LogUtil.i("SmartDialSearchFragment.onStart", "registering smart dial update receiver"); - - getActivity() - .registerReceiver( - smartDialUpdatedReceiver, - new IntentFilter(DialerDatabaseHelper.ACTION_SMART_DIAL_UPDATED)); - } - - @Override - public void onStop() { - super.onStop(); - - LogUtil.i("SmartDialSearchFragment.onStop", "unregistering smart dial update receiver"); - - getActivity().unregisterReceiver(smartDialUpdatedReceiver); - } - - @Override - public void onEmptyViewActionButtonClicked() { - final Activity activity = getActivity(); - if (activity == null) { - return; - } - - String[] deniedPermissions = - PermissionsUtil.getPermissionsCurrentlyDenied( - getContext(), PermissionsUtil.allPhoneGroupPermissionsUsedInDialer); - if (deniedPermissions.length > 0) { - LogUtil.i( - "SmartDialSearchFragment.onEmptyViewActionButtonClicked", - "Requesting permissions: " + Arrays.toString(deniedPermissions)); - FragmentCompat.requestPermissions( - this, deniedPermissions, CALL_PHONE_PERMISSION_REQUEST_CODE); - } - } - - @Override - public void onRequestPermissionsResult( - int requestCode, String[] permissions, int[] grantResults) { - if (requestCode == CALL_PHONE_PERMISSION_REQUEST_CODE) { - setupEmptyView(); - } - } - - @Override - protected CallInitiationType.Type getCallInitiationType(boolean isRemoteDirectory) { - return CallInitiationType.Type.SMART_DIAL; - } - - public boolean isShowingPermissionRequest() { - return emptyView != null && emptyView.isShowingContent(); - } - - @Override - public void setShowEmptyListForNullQuery(boolean show) { - if (getAdapter() != null) { - ((SmartDialNumberListAdapter) getAdapter()).setShowEmptyListForNullQuery(show); - } - super.setShowEmptyListForNullQuery(show); - } -} diff --git a/java/com/android/dialer/app/res/layout/all_contacts_fragment.xml b/java/com/android/dialer/app/res/layout/all_contacts_fragment.xml deleted file mode 100644 index 422c52991..000000000 --- a/java/com/android/dialer/app/res/layout/all_contacts_fragment.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/java/com/android/dialer/app/res/layout/blocked_number_header.xml b/java/com/android/dialer/app/res/layout/blocked_number_header.xml index e34510b73..e1019d1eb 100644 --- a/java/com/android/dialer/app/res/layout/blocked_number_header.xml +++ b/java/com/android/dialer/app/res/layout/blocked_number_header.xml @@ -166,46 +166,6 @@ - - - - - - - - - - rankList(List phoneNumbers) { - return phoneNumbers; - } - - @NonNull - @Override - public Cursor rankCursor(@NonNull Cursor phoneQueryResults, int queryLength) { - return phoneQueryResults; - } - - @Override - public boolean shouldShowEmptyListForNullQuery() { - return true; - } - }; - } - - public static void setForTesting(@NonNull P13nRanker ranker) { - P13nRanking.ranker = ranker; - } -} diff --git a/java/com/android/dialer/p13n/inference/protocol/P13nRanker.java b/java/com/android/dialer/p13n/inference/protocol/P13nRanker.java deleted file mode 100644 index 41f1de49d..000000000 --- a/java/com/android/dialer/p13n/inference/protocol/P13nRanker.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ - -package com.android.dialer.p13n.inference.protocol; - -import android.database.Cursor; -import android.support.annotation.MainThread; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import java.util.List; - -/** Provides personalized ranking of outgoing call targets. */ -public interface P13nRanker { - - /** - * Re-orders a list of phone numbers according to likelihood they will be the next outgoing call. - * - * @param phoneNumbers the list of candidate numbers to call (may be in contacts list or not) - */ - @NonNull - @MainThread - List rankList(@NonNull List phoneNumbers); - - /** - * Re-orders a retrieved contact list according to likelihood they will be the next outgoing call. - * - *

A new cursor with reordered data is returned; the input cursor is unmodified except for its - * position. If the order is unchanged, this method may return a reference to the unmodified input - * cursor directly. The order would be unchanged if the ranking cache is not yet ready, or if the - * input cursor is closed or invalid, or if any other error occurs in the ranking process. - * - * @param phoneQueryResults cursor of results of a Dialer search query - * @param queryLength length of the search query that resulted in the cursor data, if below 0, - * assumes no length is specified, thus applies the default behavior which is same as when - * queryLength is greater than zero. - * @return new cursor of data reordered by ranking (or reference to input cursor if order - * unchanged) - */ - @NonNull - @MainThread - Cursor rankCursor(@NonNull Cursor phoneQueryResults, int queryLength); - - /** - * Refreshes ranking cache (pulls fresh contextual features, pre-caches inference results, etc.). - * - *

Asynchronously runs in background as the process might take a few seconds, notifying a - * listener upon completion; meanwhile, any calls to {@link #rankList} will simply return the - * input in same order. - * - * @param listener callback for when ranking refresh has completed; null value skips notification. - */ - @MainThread - void refresh(@Nullable P13nRefreshCompleteListener listener); - - /** Decides if results should be displayed for no-query search. */ - @MainThread - boolean shouldShowEmptyListForNullQuery(); - - /** - * Callback class for when ranking refresh has completed. - * - *

Primary use is to notify {@link com.android.dialer.app.DialtactsActivity} that the ranking - * functions {@link #rankList} and {@link #rankCursor(Cursor, int)} will now give useful results. - */ - interface P13nRefreshCompleteListener { - - /** Callback for when ranking refresh has completed. */ - void onP13nRefreshComplete(); - } -} diff --git a/java/com/android/dialer/p13n/inference/protocol/P13nRankerFactory.java b/java/com/android/dialer/p13n/inference/protocol/P13nRankerFactory.java deleted file mode 100644 index 7038cf456..000000000 --- a/java/com/android/dialer/p13n/inference/protocol/P13nRankerFactory.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ - -package com.android.dialer.p13n.inference.protocol; - -import android.support.annotation.Nullable; - -/** - * This interface should be implemented by the Application subclass. It allows this module to get - * references to the {@link P13nRanker}. - */ -public interface P13nRankerFactory { - @Nullable - P13nRanker newP13nRanker(); -} diff --git a/java/com/android/dialer/p13n/logging/P13nLogger.java b/java/com/android/dialer/p13n/logging/P13nLogger.java deleted file mode 100644 index 069a29328..000000000 --- a/java/com/android/dialer/p13n/logging/P13nLogger.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ - -package com.android.dialer.p13n.logging; - -import com.android.contacts.common.list.PhoneNumberListAdapter; - -/** Allows logging of data for personalization. */ -public interface P13nLogger { - - /** - * Logs a search query (text or digits) entered by user. - * - * @param query search text (or digits) entered by user - * @param adapter list adapter providing access to contacts matching search query - */ - void onSearchQuery(String query, PhoneNumberListAdapter adapter); - - /** - * Resets logging session (clears searches, re-initializes app entry timestamp, etc.) Should be - * called when Dialer app is resumed. - */ - void reset(); -} diff --git a/java/com/android/dialer/p13n/logging/P13nLoggerFactory.java b/java/com/android/dialer/p13n/logging/P13nLoggerFactory.java deleted file mode 100644 index 7350e99e1..000000000 --- a/java/com/android/dialer/p13n/logging/P13nLoggerFactory.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ - -package com.android.dialer.p13n.logging; - -import android.content.Context; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; - -/** - * This interface should be implemented by the Application subclass. It allows this module to get - * references to the P13nLogger. - */ -public interface P13nLoggerFactory { - - @Nullable - P13nLogger newP13nLogger(@NonNull Context context); -} diff --git a/java/com/android/dialer/p13n/logging/P13nLogging.java b/java/com/android/dialer/p13n/logging/P13nLogging.java deleted file mode 100644 index 21b97257b..000000000 --- a/java/com/android/dialer/p13n/logging/P13nLogging.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dialer.p13n.logging; - -import android.content.Context; -import android.support.annotation.NonNull; -import com.android.contacts.common.list.PhoneNumberListAdapter; -import com.android.dialer.common.Assert; - -/** Single entry point for all logging for personalization. */ -public final class P13nLogging { - - private static P13nLogger logger; - - private P13nLogging() {} - - @NonNull - public static P13nLogger get(@NonNull Context context) { - Assert.isNotNull(context); - Assert.isMainThread(); - if (logger != null) { - return logger; - } - - Context application = context.getApplicationContext(); - if (application instanceof P13nLoggerFactory) { - logger = ((P13nLoggerFactory) application).newP13nLogger(context); - } - - if (logger == null) { - logger = - new P13nLogger() { - @Override - public void onSearchQuery(String query, PhoneNumberListAdapter adapter) {} - - @Override - public void reset() {} - }; - } - return logger; - } - - public static void setForTesting(@NonNull P13nLogger logger) { - P13nLogging.logger = logger; - } -} diff --git a/java/com/android/dialer/smartdial/SmartDialCursorLoader.java b/java/com/android/dialer/smartdial/SmartDialCursorLoader.java index f2e41b22b..205362c14 100644 --- a/java/com/android/dialer/smartdial/SmartDialCursorLoader.java +++ b/java/com/android/dialer/smartdial/SmartDialCursorLoader.java @@ -20,7 +20,7 @@ import android.content.AsyncTaskLoader; import android.content.Context; import android.database.Cursor; import android.database.MatrixCursor; -import com.android.contacts.common.list.PhoneNumberListAdapter.PhoneQuery; +import android.provider.ContactsContract.CommonDataKinds.Phone; import com.android.dialer.common.LogUtil; import com.android.dialer.database.Database; import com.android.dialer.database.DialerDatabaseHelper; @@ -28,6 +28,8 @@ import com.android.dialer.database.DialerDatabaseHelper.ContactNumber; import com.android.dialer.smartdial.util.SmartDialNameMatcher; import com.android.dialer.util.PermissionsUtil; import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; /** Implements a Loader class to asynchronously load SmartDial search results. */ public class SmartDialCursorLoader extends AsyncTaskLoader { @@ -179,4 +181,60 @@ public class SmartDialCursorLoader extends AsyncTaskLoader { nameMatcher.setShouldMatchEmptyQuery(!show); } } + + /** Moved from contacts/common, contains all of the projections needed for Smart Dial queries. */ + public static class PhoneQuery { + + public static final String[] PROJECTION_PRIMARY_INTERNAL = + new String[] { + Phone._ID, // 0 + Phone.TYPE, // 1 + Phone.LABEL, // 2 + Phone.NUMBER, // 3 + Phone.CONTACT_ID, // 4 + Phone.LOOKUP_KEY, // 5 + Phone.PHOTO_ID, // 6 + Phone.DISPLAY_NAME_PRIMARY, // 7 + Phone.PHOTO_THUMBNAIL_URI, // 8 + }; + + public static final String[] PROJECTION_PRIMARY; + public static final String[] PROJECTION_ALTERNATIVE_INTERNAL = + new String[] { + Phone._ID, // 0 + Phone.TYPE, // 1 + Phone.LABEL, // 2 + Phone.NUMBER, // 3 + Phone.CONTACT_ID, // 4 + Phone.LOOKUP_KEY, // 5 + Phone.PHOTO_ID, // 6 + Phone.DISPLAY_NAME_ALTERNATIVE, // 7 + Phone.PHOTO_THUMBNAIL_URI, // 8 + }; + public static final String[] PROJECTION_ALTERNATIVE; + public static final int PHONE_ID = 0; + public static final int PHONE_TYPE = 1; + public static final int PHONE_LABEL = 2; + public static final int PHONE_NUMBER = 3; + public static final int CONTACT_ID = 4; + public static final int LOOKUP_KEY = 5; + public static final int PHOTO_ID = 6; + public static final int DISPLAY_NAME = 7; + public static final int PHOTO_URI = 8; + public static final int CARRIER_PRESENCE = 9; + + static { + final List projectionList = + new ArrayList<>(Arrays.asList(PROJECTION_PRIMARY_INTERNAL)); + projectionList.add(Phone.CARRIER_PRESENCE); // 9 + PROJECTION_PRIMARY = projectionList.toArray(new String[projectionList.size()]); + } + + static { + final List projectionList = + new ArrayList<>(Arrays.asList(PROJECTION_ALTERNATIVE_INTERNAL)); + projectionList.add(Phone.CARRIER_PRESENCE); // 9 + PROJECTION_ALTERNATIVE = projectionList.toArray(new String[projectionList.size()]); + } + } } -- cgit v1.2.3