From 73b51d5771b31c932a589abc9bb0fe64c52fe102 Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Fri, 8 Dec 2017 20:52:56 -0800 Subject: Implemented adding a new favorites contact flow NUI. This change consists of mainly 3 things: - Update contacts fragment to meet AddFavoriteActivity requirements - Implement AddFavoriteActivity - Passing the contact back to SpeedDialFragment Bug: 36841782 Test: SpeedDialIntegrationTest PiperOrigin-RevId: 178461265 Change-Id: Ib3a13eae311acf6ce10a94df4f2c95b9af120cff --- .../dialer/speeddial/SpeedDialFragment.java | 40 +++++++++------------- 1 file changed, 16 insertions(+), 24 deletions(-) (limited to 'java/com/android/dialer/speeddial/SpeedDialFragment.java') diff --git a/java/com/android/dialer/speeddial/SpeedDialFragment.java b/java/com/android/dialer/speeddial/SpeedDialFragment.java index 65e542cd4..08861dae9 100644 --- a/java/com/android/dialer/speeddial/SpeedDialFragment.java +++ b/java/com/android/dialer/speeddial/SpeedDialFragment.java @@ -18,10 +18,10 @@ package com.android.dialer.speeddial; import android.app.Fragment; import android.app.LoaderManager.LoaderCallbacks; +import android.content.Intent; import android.content.Loader; import android.database.Cursor; import android.os.Bundle; -import android.provider.ContactsContract.Contacts; import android.support.annotation.Nullable; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; @@ -35,7 +35,16 @@ import com.android.dialer.speeddial.FavoritesViewHolder.FavoriteContactsListener import com.android.dialer.speeddial.HeaderViewHolder.SpeedDialHeaderListener; import com.android.dialer.speeddial.SuggestionViewHolder.SuggestedContactsListener; -/** Favorites fragment. Contents TBD. TODO(calderwoodra) */ +/** + * Fragment for displaying: + * + * + * + *

Suggested contacts built from {@link android.provider.ContactsContract#STREQUENT_PHONE_ONLY}. + */ public class SpeedDialFragment extends Fragment { private static final int STREQUENT_CONTACTS_LOADER_ID = 1; @@ -73,16 +82,16 @@ public class SpeedDialFragment extends Fragment { } @Override - public void onPause() { - super.onPause(); - loaderCallback.unregisterContentObserver(); + public void onResume() { + super.onResume(); + getLoaderManager().restartLoader(STREQUENT_CONTACTS_LOADER_ID, null, loaderCallback); } - private static class SpeedDialFragmentHeaderListener implements SpeedDialHeaderListener { + private class SpeedDialFragmentHeaderListener implements SpeedDialHeaderListener { @Override public void onAddFavoriteClicked() { - // TODO(calderwoodra): implement add favorite screen + startActivity(new Intent(getContext(), AddFavoriteActivity.class)); } } @@ -123,8 +132,6 @@ public class SpeedDialFragment extends Fragment { */ private class SpeedDialFragmentLoaderCallback implements LoaderCallbacks { - private StrequentContactsCursorLoader cursorLoader; - @Override public Loader onCreateLoader(int id, Bundle args) { if (id == STREQUENT_CONTACTS_LOADER_ID) { @@ -135,24 +142,9 @@ public class SpeedDialFragment extends Fragment { @Override public void onLoadFinished(Loader loader, Cursor data) { - cursorLoader = (StrequentContactsCursorLoader) loader; - // Since the original cursor we queried against was modified and closed, we need to register a - // new content observer in order to get updates on changes to our contacts. - getContext() - .getContentResolver() - .registerContentObserver( - Contacts.CONTENT_STREQUENT_URI, - true /* notifyForDescendants*/, - cursorLoader.getContentObserver()); adapter.setCursor((SpeedDialCursor) data); } - public void unregisterContentObserver() { - getContext() - .getContentResolver() - .unregisterContentObserver(cursorLoader.getContentObserver()); - } - @Override public void onLoaderReset(Loader loader) { adapter.setCursor(null); -- cgit v1.2.3