diff options
Diffstat (limited to 'java/com/android/dialer/app/list')
18 files changed, 569 insertions, 570 deletions
diff --git a/java/com/android/dialer/app/list/AllContactsFragment.java b/java/com/android/dialer/app/list/AllContactsFragment.java index 32a99e795..5076fd9cf 100644 --- a/java/com/android/dialer/app/list/AllContactsFragment.java +++ b/java/com/android/dialer/app/list/AllContactsFragment.java @@ -56,13 +56,13 @@ public class AllContactsFragment extends ContactEntryListFragment<ContactEntryLi private static final int READ_CONTACTS_PERMISSION_REQUEST_CODE = 1; - private EmptyContentView mEmptyListView; + 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 mReadContactsPermissionGrantedReceiver = + private BroadcastReceiver readContactsPermissionGrantedReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { @@ -83,25 +83,25 @@ public class AllContactsFragment extends ContactEntryListFragment<ContactEntryLi public void onViewCreated(View view, android.os.Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - mEmptyListView = (EmptyContentView) view.findViewById(R.id.empty_list_view); - mEmptyListView.setImage(R.drawable.empty_contacts); - mEmptyListView.setDescription(R.string.all_contacts_empty); - mEmptyListView.setActionClickedListener(this); - getListView().setEmptyView(mEmptyListView); - mEmptyListView.setVisibility(View.GONE); + 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(), mReadContactsPermissionGrantedReceiver, READ_CONTACTS); + getActivity(), readContactsPermissionGrantedReceiver, READ_CONTACTS); } @Override public void onStop() { PermissionsUtil.unregisterPermissionReceiver( - getActivity(), mReadContactsPermissionGrantedReceiver); + getActivity(), readContactsPermissionGrantedReceiver); super.onStop(); } @@ -109,12 +109,12 @@ public class AllContactsFragment extends ContactEntryListFragment<ContactEntryLi protected void startLoading() { if (PermissionsUtil.hasPermission(getActivity(), READ_CONTACTS)) { super.startLoading(); - mEmptyListView.setDescription(R.string.all_contacts_empty); - mEmptyListView.setActionLabel(R.string.all_contacts_empty_add_contact_action); + emptyListView.setDescription(R.string.all_contacts_empty); + emptyListView.setActionLabel(R.string.all_contacts_empty_add_contact_action); } else { - mEmptyListView.setDescription(R.string.permission_no_contacts); - mEmptyListView.setActionLabel(R.string.permission_single_turn_on); - mEmptyListView.setVisibility(View.VISIBLE); + emptyListView.setDescription(R.string.permission_no_contacts); + emptyListView.setActionLabel(R.string.permission_single_turn_on); + emptyListView.setVisibility(View.VISIBLE); } } @@ -123,7 +123,7 @@ public class AllContactsFragment extends ContactEntryListFragment<ContactEntryLi super.onLoadFinished(loader, data); if (data == null || data.getCount() == 0) { - mEmptyListView.setVisibility(View.VISIBLE); + emptyListView.setVisibility(View.VISIBLE); } } diff --git a/java/com/android/dialer/app/list/BlockedListSearchAdapter.java b/java/com/android/dialer/app/list/BlockedListSearchAdapter.java index 96d02d7bf..575d6e63f 100644 --- a/java/com/android/dialer/app/list/BlockedListSearchAdapter.java +++ b/java/com/android/dialer/app/list/BlockedListSearchAdapter.java @@ -27,26 +27,26 @@ import com.android.dialer.location.GeoUtil; /** List adapter to display search results for adding a blocked number. */ public class BlockedListSearchAdapter extends RegularSearchListAdapter { - private Resources mResources; - private FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler; + private Resources resources; + private FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler; public BlockedListSearchAdapter(Context context) { super(context); - mResources = context.getResources(); + resources = context.getResources(); disableAllShortcuts(); setShortcutEnabled(SHORTCUT_BLOCK_NUMBER, true); - mFilteredNumberAsyncQueryHandler = new FilteredNumberAsyncQueryHandler(context); + filteredNumberAsyncQueryHandler = new FilteredNumberAsyncQueryHandler(context); } @Override protected boolean isChanged(boolean showNumberShortcuts) { - return setShortcutEnabled(SHORTCUT_BLOCK_NUMBER, showNumberShortcuts || mIsQuerySipAddress); + return setShortcutEnabled(SHORTCUT_BLOCK_NUMBER, showNumberShortcuts || isQuerySipAddress); } public void setViewBlocked(ContactListItemView view, Integer id) { view.setTag(R.id.block_id, id); - final int textColor = mResources.getColor(R.color.blocked_number_block_color); + final int textColor = resources.getColor(R.color.blocked_number_block_color); view.getDataView().setTextColor(textColor); view.getLabelView().setTextColor(textColor); //TODO: Add icon @@ -54,7 +54,7 @@ public class BlockedListSearchAdapter extends RegularSearchListAdapter { public void setViewUnblocked(ContactListItemView view) { view.setTag(R.id.block_id, null); - final int textColor = mResources.getColor(R.color.dialer_secondary_text_color); + final int textColor = resources.getColor(R.color.dialer_secondary_text_color); view.getDataView().setTextColor(textColor); view.getLabelView().setTextColor(textColor); //TODO: Remove icon @@ -79,6 +79,6 @@ public class BlockedListSearchAdapter extends RegularSearchListAdapter { } } }; - mFilteredNumberAsyncQueryHandler.isBlockedNumber(onCheckListener, number, countryIso); + 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 index bef5af713..de9dbaee6 100644 --- a/java/com/android/dialer/app/list/BlockedListSearchFragment.java +++ b/java/com/android/dialer/app/list/BlockedListSearchFragment.java @@ -44,7 +44,7 @@ import com.android.dialer.logging.Logger; public class BlockedListSearchFragment extends RegularSearchFragment implements BlockNumberDialogFragment.Callback { - private final TextWatcher mPhoneSearchQueryTextListener = + private final TextWatcher phoneSearchQueryTextListener = new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @@ -57,7 +57,7 @@ public class BlockedListSearchFragment extends RegularSearchFragment @Override public void afterTextChanged(Editable s) {} }; - private final SearchEditTextLayout.Callback mSearchLayoutCallback = + private final SearchEditTextLayout.Callback searchLayoutCallback = new SearchEditTextLayout.Callback() { @Override public void onBackButtonClicked() { @@ -67,8 +67,8 @@ public class BlockedListSearchFragment extends RegularSearchFragment @Override public void onSearchViewClicked() {} }; - private FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler; - private EditText mSearchView; + private FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler; + private EditText searchView; @Override public void onCreate(Bundle savedInstanceState) { @@ -83,7 +83,7 @@ public class BlockedListSearchFragment extends RegularSearchFragment * query, which results in showing an empty view */ setQueryString(getQueryString() == null ? "" : getQueryString()); - mFilteredNumberAsyncQueryHandler = new FilteredNumberAsyncQueryHandler(getContext()); + filteredNumberAsyncQueryHandler = new FilteredNumberAsyncQueryHandler(getContext()); } @Override @@ -99,23 +99,23 @@ public class BlockedListSearchFragment extends RegularSearchFragment final SearchEditTextLayout searchEditTextLayout = (SearchEditTextLayout) actionBar.getCustomView().findViewById(R.id.search_view_container); searchEditTextLayout.expand(false, true); - searchEditTextLayout.setCallback(mSearchLayoutCallback); + searchEditTextLayout.setCallback(searchLayoutCallback); searchEditTextLayout.setBackgroundDrawable(null); - mSearchView = (EditText) searchEditTextLayout.findViewById(R.id.search_view); - mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener); - mSearchView.setHint(R.string.block_number_search_hint); + 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())) { - mSearchView.setText(getQueryString()); + searchView.setText(getQueryString()); } // TODO: Don't set custom text size; use default search text size. - mSearchView.setTextSize( + searchView.setTextSize( TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.blocked_number_search_text_size)); } @@ -195,7 +195,7 @@ public class BlockedListSearchFragment extends RegularSearchFragment } } }; - mFilteredNumberAsyncQueryHandler.isBlockedNumber(onCheckListener, number, countryIso); + filteredNumberAsyncQueryHandler.isBlockedNumber(onCheckListener, number, countryIso); } @Override diff --git a/java/com/android/dialer/app/list/ContentChangedFilter.java b/java/com/android/dialer/app/list/ContentChangedFilter.java index 663846da5..8c532badb 100644 --- a/java/com/android/dialer/app/list/ContentChangedFilter.java +++ b/java/com/android/dialer/app/list/ContentChangedFilter.java @@ -29,12 +29,12 @@ import android.view.accessibility.AccessibilityEvent; */ public class ContentChangedFilter extends AccessibilityDelegate { - //the view we don't want TYPE_WINDOW_CONTENT_CHANGED to fire. - private View mView; + // the view we don't want TYPE_WINDOW_CONTENT_CHANGED to fire. + private View view; private ContentChangedFilter(View view) { super(); - mView = view; + this.view = view; } /** Add this delegate to the parent of @param view to filter out TYPE_WINDOW_CONTENT_CHANGED */ @@ -46,7 +46,7 @@ public class ContentChangedFilter extends AccessibilityDelegate { @Override public boolean onRequestSendAccessibilityEvent( ViewGroup host, View child, AccessibilityEvent event) { - if (child == mView) { + if (child == view) { if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) { return false; } diff --git a/java/com/android/dialer/app/list/DialerPhoneNumberListAdapter.java b/java/com/android/dialer/app/list/DialerPhoneNumberListAdapter.java index fc0bd3ccf..3711e6e75 100644 --- a/java/com/android/dialer/app/list/DialerPhoneNumberListAdapter.java +++ b/java/com/android/dialer/app/list/DialerPhoneNumberListAdapter.java @@ -49,16 +49,16 @@ public class DialerPhoneNumberListAdapter extends PhoneNumberListAdapter { public static final int SHORTCUT_BLOCK_NUMBER = 5; public static final int SHORTCUT_COUNT = 6; - private final boolean[] mShortcutEnabled = new boolean[SHORTCUT_COUNT]; - private final BidiFormatter mBidiFormatter = BidiFormatter.getInstance(); - private final String mCountryIso; + private final boolean[] shortcutEnabled = new boolean[SHORTCUT_COUNT]; + private final BidiFormatter bidiFormatter = BidiFormatter.getInstance(); + private final String countryIso; - private String mFormattedQueryString; + private String formattedQueryString; public DialerPhoneNumberListAdapter(Context context) { super(context); - mCountryIso = GeoUtil.getCurrentCountryIso(context); + countryIso = GeoUtil.getCurrentCountryIso(context); } @Override @@ -69,8 +69,8 @@ public class DialerPhoneNumberListAdapter extends PhoneNumberListAdapter { /** @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 < mShortcutEnabled.length; i++) { - if (mShortcutEnabled[i]) { + for (int i = 0; i < shortcutEnabled.length; i++) { + if (shortcutEnabled[i]) { count++; } } @@ -78,8 +78,8 @@ public class DialerPhoneNumberListAdapter extends PhoneNumberListAdapter { } public void disableAllShortcuts() { - for (int i = 0; i < mShortcutEnabled.length; i++) { - mShortcutEnabled[i] = false; + for (int i = 0; i < shortcutEnabled.length; i++) { + shortcutEnabled[i] = false; } } @@ -137,8 +137,8 @@ public class DialerPhoneNumberListAdapter extends PhoneNumberListAdapter { 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 < mShortcutEnabled.length; i++) { - if (mShortcutEnabled[i]) { + for (int i = 0; shortcutCount >= 0 && i < shortcutEnabled.length; i++) { + if (shortcutEnabled[i]) { shortcutCount--; if (shortcutCount < 0) { return i; @@ -177,7 +177,7 @@ public class DialerPhoneNumberListAdapter extends PhoneNumberListAdapter { ContactDisplayUtils.getTtsSpannedPhoneNumber( resources, R.string.search_shortcut_call_number, - mBidiFormatter.unicodeWrap(number, TextDirectionHeuristics.LTR)); + bidiFormatter.unicodeWrap(number, TextDirectionHeuristics.LTR)); drawable = ContextCompat.getDrawable(getContext(), R.drawable.quantum_ic_call_vd_theme_24); break; case SHORTCUT_CREATE_NEW_CONTACT: @@ -216,19 +216,19 @@ public class DialerPhoneNumberListAdapter extends PhoneNumberListAdapter { /** @return True if the shortcut state (disabled vs enabled) was changed by this operation */ public boolean setShortcutEnabled(int shortcutType, boolean visible) { - final boolean changed = mShortcutEnabled[shortcutType] != visible; - mShortcutEnabled[shortcutType] = visible; + final boolean changed = shortcutEnabled[shortcutType] != visible; + shortcutEnabled[shortcutType] = visible; return changed; } public String getFormattedQueryString() { - return mFormattedQueryString; + return formattedQueryString; } @Override public void setQueryString(String queryString) { - mFormattedQueryString = - PhoneNumberUtils.formatNumber(PhoneNumberUtils.normalizeNumber(queryString), mCountryIso); + formattedQueryString = + PhoneNumberUtils.formatNumber(PhoneNumberUtils.normalizeNumber(queryString), countryIso); super.setQueryString(queryString); } } diff --git a/java/com/android/dialer/app/list/DragDropController.java b/java/com/android/dialer/app/list/DragDropController.java index c22dd1318..458e31e69 100644 --- a/java/com/android/dialer/app/list/DragDropController.java +++ b/java/com/android/dialer/app/list/DragDropController.java @@ -28,12 +28,12 @@ import java.util.List; */ public class DragDropController { - private final List<OnDragDropListener> mOnDragDropListeners = new ArrayList<OnDragDropListener>(); - private final DragItemContainer mDragItemContainer; - private final int[] mLocationOnScreen = new int[2]; + private final List<OnDragDropListener> onDragDropListeners = new ArrayList<OnDragDropListener>(); + private final DragItemContainer dragItemContainer; + private final int[] locationOnScreen = new int[2]; public DragDropController(DragItemContainer dragItemContainer) { - mDragItemContainer = dragItemContainer; + this.dragItemContainer = dragItemContainer; } /** @return True if the drag is started, false if the drag is cancelled for some reason. */ @@ -43,54 +43,53 @@ public class DragDropController { // The coordinates in dragEvent of DragEvent.ACTION_DRAG_STARTED before NYC is window-related. // This is fixed in NYC. if (VERSION.SDK_INT >= VERSION_CODES.N) { - v.getLocationOnScreen(mLocationOnScreen); - screenX = x + mLocationOnScreen[0]; - screenY = y + mLocationOnScreen[1]; + v.getLocationOnScreen(locationOnScreen); + screenX = x + locationOnScreen[0]; + screenY = y + locationOnScreen[1]; } final PhoneFavoriteSquareTileView tileView = - mDragItemContainer.getViewForLocation(screenX, screenY); + dragItemContainer.getViewForLocation(screenX, screenY); if (tileView == null) { return false; } - for (int i = 0; i < mOnDragDropListeners.size(); i++) { - mOnDragDropListeners.get(i).onDragStarted(screenX, screenY, tileView); + for (int i = 0; i < onDragDropListeners.size(); i++) { + onDragDropListeners.get(i).onDragStarted(screenX, screenY, tileView); } return true; } public void handleDragHovered(View v, int x, int y) { - v.getLocationOnScreen(mLocationOnScreen); - final int screenX = x + mLocationOnScreen[0]; - final int screenY = y + mLocationOnScreen[1]; - final PhoneFavoriteSquareTileView view = - mDragItemContainer.getViewForLocation(screenX, screenY); - for (int i = 0; i < mOnDragDropListeners.size(); i++) { - mOnDragDropListeners.get(i).onDragHovered(screenX, screenY, view); + v.getLocationOnScreen(locationOnScreen); + final int screenX = x + locationOnScreen[0]; + final int screenY = y + locationOnScreen[1]; + final PhoneFavoriteSquareTileView view = dragItemContainer.getViewForLocation(screenX, screenY); + for (int i = 0; i < onDragDropListeners.size(); i++) { + onDragDropListeners.get(i).onDragHovered(screenX, screenY, view); } } public void handleDragFinished(int x, int y, boolean isRemoveView) { if (isRemoveView) { - for (int i = 0; i < mOnDragDropListeners.size(); i++) { - mOnDragDropListeners.get(i).onDroppedOnRemove(); + for (int i = 0; i < onDragDropListeners.size(); i++) { + onDragDropListeners.get(i).onDroppedOnRemove(); } } - for (int i = 0; i < mOnDragDropListeners.size(); i++) { - mOnDragDropListeners.get(i).onDragFinished(x, y); + for (int i = 0; i < onDragDropListeners.size(); i++) { + onDragDropListeners.get(i).onDragFinished(x, y); } } public void addOnDragDropListener(OnDragDropListener listener) { - if (!mOnDragDropListeners.contains(listener)) { - mOnDragDropListeners.add(listener); + if (!onDragDropListeners.contains(listener)) { + onDragDropListeners.add(listener); } } public void removeOnDragDropListener(OnDragDropListener listener) { - if (mOnDragDropListeners.contains(listener)) { - mOnDragDropListeners.remove(listener); + if (onDragDropListeners.contains(listener)) { + onDragDropListeners.remove(listener); } } diff --git a/java/com/android/dialer/app/list/ListsFragment.java b/java/com/android/dialer/app/list/ListsFragment.java index 05c647aec..7c24cc0f0 100644 --- a/java/com/android/dialer/app/list/ListsFragment.java +++ b/java/com/android/dialer/app/list/ListsFragment.java @@ -63,21 +63,21 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis private static final String TAG = "ListsFragment"; - private DialerViewPager mViewPager; - private ViewPagerTabs mViewPagerTabs; - private DialtactsPagerAdapter mAdapter; - private RemoveView mRemoveView; - private View mRemoveViewContent; - private Fragment mCurrentPage; - private SharedPreferences mPrefs; - private boolean mHasFetchedVoicemailStatus; - private boolean mShowVoicemailTabAfterVoicemailStatusIsFetched; - private final ArrayList<OnPageChangeListener> mOnPageChangeListeners = new ArrayList<>(); + private DialerViewPager viewPager; + private ViewPagerTabs viewPagerTabs; + private DialtactsPagerAdapter adapter; + private RemoveView removeView; + private View removeViewContent; + private Fragment currentPage; + private SharedPreferences prefs; + private boolean hasFetchedVoicemailStatus; + private boolean showVoicemailTabAfterVoicemailStatusIsFetched; + private final ArrayList<OnPageChangeListener> onPageChangeListeners = new ArrayList<>(); /** The position of the currently selected tab. */ - private int mTabIndex = DialtactsPagerAdapter.TAB_INDEX_SPEED_DIAL; + private int tabIndex = DialtactsPagerAdapter.TAB_INDEX_SPEED_DIAL; - private boolean mPaused; - private CallLogQueryHandler mCallLogQueryHandler; + private boolean paused; + private CallLogQueryHandler callLogQueryHandler; private UiAction.Type[] actionTypeList; private final DialerImpression.Type[] swipeImpressionList = @@ -88,12 +88,12 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis // Only for detecting page selected by swiping or clicking. private boolean onPageScrolledBeforeScrollStateSettling; - private final ContentObserver mVoicemailStatusObserver = + private final ContentObserver voicemailStatusObserver = new ContentObserver(new Handler()) { @Override public void onChange(boolean selfChange) { super.onChange(selfChange); - mCallLogQueryHandler.fetchVoicemailStatus(); + callLogQueryHandler.fetchVoicemailStatus(); } }; @@ -102,7 +102,7 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis LogUtil.d("ListsFragment.onCreate", null); Trace.beginSection(TAG + " onCreate"); super.onCreate(savedInstanceState); - mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext()); + prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext()); Trace.endSection(); } @@ -112,19 +112,19 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis Trace.beginSection(TAG + " onResume"); super.onResume(); - mPaused = false; + paused = false; if (getUserVisibleHint()) { sendScreenViewForCurrentPosition(); } // Fetch voicemail status to determine if we should show the voicemail tab. - mCallLogQueryHandler = + callLogQueryHandler = new CallLogQueryHandler(getActivity(), getActivity().getContentResolver(), this); - mCallLogQueryHandler.fetchVoicemailStatus(); - mCallLogQueryHandler.fetchMissedCallsUnreadCount(); + callLogQueryHandler.fetchVoicemailStatus(); + callLogQueryHandler.fetchMissedCallsUnreadCount(); Trace.endSection(); - mCurrentPage = mAdapter.getItem(mViewPager.getCurrentItem()); + currentPage = adapter.getItem(viewPager.getCurrentItem()); } @Override @@ -132,13 +132,13 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis LogUtil.enterBlock("ListsFragment.onPause"); super.onPause(); - mPaused = true; + paused = true; } @Override public void onDestroyView() { super.onDestroyView(); - mViewPager.removeOnPageChangeListener(this); + viewPager.removeOnPageChangeListener(this); } @Override @@ -194,36 +194,36 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis tabIcons[DialtactsPagerAdapter.TAB_INDEX_ALL_CONTACTS] = R.drawable.quantum_ic_people_white_24; tabIcons[DialtactsPagerAdapter.TAB_INDEX_VOICEMAIL] = R.drawable.quantum_ic_voicemail_white_24; - mViewPager = (DialerViewPager) parentView.findViewById(R.id.lists_pager); - mAdapter = + viewPager = (DialerViewPager) parentView.findViewById(R.id.lists_pager); + adapter = new DialtactsPagerAdapter( getContext(), getChildFragmentManager(), tabTitles, - mPrefs.getBoolean( + prefs.getBoolean( VisualVoicemailEnabledChecker.PREF_KEY_HAS_ACTIVE_VOICEMAIL_PROVIDER, false)); - mViewPager.setAdapter(mAdapter); + viewPager.setAdapter(adapter); // This is deliberate. See cl/172018946 for the app startup implications of using 1 here // versus loading more fragments upfront. - mViewPager.setOffscreenPageLimit(1); + viewPager.setOffscreenPageLimit(1); - mViewPager.addOnPageChangeListener(this); + viewPager.addOnPageChangeListener(this); showTab(DialtactsPagerAdapter.TAB_INDEX_SPEED_DIAL); - mViewPagerTabs = (ViewPagerTabs) parentView.findViewById(R.id.lists_pager_header); - mViewPagerTabs.configureTabIcons(tabIcons); - mViewPagerTabs.setViewPager(mViewPager); - addOnPageChangeListener(mViewPagerTabs); - mRemoveView = (RemoveView) parentView.findViewById(R.id.remove_view); - mRemoveViewContent = parentView.findViewById(R.id.remove_view_content); + viewPagerTabs = (ViewPagerTabs) parentView.findViewById(R.id.lists_pager_header); + viewPagerTabs.configureTabIcons(tabIcons); + viewPagerTabs.setViewPager(viewPager); + addOnPageChangeListener(viewPagerTabs); + removeView = (RemoveView) parentView.findViewById(R.id.remove_view); + removeViewContent = parentView.findViewById(R.id.remove_view_content); if (PermissionsUtil.hasReadVoicemailPermissions(getContext()) && PermissionsUtil.hasAddVoicemailPermissions(getContext())) { getActivity() .getContentResolver() .registerContentObserver( - VoicemailContract.Status.CONTENT_URI, true, mVoicemailStatusObserver); + VoicemailContract.Status.CONTENT_URI, true, voicemailStatusObserver); } else { LogUtil.w("ListsFragment.onCreateView", "no voicemail read permissions"); } @@ -235,13 +235,13 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis @Override public void onDestroy() { - getActivity().getContentResolver().unregisterContentObserver(mVoicemailStatusObserver); + getActivity().getContentResolver().unregisterContentObserver(voicemailStatusObserver); super.onDestroy(); } public void addOnPageChangeListener(OnPageChangeListener onPageChangeListener) { - if (!mOnPageChangeListeners.contains(onPageChangeListener)) { - mOnPageChangeListeners.add(onPageChangeListener); + if (!onPageChangeListeners.contains(onPageChangeListener)) { + onPageChangeListeners.add(onPageChangeListener); } } @@ -252,15 +252,14 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis */ public void showTab(int index) { if (index == DialtactsPagerAdapter.TAB_INDEX_VOICEMAIL) { - if (mAdapter.hasActiveVoicemailProvider()) { - mViewPager.setCurrentItem( - mAdapter.getRtlPosition(DialtactsPagerAdapter.TAB_INDEX_VOICEMAIL)); - } else if (!mHasFetchedVoicemailStatus) { + if (adapter.hasActiveVoicemailProvider()) { + viewPager.setCurrentItem(adapter.getRtlPosition(DialtactsPagerAdapter.TAB_INDEX_VOICEMAIL)); + } else if (!hasFetchedVoicemailStatus) { // Try to show the voicemail tab after the voicemail status returns. - mShowVoicemailTabAfterVoicemailStatusIsFetched = true; + showVoicemailTabAfterVoicemailStatusIsFetched = true; } } else if (index < getTabCount()) { - mViewPager.setCurrentItem(mAdapter.getRtlPosition(index)); + viewPager.setCurrentItem(adapter.getRtlPosition(index)); } } @@ -271,11 +270,11 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis if (positionOffsetPixels != 0) { onPageScrolledBeforeScrollStateSettling = true; } - mTabIndex = mAdapter.getRtlPosition(position); + tabIndex = adapter.getRtlPosition(position); - final int count = mOnPageChangeListeners.size(); + final int count = onPageChangeListeners.size(); for (int i = 0; i < count; i++) { - mOnPageChangeListeners.get(i).onPageScrolled(position, positionOffset, positionOffsetPixels); + onPageChangeListeners.get(i).onPageScrolled(position, positionOffset, positionOffsetPixels); } } @@ -294,23 +293,23 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis PerformanceReport.recordClick(actionTypeList[position]); LogUtil.i("ListsFragment.onPageSelected", "position: %d", position); - mTabIndex = mAdapter.getRtlPosition(position); + tabIndex = adapter.getRtlPosition(position); // Show the tab which has been selected instead. - mShowVoicemailTabAfterVoicemailStatusIsFetched = false; + showVoicemailTabAfterVoicemailStatusIsFetched = false; - final int count = mOnPageChangeListeners.size(); + final int count = onPageChangeListeners.size(); for (int i = 0; i < count; i++) { - mOnPageChangeListeners.get(i).onPageSelected(position); + onPageChangeListeners.get(i).onPageSelected(position); } sendScreenViewForCurrentPosition(); - if (mCurrentPage instanceof CallLogFragment) { - ((CallLogFragment) mCurrentPage).onNotVisible(); + if (currentPage instanceof CallLogFragment) { + ((CallLogFragment) currentPage).onNotVisible(); } - mCurrentPage = mAdapter.getItem(position); - if (mCurrentPage instanceof CallLogFragment) { - ((CallLogFragment) mCurrentPage).onVisible(); + currentPage = adapter.getItem(position); + if (currentPage instanceof CallLogFragment) { + ((CallLogFragment) currentPage).onVisible(); } } @@ -320,17 +319,17 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis onPageScrolledBeforeScrollStateSettling = false; } - final int count = mOnPageChangeListeners.size(); + final int count = onPageChangeListeners.size(); for (int i = 0; i < count; i++) { - mOnPageChangeListeners.get(i).onPageScrollStateChanged(state); + onPageChangeListeners.get(i).onPageScrollStateChanged(state); } } @Override public void onVoicemailStatusFetched(Cursor statusCursor) { - mHasFetchedVoicemailStatus = true; + hasFetchedVoicemailStatus = true; - if (getActivity() == null || mPaused) { + if (getActivity() == null || paused) { return; } @@ -340,19 +339,19 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis // Update hasActiveVoicemailProvider, which controls the number of tabs displayed. boolean hasActiveVoicemailProvider = VoicemailStatusHelper.getNumberActivityVoicemailSources(statusCursor) > 0; - if (hasActiveVoicemailProvider != mAdapter.hasActiveVoicemailProvider()) { - mAdapter.setHasActiveVoicemailProvider(hasActiveVoicemailProvider); - mAdapter.notifyDataSetChanged(); + if (hasActiveVoicemailProvider != adapter.hasActiveVoicemailProvider()) { + adapter.setHasActiveVoicemailProvider(hasActiveVoicemailProvider); + adapter.notifyDataSetChanged(); if (hasActiveVoicemailProvider) { Logger.get(getContext()).logImpression(DialerImpression.Type.VVM_TAB_VISIBLE); - mViewPagerTabs.updateTab(DialtactsPagerAdapter.TAB_INDEX_VOICEMAIL); + viewPagerTabs.updateTab(DialtactsPagerAdapter.TAB_INDEX_VOICEMAIL); } else { - mViewPagerTabs.removeTab(DialtactsPagerAdapter.TAB_INDEX_VOICEMAIL); - mAdapter.removeVoicemailFragment(getChildFragmentManager()); + viewPagerTabs.removeTab(DialtactsPagerAdapter.TAB_INDEX_VOICEMAIL); + adapter.removeVoicemailFragment(getChildFragmentManager()); } - mPrefs + prefs .edit() .putBoolean( VisualVoicemailEnabledChecker.PREF_KEY_HAS_ACTIVE_VOICEMAIL_PROVIDER, @@ -361,11 +360,11 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis } if (hasActiveVoicemailProvider) { - mCallLogQueryHandler.fetchVoicemailUnreadCount(); + callLogQueryHandler.fetchVoicemailUnreadCount(); } - if (mAdapter.hasActiveVoicemailProvider() && mShowVoicemailTabAfterVoicemailStatusIsFetched) { - mShowVoicemailTabAfterVoicemailStatusIsFetched = false; + if (adapter.hasActiveVoicemailProvider() && showVoicemailTabAfterVoicemailStatusIsFetched) { + showVoicemailTabAfterVoicemailStatusIsFetched = false; showTab(DialtactsPagerAdapter.TAB_INDEX_VOICEMAIL); } } @@ -383,8 +382,8 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis cursor.close(); } - mViewPagerTabs.setUnreadCount(count, DialtactsPagerAdapter.TAB_INDEX_VOICEMAIL); - mViewPagerTabs.updateTab(DialtactsPagerAdapter.TAB_INDEX_VOICEMAIL); + viewPagerTabs.setUnreadCount(count, DialtactsPagerAdapter.TAB_INDEX_VOICEMAIL); + viewPagerTabs.updateTab(DialtactsPagerAdapter.TAB_INDEX_VOICEMAIL); } @Override @@ -400,8 +399,8 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis cursor.close(); } - mViewPagerTabs.setUnreadCount(count, DialtactsPagerAdapter.TAB_INDEX_HISTORY); - mViewPagerTabs.updateTab(DialtactsPagerAdapter.TAB_INDEX_HISTORY); + viewPagerTabs.setUnreadCount(count, DialtactsPagerAdapter.TAB_INDEX_HISTORY); + viewPagerTabs.updateTab(DialtactsPagerAdapter.TAB_INDEX_HISTORY); } @Override @@ -411,13 +410,13 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis } public int getCurrentTabIndex() { - return mTabIndex; + return tabIndex; } public boolean shouldShowFab() { // If the VVM TOS is visible, don't show the fab - if (mCurrentPage instanceof VisualVoicemailCallLogFragment - && ((VisualVoicemailCallLogFragment) mCurrentPage).isModalAlertVisible()) { + if (currentPage instanceof VisualVoicemailCallLogFragment + && ((VisualVoicemailCallLogFragment) currentPage).isModalAlertVisible()) { return false; } @@ -429,47 +428,47 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis * voicemail in the call log or when the user expands an unread call in the call history tab. */ public void updateTabUnreadCounts() { - if (mCallLogQueryHandler != null) { - mCallLogQueryHandler.fetchMissedCallsUnreadCount(); - if (mAdapter.hasActiveVoicemailProvider()) { - mCallLogQueryHandler.fetchVoicemailUnreadCount(); + if (callLogQueryHandler != null) { + callLogQueryHandler.fetchMissedCallsUnreadCount(); + if (adapter.hasActiveVoicemailProvider()) { + callLogQueryHandler.fetchVoicemailUnreadCount(); } } } /** External method to mark all missed calls as read. */ public void markMissedCallsAsReadAndRemoveNotifications() { - if (mCallLogQueryHandler != null) { - mCallLogQueryHandler.markMissedCallsAsRead(); + if (callLogQueryHandler != null) { + callLogQueryHandler.markMissedCallsAsRead(); CallLogNotificationsService.cancelAllMissedCalls(getContext()); } } public void showRemoveView(boolean show) { - mRemoveViewContent.setVisibility(show ? View.VISIBLE : View.GONE); - mRemoveView.setAlpha(show ? 0 : 1); - mRemoveView.animate().alpha(show ? 1 : 0).start(); + removeViewContent.setVisibility(show ? View.VISIBLE : View.GONE); + removeView.setAlpha(show ? 0 : 1); + removeView.animate().alpha(show ? 1 : 0).start(); } public void showMultiSelectRemoveView(boolean show) { - mViewPagerTabs.setVisibility(show ? View.GONE : View.VISIBLE); - mViewPager.setEnableSwipingPages(!show); + viewPagerTabs.setVisibility(show ? View.GONE : View.VISIBLE); + viewPager.setEnableSwipingPages(!show); } public boolean hasFrequents() { Fragment page = - mAdapter.getItem(mAdapter.getRtlPosition(DialtactsPagerAdapter.TAB_INDEX_SPEED_DIAL)); + adapter.getItem(adapter.getRtlPosition(DialtactsPagerAdapter.TAB_INDEX_SPEED_DIAL)); return page instanceof OldSpeedDialFragment ? ((OldSpeedDialFragment) page).hasFrequents() : ((SpeedDialFragment) page).hasFrequents(); } public RemoveView getRemoveView() { - return mRemoveView; + return removeView; } public int getTabCount() { - return mAdapter.getCount(); + return adapter.getCount(); } public void sendScreenViewForCurrentPosition() { diff --git a/java/com/android/dialer/app/list/OldSpeedDialFragment.java b/java/com/android/dialer/app/list/OldSpeedDialFragment.java index afc7c133b..1b366c1ee 100644 --- a/java/com/android/dialer/app/list/OldSpeedDialFragment.java +++ b/java/com/android/dialer/app/list/OldSpeedDialFragment.java @@ -81,22 +81,22 @@ public class OldSpeedDialFragment extends Fragment /** Used with LoaderManager. */ private static final int LOADER_ID_CONTACT_TILE = 1; - private final LongSparseArray<Integer> mItemIdTopMap = new LongSparseArray<>(); - private final LongSparseArray<Integer> mItemIdLeftMap = new LongSparseArray<>(); - private final ContactTileView.Listener mContactTileAdapterListener = + private final LongSparseArray<Integer> itemIdTopMap = new LongSparseArray<>(); + private final LongSparseArray<Integer> itemIdLeftMap = new LongSparseArray<>(); + private final ContactTileView.Listener contactTileAdapterListener = new ContactTileAdapterListener(); - private final LoaderManager.LoaderCallbacks<Cursor> mContactTileLoaderListener = + private final LoaderManager.LoaderCallbacks<Cursor> contactTileLoaderListener = new ContactTileLoaderListener(); - private final ScrollListener mScrollListener = new ScrollListener(); - private int mAnimationDuration; - private OnPhoneNumberPickerActionListener mPhoneNumberPickerActionListener; - private OnListFragmentScrolledListener mActivityScrollListener; - private PhoneFavoritesTileAdapter mContactTileAdapter; - private View mParentView; - private PhoneFavoriteListView mListView; - private View mContactTileFrame; + private final ScrollListener scrollListener = new ScrollListener(); + private int animationDuration; + private OnPhoneNumberPickerActionListener phoneNumberPickerActionListener; + private OnListFragmentScrolledListener activityScrollListener; + private PhoneFavoritesTileAdapter contactTileAdapter; + private View parentView; + private PhoneFavoriteListView listView; + private View contactTileFrame; /** Layout used when there are no favorites. */ - private EmptyContentView mEmptyView; + private EmptyContentView emptyView; @Override public void onCreate(Bundle savedState) { @@ -109,10 +109,10 @@ public class OldSpeedDialFragment extends Fragment // Construct two base adapters which will become part of PhoneFavoriteMergedAdapter. // We don't construct the resultant adapter at this moment since it requires LayoutInflater // that will be available on onCreateView(). - mContactTileAdapter = - new PhoneFavoritesTileAdapter(getActivity(), mContactTileAdapterListener, this); - mContactTileAdapter.setPhotoLoader(ContactPhotoManager.getInstance(getActivity())); - mAnimationDuration = getResources().getInteger(R.integer.fade_duration); + contactTileAdapter = + new PhoneFavoritesTileAdapter(getActivity(), contactTileAdapterListener, this); + contactTileAdapter.setPhotoLoader(ContactPhotoManager.getInstance(getActivity())); + animationDuration = getResources().getInteger(R.integer.fade_duration); Trace.endSection(); } @@ -120,22 +120,22 @@ public class OldSpeedDialFragment extends Fragment public void onResume() { Trace.beginSection(TAG + " onResume"); super.onResume(); - if (mContactTileAdapter != null) { - mContactTileAdapter.refreshContactsPreferences(); + if (contactTileAdapter != null) { + contactTileAdapter.refreshContactsPreferences(); } if (PermissionsUtil.hasContactsReadPermissions(getActivity())) { if (getLoaderManager().getLoader(LOADER_ID_CONTACT_TILE) == null) { - getLoaderManager().initLoader(LOADER_ID_CONTACT_TILE, null, mContactTileLoaderListener); + getLoaderManager().initLoader(LOADER_ID_CONTACT_TILE, null, contactTileLoaderListener); } else { getLoaderManager().getLoader(LOADER_ID_CONTACT_TILE).forceLoad(); } - mEmptyView.setDescription(R.string.speed_dial_empty); - mEmptyView.setActionLabel(R.string.speed_dial_empty_add_favorite_action); + emptyView.setDescription(R.string.speed_dial_empty); + emptyView.setActionLabel(R.string.speed_dial_empty_add_favorite_action); } else { - mEmptyView.setDescription(R.string.permission_no_speeddial); - mEmptyView.setActionLabel(R.string.permission_single_turn_on); + emptyView.setDescription(R.string.permission_no_speeddial); + emptyView.setActionLabel(R.string.permission_single_turn_on); } Trace.endSection(); } @@ -144,62 +144,62 @@ public class OldSpeedDialFragment extends Fragment public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Trace.beginSection(TAG + " onCreateView"); - mParentView = inflater.inflate(R.layout.speed_dial_fragment, container, false); + parentView = inflater.inflate(R.layout.speed_dial_fragment, container, false); - mListView = (PhoneFavoriteListView) mParentView.findViewById(R.id.contact_tile_list); - mListView.setOnItemClickListener(this); - mListView.setVerticalScrollBarEnabled(false); - mListView.setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_RIGHT); - mListView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY); - mListView.getDragDropController().addOnDragDropListener(mContactTileAdapter); + listView = (PhoneFavoriteListView) parentView.findViewById(R.id.contact_tile_list); + listView.setOnItemClickListener(this); + listView.setVerticalScrollBarEnabled(false); + listView.setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_RIGHT); + listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY); + listView.getDragDropController().addOnDragDropListener(contactTileAdapter); final ImageView dragShadowOverlay = (ImageView) getActivity().findViewById(R.id.contact_tile_drag_shadow_overlay); - mListView.setDragShadowOverlay(dragShadowOverlay); + listView.setDragShadowOverlay(dragShadowOverlay); - mEmptyView = (EmptyContentView) mParentView.findViewById(R.id.empty_list_view); - mEmptyView.setImage(R.drawable.empty_speed_dial); - mEmptyView.setActionClickedListener(this); + emptyView = (EmptyContentView) parentView.findViewById(R.id.empty_list_view); + emptyView.setImage(R.drawable.empty_speed_dial); + emptyView.setActionClickedListener(this); - mContactTileFrame = mParentView.findViewById(R.id.contact_tile_frame); + contactTileFrame = parentView.findViewById(R.id.contact_tile_frame); final LayoutAnimationController controller = new LayoutAnimationController( AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in)); controller.setDelay(0); - mListView.setLayoutAnimation(controller); - mListView.setAdapter(mContactTileAdapter); + listView.setLayoutAnimation(controller); + listView.setAdapter(contactTileAdapter); - mListView.setOnScrollListener(mScrollListener); - mListView.setFastScrollEnabled(false); - mListView.setFastScrollAlwaysVisible(false); + listView.setOnScrollListener(scrollListener); + listView.setFastScrollEnabled(false); + listView.setFastScrollAlwaysVisible(false); - //prevent content changes of the list from firing accessibility events. - mListView.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_NONE); - ContentChangedFilter.addToParent(mListView); + // prevent content changes of the list from firing accessibility events. + listView.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_NONE); + ContentChangedFilter.addToParent(listView); Trace.endSection(); - return mParentView; + return parentView; } public boolean hasFrequents() { - if (mContactTileAdapter == null) { + if (contactTileAdapter == null) { return false; } - return mContactTileAdapter.getNumFrequents() > 0; + return contactTileAdapter.getNumFrequents() > 0; } /* package */ void setEmptyViewVisibility(final boolean visible) { - final int previousVisibility = mEmptyView.getVisibility(); + final int previousVisibility = emptyView.getVisibility(); final int emptyViewVisibility = visible ? View.VISIBLE : View.GONE; final int listViewVisibility = visible ? View.GONE : View.VISIBLE; if (previousVisibility != emptyViewVisibility) { - final FrameLayout.LayoutParams params = (LayoutParams) mContactTileFrame.getLayoutParams(); + final FrameLayout.LayoutParams params = (LayoutParams) contactTileFrame.getLayoutParams(); params.height = visible ? LayoutParams.WRAP_CONTENT : LayoutParams.MATCH_PARENT; - mContactTileFrame.setLayoutParams(params); - mEmptyView.setVisibility(emptyViewVisibility); - mListView.setVisibility(listViewVisibility); + contactTileFrame.setLayoutParams(params); + emptyView.setVisibility(emptyViewVisibility); + listView.setVisibility(listViewVisibility); } } @@ -210,7 +210,7 @@ public class OldSpeedDialFragment extends Fragment final Activity activity = getActivity(); try { - mActivityScrollListener = (OnListFragmentScrolledListener) activity; + activityScrollListener = (OnListFragmentScrolledListener) activity; } catch (ClassCastException e) { throw new ClassCastException( activity.toString() + " must implement OnListFragmentScrolledListener"); @@ -218,15 +218,15 @@ public class OldSpeedDialFragment extends Fragment try { OnDragDropListener listener = (OnDragDropListener) activity; - mListView.getDragDropController().addOnDragDropListener(listener); - ((HostInterface) activity).setDragDropController(mListView.getDragDropController()); + listView.getDragDropController().addOnDragDropListener(listener); + ((HostInterface) activity).setDragDropController(listView.getDragDropController()); } catch (ClassCastException e) { throw new ClassCastException( activity.toString() + " must implement OnDragDropListener and HostInterface"); } try { - mPhoneNumberPickerActionListener = (OnPhoneNumberPickerActionListener) activity; + phoneNumberPickerActionListener = (OnPhoneNumberPickerActionListener) activity; } catch (ClassCastException e) { throw new ClassCastException( activity.toString() + " must implement PhoneFavoritesFragment.listener"); @@ -236,7 +236,7 @@ public class OldSpeedDialFragment extends Fragment // This method call implicitly assures ContactTileLoaderListener's onLoadFinished() will // be called, on which we'll check if "all" contacts should be reloaded again or not. if (PermissionsUtil.hasContactsReadPermissions(activity)) { - getLoaderManager().initLoader(LOADER_ID_CONTACT_TILE, null, mContactTileLoaderListener); + getLoaderManager().initLoader(LOADER_ID_CONTACT_TILE, null, contactTileLoaderListener); } else { setEmptyViewVisibility(true); } @@ -245,12 +245,12 @@ public class OldSpeedDialFragment extends Fragment /** * {@inheritDoc} * - * <p>This is only effective for elements provided by {@link #mContactTileAdapter}. {@link - * #mContactTileAdapter} has its own logic for click events. + * <p>This is only effective for elements provided by {@link #contactTileAdapter}. {@link + * #contactTileAdapter} has its own logic for click events. */ @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { - final int contactTileAdapterCount = mContactTileAdapter.getCount(); + final int contactTileAdapterCount = contactTileAdapter.getCount(); if (position <= contactTileAdapterCount) { LogUtil.e( "OldSpeedDialFragment.onItemClick", @@ -267,36 +267,36 @@ public class OldSpeedDialFragment extends Fragment * are sliding into their new positions. */ private void saveOffsets(int removedItemHeight) { - final int firstVisiblePosition = mListView.getFirstVisiblePosition(); + final int firstVisiblePosition = listView.getFirstVisiblePosition(); if (DEBUG) { - LogUtil.d("OldSpeedDialFragment.saveOffsets", "Child count : " + mListView.getChildCount()); + LogUtil.d("OldSpeedDialFragment.saveOffsets", "Child count : " + listView.getChildCount()); } - for (int i = 0; i < mListView.getChildCount(); i++) { - final View child = mListView.getChildAt(i); + for (int i = 0; i < listView.getChildCount(); i++) { + final View child = listView.getChildAt(i); final int position = firstVisiblePosition + i; // Since we are getting the position from mListView and then querying // mContactTileAdapter, its very possible that things are out of sync // and we might index out of bounds. Let's make sure that this doesn't happen. - if (!mContactTileAdapter.isIndexInBound(position)) { + if (!contactTileAdapter.isIndexInBound(position)) { continue; } - final long itemId = mContactTileAdapter.getItemId(position); + final long itemId = contactTileAdapter.getItemId(position); if (DEBUG) { LogUtil.d( "OldSpeedDialFragment.saveOffsets", "Saving itemId: " + itemId + " for listview child " + i + " Top: " + child.getTop()); } - mItemIdTopMap.put(itemId, child.getTop()); - mItemIdLeftMap.put(itemId, child.getLeft()); + itemIdTopMap.put(itemId, child.getTop()); + itemIdLeftMap.put(itemId, child.getLeft()); } - mItemIdTopMap.put(KEY_REMOVED_ITEM_HEIGHT, removedItemHeight); + itemIdTopMap.put(KEY_REMOVED_ITEM_HEIGHT, removedItemHeight); } /* * Performs animations for the gridView */ private void animateGridView(final long... idsInPlace) { - if (mItemIdTopMap.size() == 0) { + if (itemIdTopMap.size() == 0) { // Don't do animations if the database is being queried for the first time and // the previous item offsets have not been cached, or the user hasn't done anything // (dragging, swiping etc) that requires an animation. @@ -304,34 +304,34 @@ public class OldSpeedDialFragment extends Fragment } ViewUtil.doOnPreDraw( - mListView, + listView, true, new Runnable() { @Override public void run() { - final int firstVisiblePosition = mListView.getFirstVisiblePosition(); + final int firstVisiblePosition = listView.getFirstVisiblePosition(); final AnimatorSet animSet = new AnimatorSet(); final ArrayList<Animator> animators = new ArrayList<Animator>(); - for (int i = 0; i < mListView.getChildCount(); i++) { - final View child = mListView.getChildAt(i); + for (int i = 0; i < listView.getChildCount(); i++) { + final View child = listView.getChildAt(i); int position = firstVisiblePosition + i; // Since we are getting the position from mListView and then querying // mContactTileAdapter, its very possible that things are out of sync // and we might index out of bounds. Let's make sure that this doesn't happen. - if (!mContactTileAdapter.isIndexInBound(position)) { + if (!contactTileAdapter.isIndexInBound(position)) { continue; } - final long itemId = mContactTileAdapter.getItemId(position); + final long itemId = contactTileAdapter.getItemId(position); if (containsId(idsInPlace, itemId)) { animators.add(ObjectAnimator.ofFloat(child, "alpha", 0.0f, 1.0f)); break; } else { - Integer startTop = mItemIdTopMap.get(itemId); - Integer startLeft = mItemIdLeftMap.get(itemId); + Integer startTop = itemIdTopMap.get(itemId); + Integer startLeft = itemIdLeftMap.get(itemId); final int top = child.getTop(); final int left = child.getLeft(); int deltaX = 0; @@ -367,12 +367,12 @@ public class OldSpeedDialFragment extends Fragment } if (animators.size() > 0) { - animSet.setDuration(mAnimationDuration).playTogether(animators); + animSet.setDuration(animationDuration).playTogether(animators); animSet.start(); } - mItemIdTopMap.clear(); - mItemIdLeftMap.clear(); + itemIdTopMap.clear(); + itemIdLeftMap.clear(); } }); } @@ -451,8 +451,8 @@ public class OldSpeedDialFragment extends Fragment if (DEBUG) { LogUtil.d("ContactTileLoaderListener.onLoadFinished", null); } - mContactTileAdapter.setContactCursor(data); - setEmptyViewVisibility(mContactTileAdapter.getCount() == 0); + contactTileAdapter.setContactCursor(data); + setEmptyViewVisibility(contactTileAdapter.getCount() == 0); } @Override @@ -468,16 +468,16 @@ public class OldSpeedDialFragment extends Fragment @Override public void onContactSelected( Uri contactUri, Rect targetRect, CallSpecificAppData callSpecificAppData) { - if (mPhoneNumberPickerActionListener != null) { - mPhoneNumberPickerActionListener.onPickDataUri( + if (phoneNumberPickerActionListener != null) { + phoneNumberPickerActionListener.onPickDataUri( contactUri, false /* isVideoCall */, callSpecificAppData); } } @Override public void onCallNumberDirectly(String phoneNumber, CallSpecificAppData callSpecificAppData) { - if (mPhoneNumberPickerActionListener != null) { - mPhoneNumberPickerActionListener.onPickPhoneNumber( + if (phoneNumberPickerActionListener != null) { + phoneNumberPickerActionListener.onPickPhoneNumber( phoneNumber, false /* isVideoCall */, callSpecificAppData); } } @@ -488,15 +488,15 @@ public class OldSpeedDialFragment extends Fragment @Override public void onScroll( AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { - if (mActivityScrollListener != null) { - mActivityScrollListener.onListFragmentScroll( + if (activityScrollListener != null) { + activityScrollListener.onListFragmentScroll( firstVisibleItem, visibleItemCount, totalItemCount); } } @Override public void onScrollStateChanged(AbsListView view, int scrollState) { - mActivityScrollListener.onListFragmentScrollStateChange(scrollState); + activityScrollListener.onListFragmentScrollStateChange(scrollState); } } } diff --git a/java/com/android/dialer/app/list/PhoneFavoriteListView.java b/java/com/android/dialer/app/list/PhoneFavoriteListView.java index f4f395ff0..ff867f9c0 100644 --- a/java/com/android/dialer/app/list/PhoneFavoriteListView.java +++ b/java/com/android/dialer/app/list/PhoneFavoriteListView.java @@ -38,58 +38,58 @@ public class PhoneFavoriteListView extends GridView implements OnDragDropListener, DragItemContainer { public static final String LOG_TAG = PhoneFavoriteListView.class.getSimpleName(); - final int[] mLocationOnScreen = new int[2]; + final int[] locationOnScreen = new int[2]; private static final long SCROLL_HANDLER_DELAY_MILLIS = 5; private static final int DRAG_SCROLL_PX_UNIT = 25; private static final float DRAG_SHADOW_ALPHA = 0.7f; /** - * {@link #mTopScrollBound} and {@link mBottomScrollBound} will be offseted to the top / bottom by + * {@link #topScrollBound} and {@link bottomScrollBound} will be offseted to the top / bottom by * {@link #getHeight} * {@link #BOUND_GAP_RATIO} pixels. */ private static final float BOUND_GAP_RATIO = 0.2f; - private float mTouchSlop; - private int mTopScrollBound; - private int mBottomScrollBound; - private int mLastDragY; - private Handler mScrollHandler; - private final Runnable mDragScroller = + private float touchSlop; + private int topScrollBound; + private int bottomScrollBound; + private int lastDragY; + private Handler scrollHandler; + private final Runnable dragScroller = new Runnable() { @Override public void run() { - if (mLastDragY <= mTopScrollBound) { + if (lastDragY <= topScrollBound) { smoothScrollBy(-DRAG_SCROLL_PX_UNIT, (int) SCROLL_HANDLER_DELAY_MILLIS); - } else if (mLastDragY >= mBottomScrollBound) { + } else if (lastDragY >= bottomScrollBound) { smoothScrollBy(DRAG_SCROLL_PX_UNIT, (int) SCROLL_HANDLER_DELAY_MILLIS); } - mScrollHandler.postDelayed(this, SCROLL_HANDLER_DELAY_MILLIS); + scrollHandler.postDelayed(this, SCROLL_HANDLER_DELAY_MILLIS); } }; - private boolean mIsDragScrollerRunning = false; - private int mTouchDownForDragStartY; - private Bitmap mDragShadowBitmap; - private ImageView mDragShadowOverlay; - private final AnimatorListenerAdapter mDragShadowOverAnimatorListener = + private boolean isDragScrollerRunning = false; + private int touchDownForDragStartY; + private Bitmap dragShadowBitmap; + private ImageView dragShadowOverlay; + private final AnimatorListenerAdapter dragShadowOverAnimatorListener = new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - if (mDragShadowBitmap != null) { - mDragShadowBitmap.recycle(); - mDragShadowBitmap = null; + if (dragShadowBitmap != null) { + dragShadowBitmap.recycle(); + dragShadowBitmap = null; } - mDragShadowOverlay.setVisibility(GONE); - mDragShadowOverlay.setImageBitmap(null); + dragShadowOverlay.setVisibility(GONE); + dragShadowOverlay.setImageBitmap(null); } }; - private View mDragShadowParent; - private int mAnimationDuration; + private View dragShadowParent; + private int animationDuration; // X and Y offsets inside the item from where the user grabbed to the // child's left coordinate. This is used to aid in the drawing of the drag shadow. - private int mTouchOffsetToChildLeft; - private int mTouchOffsetToChildTop; - private int mDragShadowLeft; - private int mDragShadowTop; - private DragDropController mDragDropController = new DragDropController(this); + private int touchOffsetToChildLeft; + private int touchOffsetToChildTop; + private int dragShadowLeft; + private int dragShadowTop; + private DragDropController dragDropController = new DragDropController(this); public PhoneFavoriteListView(Context context) { this(context, null); @@ -101,15 +101,15 @@ public class PhoneFavoriteListView extends GridView public PhoneFavoriteListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); - mAnimationDuration = context.getResources().getInteger(R.integer.fade_duration); - mTouchSlop = ViewConfiguration.get(context).getScaledPagingTouchSlop(); - mDragDropController.addOnDragDropListener(this); + animationDuration = context.getResources().getInteger(R.integer.fade_duration); + touchSlop = ViewConfiguration.get(context).getScaledPagingTouchSlop(); + dragDropController.addOnDragDropListener(this); } @Override protected void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); - mTouchSlop = ViewConfiguration.get(getContext()).getScaledPagingTouchSlop(); + touchSlop = ViewConfiguration.get(getContext()).getScaledPagingTouchSlop(); } /** @@ -119,7 +119,7 @@ public class PhoneFavoriteListView extends GridView @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { - mTouchDownForDragStartY = (int) ev.getY(); + touchDownForDragStartY = (int) ev.getY(); } return super.onInterceptTouchEvent(ev); @@ -138,38 +138,38 @@ public class PhoneFavoriteListView extends GridView // on a {@link PhoneFavoriteTileView} return false; } - if (!mDragDropController.handleDragStarted(this, eX, eY)) { + if (!dragDropController.handleDragStarted(this, eX, eY)) { return false; } break; } case DragEvent.ACTION_DRAG_LOCATION: - mLastDragY = eY; - mDragDropController.handleDragHovered(this, eX, eY); + lastDragY = eY; + dragDropController.handleDragHovered(this, eX, eY); // Kick off {@link #mScrollHandler} if it's not started yet. - if (!mIsDragScrollerRunning + if (!isDragScrollerRunning && // And if the distance traveled while dragging exceeds the touch slop - (Math.abs(mLastDragY - mTouchDownForDragStartY) >= 4 * mTouchSlop)) { - mIsDragScrollerRunning = true; + (Math.abs(lastDragY - touchDownForDragStartY) >= 4 * touchSlop)) { + isDragScrollerRunning = true; ensureScrollHandler(); - mScrollHandler.postDelayed(mDragScroller, SCROLL_HANDLER_DELAY_MILLIS); + scrollHandler.postDelayed(dragScroller, SCROLL_HANDLER_DELAY_MILLIS); } break; case DragEvent.ACTION_DRAG_ENTERED: final int boundGap = (int) (getHeight() * BOUND_GAP_RATIO); - mTopScrollBound = (getTop() + boundGap); - mBottomScrollBound = (getBottom() - boundGap); + topScrollBound = (getTop() + boundGap); + bottomScrollBound = (getBottom() - boundGap); break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: ensureScrollHandler(); - mScrollHandler.removeCallbacks(mDragScroller); - mIsDragScrollerRunning = false; + scrollHandler.removeCallbacks(dragScroller); + isDragScrollerRunning = false; // Either a successful drop or it's ended with out drop. if (action == DragEvent.ACTION_DROP || action == DragEvent.ACTION_DRAG_ENDED) { - mDragDropController.handleDragFinished(eX, eY, false); + dragDropController.handleDragFinished(eX, eY, false); } break; default: @@ -180,8 +180,8 @@ public class PhoneFavoriteListView extends GridView } public void setDragShadowOverlay(ImageView overlay) { - mDragShadowOverlay = overlay; - mDragShadowParent = (View) mDragShadowOverlay.getParent(); + dragShadowOverlay = overlay; + dragShadowParent = (View) dragShadowOverlay.getParent(); } /** Find the view under the pointer. */ @@ -201,73 +201,73 @@ public class PhoneFavoriteListView extends GridView } private void ensureScrollHandler() { - if (mScrollHandler == null) { - mScrollHandler = getHandler(); + if (scrollHandler == null) { + scrollHandler = getHandler(); } } public DragDropController getDragDropController() { - return mDragDropController; + return dragDropController; } @Override public void onDragStarted(int x, int y, PhoneFavoriteSquareTileView tileView) { - if (mDragShadowOverlay == null) { + if (dragShadowOverlay == null) { return; } - mDragShadowOverlay.clearAnimation(); - mDragShadowBitmap = createDraggedChildBitmap(tileView); - if (mDragShadowBitmap == null) { + dragShadowOverlay.clearAnimation(); + dragShadowBitmap = createDraggedChildBitmap(tileView); + if (dragShadowBitmap == null) { return; } - tileView.getLocationOnScreen(mLocationOnScreen); - mDragShadowLeft = mLocationOnScreen[0]; - mDragShadowTop = mLocationOnScreen[1]; + tileView.getLocationOnScreen(locationOnScreen); + dragShadowLeft = locationOnScreen[0]; + dragShadowTop = locationOnScreen[1]; // x and y are the coordinates of the on-screen touch event. Using these // and the on-screen location of the tileView, calculate the difference between // the position of the user's finger and the position of the tileView. These will // be used to offset the location of the drag shadow so that it appears that the // tileView is positioned directly under the user's finger. - mTouchOffsetToChildLeft = x - mDragShadowLeft; - mTouchOffsetToChildTop = y - mDragShadowTop; + touchOffsetToChildLeft = x - dragShadowLeft; + touchOffsetToChildTop = y - dragShadowTop; - mDragShadowParent.getLocationOnScreen(mLocationOnScreen); - mDragShadowLeft -= mLocationOnScreen[0]; - mDragShadowTop -= mLocationOnScreen[1]; + dragShadowParent.getLocationOnScreen(locationOnScreen); + dragShadowLeft -= locationOnScreen[0]; + dragShadowTop -= locationOnScreen[1]; - mDragShadowOverlay.setImageBitmap(mDragShadowBitmap); - mDragShadowOverlay.setVisibility(VISIBLE); - mDragShadowOverlay.setAlpha(DRAG_SHADOW_ALPHA); + dragShadowOverlay.setImageBitmap(dragShadowBitmap); + dragShadowOverlay.setVisibility(VISIBLE); + dragShadowOverlay.setAlpha(DRAG_SHADOW_ALPHA); - mDragShadowOverlay.setX(mDragShadowLeft); - mDragShadowOverlay.setY(mDragShadowTop); + dragShadowOverlay.setX(dragShadowLeft); + dragShadowOverlay.setY(dragShadowTop); } @Override public void onDragHovered(int x, int y, PhoneFavoriteSquareTileView tileView) { // Update the drag shadow location. - mDragShadowParent.getLocationOnScreen(mLocationOnScreen); - mDragShadowLeft = x - mTouchOffsetToChildLeft - mLocationOnScreen[0]; - mDragShadowTop = y - mTouchOffsetToChildTop - mLocationOnScreen[1]; + dragShadowParent.getLocationOnScreen(locationOnScreen); + dragShadowLeft = x - touchOffsetToChildLeft - locationOnScreen[0]; + dragShadowTop = y - touchOffsetToChildTop - locationOnScreen[1]; // Draw the drag shadow at its last known location if the drag shadow exists. - if (mDragShadowOverlay != null) { - mDragShadowOverlay.setX(mDragShadowLeft); - mDragShadowOverlay.setY(mDragShadowTop); + if (dragShadowOverlay != null) { + dragShadowOverlay.setX(dragShadowLeft); + dragShadowOverlay.setY(dragShadowTop); } } @Override public void onDragFinished(int x, int y) { - if (mDragShadowOverlay != null) { - mDragShadowOverlay.clearAnimation(); - mDragShadowOverlay + if (dragShadowOverlay != null) { + dragShadowOverlay.clearAnimation(); + dragShadowOverlay .animate() .alpha(0.0f) - .setDuration(mAnimationDuration) - .setListener(mDragShadowOverAnimatorListener) + .setDuration(animationDuration) + .setListener(dragShadowOverAnimatorListener) .start(); } } @@ -297,10 +297,10 @@ public class PhoneFavoriteListView extends GridView @Override public PhoneFavoriteSquareTileView getViewForLocation(int x, int y) { - getLocationOnScreen(mLocationOnScreen); + getLocationOnScreen(locationOnScreen); // Calculate the X and Y coordinates of the drag event relative to the view - final int viewX = x - mLocationOnScreen[0]; - final int viewY = y - mLocationOnScreen[1]; + final int viewX = x - locationOnScreen[0]; + final int viewY = y - locationOnScreen[1]; final View child = getViewAtPosition(viewX, viewY); if (!(child instanceof PhoneFavoriteSquareTileView)) { diff --git a/java/com/android/dialer/app/list/PhoneFavoriteSquareTileView.java b/java/com/android/dialer/app/list/PhoneFavoriteSquareTileView.java index 40f23ea6f..330a3614c 100644 --- a/java/com/android/dialer/app/list/PhoneFavoriteSquareTileView.java +++ b/java/com/android/dialer/app/list/PhoneFavoriteSquareTileView.java @@ -34,16 +34,16 @@ public class PhoneFavoriteSquareTileView extends PhoneFavoriteTileView { private static final String TAG = PhoneFavoriteSquareTileView.class.getSimpleName(); - private final float mHeightToWidthRatio; + private final float heightToWidthRatio; - private ImageButton mSecondaryButton; + private ImageButton secondaryButton; - private ContactEntry mContactEntry; + private ContactEntry contactEntry; public PhoneFavoriteSquareTileView(Context context, AttributeSet attrs) { super(context, attrs); - mHeightToWidthRatio = + heightToWidthRatio = getResources().getFraction(R.dimen.contact_tile_height_to_width_ratio, 1, 1); } @@ -54,7 +54,7 @@ public class PhoneFavoriteSquareTileView extends PhoneFavoriteTileView { nameView.setElegantTextHeight(false); final TextView phoneTypeView = (TextView) findViewById(R.id.contact_tile_phone_type); phoneTypeView.setElegantTextHeight(false); - mSecondaryButton = (ImageButton) findViewById(R.id.contact_tile_secondary_button); + secondaryButton = (ImageButton) findViewById(R.id.contact_tile_secondary_button); } @Override @@ -85,7 +85,7 @@ public class PhoneFavoriteSquareTileView extends PhoneFavoriteTileView { public void loadFromContact(ContactEntry entry) { super.loadFromContact(entry); if (entry != null) { - mSecondaryButton.setOnClickListener( + secondaryButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { @@ -95,13 +95,13 @@ public class PhoneFavoriteSquareTileView extends PhoneFavoriteTileView { } }); } - mContactEntry = entry; + contactEntry = entry; } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { final int width = MeasureSpec.getSize(widthMeasureSpec); - final int height = (int) (mHeightToWidthRatio * width); + final int height = (int) (heightToWidthRatio * width); final int count = getChildCount(); for (int i = 0; i < count; i++) { getChildAt(i) @@ -118,6 +118,6 @@ public class PhoneFavoriteSquareTileView extends PhoneFavoriteTileView { } public ContactEntry getContactEntry() { - return mContactEntry; + return contactEntry; } } diff --git a/java/com/android/dialer/app/list/PhoneFavoriteTileView.java b/java/com/android/dialer/app/list/PhoneFavoriteTileView.java index e0961be4b..3b27d3118 100644 --- a/java/com/android/dialer/app/list/PhoneFavoriteTileView.java +++ b/java/com/android/dialer/app/list/PhoneFavoriteTileView.java @@ -60,9 +60,10 @@ public abstract class PhoneFavoriteTileView extends ContactTileView { // don't crash with an NPE if the drag shadow is released in their bounds private static final ClipData EMPTY_CLIP_DATA = ClipData.newPlainText("", ""); /** View that contains the transparent shadow that is overlaid on top of the contact image. */ - private View mShadowOverlay; + private View shadowOverlay; /** Users' most frequent phone number. */ - private String mPhoneNumberString; + private String phoneNumberString; + private boolean isPinned; private boolean isStarred; private int position = -1; @@ -74,7 +75,7 @@ public abstract class PhoneFavoriteTileView extends ContactTileView { @Override protected void onFinishInflate() { super.onFinishInflate(); - mShadowOverlay = findViewById(R.id.shadow_overlay); + shadowOverlay = findViewById(R.id.shadow_overlay); setOnLongClickListener( new OnLongClickListener() { @@ -93,13 +94,13 @@ public abstract class PhoneFavoriteTileView extends ContactTileView { public void loadFromContact(ContactEntry entry) { super.loadFromContact(entry); // Set phone number to null in case we're reusing the view. - mPhoneNumberString = null; + phoneNumberString = null; isPinned = (entry.pinned != PinnedPositions.UNPINNED); isStarred = entry.isFavorite; if (entry != null) { sendViewNotification(getContext(), entry.lookupUri); // Grab the phone-number to call directly. See {@link onClick()}. - mPhoneNumberString = entry.phoneNumber; + phoneNumberString = entry.phoneNumber; // If this is a blank entry, don't show anything. For this to truly look like an empty row // the entire ContactTileRow needs to be hidden. @@ -141,7 +142,7 @@ public abstract class PhoneFavoriteTileView extends ContactTileView { callSpecificAppData.addSpeedDialContactType(SpeedDialContactType.Type.PINNED_CONTACT); } - if (TextUtils.isEmpty(mPhoneNumberString)) { + if (TextUtils.isEmpty(phoneNumberString)) { // Don't set performance report now, since user may spend some time on picking a number // Copy "superclass" implementation @@ -156,7 +157,7 @@ public abstract class PhoneFavoriteTileView extends ContactTileView { // call them at the number that you usually talk to them // at (i.e. the one displayed in the UI), regardless of // whether that's their default number. - mListener.onCallNumberDirectly(mPhoneNumberString, callSpecificAppData.build()); + mListener.onCallNumberDirectly(phoneNumberString, callSpecificAppData.build()); } } }; @@ -176,8 +177,8 @@ public abstract class PhoneFavoriteTileView extends ContactTileView { @Override protected void configureViewForImage(boolean isDefaultImage) { // Hide the shadow overlay if the image is a default image (i.e. colored letter tile) - if (mShadowOverlay != null) { - mShadowOverlay.setVisibility(isDefaultImage ? View.GONE : View.VISIBLE); + if (shadowOverlay != null) { + shadowOverlay.setVisibility(isDefaultImage ? View.GONE : View.VISIBLE); } } diff --git a/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java b/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java index cd5843c85..ed64f7a52 100644 --- a/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java +++ b/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java @@ -68,17 +68,17 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop */ private static final int TILES_SOFT_LIMIT = 20; /** Contact data stored in cache. This is used to populate the associated view. */ - private ArrayList<ContactEntry> mContactEntries = null; + private ArrayList<ContactEntry> contactEntries = null; - private int mNumFrequents; - private int mNumStarred; + private int numFrequents; + private int numStarred; - private ContactTileView.Listener mListener; - private OnDataSetChangedForAnimationListener mDataSetChangedListener; - private Context mContext; - private Resources mResources; - private ContactsPreferences mContactsPreferences; - private final Comparator<ContactEntry> mContactEntryComparator = + private ContactTileView.Listener listener; + private OnDataSetChangedForAnimationListener dataSetChangedListener; + private Context context; + private Resources resources; + private ContactsPreferences contactsPreferences; + private final Comparator<ContactEntry> contactEntryComparator = new Comparator<ContactEntry>() { @Override public int compare(ContactEntry lhs, ContactEntry rhs) { @@ -89,7 +89,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop } private String getPreferredSortName(ContactEntry contactEntry) { - if (mContactsPreferences.getSortOrder() == ContactsPreferences.SORT_ORDER_PRIMARY + if (contactsPreferences.getSortOrder() == ContactsPreferences.SORT_ORDER_PRIMARY || TextUtils.isEmpty(contactEntry.nameAlternative)) { return contactEntry.namePrimary; } @@ -97,36 +97,36 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop } }; /** Back up of the temporarily removed Contact during dragging. */ - private ContactEntry mDraggedEntry = null; + private ContactEntry draggedEntry = null; /** Position of the temporarily removed contact in the cache. */ - private int mDraggedEntryIndex = -1; + private int draggedEntryIndex = -1; /** New position of the temporarily removed contact in the cache. */ - private int mDropEntryIndex = -1; + private int dropEntryIndex = -1; /** New position of the temporarily entered contact in the cache. */ - private int mDragEnteredEntryIndex = -1; + private int dragEnteredEntryIndex = -1; - private boolean mAwaitingRemove = false; - private boolean mDelayCursorUpdates = false; - private ContactPhotoManager mPhotoManager; + private boolean awaitingRemove = false; + private boolean delayCursorUpdates = false; + private ContactPhotoManager photoManager; /** Indicates whether a drag is in process. */ - private boolean mInDragging = false; + private boolean inDragging = false; public PhoneFavoritesTileAdapter( Context context, ContactTileView.Listener listener, OnDataSetChangedForAnimationListener dataSetChangedListener) { - mDataSetChangedListener = dataSetChangedListener; - mListener = listener; - mContext = context; - mResources = context.getResources(); - mContactsPreferences = new ContactsPreferences(mContext); - mNumFrequents = 0; - mContactEntries = new ArrayList<>(); + this.dataSetChangedListener = dataSetChangedListener; + this.listener = listener; + this.context = context; + resources = context.getResources(); + contactsPreferences = new ContactsPreferences(this.context); + numFrequents = 0; + contactEntries = new ArrayList<>(); } void setPhotoLoader(ContactPhotoManager photoLoader) { - mPhotoManager = photoLoader; + photoManager = photoLoader; } /** @@ -135,13 +135,13 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop * @param inDragging Boolean variable indicating whether there is a drag in process. */ private void setInDragging(boolean inDragging) { - mDelayCursorUpdates = inDragging; - mInDragging = inDragging; + delayCursorUpdates = inDragging; + this.inDragging = inDragging; } void refreshContactsPreferences() { - mContactsPreferences.refreshValue(ContactsPreferences.DISPLAY_ORDER_KEY); - mContactsPreferences.refreshValue(ContactsPreferences.SORT_ORDER_KEY); + contactsPreferences.refreshValue(ContactsPreferences.DISPLAY_ORDER_KEY); + contactsPreferences.refreshValue(ContactsPreferences.SORT_ORDER_KEY); } /** @@ -152,7 +152,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop * @param cursor The cursor to get number of frequents from. */ private void saveNumFrequentsFromCursor(Cursor cursor) { - mNumFrequents = cursor.getCount() - mNumStarred; + numFrequents = cursor.getCount() - numStarred; } /** @@ -161,10 +161,10 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop * <p>Else use {@link ContactTileLoaderFactory} */ void setContactCursor(Cursor cursor) { - if (!mDelayCursorUpdates && cursor != null && !cursor.isClosed()) { - mNumStarred = getNumStarredContacts(cursor); - if (mAwaitingRemove) { - mDataSetChangedListener.cacheOffsetsForDatasetChange(); + if (!delayCursorUpdates && cursor != null && !cursor.isClosed()) { + numStarred = getNumStarredContacts(cursor); + if (awaitingRemove) { + dataSetChangedListener.cacheOffsetsForDatasetChange(); } saveNumFrequentsFromCursor(cursor); @@ -172,7 +172,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop // cause a refresh of any views that rely on this data notifyDataSetChanged(); // about to start redraw - mDataSetChangedListener.onDataSetChangedForAnimation(); + dataSetChangedListener.onDataSetChangedForAnimation(); } } @@ -183,7 +183,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop * view. */ private void saveCursorToCache(Cursor cursor) { - mContactEntries.clear(); + contactEntries.clear(); if (cursor == null) { return; @@ -250,12 +250,12 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop contact.id = id; contact.namePrimary = - (!TextUtils.isEmpty(name)) ? name : mResources.getString(R.string.missing_name); + (!TextUtils.isEmpty(name)) ? name : resources.getString(R.string.missing_name); contact.nameAlternative = (!TextUtils.isEmpty(nameAlternative)) ? nameAlternative - : mResources.getString(R.string.missing_name); - contact.nameDisplayOrder = mContactsPreferences.getDisplayOrder(); + : resources.getString(R.string.missing_name); + contact.nameDisplayOrder = contactsPreferences.getDisplayOrder(); contact.photoUri = (photoUri != null ? Uri.parse(photoUri) : null); contact.lookupKey = lookupKey; contact.lookupUri = @@ -268,11 +268,11 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop final int phoneNumberType = cursor.getInt(phoneTypeColumn); final String phoneNumberCustomLabel = cursor.getString(phoneLabelColumn); contact.phoneLabel = - (String) Phone.getTypeLabel(mResources, phoneNumberType, phoneNumberCustomLabel); + (String) Phone.getTypeLabel(resources, phoneNumberType, phoneNumberCustomLabel); contact.phoneNumber = cursor.getString(phoneNumberColumn); contact.pinned = pinned; - mContactEntries.add(contact); + contactEntries.add(contact); // Set counts for logging if (isStarred) { @@ -296,23 +296,23 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop } while (cursor.moveToNext()); } - mAwaitingRemove = false; + awaitingRemove = false; - arrangeContactsByPinnedPosition(mContactEntries); + arrangeContactsByPinnedPosition(contactEntries); - ShortcutRefresher.refresh(mContext, mContactEntries); + ShortcutRefresher.refresh(context, contactEntries); notifyDataSetChanged(); - Duo duo = DuoComponent.get(mContext).getDuo(); - for (ContactEntry contact : mContactEntries) { + Duo duo = DuoComponent.get(context).getDuo(); + for (ContactEntry contact : contactEntries) { if (contact.phoneNumber == null) { multipleNumbersContactsCount++; - } else if (duo.isReachable(mContext, contact.phoneNumber)) { + } else if (duo.isReachable(context, contact.phoneNumber)) { lightbringerReachableContactsCount++; } } - Logger.get(mContext) + Logger.get(context) .logSpeedDialContactComposition( counter, starredContactsCount, @@ -366,16 +366,16 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop /** Returns the number of frequents that will be displayed in the list. */ int getNumFrequents() { - return mNumFrequents; + return numFrequents; } @Override public int getCount() { - if (mContactEntries == null) { + if (contactEntries == null) { return 0; } - return mContactEntries.size(); + return contactEntries.size(); } /** @@ -384,7 +384,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop */ @Override public ContactEntry getItem(int position) { - return mContactEntries.get(position); + return contactEntries.get(position); } /** @@ -435,10 +435,10 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop if (tileView == null) { tileView = - (PhoneFavoriteTileView) View.inflate(mContext, R.layout.phone_favorite_tile_view, null); + (PhoneFavoriteTileView) View.inflate(context, R.layout.phone_favorite_tile_view, null); } - tileView.setPhotoManager(mPhotoManager); - tileView.setListener(mListener); + tileView.setPhotoManager(photoManager); + tileView.setListener(listener); tileView.loadFromContact(getItem(position)); tileView.setPosition(position); return tileView; @@ -462,37 +462,37 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop */ private void popContactEntry(int index) { if (isIndexInBound(index)) { - mDraggedEntry = mContactEntries.get(index); - mDraggedEntryIndex = index; - mDragEnteredEntryIndex = index; - markDropArea(mDragEnteredEntryIndex); + draggedEntry = contactEntries.get(index); + draggedEntryIndex = index; + dragEnteredEntryIndex = index; + markDropArea(dragEnteredEntryIndex); } } /** - * @param itemIndex Position of the contact in {@link #mContactEntries}. - * @return True if the given index is valid for {@link #mContactEntries}. + * @param itemIndex Position of the contact in {@link #contactEntries}. + * @return True if the given index is valid for {@link #contactEntries}. */ boolean isIndexInBound(int itemIndex) { - return itemIndex >= 0 && itemIndex < mContactEntries.size(); + return itemIndex >= 0 && itemIndex < contactEntries.size(); } /** - * Mark the tile as drop area by given the item index in {@link #mContactEntries}. + * Mark the tile as drop area by given the item index in {@link #contactEntries}. * - * @param itemIndex Position of the contact in {@link #mContactEntries}. + * @param itemIndex Position of the contact in {@link #contactEntries}. */ private void markDropArea(int itemIndex) { - if (mDraggedEntry != null - && isIndexInBound(mDragEnteredEntryIndex) + if (draggedEntry != null + && isIndexInBound(dragEnteredEntryIndex) && isIndexInBound(itemIndex)) { - mDataSetChangedListener.cacheOffsetsForDatasetChange(); + dataSetChangedListener.cacheOffsetsForDatasetChange(); // Remove the old placeholder item and place the new placeholder item. - mContactEntries.remove(mDragEnteredEntryIndex); - mDragEnteredEntryIndex = itemIndex; - mContactEntries.add(mDragEnteredEntryIndex, ContactEntry.BLANK_ENTRY); - ContactEntry.BLANK_ENTRY.id = mDraggedEntry.id; - mDataSetChangedListener.onDataSetChangedForAnimation(); + contactEntries.remove(dragEnteredEntryIndex); + dragEnteredEntryIndex = itemIndex; + contactEntries.add(dragEnteredEntryIndex, ContactEntry.BLANK_ENTRY); + ContactEntry.BLANK_ENTRY.id = draggedEntry.id; + dataSetChangedListener.onDataSetChangedForAnimation(); notifyDataSetChanged(); } } @@ -500,38 +500,38 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop /** Drops the temporarily removed contact to the desired location in the list. */ private void handleDrop() { boolean changed = false; - if (mDraggedEntry != null) { - if (isIndexInBound(mDragEnteredEntryIndex) && mDragEnteredEntryIndex != mDraggedEntryIndex) { + if (draggedEntry != null) { + if (isIndexInBound(dragEnteredEntryIndex) && dragEnteredEntryIndex != draggedEntryIndex) { // Don't add the ContactEntry here (to prevent a double animation from occuring). // When we receive a new cursor the list of contact entries will automatically be // populated with the dragged ContactEntry at the correct spot. - mDropEntryIndex = mDragEnteredEntryIndex; - mContactEntries.set(mDropEntryIndex, mDraggedEntry); - mDataSetChangedListener.cacheOffsetsForDatasetChange(); + dropEntryIndex = dragEnteredEntryIndex; + contactEntries.set(dropEntryIndex, draggedEntry); + dataSetChangedListener.cacheOffsetsForDatasetChange(); changed = true; - } else if (isIndexInBound(mDraggedEntryIndex)) { + } else if (isIndexInBound(draggedEntryIndex)) { // If {@link #mDragEnteredEntryIndex} is invalid, // falls back to the original position of the contact. - mContactEntries.remove(mDragEnteredEntryIndex); - mContactEntries.add(mDraggedEntryIndex, mDraggedEntry); - mDropEntryIndex = mDraggedEntryIndex; + contactEntries.remove(dragEnteredEntryIndex); + contactEntries.add(draggedEntryIndex, draggedEntry); + dropEntryIndex = draggedEntryIndex; notifyDataSetChanged(); } - if (changed && mDropEntryIndex < PIN_LIMIT) { + if (changed && dropEntryIndex < PIN_LIMIT) { final ArrayList<ContentProviderOperation> operations = - getReflowedPinningOperations(mContactEntries, mDraggedEntryIndex, mDropEntryIndex); + getReflowedPinningOperations(contactEntries, draggedEntryIndex, dropEntryIndex); if (!operations.isEmpty()) { // update the database here with the new pinned positions try { - mContext.getContentResolver().applyBatch(ContactsContract.AUTHORITY, operations); - Logger.get(mContext).logInteraction(InteractionEvent.Type.SPEED_DIAL_PIN_CONTACT); + context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, operations); + Logger.get(context).logInteraction(InteractionEvent.Type.SPEED_DIAL_PIN_CONTACT); } catch (RemoteException | OperationApplicationException e) { LogUtil.e(TAG, "Exception thrown when pinning contacts", e); } } } - mDraggedEntry = null; + draggedEntry = null; } } @@ -543,7 +543,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop final ContentValues values = new ContentValues(2); values.put(Contacts.STARRED, false); values.put(Contacts.PINNED, PinnedPositions.DEMOTED); - mContext.getContentResolver().update(contactUri, values, null, null); + context.getContentResolver().update(contactUri, values, null, null); } /** @@ -559,7 +559,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop @VisibleForTesting private void arrangeContactsByPinnedPosition(ArrayList<ContactEntry> toArrange) { final PriorityQueue<ContactEntry> pinnedQueue = - new PriorityQueue<>(PIN_LIMIT, mContactEntryComparator); + new PriorityQueue<>(PIN_LIMIT, contactEntryComparator); final List<ContactEntry> unpinnedContacts = new LinkedList<>(); @@ -643,7 +643,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop @Override public void onDragStarted(int x, int y, PhoneFavoriteSquareTileView view) { setInDragging(true); - final int itemIndex = mContactEntries.indexOf(view.getContactEntry()); + final int itemIndex = contactEntries.indexOf(view.getContactEntry()); popContactEntry(itemIndex); } @@ -654,9 +654,9 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop // anything here. return; } - final int itemIndex = mContactEntries.indexOf(view.getContactEntry()); - if (mInDragging - && mDragEnteredEntryIndex != itemIndex + final int itemIndex = contactEntries.indexOf(view.getContactEntry()); + if (inDragging + && dragEnteredEntryIndex != itemIndex && isIndexInBound(itemIndex) && itemIndex < PIN_LIMIT && itemIndex >= 0) { @@ -670,17 +670,17 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop // A contact has been dragged to the RemoveView in order to be unstarred, so simply wait // for the new contact cursor which will cause the UI to be refreshed without the unstarred // contact. - if (!mAwaitingRemove) { + if (!awaitingRemove) { handleDrop(); } } @Override public void onDroppedOnRemove() { - if (mDraggedEntry != null) { - unstarAndUnpinContact(mDraggedEntry.lookupUri); - mAwaitingRemove = true; - Logger.get(mContext).logInteraction(InteractionEvent.Type.SPEED_DIAL_REMOVE_CONTACT); + if (draggedEntry != null) { + unstarAndUnpinContact(draggedEntry.lookupUri); + awaitingRemove = true; + Logger.get(context).logInteraction(InteractionEvent.Type.SPEED_DIAL_REMOVE_CONTACT); } } diff --git a/java/com/android/dialer/app/list/RegularSearchFragment.java b/java/com/android/dialer/app/list/RegularSearchFragment.java index 48f77dcdc..d1927f08a 100644 --- a/java/com/android/dialer/app/list/RegularSearchFragment.java +++ b/java/com/android/dialer/app/list/RegularSearchFragment.java @@ -48,7 +48,7 @@ public class RegularSearchFragment extends SearchFragment public static final int PERMISSION_REQUEST_CODE = 1; private static final int SEARCH_DIRECTORY_RESULT_LIMIT = 5; - protected String mPermissionToRequest; + protected String permissionToRequest; private DialerExecutor<CachedContactInfo> addContactTask; @@ -104,7 +104,7 @@ public class RegularSearchFragment extends SearchFragment @Override protected void setupEmptyView() { - if (mEmptyView != null && getActivity() != null) { + if (emptyView != null && getActivity() != null) { final int imageResource; final int actionLabelResource; final int descriptionResource; @@ -114,20 +114,20 @@ public class RegularSearchFragment extends SearchFragment actionLabelResource = R.string.permission_single_turn_on; descriptionResource = R.string.permission_no_search; listener = this; - mPermissionToRequest = READ_CONTACTS; + permissionToRequest = READ_CONTACTS; } else { imageResource = EmptyContentView.NO_IMAGE; actionLabelResource = EmptyContentView.NO_LABEL; descriptionResource = EmptyContentView.NO_LABEL; listener = null; - mPermissionToRequest = null; + permissionToRequest = null; } - mEmptyView.setImage(imageResource); - mEmptyView.setActionLabel(actionLabelResource); - mEmptyView.setDescription(descriptionResource); + emptyView.setImage(imageResource); + emptyView.setActionLabel(actionLabelResource); + emptyView.setDescription(descriptionResource); if (listener != null) { - mEmptyView.setActionClickedListener(listener); + emptyView.setActionClickedListener(listener); } } } @@ -139,7 +139,7 @@ public class RegularSearchFragment extends SearchFragment return; } - if (READ_CONTACTS.equals(mPermissionToRequest)) { + if (READ_CONTACTS.equals(permissionToRequest)) { String[] deniedPermissions = PermissionsUtil.getPermissionsCurrentlyDenied( getContext(), PermissionsUtil.allContactsGroupPermissionsUsedInDialer); diff --git a/java/com/android/dialer/app/list/RegularSearchListAdapter.java b/java/com/android/dialer/app/list/RegularSearchListAdapter.java index 94544d2db..aee68ae58 100644 --- a/java/com/android/dialer/app/list/RegularSearchListAdapter.java +++ b/java/com/android/dialer/app/list/RegularSearchListAdapter.java @@ -31,7 +31,7 @@ import com.android.dialer.util.CallUtil; /** List adapter to display regular search results. */ public class RegularSearchListAdapter extends DialerPhoneNumberListAdapter { - protected boolean mIsQuerySipAddress; + protected boolean isQuerySipAddress; public RegularSearchListAdapter(Context context) { super(context); @@ -82,7 +82,7 @@ public class RegularSearchListAdapter extends DialerPhoneNumberListAdapter { @Override public String getFormattedQueryString() { - if (mIsQuerySipAddress) { + if (isQuerySipAddress) { // Return unnormalized SIP address return getQueryString(); } @@ -94,7 +94,7 @@ public class RegularSearchListAdapter extends DialerPhoneNumberListAdapter { // Don't show actions if the query string contains a letter. final boolean showNumberShortcuts = !TextUtils.isEmpty(getFormattedQueryString()) && hasDigitsInQueryString(); - mIsQuerySipAddress = PhoneNumberHelper.isUriNumber(queryString); + isQuerySipAddress = PhoneNumberHelper.isUriNumber(queryString); if (isChanged(showNumberShortcuts)) { notifyDataSetChanged(); @@ -104,7 +104,7 @@ public class RegularSearchListAdapter extends DialerPhoneNumberListAdapter { protected boolean isChanged(boolean showNumberShortcuts) { boolean changed = false; - changed |= setShortcutEnabled(SHORTCUT_DIRECT_CALL, showNumberShortcuts || mIsQuerySipAddress); + changed |= setShortcutEnabled(SHORTCUT_DIRECT_CALL, showNumberShortcuts || isQuerySipAddress); changed |= setShortcutEnabled(SHORTCUT_SEND_SMS_MESSAGE, showNumberShortcuts); changed |= setShortcutEnabled( diff --git a/java/com/android/dialer/app/list/RemoveView.java b/java/com/android/dialer/app/list/RemoveView.java index 244f2da24..ed133d45b 100644 --- a/java/com/android/dialer/app/list/RemoveView.java +++ b/java/com/android/dialer/app/list/RemoveView.java @@ -29,12 +29,12 @@ import com.android.dialer.app.R; public class RemoveView extends FrameLayout { - DragDropController mDragDropController; - TextView mRemoveText; - ImageView mRemoveIcon; - int mUnhighlightedColor; - int mHighlightedColor; - Drawable mRemoveDrawable; + DragDropController dragDropController; + TextView removeText; + ImageView removeIcon; + int unhighlightedColor; + int highlightedColor; + Drawable removeDrawable; public RemoveView(Context context) { super(context); @@ -50,16 +50,16 @@ public class RemoveView extends FrameLayout { @Override protected void onFinishInflate() { - mRemoveText = (TextView) findViewById(R.id.remove_view_text); - mRemoveIcon = (ImageView) findViewById(R.id.remove_view_icon); + removeText = (TextView) findViewById(R.id.remove_view_text); + removeIcon = (ImageView) findViewById(R.id.remove_view_icon); final Resources r = getResources(); - mUnhighlightedColor = r.getColor(R.color.remove_text_color); - mHighlightedColor = r.getColor(R.color.remove_highlighted_text_color); - mRemoveDrawable = r.getDrawable(R.drawable.ic_remove); + unhighlightedColor = r.getColor(R.color.remove_text_color); + highlightedColor = r.getColor(R.color.remove_highlighted_text_color); + removeDrawable = r.getDrawable(R.drawable.ic_remove); } public void setDragDropController(DragDropController controller) { - mDragDropController = controller; + dragDropController = controller; } @Override @@ -76,14 +76,14 @@ public class RemoveView extends FrameLayout { setAppearanceNormal(); break; case DragEvent.ACTION_DRAG_LOCATION: - if (mDragDropController != null) { - mDragDropController.handleDragHovered(this, (int) event.getX(), (int) event.getY()); + if (dragDropController != null) { + dragDropController.handleDragHovered(this, (int) event.getX(), (int) event.getY()); } break; case DragEvent.ACTION_DROP: sendAccessibilityEvent(AccessibilityEvent.TYPE_ANNOUNCEMENT); - if (mDragDropController != null) { - mDragDropController.handleDragFinished((int) event.getX(), (int) event.getY(), true); + if (dragDropController != null) { + dragDropController.handleDragFinished((int) event.getX(), (int) event.getY(), true); } setAppearanceNormal(); break; @@ -92,14 +92,14 @@ public class RemoveView extends FrameLayout { } private void setAppearanceNormal() { - mRemoveText.setTextColor(mUnhighlightedColor); - mRemoveIcon.setColorFilter(mUnhighlightedColor); + removeText.setTextColor(unhighlightedColor); + removeIcon.setColorFilter(unhighlightedColor); invalidate(); } private void setAppearanceHighlighted() { - mRemoveText.setTextColor(mHighlightedColor); - mRemoveIcon.setColorFilter(mHighlightedColor); + removeText.setTextColor(highlightedColor); + removeIcon.setColorFilter(highlightedColor); invalidate(); } } diff --git a/java/com/android/dialer/app/list/SearchFragment.java b/java/com/android/dialer/app/list/SearchFragment.java index 9330fc8c7..afb678969 100644 --- a/java/com/android/dialer/app/list/SearchFragment.java +++ b/java/com/android/dialer/app/list/SearchFragment.java @@ -51,28 +51,28 @@ import com.android.dialer.widget.EmptyContentView; public class SearchFragment extends PhoneNumberPickerFragment { - protected EmptyContentView mEmptyView; - private OnListFragmentScrolledListener mActivityScrollListener; - private View.OnTouchListener mActivityOnTouchListener; + 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 mAddToContactNumber; - private int mActionBarHeight; - private int mShadowHeight; - private int mPaddingTop; - private int mShowDialpadDuration; - private int mHideDialpadDuration; + 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 mSpacer; + private Space spacer; - private HostInterface mActivity; + private HostInterface activity; @Override public void onAttach(Activity activity) { @@ -84,7 +84,7 @@ public class SearchFragment extends PhoneNumberPickerFragment { setUseCallableUri(true); try { - mActivityScrollListener = (OnListFragmentScrolledListener) activity; + activityScrollListener = (OnListFragmentScrolledListener) activity; } catch (ClassCastException e) { LogUtil.v( "SearchFragment.onAttach", @@ -99,25 +99,25 @@ public class SearchFragment extends PhoneNumberPickerFragment { LogUtil.d("SearchFragment.onStart", ""); super.onStart(); - mActivity = (HostInterface) getActivity(); + activity = (HostInterface) getActivity(); final Resources res = getResources(); - mActionBarHeight = mActivity.getActionBarHeight(); - mShadowHeight = res.getDrawable(R.drawable.search_shadow).getIntrinsicHeight(); - mPaddingTop = res.getDimensionPixelSize(R.dimen.search_list_padding_top); - mShowDialpadDuration = res.getInteger(R.integer.dialpad_slide_in_duration); - mHideDialpadDuration = res.getInteger(R.integer.dialpad_slide_out_duration); + 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 (mEmptyView == null) { + if (emptyView == null) { if (this instanceof SmartDialSearchFragment) { - mEmptyView = new DialpadSearchEmptyContentView(getActivity()); + emptyView = new DialpadSearchEmptyContentView(getActivity()); } else { - mEmptyView = new EmptyContentView(getActivity()); + emptyView = new EmptyContentView(getActivity()); } - ((ViewGroup) getListView().getParent()).addView(mEmptyView); - getListView().setEmptyView(mEmptyView); + ((ViewGroup) getListView().getParent()).addView(emptyView); + getListView().setEmptyView(emptyView); setupEmptyView(); } @@ -133,8 +133,8 @@ public class SearchFragment extends PhoneNumberPickerFragment { new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { - if (mActivityScrollListener != null) { - mActivityScrollListener.onListFragmentScrollStateChange(scrollState); + if (activityScrollListener != null) { + activityScrollListener.onListFragmentScrollStateChange(scrollState); } } @@ -142,8 +142,8 @@ public class SearchFragment extends PhoneNumberPickerFragment { public void onScroll( AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {} }); - if (mActivityOnTouchListener != null) { - listView.setOnTouchListener(mActivityOnTouchListener); + if (activityOnTouchListener != null) { + listView.setOnTouchListener(activityOnTouchListener); } updatePosition(false /* animate */); @@ -170,7 +170,7 @@ public class SearchFragment extends PhoneNumberPickerFragment { } public void setAddToContactNumber(String addToContactNumber) { - mAddToContactNumber = addToContactNumber; + this.addToContactNumber = addToContactNumber; } /** @@ -241,9 +241,9 @@ public class SearchFragment extends PhoneNumberPickerFragment { .logImpression(DialerImpression.Type.CREATE_NEW_CONTACT_FROM_DIALPAD); } number = - TextUtils.isEmpty(mAddToContactNumber) + TextUtils.isEmpty(addToContactNumber) ? adapter.getFormattedQueryString() - : mAddToContactNumber; + : addToContactNumber; intent = IntentUtil.getNewContactIntent(number); DialerUtils.startActivityWithErrorToast(getActivity(), intent); break; @@ -253,24 +253,24 @@ public class SearchFragment extends PhoneNumberPickerFragment { .logImpression(DialerImpression.Type.ADD_TO_A_CONTACT_FROM_DIALPAD); } number = - TextUtils.isEmpty(mAddToContactNumber) + TextUtils.isEmpty(addToContactNumber) ? adapter.getFormattedQueryString() - : mAddToContactNumber; + : 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(mAddToContactNumber) + TextUtils.isEmpty(addToContactNumber) ? adapter.getFormattedQueryString() - : mAddToContactNumber; + : addToContactNumber; intent = IntentUtil.getSendSmsIntent(number); DialerUtils.startActivityWithErrorToast(getActivity(), intent); break; case DialerPhoneNumberListAdapter.SHORTCUT_MAKE_VIDEO_CALL: number = - TextUtils.isEmpty(mAddToContactNumber) ? adapter.getQueryString() : mAddToContactNumber; + TextUtils.isEmpty(addToContactNumber) ? adapter.getQueryString() : addToContactNumber; listener = getOnPhoneNumberPickerListener(); if (listener != null && !checkForProhibitedPhoneNumber(number)) { CallSpecificAppData callSpecificAppData = @@ -296,25 +296,25 @@ public class SearchFragment extends PhoneNumberPickerFragment { */ public void updatePosition(boolean animate) { LogUtil.d("SearchFragment.updatePosition", "animate: %b", animate); - if (mActivity == null) { + 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 = - mActivity.isDialpadShown() ? mActionBarHeight - mShadowHeight : -mShadowHeight; + activity.isDialpadShown() ? actionBarHeight - shadowHeight : -shadowHeight; int endTranslationValue = 0; // Prevents ListView from being translated down after a rotation when the ActionBar is up. - if (animate || mActivity.isActionBarShowing()) { - endTranslationValue = mActivity.isDialpadShown() ? 0 : mActionBarHeight - mShadowHeight; + 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 = mActivity.isDialpadShown(); + final boolean slideUp = activity.isDialpadShown(); Interpolator interpolator = slideUp ? AnimUtils.EASE_IN : AnimUtils.EASE_OUT; - int duration = slideUp ? mShowDialpadDuration : mHideDialpadDuration; + int duration = slideUp ? showDialpadDuration : hideDialpadDuration; getView().setTranslationY(startTranslationValue); getView() .animate() @@ -344,7 +344,7 @@ public class SearchFragment extends PhoneNumberPickerFragment { } // There is padding which should only be applied when the dialpad is not shown. - int paddingTop = mActivity.isDialpadShown() ? 0 : mPaddingTop; + int paddingTop = activity.isDialpadShown() ? 0 : this.paddingTop; final ListView listView = getListView(); listView.setPaddingRelative( listView.getPaddingStart(), @@ -354,21 +354,21 @@ public class SearchFragment extends PhoneNumberPickerFragment { } public void resizeListView() { - if (mSpacer == null) { + if (spacer == null) { return; } - int spacerHeight = mActivity.isDialpadShown() ? mActivity.getDialpadHeight() : 0; + int spacerHeight = activity.isDialpadShown() ? activity.getDialpadHeight() : 0; LogUtil.d( "SearchFragment.resizeListView", "spacerHeight: %d -> %d, isDialpadShown: %b, dialpad height: %d", - mSpacer.getHeight(), + spacer.getHeight(), spacerHeight, - mActivity.isDialpadShown(), - mActivity.getDialpadHeight()); - if (spacerHeight != mSpacer.getHeight()) { - final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mSpacer.getLayoutParams(); + activity.isDialpadShown(), + activity.getDialpadHeight()); + if (spacerHeight != spacer.getHeight()) { + final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) spacer.getLayoutParams(); lp.height = spacerHeight; - mSpacer.setLayoutParams(lp); + spacer.setLayoutParams(lp); } } @@ -395,7 +395,7 @@ public class SearchFragment extends PhoneNumberPickerFragment { } public void setOnTouchListener(View.OnTouchListener onTouchListener) { - mActivityOnTouchListener = onTouchListener; + activityOnTouchListener = onTouchListener; } @Override @@ -403,9 +403,9 @@ public class SearchFragment extends PhoneNumberPickerFragment { final LinearLayout parent = (LinearLayout) super.inflateView(inflater, container); final int orientation = getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_PORTRAIT) { - mSpacer = new Space(getActivity()); + spacer = new Space(getActivity()); parent.addView( - mSpacer, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0)); + spacer, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0)); } return parent; } diff --git a/java/com/android/dialer/app/list/SmartDialNumberListAdapter.java b/java/com/android/dialer/app/list/SmartDialNumberListAdapter.java index 1d2cda3ea..c84bff7fc 100644 --- a/java/com/android/dialer/app/list/SmartDialNumberListAdapter.java +++ b/java/com/android/dialer/app/list/SmartDialNumberListAdapter.java @@ -34,13 +34,13 @@ public class SmartDialNumberListAdapter extends DialerPhoneNumberListAdapter { private static final String TAG = SmartDialNumberListAdapter.class.getSimpleName(); private static final boolean DEBUG = false; - private final Context mContext; - @NonNull private final SmartDialNameMatcher mNameMatcher; + private final Context context; + @NonNull private final SmartDialNameMatcher nameMatcher; public SmartDialNumberListAdapter(Context context) { super(context); - mContext = context; - mNameMatcher = new SmartDialNameMatcher(""); + this.context = context; + nameMatcher = new SmartDialNameMatcher(""); setShortcutEnabled(SmartDialNumberListAdapter.SHORTCUT_DIRECT_CALL, false); if (DEBUG) { @@ -56,10 +56,10 @@ public class SmartDialNumberListAdapter extends DialerPhoneNumberListAdapter { if (getQueryString() == null) { loader.configureQuery(""); - mNameMatcher.setQuery(""); + nameMatcher.setQuery(""); } else { loader.configureQuery(getQueryString()); - mNameMatcher.setQuery(PhoneNumberUtils.normalizeNumber(getQueryString())); + nameMatcher.setQuery(PhoneNumberUtils.normalizeNumber(getQueryString())); } } @@ -73,8 +73,8 @@ public class SmartDialNumberListAdapter extends DialerPhoneNumberListAdapter { protected void setHighlight(ContactListItemView view, Cursor cursor) { view.clearHighlightSequences(); - if (mNameMatcher.matches(mContext, cursor.getString(PhoneQuery.DISPLAY_NAME))) { - final ArrayList<SmartDialMatchPosition> nameMatches = mNameMatcher.getMatchPositions(); + if (nameMatcher.matches(context, cursor.getString(PhoneQuery.DISPLAY_NAME))) { + final ArrayList<SmartDialMatchPosition> nameMatches = nameMatcher.getMatchPositions(); for (SmartDialMatchPosition match : nameMatches) { view.addNameHighlightSequence(match.start, match.end); if (DEBUG) { @@ -82,7 +82,7 @@ public class SmartDialNumberListAdapter extends DialerPhoneNumberListAdapter { TAG, cursor.getString(PhoneQuery.DISPLAY_NAME) + " " - + mNameMatcher.getQuery() + + nameMatcher.getQuery() + " " + String.valueOf(match.start)); } @@ -90,7 +90,7 @@ public class SmartDialNumberListAdapter extends DialerPhoneNumberListAdapter { } final SmartDialMatchPosition numberMatch = - mNameMatcher.matchesNumber(mContext, cursor.getString(PhoneQuery.PHONE_NUMBER)); + nameMatcher.matchesNumber(context, cursor.getString(PhoneQuery.PHONE_NUMBER)); if (numberMatch != null) { view.addNumberHighlightSequence(numberMatch.start, numberMatch.end); } @@ -113,6 +113,6 @@ public class SmartDialNumberListAdapter extends DialerPhoneNumberListAdapter { } public void setShowEmptyListForNullQuery(boolean show) { - mNameMatcher.setShouldMatchEmptyQuery(!show); + nameMatcher.setShouldMatchEmptyQuery(!show); } } diff --git a/java/com/android/dialer/app/list/SmartDialSearchFragment.java b/java/com/android/dialer/app/list/SmartDialSearchFragment.java index 1a7f19515..fdf0b5a56 100644 --- a/java/com/android/dialer/app/list/SmartDialSearchFragment.java +++ b/java/com/android/dialer/app/list/SmartDialSearchFragment.java @@ -43,7 +43,7 @@ public class SmartDialSearchFragment extends SearchFragment private static final int CALL_PHONE_PERMISSION_REQUEST_CODE = 1; - private final BroadcastReceiver mSmartDialUpdatedReceiver = + private final BroadcastReceiver smartDialUpdatedReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { @@ -87,16 +87,16 @@ public class SmartDialSearchFragment extends SearchFragment @Override protected void setupEmptyView() { - if (mEmptyView != null && getActivity() != null) { + if (emptyView != null && getActivity() != null) { if (!PermissionsUtil.hasPermission(getActivity(), CALL_PHONE)) { - mEmptyView.setImage(R.drawable.empty_contacts); - mEmptyView.setActionLabel(R.string.permission_single_turn_on); - mEmptyView.setDescription(R.string.permission_place_call); - mEmptyView.setActionClickedListener(this); + 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 { - mEmptyView.setImage(EmptyContentView.NO_IMAGE); - mEmptyView.setActionLabel(EmptyContentView.NO_LABEL); - mEmptyView.setDescription(EmptyContentView.NO_LABEL); + emptyView.setImage(EmptyContentView.NO_IMAGE); + emptyView.setActionLabel(EmptyContentView.NO_LABEL); + emptyView.setDescription(EmptyContentView.NO_LABEL); } } } @@ -109,7 +109,7 @@ public class SmartDialSearchFragment extends SearchFragment getActivity() .registerReceiver( - mSmartDialUpdatedReceiver, + smartDialUpdatedReceiver, new IntentFilter(DialerDatabaseHelper.ACTION_SMART_DIAL_UPDATED)); } @@ -119,7 +119,7 @@ public class SmartDialSearchFragment extends SearchFragment LogUtil.i("SmartDialSearchFragment.onStop", "unregistering smart dial update receiver"); - getActivity().unregisterReceiver(mSmartDialUpdatedReceiver); + getActivity().unregisterReceiver(smartDialUpdatedReceiver); } @Override @@ -155,7 +155,7 @@ public class SmartDialSearchFragment extends SearchFragment } public boolean isShowingPermissionRequest() { - return mEmptyView != null && mEmptyView.isShowingContent(); + return emptyView != null && emptyView.isShowingContent(); } @Override |