diff options
Diffstat (limited to 'src/com/android/dialer/list')
-rw-r--r-- | src/com/android/dialer/list/AllContactsActivity.java | 100 | ||||
-rw-r--r-- | src/com/android/dialer/list/AllContactsFragment.java (renamed from src/com/android/dialer/list/ShowAllContactsFragment.java) | 36 | ||||
-rw-r--r-- | src/com/android/dialer/list/PhoneFavoriteFragment.java | 19 |
3 files changed, 115 insertions, 40 deletions
diff --git a/src/com/android/dialer/list/AllContactsActivity.java b/src/com/android/dialer/list/AllContactsActivity.java new file mode 100644 index 000000000..c46702f7a --- /dev/null +++ b/src/com/android/dialer/list/AllContactsActivity.java @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.dialer.list; + +import android.app.ActionBar; +import android.app.Fragment; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.text.Spannable; +import android.text.SpannableString; +import android.text.style.TypefaceSpan; +import android.util.Log; + +import com.android.contacts.common.CallUtil; +import com.android.contacts.common.activity.TransactionSafeActivity; +import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; +import com.android.dialer.DialtactsActivity; +import com.android.dialer.R; +import com.android.dialer.interactions.PhoneNumberInteraction; + +public class AllContactsActivity extends TransactionSafeActivity { + private static final String TAG = AllContactsActivity.class.getSimpleName(); + + private AllContactsFragment mAllContactsFragment; + + // Same behavior as {@link DialtactsActivity} + private final OnPhoneNumberPickerActionListener mPhoneNumberPickerActionListener = + new OnPhoneNumberPickerActionListener() { + @Override + public void onPickPhoneNumberAction(Uri dataUri) { + // Specify call-origin so that users will see the previous tab instead of + // CallLog screen (search UI will be automatically exited). + PhoneNumberInteraction.startInteractionForPhoneCall( + AllContactsActivity.this, dataUri, null); + } + + @Override + public void onCallNumberDirectly(String phoneNumber) { + final Intent intent = CallUtil.getCallIntent(phoneNumber, null); + startActivity(intent); + } + + @Override + public void onShortcutIntentCreated(Intent intent) { + Log.w(TAG, "Unsupported intent has come (" + intent + "). Ignoring."); + } + + @Override + public void onHomeInActionBarSelected() { + // {@link PhoneNumberPickerFragment handles onClick on the home button + // and performs the callback here. This means we don't have to handle it + // ourself in the activity. + final Intent intent = new Intent(AllContactsActivity.this, + DialtactsActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + } + }; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + final ActionBar actionBar = getActionBar(); + actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); + actionBar.setDisplayShowHomeEnabled(true); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setDisplayShowTitleEnabled(true); + + final SpannableString s = new SpannableString(getString(R.string.show_all_contacts_title)); + s.setSpan(new TypefaceSpan(getString(R.string.show_all_contacts_title_font_family)), 0, + s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + actionBar.setTitle(s); + + setContentView(R.layout.all_contacts_activity); + } + + @Override + public void onAttachFragment(Fragment fragment) { + if (fragment instanceof AllContactsFragment) { + mAllContactsFragment = (AllContactsFragment) fragment; + mAllContactsFragment.setOnPhoneNumberPickerActionListener( + mPhoneNumberPickerActionListener); + } + } +} diff --git a/src/com/android/dialer/list/ShowAllContactsFragment.java b/src/com/android/dialer/list/AllContactsFragment.java index 85806b6b5..40d5c14b7 100644 --- a/src/com/android/dialer/list/ShowAllContactsFragment.java +++ b/src/com/android/dialer/list/AllContactsFragment.java @@ -17,12 +17,8 @@ package com.android.dialer.list; -import android.app.ActionBar; import android.app.Activity; import android.os.Bundle; -import android.text.Spannable; -import android.text.SpannableString; -import android.text.style.TypefaceSpan; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -31,11 +27,10 @@ import com.android.contacts.common.list.ContactListItemView; import com.android.contacts.common.list.PhoneNumberPickerFragment; import com.android.dialer.R; -// TODO{klp}: Wrap this fragment with an activity. /** * Fragments to show all contacts with phone numbers. */ -public class ShowAllContactsFragment extends PhoneNumberPickerFragment{ +public class AllContactsFragment extends PhoneNumberPickerFragment{ @Override public void onCreate(Bundle savedInstanceState) { @@ -54,35 +49,6 @@ public class ShowAllContactsFragment extends PhoneNumberPickerFragment{ } @Override - public void onStart() { - // Displays action bar for quick navigation. - final ActionBar actionBar = getActivity().getActionBar(); - actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); - actionBar.setDisplayShowHomeEnabled(true); - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowTitleEnabled(true); - - final SpannableString s = new SpannableString(getString(R.string.show_all_contacts_title)); - s.setSpan(new TypefaceSpan(getString(R.string.show_all_contacts_title)), 0, - s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - actionBar.setTitle(s); - - super.onStart(); - } - - @Override - public void onHiddenChanged(boolean hidden) { - // Hides the action bar as it is hidden in the main activity - if (getActivity() != null) { - if (hidden) { - getActivity().getActionBar().hide(); - } else { - getActivity().getActionBar().show(); - } - } - } - - @Override protected View inflateView(LayoutInflater inflater, ViewGroup container) { return inflater.inflate(R.layout.show_all_contacts_fragment, null); } diff --git a/src/com/android/dialer/list/PhoneFavoriteFragment.java b/src/com/android/dialer/list/PhoneFavoriteFragment.java index 64a9b84d2..589a7b134 100644 --- a/src/com/android/dialer/list/PhoneFavoriteFragment.java +++ b/src/com/android/dialer/list/PhoneFavoriteFragment.java @@ -19,6 +19,7 @@ import android.app.Activity; import android.app.Fragment; import android.app.LoaderManager; import android.content.CursorLoader; +import android.content.Intent; import android.content.Loader; import android.database.Cursor; import android.graphics.Rect; @@ -70,6 +71,10 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen public void onPhoneFavoriteFragmentStarted(); } + public interface OnShowAllContactsListener { + public void onShowAllContacts(); + } + public interface Listener { public void onContactSelected(Uri contactUri); public void onCallNumberDirectly(String phoneNumber); @@ -133,9 +138,9 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen private Listener mListener; private OnListFragmentScrolledListener mActivityScrollListener; + private OnShowAllContactsListener mShowAllContactsListener; private PhoneFavoriteMergedAdapter mAdapter; private PhoneFavoritesTileAdapter mContactTileAdapter; - private PhoneNumberListAdapter mAllContactsAdapter; private CallLogAdapter mCallLogAdapter; private CallLogQueryHandler mCallLogQueryHandler; @@ -286,6 +291,13 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen + " must implement OnListFragmentScrolledListener"); } + try { + mShowAllContactsListener = (OnShowAllContactsListener) activity; + } catch (ClassCastException e) { + throw new ClassCastException(activity.toString() + + " must implement OnShowAllContactsListener"); + } + // Use initLoader() instead of restartLoader() to refraining unnecessary reload. // 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. @@ -311,10 +323,7 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen * Gets called when user click on the show all contacts button. */ private void showAllContacts() { - // TODO {klp} Use interface for the fragment to communicate with the activity - if (getActivity() instanceof DialtactsActivity) { - ((DialtactsActivity) getActivity()).showAllContactsFragment(); - } + mShowAllContactsListener.onShowAllContacts(); } public void setListener(Listener listener) { |