summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2013-08-08 10:24:27 -0700
committerYorke Lee <yorkelee@google.com>2013-08-08 11:54:47 -0700
commit8898cd0577d41cfa4e6acf785c9e904bd71fbdfd (patch)
treecf252b828f4ffb907effaa822f6e8df6a1f68f33 /src
parent243cc85743504c7ac444e988d4e8ab6cbe8a7716 (diff)
Removing and renaming classes from Dialer
* No code was changed, just either removed or renamed * Reshuffled a couple of ids around in dialpad_fragment to fix some compile time errors that somehow weren't caught before Change-Id: I9e2381edfb14b0940015deb8cbd94786a1242f43
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/DialtactsActivity.java26
-rw-r--r--src/com/android/dialer/SearchFragment.java (renamed from src/com/android/dialer/NewSearchFragment.java)4
-rw-r--r--src/com/android/dialer/calllog/CallLogActivity.java2
-rw-r--r--src/com/android/dialer/dialpad/DialpadFragment.java4
-rw-r--r--src/com/android/dialer/dialpad/SmartDialEntry.java44
-rw-r--r--src/com/android/dialer/dialpad/SmartDialLoaderTask.java107
-rw-r--r--src/com/android/dialer/dialpad/SmartDialTextView.java76
-rw-r--r--src/com/android/dialer/list/NewPhoneFavoriteMergedAdapter.java204
-rw-r--r--src/com/android/dialer/list/PhoneFavoriteFragment.java (renamed from src/com/android/dialer/list/NewPhoneFavoriteFragment.java)11
-rw-r--r--src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java301
10 files changed, 122 insertions, 657 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 89e5b5a6b..726c17687 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -71,7 +71,7 @@ import com.android.dialer.calllog.CallLogActivity;
import com.android.dialer.dialpad.DialpadFragment;
import com.android.dialer.dialpad.SmartDialNameMatcher;
import com.android.dialer.interactions.PhoneNumberInteraction;
-import com.android.dialer.list.NewPhoneFavoriteFragment;
+import com.android.dialer.list.PhoneFavoriteFragment;
import com.android.dialer.list.OnListFragmentScrolledListener;
import com.android.dialer.list.ShowAllContactsFragment;
import com.android.dialer.list.SmartDialSearchFragment;
@@ -88,7 +88,7 @@ import java.util.ArrayList;
public class DialtactsActivity extends TransactionSafeActivity implements View.OnClickListener,
DialpadFragment.OnDialpadQueryChangedListener, PopupMenu.OnMenuItemClickListener,
OnListFragmentScrolledListener,
- NewPhoneFavoriteFragment.OnPhoneFavoriteFragmentStartedListener,
+ PhoneFavoriteFragment.OnPhoneFavoriteFragmentStartedListener,
DialpadFragment.OnDialpadFragmentStartedListener {
private static final String TAG = "DialtactsActivity";
@@ -124,7 +124,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
/**
* The main fragment displaying the user's favorites and frequent contacts
*/
- private NewPhoneFavoriteFragment mPhoneFavoriteFragment;
+ private PhoneFavoriteFragment mPhoneFavoriteFragment;
/**
* Fragment containing the dialpad that slides into view
@@ -134,7 +134,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
/**
* Fragment for searching phone numbers using the alphanumeric keyboard.
*/
- private NewSearchFragment mRegularSearchFragment;
+ private SearchFragment mRegularSearchFragment;
/**
* Fragment for searching phone numbers using the dialpad.
@@ -246,15 +246,15 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
final Intent intent = getIntent();
fixIntent(intent);
- setContentView(R.layout.new_dialtacts_activity);
+ setContentView(R.layout.dialtacts_activity);
getActionBar().hide();
if (savedInstanceState == null) {
- mPhoneFavoriteFragment = new NewPhoneFavoriteFragment();
+ mPhoneFavoriteFragment = new PhoneFavoriteFragment();
mPhoneFavoriteFragment.setListener(mPhoneFavoriteListener);
- mRegularSearchFragment = new NewSearchFragment();
+ mRegularSearchFragment = new SearchFragment();
mSmartDialSearchFragment = new SmartDialSearchFragment();
mDialpadFragment = new DialpadFragment();
mShowAllContactsFragment = new ShowAllContactsFragment();
@@ -284,11 +284,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
protected void onResume() {
super.onResume();
final FragmentManager fm = getFragmentManager();
- mPhoneFavoriteFragment = (NewPhoneFavoriteFragment) fm.findFragmentByTag(
+ mPhoneFavoriteFragment = (PhoneFavoriteFragment) fm.findFragmentByTag(
TAG_FAVORITES_FRAGMENT);
mDialpadFragment = (DialpadFragment) fm.findFragmentByTag(TAG_DIALPAD_FRAGMENT);
- mRegularSearchFragment = (NewSearchFragment) fm.findFragmentByTag(
+ mRegularSearchFragment = (SearchFragment) fm.findFragmentByTag(
TAG_REGULAR_SEARCH_FRAGMENT);
mRegularSearchFragment.setOnPhoneNumberPickerActionListener(
mPhoneNumberPickerActionListener);
@@ -311,7 +311,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
@Override
public void onAttachFragment(Fragment fragment) {
- if (fragment instanceof DialpadFragment || fragment instanceof NewSearchFragment
+ if (fragment instanceof DialpadFragment || fragment instanceof SearchFragment
|| fragment instanceof SmartDialSearchFragment
|| fragment instanceof ShowAllContactsFragment) {
final FragmentTransaction transaction = getFragmentManager().beginTransaction();
@@ -369,7 +369,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
case R.id.overflow_menu: {
final PopupMenu popupMenu = new PopupMenu(DialtactsActivity.this, view);
final Menu menu = popupMenu.getMenu();
- popupMenu.inflate(R.menu.dialtacts_options_new);
+ popupMenu.inflate(R.menu.dialtacts_options);
popupMenu.setOnMenuItemClickListener(this);
popupMenu.show();
break;
@@ -704,8 +704,8 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
}
}
- private final NewPhoneFavoriteFragment.Listener mPhoneFavoriteListener =
- new NewPhoneFavoriteFragment.Listener() {
+ private final PhoneFavoriteFragment.Listener mPhoneFavoriteListener =
+ new PhoneFavoriteFragment.Listener() {
@Override
public void onContactSelected(Uri contactUri) {
PhoneNumberInteraction.startInteractionForPhoneCall(
diff --git a/src/com/android/dialer/NewSearchFragment.java b/src/com/android/dialer/SearchFragment.java
index e8e40d6aa..54d29d43f 100644
--- a/src/com/android/dialer/NewSearchFragment.java
+++ b/src/com/android/dialer/SearchFragment.java
@@ -25,11 +25,11 @@ import com.android.contacts.common.list.ContactListItemView;
import com.android.contacts.common.list.PhoneNumberPickerFragment;
import com.android.dialer.list.OnListFragmentScrolledListener;
-public class NewSearchFragment extends PhoneNumberPickerFragment {
+public class SearchFragment extends PhoneNumberPickerFragment {
private OnListFragmentScrolledListener mActivityScrollListener;
- public NewSearchFragment() {
+ public SearchFragment() {
setDirectorySearchEnabled(true);
}
diff --git a/src/com/android/dialer/calllog/CallLogActivity.java b/src/com/android/dialer/calllog/CallLogActivity.java
index 39909a1f8..662614f95 100644
--- a/src/com/android/dialer/calllog/CallLogActivity.java
+++ b/src/com/android/dialer/calllog/CallLogActivity.java
@@ -151,7 +151,7 @@ public class CallLogActivity extends Activity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
final MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.call_log_options_new, menu);
+ inflater.inflate(R.menu.call_log_options, menu);
return true;
}
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java
index 76cca3362..3052c67f0 100644
--- a/src/com/android/dialer/dialpad/DialpadFragment.java
+++ b/src/com/android/dialer/dialpad/DialpadFragment.java
@@ -346,7 +346,7 @@ public class DialpadFragment extends Fragment
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
- final View fragmentView = inflater.inflate(R.layout.new_dialpad_fragment, container,
+ final View fragmentView = inflater.inflate(R.layout.dialpad_fragment, container,
false);
fragmentView.buildLayer();
@@ -938,7 +938,7 @@ public class DialpadFragment extends Fragment
case R.id.overflow_menu_on_dialpad: {
final PopupMenu popupMenu = new PopupMenu(getActivity(), view);
final Menu menu = popupMenu.getMenu();
- popupMenu.inflate(R.menu.dialpad_options_new);
+ popupMenu.inflate(R.menu.dialpad_options);
popupMenu.setOnMenuItemClickListener(this);
setupMenuItems(menu);
popupMenu.show();
diff --git a/src/com/android/dialer/dialpad/SmartDialEntry.java b/src/com/android/dialer/dialpad/SmartDialEntry.java
deleted file mode 100644
index 9ff491293..000000000
--- a/src/com/android/dialer/dialpad/SmartDialEntry.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.dialer.dialpad;
-
-import android.net.Uri;
-
-import java.util.ArrayList;
-
-public class SmartDialEntry {
- /** Display name for the contact. */
- public final CharSequence displayName;
- public final Uri contactUri;
- public final CharSequence phoneNumber;
-
- public final ArrayList<SmartDialMatchPosition> matchPositions;
- public final SmartDialMatchPosition phoneNumberMatchPosition;
-
- public static final SmartDialEntry NULL = new SmartDialEntry("", Uri.EMPTY, "",
- new ArrayList<SmartDialMatchPosition>(), null);
-
- public SmartDialEntry(CharSequence displayName, Uri contactUri, CharSequence phoneNumber,
- ArrayList<SmartDialMatchPosition> matchPositions,
- SmartDialMatchPosition phoneNumberMatchPosition) {
- this.displayName = displayName;
- this.contactUri = contactUri;
- this.matchPositions = matchPositions;
- this.phoneNumber = phoneNumber;
- this.phoneNumberMatchPosition = phoneNumberMatchPosition;
- }
-}
diff --git a/src/com/android/dialer/dialpad/SmartDialLoaderTask.java b/src/com/android/dialer/dialpad/SmartDialLoaderTask.java
deleted file mode 100644
index 38a04ad8f..000000000
--- a/src/com/android/dialer/dialpad/SmartDialLoaderTask.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.dialer.dialpad;
-
-import android.content.Context;
-import android.os.AsyncTask;
-import android.provider.ContactsContract;
-import android.provider.ContactsContract.Contacts;
-import android.telephony.PhoneNumberUtils;
-
-import com.android.contacts.common.preference.ContactsPreferences;
-import com.android.contacts.common.util.StopWatch;
-import com.android.dialer.database.DialerDatabaseHelper;
-import com.android.dialer.database.DialerDatabaseHelper.ContactNumber;
-
-import com.google.common.collect.Lists;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This task searches through the provided cache to return the top 3 contacts(ranked by confidence)
- * that match the query, then passes it back to the {@link SmartDialLoaderCallback} through a
- * callback function.
- */
-public class SmartDialLoaderTask extends AsyncTask<String, Integer, List<SmartDialEntry>> {
- private final String TAG = SmartDialLoaderTask.class.getSimpleName();
-
- public interface SmartDialLoaderCallback {
- void setSmartDialAdapterEntries(List<SmartDialEntry> list, String query);
- }
-
- static private final boolean DEBUG = false;
-
- private final SmartDialLoaderCallback mCallback;
-
- private final DialerDatabaseHelper mDialerDatabaseHelper;
-
- private final String mQuery;
-
- private final SmartDialNameMatcher mNameMatcher;
-
- public SmartDialLoaderTask(SmartDialLoaderCallback callback, String query, Context context) {
- this.mCallback = callback;
- mDialerDatabaseHelper = DialerDatabaseHelper.getInstance(context);
- this.mQuery = query;
- this.mNameMatcher = new SmartDialNameMatcher(PhoneNumberUtils.normalizeNumber(query),
- SmartDialPrefix.getMap());
- }
-
- @Override
- protected List<SmartDialEntry> doInBackground(String... params) {
- return getContactMatches();
- }
-
- @Override
- protected void onPostExecute(List<SmartDialEntry> result) {
- if (mCallback != null) {
- mCallback.setSmartDialAdapterEntries(result, mQuery);
- }
- }
-
- /**
- * Loads top visible contacts with phone numbers and check if their display names match the
- * query.
- */
- private ArrayList<SmartDialEntry> getContactMatches() {
-
- final StopWatch stopWatch = DEBUG ? StopWatch.start("Start Match") : null;
-
- final ArrayList<ContactNumber> allMatches = mDialerDatabaseHelper.getLooseMatches(mQuery,
- mNameMatcher);
- if (DEBUG) {
- stopWatch.lap("Find matches");
- }
-
- final ArrayList<SmartDialEntry> candidates = Lists.newArrayList();
- for (ContactNumber contact : allMatches) {
- final boolean matches = mNameMatcher.matches(contact.displayName);
- candidates.add(new SmartDialEntry(
- contact.displayName,
- Contacts.getLookupUri(contact.id, contact.lookupKey),
- contact.phoneNumber,
- mNameMatcher.getMatchPositions(),
- mNameMatcher.matchesNumber(contact.phoneNumber, mNameMatcher.getQuery())
- ));
- }
- if (DEBUG) {
- stopWatch.stopAndLog(TAG + " Match Complete", 0);
- }
- return candidates;
- }
-}
diff --git a/src/com/android/dialer/dialpad/SmartDialTextView.java b/src/com/android/dialer/dialpad/SmartDialTextView.java
deleted file mode 100644
index 398f99ba5..000000000
--- a/src/com/android/dialer/dialpad/SmartDialTextView.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.dialer.dialpad;
-
-import android.content.Context;
-import android.graphics.Paint;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.widget.TextView;
-
-import com.android.dialer.R;
-
-public class SmartDialTextView extends TextView {
-
- private final float mPadding;
- private final float mExtraPadding;
-
- public SmartDialTextView(Context context) {
- this(context, null);
- }
-
- public SmartDialTextView(Context context, AttributeSet attrs) {
- super(context, attrs);
- mPadding = getResources().getDimension(R.dimen.smartdial_suggestions_padding);
- mExtraPadding = getResources().getDimension(R.dimen.smartdial_suggestions_extra_padding);
- }
-
- @Override
- protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
- super.onTextChanged(text, start, lengthBefore, lengthAfter);
- rescaleText(getWidth());
- }
-
- @Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- super.onSizeChanged(w, h, oldw, oldh);
- rescaleText(w);
- }
-
- private void rescaleText(int w) {
- if (w == 0) {
- return;
- }
- setTextScaleX(1);
- final Paint paint = getPaint();
- float width = w - 2 * mPadding - 2 * mExtraPadding;
-
- float ratio = width / paint.measureText(getText().toString());
- TextUtils.TruncateAt ellipsizeAt = null;
- if (ratio < 1.0f) {
- if (ratio < 0.8f) {
- // If the text is too big to fit even after scaling to 80%, just ellipsize it
- // instead.
- ellipsizeAt = TextUtils.TruncateAt.END;
- setTextScaleX(0.8f);
- } else {
- setTextScaleX(ratio);
- }
- }
- setEllipsize(ellipsizeAt);
- }
-}
diff --git a/src/com/android/dialer/list/NewPhoneFavoriteMergedAdapter.java b/src/com/android/dialer/list/NewPhoneFavoriteMergedAdapter.java
deleted file mode 100644
index 3c3200407..000000000
--- a/src/com/android/dialer/list/NewPhoneFavoriteMergedAdapter.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc.
- * Licensed to The Android Open Source Project.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.dialer.list;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.database.DataSetObserver;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.FrameLayout;
-
-import com.android.dialer.R;
-import com.android.dialer.calllog.CallLogAdapter;
-
-/**
- * An adapter that combines items from {@link com.android.contacts.common.list.ContactTileAdapter}
- * and {@link com.android.dialer.calllog.CallLogAdapter} into a single list.
- */
-public class NewPhoneFavoriteMergedAdapter extends BaseAdapter {
-
- private class CustomDataSetObserver extends DataSetObserver {
- @Override
- public void onChanged() {
- notifyDataSetChanged();
- }
- }
-
- private static final String TAG = NewPhoneFavoriteMergedAdapter.class.getSimpleName();
-
- private final PhoneFavoritesTileAdapter mContactTileAdapter;
- private final CallLogAdapter mCallLogAdapter;
- private final View mLoadingView;
- private final View mShowAllContactsButton;
-
- private final int mCallLogPadding;
-
- private final Context mContext;
-
- private final DataSetObserver mObserver;
-
- public NewPhoneFavoriteMergedAdapter(Context context,
- PhoneFavoritesTileAdapter contactTileAdapter,
- View accountFilterHeaderContainer,
- CallLogAdapter callLogAdapter,
- View loadingView,
- View showAllContactsButton) {
- final Resources resources = context.getResources();
- mContext = context;
- mCallLogPadding = resources.getDimensionPixelSize(R.dimen.recent_call_log_item_padding);
- mContactTileAdapter = contactTileAdapter;
- mCallLogAdapter = callLogAdapter;
-
- mObserver = new CustomDataSetObserver();
- mContactTileAdapter.registerDataSetObserver(mObserver);
- mLoadingView = loadingView;
- mShowAllContactsButton = showAllContactsButton;
- }
-
- @Override
- public boolean isEmpty() {
- // This adapter will always contain at least the all contacts button
- return false;
- }
-
- @Override
- public int getCount() {
- return mContactTileAdapter.getCount() + mCallLogAdapter.getCount() + 1;
- }
-
- @Override
- public Object getItem(int position) {
- final int callLogAdapterCount = mCallLogAdapter.getCount();
-
- if (callLogAdapterCount > 0) {
- if (position < callLogAdapterCount) {
- return mCallLogAdapter.getItem(position);
- }
- // Set position to the position of the actual favorite contact in the favorites adapter
- position = getAdjustedFavoritePosition(position, callLogAdapterCount);
- }
- return mContactTileAdapter.getItem(position);
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public int getViewTypeCount() {
- return (mContactTileAdapter.getViewTypeCount() + mCallLogAdapter.getViewTypeCount() + 1);
- }
-
- @Override
- public int getItemViewType(int position) {
- final int callLogAdapterCount = mCallLogAdapter.getCount();
-
- if (position < callLogAdapterCount) {
- // View type of the call log adapter is the last view type of the contact tile adapter
- // + 1
- return mContactTileAdapter.getViewTypeCount();
- } else if (position < getCount() - 1) {
- return mContactTileAdapter.getItemViewType(
- getAdjustedFavoritePosition(position, callLogAdapterCount));
- } else {
- // View type of the show all contact button is the last view type of the contact tile
- // adapter + 2
- return mContactTileAdapter.getViewTypeCount() + 1;
- }
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- final int callLogAdapterCount = mCallLogAdapter.getCount();
-
- if (position == getCount() - 1) {
- return mShowAllContactsButton;
- }
-
- if (callLogAdapterCount > 0) {
- if (position == 0) {
- final FrameLayout wrapper;
- if (convertView == null) {
- wrapper = new FrameLayout(mContext);
- } else {
- wrapper = (FrameLayout) convertView;
- }
-
- // Special case wrapper view for the most recent call log item. This allows
- // us to create a card-like effect for the more recent call log item in
- // the PhoneFavoriteMergedAdapter, but keep the original look of the item in
- // the CallLogAdapter.
- final View view = mCallLogAdapter.getView(position, convertView == null ?
- null : wrapper.getChildAt(0), parent);
- wrapper.removeAllViews();
- view.setBackgroundResource(R.drawable.dialer_recent_card_bg);
-
- final FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
- FrameLayout.LayoutParams.WRAP_CONTENT,
- FrameLayout.LayoutParams.WRAP_CONTENT);
-
- params.setMarginsRelative(mCallLogPadding, mCallLogPadding, mCallLogPadding,
- mCallLogPadding);
- view.setLayoutParams(params);
- wrapper.addView(view);
-
- return wrapper;
- }
- // Set position to the position of the actual favorite contact in the
- // favorites adapter
- position = getAdjustedFavoritePosition(position, callLogAdapterCount);
- }
-
- // Favorites section
- final View view = mContactTileAdapter.getView(position, convertView, parent);
- if (position >= mContactTileAdapter.getMaxTiledRows()) {
- final FrameLayout frameLayout = (FrameLayout) view;
- final View child = frameLayout.getChildAt(0);
- FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
- FrameLayout.LayoutParams.WRAP_CONTENT,
- FrameLayout.LayoutParams.WRAP_CONTENT);
- child.setLayoutParams(params);
- }
- return view;
- }
-
- @Override
- public boolean areAllItemsEnabled() {
- // If "all" section is being loaded we'll show mLoadingView, which is not enabled.
- // Otherwise check the all the other components in the ListView and return appropriate
- // result.
- return mCallLogAdapter.areAllItemsEnabled() && mContactTileAdapter.areAllItemsEnabled();
- }
-
- @Override
- public boolean isEnabled(int position) {
- final int callLogAdapterCount = mCallLogAdapter.getCount();
- if (position < callLogAdapterCount) {
- return mCallLogAdapter.isEnabled(position);
- } else { // For favorites section
- return mContactTileAdapter.isEnabled(
- getAdjustedFavoritePosition(position, callLogAdapterCount));
- }
- }
-
- private int getAdjustedFavoritePosition(int position, int callLogAdapterCount) {
- return position - callLogAdapterCount;
- }
-}
diff --git a/src/com/android/dialer/list/NewPhoneFavoriteFragment.java b/src/com/android/dialer/list/PhoneFavoriteFragment.java
index 58dac2fb6..64a9b84d2 100644
--- a/src/com/android/dialer/list/NewPhoneFavoriteFragment.java
+++ b/src/com/android/dialer/list/PhoneFavoriteFragment.java
@@ -56,16 +56,15 @@ import com.android.dialer.calllog.CallLogQueryHandler;
* {@link com.android.contacts.common.list.PhoneNumberListAdapter} into one unified list using {@link PhoneFavoriteMergedAdapter}.
* A contact filter header is also inserted between those adapters' results.
*/
-public class NewPhoneFavoriteFragment extends Fragment implements OnItemClickListener,
+public class PhoneFavoriteFragment extends Fragment implements OnItemClickListener,
CallLogQueryHandler.Listener, CallLogAdapter.CallFetcher {
- private static final String TAG = NewPhoneFavoriteFragment.class.getSimpleName();
+ private static final String TAG = PhoneFavoriteFragment.class.getSimpleName();
private static final boolean DEBUG = false;
/**
* Used with LoaderManager.
*/
private static int LOADER_ID_CONTACT_TILE = 1;
- private static int LOADER_ID_ALL_CONTACTS = 2;
public interface OnPhoneFavoriteFragmentStartedListener {
public void onPhoneFavoriteFragmentStarted();
@@ -134,7 +133,7 @@ public class NewPhoneFavoriteFragment extends Fragment implements OnItemClickLis
private Listener mListener;
private OnListFragmentScrolledListener mActivityScrollListener;
- private NewPhoneFavoriteMergedAdapter mAdapter;
+ private PhoneFavoriteMergedAdapter mAdapter;
private PhoneFavoritesTileAdapter mContactTileAdapter;
private PhoneNumberListAdapter mAllContactsAdapter;
@@ -203,7 +202,7 @@ public class NewPhoneFavoriteFragment extends Fragment implements OnItemClickLis
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View listLayout = inflater.inflate(
- R.layout.new_phone_favorites_fragment, container, false);
+ R.layout.phone_favorites_fragment, container, false);
mListView = (ListView) listLayout.findViewById(R.id.contact_tile_list);
mListView.setItemsCanFocus(true);
@@ -229,7 +228,7 @@ public class NewPhoneFavoriteFragment extends Fragment implements OnItemClickLis
}
});
- mAdapter = new NewPhoneFavoriteMergedAdapter(getActivity(), mContactTileAdapter,
+ mAdapter = new PhoneFavoriteMergedAdapter(getActivity(), mContactTileAdapter,
mAccountFilterHeaderContainer, mCallLogAdapter, mLoadingView,
mShowAllContactsButton);
diff --git a/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java b/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java
index ba291a00f..0e5594ee5 100644
--- a/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java
+++ b/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java
@@ -23,19 +23,15 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.FrameLayout;
-import android.widget.SectionIndexer;
-import com.android.contacts.common.list.ContactEntryListAdapter;
-import com.android.contacts.common.list.ContactListItemView;
-import com.android.contacts.common.list.ContactTileAdapter;
import com.android.dialer.R;
+import com.android.dialer.calllog.CallLogAdapter;
/**
- * An adapter that combines items from {@link com.android.contacts.common.list.ContactTileAdapter} and
- * {@link com.android.contacts.common.list.ContactEntryListAdapter} into a single list. In between those two results,
- * an account filter header will be inserted.
+ * An adapter that combines items from {@link com.android.contacts.common.list.ContactTileAdapter}
+ * and {@link com.android.dialer.calllog.CallLogAdapter} into a single list.
*/
-public class PhoneFavoriteMergedAdapter extends BaseAdapter implements SectionIndexer {
+public class PhoneFavoriteMergedAdapter extends BaseAdapter {
private class CustomDataSetObserver extends DataSetObserver {
@Override
@@ -44,80 +40,60 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter implements SectionIn
}
}
- private final ContactTileAdapter mContactTileAdapter;
- private final ContactEntryListAdapter mContactEntryListAdapter;
- private final View mAccountFilterHeaderContainer;
+ private static final String TAG = PhoneFavoriteMergedAdapter.class.getSimpleName();
+
+ private final PhoneFavoritesTileAdapter mContactTileAdapter;
+ private final CallLogAdapter mCallLogAdapter;
private final View mLoadingView;
+ private final View mShowAllContactsButton;
- private final int mItemPaddingLeft;
- private final int mItemPaddingRight;
+ private final int mCallLogPadding;
- // Make frequent header consistent with account filter header.
- private final int mFrequentHeaderPaddingTop;
+ private final Context mContext;
private final DataSetObserver mObserver;
public PhoneFavoriteMergedAdapter(Context context,
- ContactTileAdapter contactTileAdapter,
+ PhoneFavoritesTileAdapter contactTileAdapter,
View accountFilterHeaderContainer,
- ContactEntryListAdapter contactEntryListAdapter,
- View loadingView) {
- Resources resources = context.getResources();
- mItemPaddingLeft = resources.getDimensionPixelSize(R.dimen.detail_item_side_margin);
- mItemPaddingRight = resources.getDimensionPixelSize(R.dimen.list_visible_scrollbar_padding);
- mFrequentHeaderPaddingTop = resources.getDimensionPixelSize(
- R.dimen.contact_browser_list_top_margin);
+ CallLogAdapter callLogAdapter,
+ View loadingView,
+ View showAllContactsButton) {
+ final Resources resources = context.getResources();
+ mContext = context;
+ mCallLogPadding = resources.getDimensionPixelSize(R.dimen.recent_call_log_item_padding);
mContactTileAdapter = contactTileAdapter;
- mContactEntryListAdapter = contactEntryListAdapter;
-
- mAccountFilterHeaderContainer = accountFilterHeaderContainer;
+ mCallLogAdapter = callLogAdapter;
mObserver = new CustomDataSetObserver();
mContactTileAdapter.registerDataSetObserver(mObserver);
- mContactEntryListAdapter.registerDataSetObserver(mObserver);
-
mLoadingView = loadingView;
+ mShowAllContactsButton = showAllContactsButton;
}
@Override
public boolean isEmpty() {
- // Cannot use the super's method here because we add extra rows in getCount() to account
- // for headers
- return mContactTileAdapter.getCount() + mContactEntryListAdapter.getCount() == 0;
+ // This adapter will always contain at least the all contacts button
+ return false;
}
@Override
public int getCount() {
- final int contactTileAdapterCount = mContactTileAdapter.getCount();
- final int contactEntryListAdapterCount = mContactEntryListAdapter.getCount();
- if (mContactEntryListAdapter.isLoading()) {
- // Hide "all" contacts during its being loaded. Instead show "loading" view.
- //
- // "+2" for mAccountFilterHeaderContainer and mLoadingView
- return contactTileAdapterCount + 2;
- } else {
- // "+1" for mAccountFilterHeaderContainer
- return contactTileAdapterCount + contactEntryListAdapterCount + 1;
- }
+ return mContactTileAdapter.getCount() + mCallLogAdapter.getCount() + 1;
}
@Override
public Object getItem(int position) {
- final int contactTileAdapterCount = mContactTileAdapter.getCount();
- final int contactEntryListAdapterCount = mContactEntryListAdapter.getCount();
- if (position < contactTileAdapterCount) { // For "tile" and "frequent" sections
- return mContactTileAdapter.getItem(position);
- } else if (position == contactTileAdapterCount) { // For "all" section's account header
- return mAccountFilterHeaderContainer;
- } else { // For "all" section
- if (mContactEntryListAdapter.isLoading()) { // "All" section is being loaded.
- return mLoadingView;
- } else {
- // "-1" for mAccountFilterHeaderContainer
- final int localPosition = position - contactTileAdapterCount - 1;
- return mContactTileAdapter.getItem(localPosition);
+ final int callLogAdapterCount = mCallLogAdapter.getCount();
+
+ if (callLogAdapterCount > 0) {
+ if (position < callLogAdapterCount) {
+ return mCallLogAdapter.getItem(position);
}
+ // Set position to the position of the actual favorite contact in the favorites adapter
+ position = getAdjustedFavoritePosition(position, callLogAdapterCount);
}
+ return mContactTileAdapter.getItem(position);
}
@Override
@@ -127,122 +103,80 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter implements SectionIn
@Override
public int getViewTypeCount() {
- // "+2" for mAccountFilterHeaderContainer and mLoadingView
- return (mContactTileAdapter.getViewTypeCount()
- + mContactEntryListAdapter.getViewTypeCount()
- + 2);
+ return (mContactTileAdapter.getViewTypeCount() + mCallLogAdapter.getViewTypeCount() + 1);
}
@Override
public int getItemViewType(int position) {
- final int contactTileAdapterCount = mContactTileAdapter.getCount();
- final int contactEntryListAdapterCount = mContactEntryListAdapter.getCount();
- // There should be four kinds of types that are usually used, and one more exceptional
- // type (IGNORE_ITEM_VIEW_TYPE), which sometimes comes from mContactTileAdapter.
- //
- // The four ordinary view types have the index equal to or more than 0, and less than
- // mContactTileAdapter.getViewTypeCount()+ mContactEntryListAdapter.getViewTypeCount() + 2.
- // (See also this class's getViewTypeCount())
- //
- // We have those values for:
- // - The view types mContactTileAdapter originally has
- // - The view types mContactEntryListAdapter originally has
- // - mAccountFilterHeaderContainer ("all" section's account header), and
- // - mLoadingView
- //
- // Those types should not be mixed, so we have a different range for each kinds of types:
- // - Types for mContactTileAdapter ("tile" and "frequent" sections)
- // They should have the index, >=0 and <mContactTileAdapter.getViewTypeCount()
- //
- // - Types for mContactEntryListAdapter ("all" sections)
- // They should have the index, >=mContactTileAdapter.getViewTypeCount() and
- // <(mContactTileAdapter.getViewTypeCount() + mContactEntryListAdapter.getViewTypeCount())
- //
- // - Type for "all" section's account header
- // It should have the exact index
- // mContactTileAdapter.getViewTypeCount()+ mContactEntryListAdapter.getViewTypeCount()
- //
- // - Type for "loading" view used during "all" section is being loaded.
- // It should have the exact index
- // mContactTileAdapter.getViewTypeCount()+ mContactEntryListAdapter.getViewTypeCount() + 1
- //
- // As an exception, IGNORE_ITEM_VIEW_TYPE (-1) will be remained as is, which will be used
- // by framework's Adapter implementation and thus should be left as is.
- if (position < contactTileAdapterCount) { // For "tile" and "frequent" sections
- return mContactTileAdapter.getItemViewType(position);
- } else if (position == contactTileAdapterCount) { // For "all" section's account header
- return mContactTileAdapter.getViewTypeCount()
- + mContactEntryListAdapter.getViewTypeCount();
- } else { // For "all" section
- if (mContactEntryListAdapter.isLoading()) { // "All" section is being loaded.
- return mContactTileAdapter.getViewTypeCount()
- + mContactEntryListAdapter.getViewTypeCount() + 1;
- } else {
- // "-1" for mAccountFilterHeaderContainer
- final int localPosition = position - contactTileAdapterCount - 1;
- final int type = mContactEntryListAdapter.getItemViewType(localPosition);
- // IGNORE_ITEM_VIEW_TYPE must be handled differently.
- return (type < 0) ? type : type + mContactTileAdapter.getViewTypeCount();
- }
+ final int callLogAdapterCount = mCallLogAdapter.getCount();
+
+ if (position < callLogAdapterCount) {
+ // View type of the call log adapter is the last view type of the contact tile adapter
+ // + 1
+ return mContactTileAdapter.getViewTypeCount();
+ } else if (position < getCount() - 1) {
+ return mContactTileAdapter.getItemViewType(
+ getAdjustedFavoritePosition(position, callLogAdapterCount));
+ } else {
+ // View type of the show all contact button is the last view type of the contact tile
+ // adapter + 2
+ return mContactTileAdapter.getViewTypeCount() + 1;
}
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
- final int contactTileAdapterCount = mContactTileAdapter.getCount();
- final int contactEntryListAdapterCount = mContactEntryListAdapter.getCount();
+ final int callLogAdapterCount = mCallLogAdapter.getCount();
+
+ if (position == getCount() - 1) {
+ return mShowAllContactsButton;
+ }
- // Obtain a View relevant for that position, and adjust its horizontal padding. Each
- // View has different implementation, so we use different way to control those padding.
- if (position < contactTileAdapterCount) { // For "tile" and "frequent" sections
- final View view = mContactTileAdapter.getView(position, convertView, parent);
- final int frequentHeaderPosition = mContactTileAdapter.getFrequentHeaderPosition();
- if (position < frequentHeaderPosition) { // "starred" contacts
- // No padding adjustment.
- } else if (position == frequentHeaderPosition) {
- view.setPadding(mItemPaddingLeft, mFrequentHeaderPaddingTop,
- mItemPaddingRight, view.getPaddingBottom());
- } else {
- // Views for "frequent" contacts use FrameLayout's margins instead of padding.
- final FrameLayout frameLayout = (FrameLayout) view;
- final View child = frameLayout.getChildAt(0);
- FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
+ if (callLogAdapterCount > 0) {
+ if (position == 0) {
+ final FrameLayout wrapper;
+ if (convertView == null) {
+ wrapper = new FrameLayout(mContext);
+ } else {
+ wrapper = (FrameLayout) convertView;
+ }
+
+ // Special case wrapper view for the most recent call log item. This allows
+ // us to create a card-like effect for the more recent call log item in
+ // the PhoneFavoriteMergedAdapter, but keep the original look of the item in
+ // the CallLogAdapter.
+ final View view = mCallLogAdapter.getView(position, convertView == null ?
+ null : wrapper.getChildAt(0), parent);
+ wrapper.removeAllViews();
+ view.setBackgroundResource(R.drawable.dialer_recent_card_bg);
+
+ final FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT);
- params.setMargins(mItemPaddingLeft, 0, mItemPaddingRight, 0);
- child.setLayoutParams(params);
- }
- return view;
- } else if (position == contactTileAdapterCount) { // For "all" section's account header
- mAccountFilterHeaderContainer.setPadding(mItemPaddingLeft,
- mAccountFilterHeaderContainer.getPaddingTop(),
- mItemPaddingRight,
- mAccountFilterHeaderContainer.getPaddingBottom());
- // Show a single "No Contacts" label under the "all" section account header
- // if no contacts are displayed.
- mAccountFilterHeaderContainer.findViewById(
- R.id.contact_list_all_empty).setVisibility(
- contactEntryListAdapterCount == 0 ? View.VISIBLE : View.GONE);
- return mAccountFilterHeaderContainer;
- } else { // For "all" section
- if (mContactEntryListAdapter.isLoading()) { // "All" section is being loaded.
- mLoadingView.setPadding(mItemPaddingLeft,
- mLoadingView.getPaddingTop(),
- mItemPaddingRight,
- mLoadingView.getPaddingBottom());
- return mLoadingView;
- } else {
- // "-1" for mAccountFilterHeaderContainer
- final int localPosition = position - contactTileAdapterCount - 1;
- final ContactListItemView itemView = (ContactListItemView)
- mContactEntryListAdapter.getView(localPosition, convertView, null);
- itemView.setPadding(mItemPaddingLeft, itemView.getPaddingTop(),
- mItemPaddingRight, itemView.getPaddingBottom());
- itemView.setSelectionBoundsHorizontalMargin(mItemPaddingLeft, mItemPaddingRight);
- return itemView;
+ params.setMarginsRelative(mCallLogPadding, mCallLogPadding, mCallLogPadding,
+ mCallLogPadding);
+ view.setLayoutParams(params);
+ wrapper.addView(view);
+
+ return wrapper;
}
+ // Set position to the position of the actual favorite contact in the
+ // favorites adapter
+ position = getAdjustedFavoritePosition(position, callLogAdapterCount);
+ }
+
+ // Favorites section
+ final View view = mContactTileAdapter.getView(position, convertView, parent);
+ if (position >= mContactTileAdapter.getMaxTiledRows()) {
+ final FrameLayout frameLayout = (FrameLayout) view;
+ final View child = frameLayout.getChildAt(0);
+ FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
+ FrameLayout.LayoutParams.WRAP_CONTENT,
+ FrameLayout.LayoutParams.WRAP_CONTENT);
+ child.setLayoutParams(params);
}
+ return view;
}
@Override
@@ -250,58 +184,21 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter implements SectionIn
// If "all" section is being loaded we'll show mLoadingView, which is not enabled.
// Otherwise check the all the other components in the ListView and return appropriate
// result.
- return !mContactEntryListAdapter.isLoading()
- && (mContactTileAdapter.areAllItemsEnabled()
- && mAccountFilterHeaderContainer.isEnabled()
- && mContactEntryListAdapter.areAllItemsEnabled());
+ return mCallLogAdapter.areAllItemsEnabled() && mContactTileAdapter.areAllItemsEnabled();
}
@Override
public boolean isEnabled(int position) {
- final int contactTileAdapterCount = mContactTileAdapter.getCount();
- final int contactEntryListAdapterCount = mContactEntryListAdapter.getCount();
- if (position < contactTileAdapterCount) { // For "tile" and "frequent" sections
- return mContactTileAdapter.isEnabled(position);
- } else if (position == contactTileAdapterCount) { // For "all" section's account header
- // This will be handled by View's onClick event instead of ListView's onItemClick event.
- return false;
- } else { // For "all" section
- if (mContactEntryListAdapter.isLoading()) { // "All" section is being loaded.
- return false;
- } else {
- // "-1" for mAccountFilterHeaderContainer
- final int localPosition = position - contactTileAdapterCount - 1;
- return mContactEntryListAdapter.isEnabled(localPosition);
- }
+ final int callLogAdapterCount = mCallLogAdapter.getCount();
+ if (position < callLogAdapterCount) {
+ return mCallLogAdapter.isEnabled(position);
+ } else { // For favorites section
+ return mContactTileAdapter.isEnabled(
+ getAdjustedFavoritePosition(position, callLogAdapterCount));
}
}
- @Override
- public int getPositionForSection(int sectionIndex) {
- final int contactTileAdapterCount = mContactTileAdapter.getCount();
- final int localPosition = mContactEntryListAdapter.getPositionForSection(sectionIndex);
- return contactTileAdapterCount + 1 + localPosition;
- }
-
- @Override
- public int getSectionForPosition(int position) {
- final int contactTileAdapterCount = mContactTileAdapter.getCount();
- if (position <= contactTileAdapterCount) {
- return 0;
- } else {
- // "-1" for mAccountFilterHeaderContainer
- final int localPosition = position - contactTileAdapterCount - 1;
- return mContactEntryListAdapter.getSectionForPosition(localPosition);
- }
- }
-
- @Override
- public Object[] getSections() {
- return mContactEntryListAdapter.getSections();
- }
-
- public boolean shouldShowFirstScroller(int firstVisibleItem) {
- final int contactTileAdapterCount = mContactTileAdapter.getCount();
- return firstVisibleItem > contactTileAdapterCount;
+ private int getAdjustedFavoritePosition(int position, int callLogAdapterCount) {
+ return position - callLogAdapterCount;
}
}