Merge "Add footer actions to Call Details." into ub-contactsdialer-a-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 94333eb..f85f25e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -142,17 +142,17 @@
</activity>
<activity android:name="com.android.dialer.settings.DialerSettingsActivity"
- android:label="@string/dialer_settings_label"
- android:parentActivityName="com.android.dialer.DialtactsActivity"
- android:theme="@style/SettingsStyle"
- android:exported="false">
+ android:label="@string/dialer_settings_label"
+ android:parentActivityName="com.android.dialer.DialtactsActivity"
+ android:theme="@style/SettingsStyle"
+ android:exported="false">
</activity>
- <activity android:name="com.android.dialer.filterednumber.BlockedNumberSearchActivity"
- android:label="@string/dialer_settings_label"
+ <activity android:name="com.android.dialer.filterednumber.ManageBlockedNumbersActivity"
+ android:label="@string/manage_blocked_numbers_label"
android:parentActivityName="com.android.dialer.settings.DialerSettingsActivity"
- android:theme="@style/DialtactsActivityTheme"
- android:windowSoftInputMode="stateVisible">
+ android:theme="@style/ManageBlockedNumbersStyle"
+ android:exported="false">
</activity>
<activity android:name="com.android.dialer.calllog.CallLogActivity"
@@ -162,11 +162,9 @@
</activity>
<activity android:name="com.android.dialer.CallDetailActivity"
- android:label="@string/callDetailTitle"
- android:theme="@style/CallDetailActivityTheme"
- android:icon="@mipmap/ic_launcher_phone"
- android:parentActivityName="com.android.dialer.calllog.CallLogActivity"
- >
+ android:label="@string/callDetailTitle"
+ android:theme="@style/CallDetailActivityTheme"
+ android:icon="@mipmap/ic_launcher_phone">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
diff --git a/res/drawable-hdpi/ic_block_18dp.png b/res/drawable-hdpi/ic_block_18dp.png
new file mode 100644
index 0000000..acab511
--- /dev/null
+++ b/res/drawable-hdpi/ic_block_18dp.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_block_18dp.png b/res/drawable-mdpi/ic_block_18dp.png
new file mode 100644
index 0000000..45b83fa
--- /dev/null
+++ b/res/drawable-mdpi/ic_block_18dp.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_block_24dp.png b/res/drawable-mdpi/ic_block_24dp.png
deleted file mode 100644
index ec1b33f..0000000
--- a/res/drawable-mdpi/ic_block_24dp.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_block_24dp.png b/res/drawable-xhdpi/ic_block_18dp.png
similarity index 100%
rename from res/drawable-hdpi/ic_block_24dp.png
rename to res/drawable-xhdpi/ic_block_18dp.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_block_24dp.png b/res/drawable-xhdpi/ic_block_24dp.png
deleted file mode 100644
index 7aba97b..0000000
--- a/res/drawable-xhdpi/ic_block_24dp.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_block_18dp.png b/res/drawable-xxhdpi/ic_block_18dp.png
new file mode 100644
index 0000000..1eee124
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_block_18dp.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_block_24dp.png b/res/drawable-xxxhdpi/ic_block_18dp.png
similarity index 100%
rename from res/drawable-xxhdpi/ic_block_24dp.png
rename to res/drawable-xxxhdpi/ic_block_18dp.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_block_24dp.png b/res/drawable-xxxhdpi/ic_block_24dp.png
deleted file mode 100644
index 0378d1b..0000000
--- a/res/drawable-xxxhdpi/ic_block_24dp.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/blocked_contact.xml b/res/drawable/blocked_contact.xml
new file mode 100644
index 0000000..38c0fc9
--- /dev/null
+++ b/res/drawable/blocked_contact.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ ~ Copyright (C) 2015 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
+ -->
+
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+ <item>
+ <shape android:shape="oval">
+ <solid android:color="@color/blocked_contact_background" />
+ <size android:width="24dp" android:height="24dp" />
+ </shape>
+ </item>
+ <item android:drawable="@drawable/ic_block_18dp" android:gravity="center" />
+</layer-list>
diff --git a/res/layout/blocked_number_fragment.xml b/res/layout/blocked_number_fragment.xml
index bbface6..e86ccb5 100644
--- a/res/layout/blocked_number_fragment.xml
+++ b/res/layout/blocked_number_fragment.xml
@@ -16,10 +16,11 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/blocked_number_fragment"
- android:orientation="vertical"
- android:background="@color/blocked_number_background"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:paddingTop="?android:attr/actionBarSize"
+ android:background="@color/blocked_number_background">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
@@ -54,4 +55,4 @@
</android.support.v7.widget.CardView>
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/res/layout/search_activity.xml b/res/layout/blocked_numbers_activity.xml
similarity index 93%
rename from res/layout/search_activity.xml
rename to res/layout/blocked_numbers_activity.xml
index 8feeac2..b5810b7 100644
--- a/res/layout/search_activity.xml
+++ b/res/layout/blocked_numbers_activity.xml
@@ -15,7 +15,7 @@
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/search_activity_container"
+ android:id="@+id/blocked_numbers_activity_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
-</FrameLayout>
\ No newline at end of file
+</FrameLayout>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 55970d9..a7044c7 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -111,6 +111,7 @@
<color name="divider_line_color">#c7c7c7</color>
<!-- Colors for blocked numbers list -->
+ <color name="blocked_contact_background">#afafaf</color>
<color name="blocked_number_primary_text_color">@color/dialtacts_primary_text_color</color>
<color name="blocked_number_secondary_text_color">@color/dialtacts_secondary_text_color</color>
<color name="delete_icon_tint">#6D6D6D</color>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 25d0462..07891f4 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -84,7 +84,7 @@
room to the search box-->
<dimen name="action_bar_height">56dp</dimen>
<dimen name="action_bar_height_large">64dp</dimen>
- <dimen name="action_bar_elevation">2dp</dimen>
+ <dimen name="action_bar_elevation">3dp</dimen>
<dimen name="tab_height">43dp</dimen>
<!-- actionbar height + tab height -->
<dimen name="actionbar_and_tab_height">107dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8a438f6..cd7ce8f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -823,8 +823,8 @@
<!-- Label for the call settings section [CHAR LIMIT=30] -->
<string name="call_settings_label">Calls</string>
- <!-- Label for the blocked calls settings section [CHAR LIMIT=30] -->
- <string name="blocked_calls_settings_label">Spam and blocked calls</string>
+ <!-- Label for the blocked numbers settings section [CHAR LIMIT=30] -->
+ <string name="manage_blocked_numbers_label">Blocked numbers</string>
<!-- Text informing the user they have previously marked contacts to be sent to voicemail.
This will be followed by two buttons, 1) to view who is marked to be sent to voicemail
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 581f799..7c81e52 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -250,6 +250,21 @@
<item name="android:textColorLink">@color/dialtacts_theme_color</item>
</style>
+ <style name="ManageBlockedNumbersStyle" parent="SettingsStyle">
+ <!-- Styles that require AppCompat compatibility, remember to update both sets -->
+ <item name="android:windowActionBarOverlay">true</item>
+ <item name="windowActionBarOverlay">true</item>
+ <item name="android:actionBarStyle">@style/ManageBlockedNumbersActionBarStyle</item>
+ <item name="actionBarStyle">@style/ManageBlockedNumbersActionBarStyle</item>
+ <item name="android:fastScrollTrackDrawable">@null</item>
+ </style>
+
+ <style name="ManageBlockedNumbersActionBarStyle" parent="DialtactsActionBarWithoutTitleStyle">
+ <!-- Styles that require AppCompat compatibility, remember to update both sets -->
+ <item name="android:height">@dimen/action_bar_height</item>
+ <item name="height">@dimen/action_bar_height</item>
+ </style>
+
<!-- Inherit from Theme.Material.Light.Dialog instead of Theme.Material.Light.Dialog.Alert
since the Alert dialog is private. They are identical anyway. -->
<style name="AlertDialogTheme" parent="@android:style/Theme.Material.Light.Dialog">
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index 90985af..703b18f 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -44,13 +44,16 @@
import com.android.dialer.R;
import com.android.dialer.contactinfo.ContactInfoCache;
import com.android.dialer.contactinfo.ContactInfoCache.OnContactInfoChangedListener;
+import com.android.dialer.contactinfo.NumberWithCountryIso;
import com.android.dialer.database.FilteredNumberAsyncQueryHandler;
+import com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnCheckBlockedListener;
import com.android.dialer.util.PhoneNumberUtil;
import com.android.dialer.voicemail.VoicemailPlaybackPresenter;
import com.google.common.annotations.VisibleForTesting;
import java.util.HashMap;
+import java.util.Map;
/**
* Adapter class to fill in data for the Call Log.
@@ -85,6 +88,7 @@
private final FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler;
protected ContactInfoCache mContactInfoCache;
+ protected final Map<NumberWithCountryIso, Integer> mBlockedIdCache;
private boolean mIsCallLogActivity;
@@ -248,6 +252,7 @@
CallTypeHelper callTypeHelper = new CallTypeHelper(resources);
mTelecomCallLogCache = new TelecomCallLogCache(mContext);
+ mBlockedIdCache = new HashMap<NumberWithCountryIso, Integer>();
PhoneCallDetailsHelper phoneCallDetailsHelper =
new PhoneCallDetailsHelper(mContext, resources, mTelecomCallLogCache);
mCallLogListItemHelper =
@@ -296,6 +301,7 @@
public void invalidateCache() {
mContactInfoCache.invalidate();
+ mBlockedIdCache.clear();
}
public void startCache() {
@@ -456,7 +462,7 @@
details.objectId = info.objectId;
}
- CallLogListItemViewHolder views = (CallLogListItemViewHolder) viewHolder;
+ final CallLogListItemViewHolder views = (CallLogListItemViewHolder) viewHolder;
views.info = info;
views.rowId = c.getLong(CallLogQuery.ID);
// Store values used when the actions ViewStub is inflated on expansion.
@@ -492,16 +498,28 @@
mCurrentlyExpandedPosition = position;
}
- views.showActions(mCurrentlyExpandedPosition == position);
-
- String nameForDefaultImage = null;
- if (TextUtils.isEmpty(info.name)) {
- nameForDefaultImage = details.displayNumber;
+ // Update the photo, once we know whether the user's number is blocked or not.
+ final NumberWithCountryIso blockedIdKey = new NumberWithCountryIso(number, countryIso);
+ if (mBlockedIdCache.containsKey(blockedIdKey)) {
+ views.blockId = mBlockedIdCache.get(blockedIdKey);
+ views.updatePhoto();
} else {
- nameForDefaultImage = info.name;
+ views.blockId = null;
+ boolean failed = mFilteredNumberAsyncQueryHandler.startBlockedQuery(
+ new OnCheckBlockedListener() {
+ @Override
+ public void onCheckComplete(Integer id) {
+ mBlockedIdCache.put(blockedIdKey, id);
+ views.blockId = id;
+ views.updatePhoto();
+ }
+ }, null, number, countryIso);
+ if (failed) {
+ views.updatePhoto();
+ }
}
- views.setPhoto(info.photoId, info.photoUri, info.lookupUri, nameForDefaultImage,
- isVoicemailNumber, views.isBusiness);
+
+ views.showActions(mCurrentlyExpandedPosition == position);
mCallLogListItemHelper.setPhoneCallDetails(views, details);
}
diff --git a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
index 4a73b9d..0e234e3 100644
--- a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
+++ b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
@@ -527,11 +527,16 @@
view.setSingleLine(!isExpanded);
}
- public void setPhoto(long photoId, Uri photoUri, Uri contactUri, String displayName,
- boolean isVoicemail, boolean isBusiness) {
- quickContactView.assignContactUri(contactUri);
+ public void updatePhoto() {
quickContactView.setOverlay(null);
+ quickContactView.assignContactUri(info.lookupUri);
+ if (blockId != null) {
+ quickContactView.setImageDrawable(mContext.getDrawable(R.drawable.blocked_contact));
+ return;
+ }
+
+ final boolean isVoicemail = mTelecomCallLogCache.isVoicemailNumber(accountHandle, number);
int contactType = ContactPhotoManager.TYPE_DEFAULT;
if (isVoicemail) {
contactType = ContactPhotoManager.TYPE_VOICEMAIL;
@@ -539,19 +544,17 @@
contactType = ContactPhotoManager.TYPE_BUSINESS;
}
- String lookupKey = null;
- if (contactUri != null) {
- lookupKey = UriUtils.getLookupKeyFromUri(contactUri);
- }
-
- DefaultImageRequest request = new DefaultImageRequest(
+ final String lookupKey = info.lookupUri != null
+ ? UriUtils.getLookupKeyFromUri(info.lookupUri) : null;
+ final String displayName = TextUtils.isEmpty(info.name) ? displayNumber : info.name;
+ final DefaultImageRequest request = new DefaultImageRequest(
displayName, lookupKey, contactType, true /* isCircular */);
- if (photoId == 0 && photoUri != null) {
- ContactPhotoManager.getInstance(mContext).loadPhoto(quickContactView, photoUri,
+ if (info.photoId == 0 && info.photoUri != null) {
+ ContactPhotoManager.getInstance(mContext).loadPhoto(quickContactView, info.photoUri,
mPhotoSize, false /* darkTheme */, true /* isCircular */, request);
} else {
- ContactPhotoManager.getInstance(mContext).loadThumbnail(quickContactView, photoId,
+ ContactPhotoManager.getInstance(mContext).loadThumbnail(quickContactView, info.photoId,
false /* darkTheme */, true /* isCircular */, request);
}
}
diff --git a/src/com/android/dialer/calllog/CallTypeIconsView.java b/src/com/android/dialer/calllog/CallTypeIconsView.java
index cfd8f97..d2be380 100644
--- a/src/com/android/dialer/calllog/CallTypeIconsView.java
+++ b/src/com/android/dialer/calllog/CallTypeIconsView.java
@@ -199,7 +199,7 @@
voicemail = r.getDrawable(R.drawable.ic_call_voicemail_holo_dark);
- blocked = getScaledBitmap(context, R.drawable.ic_block_24dp);
+ blocked = getScaledBitmap(context, R.drawable.ic_block_18dp);
blocked.setColorFilter(r.getColor(R.color.blocked_call), PorterDuff.Mode.MULTIPLY);
videoCall = getScaledBitmap(context, R.drawable.ic_videocam_24dp);
diff --git a/src/com/android/dialer/filterednumber/BlockedNumberFragment.java b/src/com/android/dialer/filterednumber/BlockedNumberFragment.java
index 79e5861..e12fd6b 100644
--- a/src/com/android/dialer/filterednumber/BlockedNumberFragment.java
+++ b/src/com/android/dialer/filterednumber/BlockedNumberFragment.java
@@ -27,7 +27,6 @@
import android.view.ViewGroup;
import com.android.dialer.R;
-import com.android.dialer.database.FilteredNumberAsyncQueryHandler;
import com.android.dialer.database.FilteredNumberContract;
public class BlockedNumberFragment extends ListFragment implements
@@ -38,12 +37,14 @@
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
+
LayoutInflater inflater = LayoutInflater.from(getContext());
getListView().addHeaderView(inflater.inflate(R.layout.blocked_number_header, null));
if (mAdapter == null) {
mAdapter = new BlockedNumberAdapter(getContext());
}
setListAdapter(mAdapter);
+
getActivity().findViewById(R.id.add_number_button).setOnClickListener(this);
getListView().getEmptyView().findViewById(R.id.add_number_button).setOnClickListener(this);
}
@@ -61,8 +62,8 @@
}
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
+ public View onCreateView(
+ LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.blocked_number_fragment, container, false);
return view;
}
@@ -95,6 +96,10 @@
@Override
public void onClick(final View v) {
- startActivity(new Intent(getActivity(), BlockedNumberSearchActivity.class));
+ ManageBlockedNumbersActivity manageBlockedNumbersActivity =
+ (ManageBlockedNumbersActivity) getActivity();
+ if (manageBlockedNumbersActivity != null && v.getId() == R.id.add_number_button) {
+ manageBlockedNumbersActivity.enterSearchUi();
+ }
}
}
diff --git a/src/com/android/dialer/filterednumber/BlockedNumberSearchActivity.java b/src/com/android/dialer/filterednumber/BlockedNumberSearchActivity.java
deleted file mode 100644
index cfa404f..0000000
--- a/src/com/android/dialer/filterednumber/BlockedNumberSearchActivity.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (C) 2015 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.filterednumber;
-
-import android.app.Fragment;
-import android.app.FragmentTransaction;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
-import android.text.Editable;
-import android.text.TextWatcher;
-import android.util.Log;
-import android.util.TypedValue;
-import android.widget.EditText;
-import android.widget.FrameLayout;
-import android.widget.FrameLayout.LayoutParams;
-import android.widget.Toast;
-
-import com.android.contacts.common.GeoUtil;
-import com.android.contacts.common.dialog.IndeterminateProgressDialog;
-import com.android.contacts.common.list.OnPhoneNumberPickerActionListener;
-import com.android.dialer.R;
-import com.android.dialer.database.FilteredNumberAsyncQueryHandler;
-import com.android.dialer.list.BlockedListSearchAdapter;
-import com.android.dialer.list.OnListFragmentScrolledListener;
-import com.android.dialer.list.BlockedListSearchFragment;
-import com.android.dialer.list.SearchFragment;
-import com.android.dialer.widget.SearchEditTextLayout;
-
-public class BlockedNumberSearchActivity extends AppCompatActivity
- implements SearchFragment.HostInterface {
- private static final String TAG_BLOCKED_SEARCH_FRAGMENT = "blocked_search";
-
- private FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler;
- private SearchFragment mSearchFragment;
- private EditText mSearchView;
- private ActionBar mActionBar;
- private String mSearchQuery;
-
- private final TextWatcher mPhoneSearchQueryTextListener = new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- final String newText = s.toString();
- if (newText.equals(mSearchQuery)) {
- return;
- }
- mSearchQuery = newText;
- mSearchFragment.setQueryString(mSearchQuery, false);
- }
-
- @Override
- public void afterTextChanged(Editable s) {
- }
- };
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- mFilteredNumberAsyncQueryHandler =
- new FilteredNumberAsyncQueryHandler(getContentResolver());
-
- setContentView(R.layout.search_activity);
-
- mActionBar = getSupportActionBar();
- mActionBar.setCustomView(R.layout.search_edittext);
- mActionBar.setBackgroundDrawable(null);
- mActionBar.setDisplayShowCustomEnabled(true);
- mActionBar.setDisplayHomeAsUpEnabled(false);
- mActionBar.setDisplayShowHomeEnabled(false);
-
- final SearchEditTextLayout searchEditTextLayout = (SearchEditTextLayout) mActionBar
- .getCustomView().findViewById(R.id.search_view_container);
- searchEditTextLayout.expand(false, true);
- searchEditTextLayout.setCallback(new SearchEditTextLayout.Callback() {
- @Override
- public void onBackButtonClicked() {
- onBackPressed();
- }
-
- @Override
- public void onSearchViewClicked() {
- }
- });
-
- mSearchView = (EditText) searchEditTextLayout.findViewById(R.id.search_view);
- mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener);
- mSearchView.setHint(R.string.block_number_search_hint);
- mSearchView.setTextSize(TypedValue.COMPLEX_UNIT_PX,
- getResources().getDimension(R.dimen.blocked_number_search_text_size));
-
- enterSearchUi();
- }
-
- private void enterSearchUi() {
- if (mSearchFragment != null) {
- return;
- }
- final FragmentTransaction transaction = getFragmentManager().beginTransaction();
- BlockedListSearchFragment fragment = (BlockedListSearchFragment) getFragmentManager()
- .findFragmentByTag(TAG_BLOCKED_SEARCH_FRAGMENT);
- if (fragment == null) {
- fragment = new BlockedListSearchFragment();
- transaction.add(R.id.search_activity_container, fragment, TAG_BLOCKED_SEARCH_FRAGMENT);
- } else {
- transaction.show(fragment);
- }
- fragment.setHasOptionsMenu(false);
- fragment.setShowEmptyListForNullQuery(true);
- fragment.setDirectorySearchEnabled(false);
- transaction.commit();
- }
-
- @Override
- public void onAttachFragment(Fragment fragment) {
- if (fragment instanceof BlockedListSearchFragment) {
- mSearchFragment = (BlockedListSearchFragment) fragment;
- }
- }
-
- @Override
- public boolean isActionBarShowing() {
- return true;
- }
-
- @Override
- public boolean isDialpadShown() {
- return false;
- }
-
- @Override
- public int getDialpadHeight() {
- return 0;
- }
-
- @Override
- public int getActionBarHideOffset() {
- return getSupportActionBar().getHideOffset();
- }
-
- @Override
- public int getActionBarHeight() {
- return getResources().getDimensionPixelSize(R.dimen.action_bar_height_large);
- }
-}
diff --git a/src/com/android/dialer/filterednumber/ManageBlockedNumbersActivity.java b/src/com/android/dialer/filterednumber/ManageBlockedNumbersActivity.java
new file mode 100644
index 0000000..356c55c
--- /dev/null
+++ b/src/com/android/dialer/filterednumber/ManageBlockedNumbersActivity.java
@@ -0,0 +1,240 @@
+/*
+ * Copyright (C) 2015 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.filterednumber;
+
+import android.app.Fragment;
+import android.app.FragmentTransaction;
+import android.content.Intent;
+import android.graphics.drawable.ColorDrawable;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.util.Log;
+import android.util.TypedValue;
+import android.view.MenuItem;
+import android.widget.EditText;
+import android.widget.FrameLayout;
+import android.widget.FrameLayout.LayoutParams;
+import android.widget.Toast;
+
+import com.android.contacts.common.GeoUtil;
+import com.android.contacts.common.dialog.IndeterminateProgressDialog;
+import com.android.contacts.common.list.OnPhoneNumberPickerActionListener;
+import com.android.dialer.R;
+import com.android.dialer.database.FilteredNumberAsyncQueryHandler;
+import com.android.dialer.list.BlockedListSearchAdapter;
+import com.android.dialer.list.OnListFragmentScrolledListener;
+import com.android.dialer.list.BlockedListSearchFragment;
+import com.android.dialer.list.SearchFragment;
+import com.android.dialer.widget.SearchEditTextLayout;
+
+public class ManageBlockedNumbersActivity extends AppCompatActivity
+ implements SearchFragment.HostInterface {
+
+ private static final String TAG_BLOCKED_MANAGEMENT_FRAGMENT = "blocked_management";
+ private static final String TAG_BLOCKED_SEARCH_FRAGMENT = "blocked_search";
+
+ private FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler;
+
+ private BlockedNumberFragment mManagementFragment;
+ private SearchFragment mSearchFragment;
+
+ private EditText mSearchView;
+ private ActionBar mActionBar;
+ private String mSearchQuery;
+
+ private boolean mIsShowingManagementUi;
+
+ private final TextWatcher mPhoneSearchQueryTextListener = new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ final String newText = s.toString();
+ if (newText.equals(mSearchQuery)) {
+ return;
+ }
+ mSearchQuery = newText;
+ mSearchFragment.setQueryString(mSearchQuery, false);
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ }
+ };
+
+ private final SearchEditTextLayout.Callback mSearchLayoutCallback =
+ new SearchEditTextLayout.Callback() {
+ @Override
+ public void onBackButtonClicked() {
+ showManagementUi();
+ }
+
+ @Override
+ public void onSearchViewClicked() {
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.blocked_numbers_activity);
+
+ mFilteredNumberAsyncQueryHandler =
+ new FilteredNumberAsyncQueryHandler(getContentResolver());
+
+ showManagementUi();
+ }
+
+ private void showManagementUi() {
+ mIsShowingManagementUi = true;
+
+ showManagementUiActionBar();
+
+ final FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ if (mSearchFragment != null) {
+ transaction.hide(mSearchFragment);
+ }
+
+ BlockedNumberFragment fragment = (BlockedNumberFragment) getFragmentManager()
+ .findFragmentByTag(TAG_BLOCKED_MANAGEMENT_FRAGMENT);
+ if (fragment == null) {
+ fragment = new BlockedNumberFragment();
+ transaction.add(R.id.blocked_numbers_activity_container, fragment,
+ TAG_BLOCKED_MANAGEMENT_FRAGMENT);
+ } else {
+ transaction.show(fragment);
+ }
+ transaction.commit();
+ }
+
+ private void showManagementUiActionBar() {
+ mActionBar = getSupportActionBar();
+ ColorDrawable backgroundDrawable = new ColorDrawable(getColor(R.color.dialer_theme_color));
+ mActionBar.setBackgroundDrawable(backgroundDrawable);
+ mActionBar.setElevation(getResources().getDimensionPixelSize(R.dimen.action_bar_elevation));
+ mActionBar.setDisplayShowCustomEnabled(false);
+ mActionBar.setDisplayHomeAsUpEnabled(true);
+ mActionBar.setDisplayShowHomeEnabled(true);
+ mActionBar.setDisplayShowTitleEnabled(true);
+ mActionBar.setTitle(R.string.manage_blocked_numbers_label);
+ }
+
+ public void enterSearchUi() {
+ mIsShowingManagementUi = false;
+
+ showSearchUiActionBar();
+
+ final FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ if (mManagementFragment != null) {
+ transaction.hide(mManagementFragment);
+ }
+
+ BlockedListSearchFragment fragment = (BlockedListSearchFragment) getFragmentManager()
+ .findFragmentByTag(TAG_BLOCKED_SEARCH_FRAGMENT);
+ if (fragment == null) {
+ fragment = new BlockedListSearchFragment();
+ fragment.setHasOptionsMenu(false);
+ fragment.setShowEmptyListForNullQuery(true);
+ fragment.setDirectorySearchEnabled(false);
+ transaction.add(R.id.blocked_numbers_activity_container, fragment,
+ TAG_BLOCKED_SEARCH_FRAGMENT);
+ } else {
+ transaction.show(fragment);
+ }
+ transaction.commit();
+ }
+
+ private void showSearchUiActionBar() {
+ mActionBar = getSupportActionBar();
+ mActionBar.setCustomView(R.layout.search_edittext);
+ mActionBar.setBackgroundDrawable(null);
+ mActionBar.setElevation(0);
+ mActionBar.setDisplayShowCustomEnabled(true);
+ mActionBar.setDisplayHomeAsUpEnabled(false);
+ mActionBar.setDisplayShowHomeEnabled(false);
+
+ final SearchEditTextLayout searchEditTextLayout = (SearchEditTextLayout) mActionBar
+ .getCustomView().findViewById(R.id.search_view_container);
+ searchEditTextLayout.expand(false, true);
+ searchEditTextLayout.setCallback(mSearchLayoutCallback);
+
+ mSearchView = (EditText) searchEditTextLayout.findViewById(R.id.search_view);
+ mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener);
+ mSearchView.setHint(R.string.block_number_search_hint);
+
+ // TODO: Don't set custom text size; use default search text size.
+ mSearchView.setTextSize(TypedValue.COMPLEX_UNIT_PX,
+ getResources().getDimension(R.dimen.blocked_number_search_text_size));
+ }
+
+ @Override
+ public void onAttachFragment(Fragment fragment) {
+ if (fragment instanceof BlockedNumberFragment) {
+ mManagementFragment = (BlockedNumberFragment) fragment;
+ } else if (fragment instanceof BlockedListSearchFragment) {
+ mSearchFragment = (BlockedListSearchFragment) fragment;
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ onBackPressed();
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void onBackPressed() {
+ if (mIsShowingManagementUi) {
+ super.onBackPressed();
+ } else {
+ showManagementUi();
+ }
+ }
+
+ @Override
+ public boolean isActionBarShowing() {
+ return true;
+ }
+
+ @Override
+ public boolean isDialpadShown() {
+ return false;
+ }
+
+ @Override
+ public int getDialpadHeight() {
+ return 0;
+ }
+
+ @Override
+ public int getActionBarHideOffset() {
+ return getSupportActionBar().getHideOffset();
+ }
+
+ @Override
+ public int getActionBarHeight() {
+ return getSupportActionBar().getHeight();
+ }
+}
diff --git a/src/com/android/dialer/list/BlockedListSearchFragment.java b/src/com/android/dialer/list/BlockedListSearchFragment.java
index 6750812..eef24af 100644
--- a/src/com/android/dialer/list/BlockedListSearchFragment.java
+++ b/src/com/android/dialer/list/BlockedListSearchFragment.java
@@ -86,13 +86,9 @@
private void blockNumber(final String number) {
final String countryIso = GeoUtil.getCurrentCountryIso(getContext());
- final IndeterminateProgressDialog progressDialog =
- IndeterminateProgressDialog.show(getFragmentManager(),
- getString(R.string.checkingNumber, number), null, 500);
final String normalizedNumber =
FilteredNumberAsyncQueryHandler.getNormalizedNumber(number, countryIso);
if (normalizedNumber == null) {
- progressDialog.dismiss();
Toast.makeText(getContext(), getString(R.string.invalidNumber, number),
Toast.LENGTH_SHORT).show();
return;
@@ -100,12 +96,11 @@
final OnCheckBlockedListener onCheckListener = new OnCheckBlockedListener() {
@Override
public void onCheckComplete(Integer id) {
- progressDialog.dismiss();
if (id == null) {
final FilterNumberDialogFragment newFragment = FilterNumberDialogFragment
.newInstance(id, normalizedNumber, number, countryIso, number);
newFragment.setParentView(
- getActivity().findViewById(R.id.search_activity_container));
+ getActivity().findViewById(R.id.blocked_numbers_activity_container));
newFragment.show(
getFragmentManager(), FilterNumberDialogFragment.BLOCK_DIALOG_FRAGMENT);
} else {
@@ -118,9 +113,11 @@
onCheckListener, normalizedNumber, number, countryIso);
}
- private void blockContactNumber(final BlockedListSearchAdapter adapter,
- final ContactListItemView view, final String number,
- final Integer blockId) {
+ private void blockContactNumber(
+ final BlockedListSearchAdapter adapter,
+ final ContactListItemView view,
+ final String number,
+ final Integer blockId) {
final String countryIso = GeoUtil.getCurrentCountryIso(getContext());
final String normalizedNumber =
FilteredNumberAsyncQueryHandler.getNormalizedNumber(number, countryIso);
@@ -136,19 +133,8 @@
}
final FilterNumberDialogFragment newFragment = FilterNumberDialogFragment
.newInstance(blockId, normalizedNumber, number, countryIso, number);
- newFragment.setParentView(getActivity().findViewById(R.id.search_activity_container));
- newFragment.setOnUndoBlockListener(new FilterNumberDialogFragment.OnUndoBlockListener() {
- @Override
- public void onUndoBlockComplete() {
- adapter.setViewUnblocked(view);
- }
- });
- newFragment.setOnBlockListener(new FilterNumberDialogFragment.OnBlockListener() {
- @Override
- public void onBlockComplete(Uri uri) {
- adapter.setViewBlocked(view, Long.valueOf(ContentUris.parseId(uri)).intValue());
- }
- });
+ newFragment.setParentView(
+ getActivity().findViewById(R.id.blocked_numbers_activity_container));
newFragment.show(getFragmentManager(), FilterNumberDialogFragment.BLOCK_DIALOG_FRAGMENT);
}
}
diff --git a/src/com/android/dialer/list/SearchFragment.java b/src/com/android/dialer/list/SearchFragment.java
index 1c895d3..c8711e7 100644
--- a/src/com/android/dialer/list/SearchFragment.java
+++ b/src/com/android/dialer/list/SearchFragment.java
@@ -289,12 +289,12 @@
public void updatePosition(boolean animate) {
// Use negative shadow height instead of 0 to account for the 9-patch's shadow.
int startTranslationValue =
- mActivity.isDialpadShown() ? mActionBarHeight - mShadowHeight: -mShadowHeight;
+ mActivity.isDialpadShown() ? mActionBarHeight - mShadowHeight : -mShadowHeight;
int endTranslationValue = 0;
// Prevents ListView from being translated down after a rotation when the ActionBar is up.
if (animate || mActivity.isActionBarShowing()) {
endTranslationValue =
- mActivity.isDialpadShown() ? 0 : mActionBarHeight -mShadowHeight;
+ mActivity.isDialpadShown() ? 0 : mActionBarHeight - mShadowHeight;
}
if (animate) {
// If the dialpad will be shown, then this animation involves sliding the list up.
diff --git a/src/com/android/dialer/settings/DialerSettingsActivity.java b/src/com/android/dialer/settings/DialerSettingsActivity.java
index 58b0ab8..6fcd221 100644
--- a/src/com/android/dialer/settings/DialerSettingsActivity.java
+++ b/src/com/android/dialer/settings/DialerSettingsActivity.java
@@ -28,7 +28,7 @@
import android.widget.Toast;
import com.android.dialer.R;
-import com.android.dialer.filterednumber.BlockedNumberFragment;
+import com.android.dialer.filterednumber.ManageBlockedNumbersActivity;
import java.util.List;
@@ -87,8 +87,8 @@
}
Header blockedCallsHeader = new Header();
- blockedCallsHeader.titleRes = R.string.blocked_calls_settings_label;
- blockedCallsHeader.fragment = BlockedNumberFragment.class.getName();
+ blockedCallsHeader.titleRes = R.string.manage_blocked_numbers_label;
+ blockedCallsHeader.intent = new Intent(this, ManageBlockedNumbersActivity.class);
target.add(blockedCallsHeader);
if (telephonyManager.isTtyModeSupported()
diff --git a/src/com/android/dialer/widget/EmptyContentView.java b/src/com/android/dialer/widget/EmptyContentView.java
index f248967..719fd3f 100644
--- a/src/com/android/dialer/widget/EmptyContentView.java
+++ b/src/com/android/dialer/widget/EmptyContentView.java
@@ -80,10 +80,11 @@
}
public void setImage(int resourceId) {
- mImageView.setImageResource(resourceId);
if (resourceId == NO_LABEL) {
+ mImageView.setImageDrawable(null);
mImageView.setVisibility(View.GONE);
} else {
+ mImageView.setImageResource(resourceId);
mImageView.setVisibility(View.VISIBLE);
}
}