diff options
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/dialer/calllog/CallLogAdapter.java | 106 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/CallLogFragment.java | 2 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/CallLogQueryHandler.java | 15 | ||||
-rw-r--r-- | src/com/android/dialer/list/ListsFragment.java | 63 | ||||
-rw-r--r-- | src/com/android/dialerbind/ObjectFactory.java | 4 |
5 files changed, 31 insertions, 159 deletions
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 36cf71024..57efc0121 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -266,12 +266,6 @@ public class CallLogAdapter extends GroupingListAdapter /** Can be set to true by tests to disable processing of requests. */ private volatile boolean mRequestProcessingDisabled = false; - private boolean mIsCallLog = true; - - private View mBadgeContainer; - private ImageView mBadgeImageView; - private TextView mBadgeText; - private int mCallLogBackgroundColor; private int mExpandedBackgroundColor; private float mExpandedTranslationZ; @@ -353,13 +347,12 @@ public class CallLogAdapter extends GroupingListAdapter public CallLogAdapter(Context context, CallFetcher callFetcher, ContactInfoHelper contactInfoHelper, CallItemExpandedListener callItemExpandedListener, - OnReportButtonClickListener onReportButtonClickListener, boolean isCallLog) { + OnReportButtonClickListener onReportButtonClickListener) { super(context); mContext = context; mCallFetcher = callFetcher; mContactInfoHelper = contactInfoHelper; - mIsCallLog = isCallLog; mCallItemExpandedListener = callItemExpandedListener; mOnReportButtonClickListener = onReportButtonClickListener; @@ -659,17 +652,12 @@ public class CallLogAdapter extends GroupingListAdapter final long rowId = c.getLong(CallLogQuery.ID); views.rowId = rowId; - // For entries in the call log, check if the day group has changed and display a header - // if necessary. - if (mIsCallLog) { - int currentGroup = getDayGroupForCall(rowId); - int previousGroup = getPreviousDayGroup(c); - if (currentGroup != previousGroup) { - views.dayGroupHeader.setVisibility(View.VISIBLE); - views.dayGroupHeader.setText(getGroupDescription(currentGroup)); - } else { - views.dayGroupHeader.setVisibility(View.GONE); - } + // Check if the day group has changed and display a header if necessary. + int currentGroup = getDayGroupForCall(rowId); + int previousGroup = getPreviousDayGroup(c); + if (currentGroup != previousGroup) { + views.dayGroupHeader.setVisibility(View.VISIBLE); + views.dayGroupHeader.setText(getGroupDescription(currentGroup)); } else { views.dayGroupHeader.setVisibility(View.GONE); } @@ -689,33 +677,11 @@ public class CallLogAdapter extends GroupingListAdapter final boolean isVoicemailNumber = mPhoneNumberUtilsWrapper.isVoicemailNumber(accountHandle, number); - // Where binding and not in the call log, use default behaviour of invoking a call when - // tapping the primary view. - if (!mIsCallLog) { - views.primaryActionView.setOnClickListener(this.mActionListener); - - // Set return call intent, otherwise null. - if (PhoneNumberUtilsWrapper.canPlaceCallsTo(number, numberPresentation)) { - // Sets the primary action to call the number. - if (isVoicemailNumber) { - views.primaryActionView.setTag( - IntentProvider.getReturnVoicemailCallIntentProvider()); - } else { - views.primaryActionView.setTag( - IntentProvider.getReturnCallIntentProvider(number)); - } - } else { - // Number is not callable, so hide button. - views.primaryActionView.setTag(null); - } - } else { - // In the call log, expand/collapse an actions section for the call log entry when - // the primary view is tapped. - views.primaryActionView.setOnClickListener(this.mExpandCollapseListener); + // Expand/collapse an actions section for the call log entry when the primary view is tapped. + views.primaryActionView.setOnClickListener(this.mExpandCollapseListener); - // Note: Binding of the action buttons is done as required in configureActionViews - // when the user expands the actions ViewStub. - } + // Note: Binding of the action buttons is done as required in configureActionViews when the + // user expands the actions ViewStub. // Lookup contacts with this number NumberWithCountryIso numberCountryIso = new NumberWithCountryIso(number, countryIso); @@ -828,8 +794,6 @@ public class CallLogAdapter extends GroupingListAdapter mViewTreeObserver = callLogItemView.getViewTreeObserver(); mViewTreeObserver.addOnPreDrawListener(this); } - - bindBadge(callLogItemView, info, details, callType); } /** @@ -1073,54 +1037,6 @@ public class CallLogAdapter extends GroupingListAdapter mCallLogViewsHelper.setActionContentDescriptions(views); } - protected void bindBadge( - View view, final ContactInfo info, final PhoneCallDetails details, int callType) { - // Do not show badge in call log. - if (!mIsCallLog) { - final ViewStub stub = (ViewStub) view.findViewById(R.id.link_stub); - if (UriUtils.isEncodedContactUri(info.lookupUri)) { - if (stub != null) { - mBadgeContainer = stub.inflate(); - } else { - mBadgeContainer = view.findViewById(R.id.badge_container); - } - - mBadgeContainer.setVisibility(View.VISIBLE); - mBadgeImageView = (ImageView) mBadgeContainer.findViewById(R.id.badge_image); - mBadgeText = (TextView) mBadgeContainer.findViewById(R.id.badge_text); - - final View clickableArea = mBadgeContainer.findViewById(R.id.badge_link_container); - if (clickableArea != null) { - clickableArea.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - // If no lookup uri is provided, we need to rely on what information - // we have available; namely the phone number and name. - if (info.lookupUri == null) { - final Intent intent = - DialtactsActivity.getAddToContactIntent(details.name, - details.number, - details.numberType); - DialerUtils.startActivityWithErrorToast(mContext, intent, - R.string.add_contact_not_available); - } else { - addContactFromLookupUri(info.lookupUri); - } - } - }); - } - mBadgeImageView.setImageResource(R.drawable.ic_person_add_24dp); - mBadgeText.setText(R.string.recentCalls_addToContact); - } else { - // Hide badge if it was previously shown. - mBadgeContainer = view.findViewById(R.id.badge_container); - if (mBadgeContainer != null) { - mBadgeContainer.setVisibility(View.GONE); - } - } - } - } - /** Checks whether the contact info from the call log matches the one from the contacts db. */ private boolean callLogInfoMatches(ContactInfo callLogInfo, ContactInfo info) { // The call log only contains a subset of the fields in the contacts db. diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index 9c95d3ec8..34dd137fb 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -192,7 +192,7 @@ public class CallLogFragment extends ListFragment String currentCountryIso = GeoUtil.getCurrentCountryIso(getActivity()); mAdapter = ObjectFactory.newCallLogAdapter(getActivity(), this, - new ContactInfoHelper(getActivity(), currentCountryIso), this, this, true); + new ContactInfoHelper(getActivity(), currentCountryIso), this, this); setListAdapter(mAdapter); mCallLogQueryHandler = new CallLogQueryHandler(getActivity().getContentResolver(), this, mLogLimit); diff --git a/src/com/android/dialer/calllog/CallLogQueryHandler.java b/src/com/android/dialer/calllog/CallLogQueryHandler.java index dfc9c7834..761c8e08c 100644 --- a/src/com/android/dialer/calllog/CallLogQueryHandler.java +++ b/src/com/android/dialer/calllog/CallLogQueryHandler.java @@ -32,11 +32,13 @@ import android.os.Looper; import android.os.Message; import android.provider.CallLog.Calls; import android.provider.VoicemailContract.Status; +import android.provider.VoicemailContract.Voicemails; import android.util.Log; import com.android.common.io.MoreCloseables; import com.android.contacts.common.database.NoNullCursorAsyncQueryHandler; import com.android.dialer.voicemail.VoicemailStatusHelperImpl; + import com.google.common.collect.Lists; import java.lang.ref.WeakReference; @@ -140,15 +142,18 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { StringBuilder where = new StringBuilder(); List<String> selectionArgs = Lists.newArrayList(); + // Ignore voicemails marked as deleted + where.append(Voicemails.DELETED); + where.append(" = 0"); + if (newOnly) { + where.append(" AND "); where.append(Calls.NEW); where.append(" = 1"); } if (callType > CALL_TYPE_ALL) { - if (where.length() > 0) { - where.append(" AND "); - } + where.append(" AND "); // Add a clause to fetch only items of type voicemail. where.append(String.format("(%s = ?)", Calls.TYPE)); // Add a clause to fetch only items newer than the requested date @@ -156,9 +161,7 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { } if (newerThan > 0) { - if (where.length() > 0) { - where.append(" AND "); - } + where.append(" AND "); where.append(String.format("(%s > ?)", Calls.DATE)); selectionArgs.add(Long.toString(newerThan)); } diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java index 45b2f689d..0e558bfa4 100644 --- a/src/com/android/dialer/list/ListsFragment.java +++ b/src/com/android/dialer/list/ListsFragment.java @@ -24,9 +24,7 @@ import com.android.contacts.common.list.ViewPagerTabs; import com.android.contacts.commonbind.analytics.AnalyticsUtil; import com.android.dialer.DialtactsActivity; import com.android.dialer.R; -import com.android.dialer.calllog.CallLogAdapter; import com.android.dialer.calllog.CallLogFragment; -import com.android.dialer.calllog.CallLogQuery; import com.android.dialer.calllog.CallLogQueryHandler; import com.android.dialer.calllog.ContactInfoHelper; import com.android.dialer.util.DialerUtils; @@ -43,8 +41,7 @@ import java.util.ArrayList; * ViewPager containing the lists up above the search bar and pin it against the top of the * screen. */ -public class ListsFragment extends Fragment implements CallLogQueryHandler.Listener, - CallLogAdapter.CallFetcher, ViewPager.OnPageChangeListener { +public class ListsFragment extends Fragment implements ViewPager.OnPageChangeListener { private static final boolean DEBUG = DialtactsActivity.DEBUG; private static final String TAG = "ListsFragment"; @@ -80,9 +77,7 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste new ArrayList<OnPageChangeListener>(); private String[] mTabTitles; - - private CallLogAdapter mCallLogAdapter; - private CallLogQueryHandler mCallLogQueryHandler; + private int[] mTabIcons; /** * Call shortcuts older than this date (persisted in shared preferences) will not show up in @@ -156,17 +151,10 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste Trace.beginSection(TAG + " onCreate"); super.onCreate(savedInstanceState); - mCallLogQueryHandler = new CallLogQueryHandler(getActivity().getContentResolver(), - this, 1); Trace.beginSection(TAG + " getCurrentCountryIso"); final String currentCountryIso = GeoUtil.getCurrentCountryIso(getActivity()); Trace.endSection(); - Trace.beginSection(TAG + " create adapters"); - mCallLogAdapter = ObjectFactory.newCallLogAdapter(getActivity(), this, - new ContactInfoHelper(getActivity(), currentCountryIso), null, null, false); - - Trace.endSection(); Trace.endSection(); } @@ -178,8 +166,6 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste DialtactsActivity.SHARED_PREFS_NAME, Context.MODE_PRIVATE); mLastCallShortcutDate = prefs.getLong(KEY_LAST_DISMISSED_CALL_SHORTCUT_DATE, 0); mActionBar = getActivity().getActionBar(); - fetchCalls(); - mCallLogAdapter.setLoading(true); if (getUserVisibleHint()) { sendScreenViewForPosition(mViewPager.getCurrentItem()); } @@ -187,20 +173,6 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste } @Override - public void onPause() { - // Wipe the cache to refresh the call shortcut item. This is not that expensive because - // it only contains one item. - mCallLogAdapter.invalidateCache(); - super.onPause(); - } - - @Override - public void onDestroy() { - mCallLogAdapter.stopRequestProcessing(); - super.onDestroy(); - } - - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Trace.beginSection(TAG + " onCreateView"); @@ -220,7 +192,13 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste mTabTitles[TAB_INDEX_RECENTS] = getResources().getString(R.string.tab_recents); mTabTitles[TAB_INDEX_ALL_CONTACTS] = getResources().getString(R.string.tab_all_contacts); + mTabIcons = new int[TAB_INDEX_COUNT]; + mTabIcons[TAB_INDEX_SPEED_DIAL] = R.drawable.tab_speed_dial; + mTabIcons[TAB_INDEX_RECENTS] = R.drawable.tab_recents; + mTabIcons[TAB_INDEX_ALL_CONTACTS] = R.drawable.tab_contacts; + mViewPagerTabs = (ViewPagerTabs) parentView.findViewById(R.id.lists_pager_header); + mViewPagerTabs.setTabIcons(mTabIcons); mViewPagerTabs.setViewPager(mViewPager); addOnPageChangeListener(mViewPagerTabs); @@ -232,31 +210,6 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste return parentView; } - @Override - public void onVoicemailStatusFetched(Cursor statusCursor) { - // no-op - } - - @Override - public boolean onCallsFetched(Cursor cursor) { - mCallLogAdapter.setLoading(false); - - // Save the date of the most recent call log item - if (cursor != null && cursor.moveToFirst()) { - mCurrentCallShortcutDate = cursor.getLong(CallLogQuery.DATE); - } - - mCallLogAdapter.changeCursor(cursor); - - // Return true; took ownership of cursor - return true; - } - - @Override - public void fetchCalls() { - mCallLogQueryHandler.fetchCalls(CallLogQueryHandler.CALL_TYPE_ALL, mLastCallShortcutDate); - } - public void addOnPageChangeListener(OnPageChangeListener onPageChangeListener) { if (!mOnPageChangeListeners.contains(onPageChangeListener)) { mOnPageChangeListeners.add(onPageChangeListener); diff --git a/src/com/android/dialerbind/ObjectFactory.java b/src/com/android/dialerbind/ObjectFactory.java index 54a5821df..e5c39d078 100644 --- a/src/com/android/dialerbind/ObjectFactory.java +++ b/src/com/android/dialerbind/ObjectFactory.java @@ -48,9 +48,9 @@ public class ObjectFactory { public static CallLogAdapter newCallLogAdapter(Context context, CallFetcher callFetcher, ContactInfoHelper contactInfoHelper, CallItemExpandedListener callItemExpandedListener, - OnReportButtonClickListener onReportButtonClickListener, boolean isCallLog) { + OnReportButtonClickListener onReportButtonClickListener) { return new CallLogAdapter(context, callFetcher, contactInfoHelper, - callItemExpandedListener, onReportButtonClickListener, isCallLog); + callItemExpandedListener, onReportButtonClickListener); } public static DialogFragment getReportDialogFragment(String number) { |