summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2013-08-08 15:57:20 -0700
committerYorke Lee <yorkelee@google.com>2013-08-09 18:20:38 -0700
commit8dd6200bef2eb07486f4c7e288941cfcfed35e79 (patch)
tree7da25173afca501aede644d8792a356343342316
parent15ef3e1d3772d9e35182572fed9b0f1c7c958547 (diff)
Extract ShowAllContactsFragment and add it to its own activity
Bug: 10244050 Change-Id: I9c815aecc3fe9f0db239129749fb5be3c73f51be
-rw-r--r--AndroidManifest.xml10
-rw-r--r--res/layout/all_contacts_activity.xml26
-rw-r--r--res/layout/show_all_contacts_fragment.xml5
-rw-r--r--res/values/styles.xml50
-rw-r--r--src/com/android/dialer/DialtactsActivity.java54
-rw-r--r--src/com/android/dialer/list/AllContactsActivity.java100
-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.java19
8 files changed, 161 insertions, 139 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 91e228e82..d26834536 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -60,7 +60,7 @@
dialpad screen. -->
<activity android:name=".DialtactsActivity"
android:label="@string/launcherDialer"
- android:theme="@style/NewDialtactsTheme"
+ android:theme="@style/DialtactsTheme"
android:uiOptions="splitActionBarWhenNarrow"
android:launchMode="singleTask"
android:clearTaskOnLaunch="true"
@@ -119,7 +119,7 @@
<activity android:name="com.android.dialer.calllog.CallLogActivity"
android:label="@string/call_log_activity_title"
- android:theme="@style/NewDialtactsTheme"
+ android:theme="@style/DialtactsTheme"
android:screenOrientation="portrait"
android:icon="@mipmap/ic_launcher_phone">
<intent-filter>
@@ -130,6 +130,12 @@
</intent-filter>
</activity>
+ <activity android:name="com.android.dialer.list.AllContactsActivity"
+ android:label="@string/show_all_contacts_title"
+ android:theme="@style/DialtactsTheme"
+ android:screenOrientation="portrait">
+ </activity>
+
<activity android:name="com.android.dialer.CallDetailActivity"
android:label="@string/callDetailTitle"
android:theme="@style/CallDetailActivityTheme"
diff --git a/res/layout/all_contacts_activity.xml b/res/layout/all_contacts_activity.xml
new file mode 100644
index 000000000..a91302711
--- /dev/null
+++ b/res/layout/all_contacts_activity.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginTop="?android:attr/actionBarSize"
+ android:id="@+id/all_contacts_frame">
+ <fragment android:name="com.android.dialer.list.AllContactsFragment"
+ android:id="@+id/all_contacts_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+</FrameLayout>
diff --git a/res/layout/show_all_contacts_fragment.xml b/res/layout/show_all_contacts_fragment.xml
index 0a95f2754..14fe340f3 100644
--- a/res/layout/show_all_contacts_fragment.xml
+++ b/res/layout/show_all_contacts_fragment.xml
@@ -19,8 +19,7 @@
android:id="@+id/pinned_header_list_layout"
android:orientation="vertical"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_marginTop="?android:attr/actionBarSize">
+ android:layout_height="match_parent">
<!-- Shown only when an Account filter is set.
- paddingTop should be here to show "shade" effect correctly. -->
@@ -35,7 +34,7 @@
android:layout_weight="1" >
<view
class="com.android.contacts.common.list.PinnedHeaderListView"
- style="@style/NewDialtactsTheme"
+ style="@style/DialtactsTheme"
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 0805dd861..aab1c538f 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -16,56 +16,6 @@
-->
<resources>
<style name="DialtactsTheme"
- parent="android:Theme.Holo">
- <item name="android:textColorSecondary">@color/dialtacts_secondary_text_color</item>
- <item name="android:windowActionBarOverlay">true</item>
- <item name="android:actionBarStyle">@style/DialtactsActionBarStyle</item>
- <item name="android:windowContentOverlay">@null</item>
- <item name="android:windowBackground">@drawable/background_dial_holo_dark</item>
- <item name="android:listViewStyle">@style/ListViewStyle</item>
- <item name="activated_background">@drawable/list_item_activated_background</item>
- <item name="section_header_background">@drawable/list_title_holo</item>
- <item name="list_section_header_height">32dip</item>
- <item name="list_item_divider">?android:attr/listDivider</item>
- <item name="list_item_padding_top">0dip</item>
- <item name="list_item_padding_right">0dip</item>
- <item name="list_item_padding_bottom">0dip</item>
- <item name="list_item_padding_left">0dip</item>
- <item name="list_item_gap_between_image_and_text">8dip</item>
- <item name="list_item_gap_between_label_and_data">5dip</item>
- <item name="list_item_presence_icon_margin">4dip</item>
- <item name="list_item_presence_icon_size">16dip</item>
- <item name="list_item_photo_size">@dimen/contact_browser_list_item_photo_size</item>
- <item name="list_item_profile_photo_size">70dip</item>
- <item name="list_item_prefix_highlight_color">@color/people_app_theme_color</item>
- <item name="list_item_header_text_indent">8dip</item>
- <item name="list_item_header_text_color">@color/people_app_theme_color</item>
- <item name="list_item_header_text_size">14sp</item>
- <item name="list_item_header_height">24dip</item>
- <item name="list_item_header_underline_height">1dip</item>
- <item name="list_item_header_underline_color">@color/people_app_theme_color</item>
- <item name="list_item_data_width_weight">5</item>
- <item name="list_item_label_width_weight">3</item>
- <item name="contact_browser_list_padding_left">16dip</item>
- <item name="contact_browser_list_padding_right">0dip</item>
- <item name="contact_browser_background">@android:color/transparent</item>
- <item name="list_item_text_indent">@dimen/contact_browser_list_item_text_indent</item>
- <!-- CallLog -->
- <item name="call_log_primary_text_color">#FFFFFF</item>
- <item name="call_log_primary_background_color">#000000</item>
- <item name="call_log_secondary_text_color">#888888</item>
- <item name="call_log_secondary_background_color">#333333</item>
- <item name="call_log_header_color">#33b5e5</item>
- <!-- VoicemailStatus -->
- <item name="call_log_voicemail_status_height">48dip</item>
- <item name="call_log_voicemail_status_background_color">#262626</item>
- <item name="call_log_voicemail_status_text_color">#888888</item>
- <item name="call_log_voicemail_status_action_text_color">#33b5e5</item>
- <!-- Favorites -->
- <item name="favorites_padding_bottom">?android:attr/actionBarSize</item>
- </style>
-
- <style name="NewDialtactsTheme"
parent="android:Theme.Holo.Light">
<item name="android:textColorPrimary">@color/dialtacts_primary_text_color</item>
<item name="android:textColorSecondary">@color/dialtacts_secondary_text_color</item>
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 726c17687..61fab1774 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -71,9 +71,9 @@ 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.AllContactsActivity;
import com.android.dialer.list.PhoneFavoriteFragment;
import com.android.dialer.list.OnListFragmentScrolledListener;
-import com.android.dialer.list.ShowAllContactsFragment;
import com.android.dialer.list.SmartDialSearchFragment;
import com.android.internal.telephony.ITelephony;
@@ -89,7 +89,8 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
DialpadFragment.OnDialpadQueryChangedListener, PopupMenu.OnMenuItemClickListener,
OnListFragmentScrolledListener,
PhoneFavoriteFragment.OnPhoneFavoriteFragmentStartedListener,
- DialpadFragment.OnDialpadFragmentStartedListener {
+ DialpadFragment.OnDialpadFragmentStartedListener,
+ PhoneFavoriteFragment.OnShowAllContactsListener {
private static final String TAG = "DialtactsActivity";
public static final boolean DEBUG = false;
@@ -141,8 +142,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
*/
private SmartDialSearchFragment mSmartDialSearchFragment;
- private ShowAllContactsFragment mShowAllContactsFragment;
-
private View mMenuButton;
private View mCallHistoryButton;
private View mDialpadButton;
@@ -257,16 +256,12 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
mRegularSearchFragment = new SearchFragment();
mSmartDialSearchFragment = new SmartDialSearchFragment();
mDialpadFragment = new DialpadFragment();
- mShowAllContactsFragment = new ShowAllContactsFragment();
- mShowAllContactsFragment.setOnPhoneNumberPickerActionListener(
- mPhoneNumberPickerActionListener);
// TODO krelease: load fragments on demand instead of creating all of them at run time
final FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.add(R.id.dialtacts_frame, mPhoneFavoriteFragment, TAG_FAVORITES_FRAGMENT);
ft.add(R.id.dialtacts_frame, mRegularSearchFragment, TAG_REGULAR_SEARCH_FRAGMENT);
ft.add(R.id.dialtacts_frame, mSmartDialSearchFragment, TAG_SMARTDIAL_SEARCH_FRAGMENT);
- ft.add(R.id.dialtacts_frame, mShowAllContactsFragment, TAG_SHOW_ALL_CONTACTS_FRAGMENT);
ft.add(R.id.dialtacts_container, mDialpadFragment, TAG_DIALPAD_FRAGMENT);
ft.commit();
}
@@ -298,11 +293,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
mSmartDialSearchFragment.setOnPhoneNumberPickerActionListener(
mPhoneNumberPickerActionListener);
- mShowAllContactsFragment = (ShowAllContactsFragment) fm.findFragmentByTag(
- TAG_SHOW_ALL_CONTACTS_FRAGMENT);
- mShowAllContactsFragment.setOnPhoneNumberPickerActionListener(
- mPhoneNumberPickerActionListener);
-
if (mFirstLaunch) {
displayFragment(getIntent());
}
@@ -312,8 +302,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
@Override
public void onAttachFragment(Fragment fragment) {
if (fragment instanceof DialpadFragment || fragment instanceof SearchFragment
- || fragment instanceof SmartDialSearchFragment
- || fragment instanceof ShowAllContactsFragment) {
+ || fragment instanceof SmartDialSearchFragment) {
final FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.hide(fragment);
transaction.commit();
@@ -323,16 +312,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
}
@Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- // Respond to the action bar's Up/Home button
- case android.R.id.home:
- hideAllContactsFragment();
- }
- return super.onOptionsItemSelected(item);
- }
-
- @Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_import_export:
@@ -439,23 +418,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
ft.commit();
}
- public void showAllContactsFragment() {
- final FragmentTransaction ft = getFragmentManager().beginTransaction();
- ft.hide(mPhoneFavoriteFragment);
- ft.show(mShowAllContactsFragment);
- // TODO{klp} Add animation
- ft.commit();
- hideSearchBar(false);
- }
-
- private void hideAllContactsFragment() {
- final FragmentTransaction ft = getFragmentManager().beginTransaction();
- ft.hide(mShowAllContactsFragment);
- ft.show(mPhoneFavoriteFragment);
- ft.commit();
- showSearchBar();
- }
-
private void prepareSearchView() {
mSearchViewContainer = findViewById(R.id.search_view_container);
mSearchViewCloseButton = findViewById(R.id.search_close_button);
@@ -801,8 +763,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
hideDialpadFragment(true);
} else if (mInSearchUi) {
mSearchView.setText(null);
- } else if (mShowAllContactsFragment.isVisible()) {
- hideAllContactsFragment();
} else if (isTaskRoot()) {
// Instead of stopping, simply push this to the back of the stack.
// This is only done when running at the top of the stack;
@@ -846,4 +806,10 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
Context.TELEPHONY_SERVICE);
return tm.getCallState() != TelephonyManager.CALL_STATE_IDLE;
}
+
+ @Override
+ public void onShowAllContacts() {
+ final Intent intent = new Intent(this, AllContactsActivity.class);
+ startActivity(intent);
+ }
}
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) {