diff options
29 files changed, 506 insertions, 238 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 94333eb1e..f85f25e57 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 Binary files differnew file mode 100644 index 000000000..acab511f6 --- /dev/null +++ b/res/drawable-hdpi/ic_block_18dp.png diff --git a/res/drawable-mdpi/ic_block_18dp.png b/res/drawable-mdpi/ic_block_18dp.png Binary files differnew file mode 100644 index 000000000..45b83facf --- /dev/null +++ b/res/drawable-mdpi/ic_block_18dp.png diff --git a/res/drawable-mdpi/ic_block_24dp.png b/res/drawable-mdpi/ic_block_24dp.png Binary files differdeleted file mode 100644 index ec1b33f0e..000000000 --- a/res/drawable-mdpi/ic_block_24dp.png +++ /dev/null diff --git a/res/drawable-hdpi/ic_block_24dp.png b/res/drawable-xhdpi/ic_block_18dp.png Binary files differindex 2ccc89d24..2ccc89d24 100644 --- a/res/drawable-hdpi/ic_block_24dp.png +++ b/res/drawable-xhdpi/ic_block_18dp.png diff --git a/res/drawable-xhdpi/ic_block_24dp.png b/res/drawable-xhdpi/ic_block_24dp.png Binary files differdeleted file mode 100644 index 7aba97b65..000000000 --- a/res/drawable-xhdpi/ic_block_24dp.png +++ /dev/null diff --git a/res/drawable-xxhdpi/ic_block_18dp.png b/res/drawable-xxhdpi/ic_block_18dp.png Binary files differnew file mode 100644 index 000000000..1eee12405 --- /dev/null +++ b/res/drawable-xxhdpi/ic_block_18dp.png diff --git a/res/drawable-xxhdpi/ic_block_24dp.png b/res/drawable-xxxhdpi/ic_block_18dp.png Binary files differindex fddfa54b8..fddfa54b8 100644 --- a/res/drawable-xxhdpi/ic_block_24dp.png +++ b/res/drawable-xxxhdpi/ic_block_18dp.png diff --git a/res/drawable-xxxhdpi/ic_block_24dp.png b/res/drawable-xxxhdpi/ic_block_24dp.png Binary files differdeleted file mode 100644 index 0378d1bed..000000000 --- a/res/drawable-xxxhdpi/ic_block_24dp.png +++ /dev/null diff --git a/res/drawable/blocked_contact.xml b/res/drawable/blocked_contact.xml new file mode 100644 index 000000000..38c0fc92c --- /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 bbface6de..e86ccb596 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 index 8feeac20d..b5810b7fa 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/layout/call_detail_footer.xml b/res/layout/call_detail_footer.xml new file mode 100644 index 000000000..7e56c02c2 --- /dev/null +++ b/res/layout/call_detail_footer.xml @@ -0,0 +1,81 @@ +<?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. +--> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <View + android:layout_width="match_parent" + android:layout_height="@dimen/divider_line_thickness" + android:background="@color/call_log_action_divider" /> + + <LinearLayout android:id="@+id/call_detail_action_block" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:visibility="gone" + style="@style/CallDetailActionItemStyle"> + + <TextView android:id="@+id/call_detail_action_block_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/action_block_number" /> + + </LinearLayout> + + <LinearLayout android:id="@+id/call_detail_action_copy" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + style="@style/CallDetailActionItemStyle"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/action_copy_number_text" /> + + </LinearLayout> + + <LinearLayout android:id="@+id/call_detail_action_edit_before_call" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:visibility="gone" + style="@style/CallDetailActionItemStyle"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/action_edit_number_before_call" /> + + </LinearLayout> + + <LinearLayout android:id="@+id/call_detail_action_report" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:visibility="gone" + style="@style/CallDetailActionItemStyle"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/action_report_number" /> + + </LinearLayout> + +</LinearLayout> diff --git a/res/menu/call_details_cab.xml b/res/menu/call_details_cab.xml deleted file mode 100644 index 7de675ff1..000000000 --- a/res/menu/call_details_cab.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2012 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. ---> -<menu xmlns:android="http://schemas.android.com/apk/res/android"> - <item - android:id="@+id/copy_phone_number" - android:icon="?android:attr/actionModeCopyDrawable" - android:title="@string/menu_copy" - /> -</menu> diff --git a/res/menu/call_details_options.xml b/res/menu/call_details_options.xml deleted file mode 100644 index 414b6711a..000000000 --- a/res/menu/call_details_options.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2011 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. ---> -<menu xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/call_details_menu"> - - <item android:id="@+id/menu_edit_number_before_call" - android:title="@string/call_log_edit_number_before_call" /> - - <item android:id="@+id/menu_report" - android:title="@string/call_detail_menu_report" /> - -</menu> diff --git a/res/values/colors.xml b/res/values/colors.xml index 55970d9e4..a7044c7cb 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 38e4d0e6e..07891f4b4 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -16,6 +16,7 @@ --> <resources> <dimen name="button_horizontal_padding">16dp</dimen> + <dimen name="divider_line_thickness">2dp</dimen> <!-- Drag to remove view (in dp because it is used in conjunction with a statically @@ -47,6 +48,8 @@ <dimen name="call_detail_header_top_margin">20dp</dimen> <dimen name="call_detail_header_bottom_margin">9dp</dimen> <dimen name="call_detail_elevation">0.5dp</dimen> + <dimen name="call_detail_action_item_padding_horizontal">36dp</dimen> + <dimen name="call_detail_action_item_padding_vertical">16dp</dimen> <dimen name="transcription_top_margin">18dp</dimen> <dimen name="transcription_bottom_margin">18dp</dimen> @@ -81,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 3f4b9e2a6..cd7ce8fa8 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -42,25 +42,24 @@ [CHAR LIMIT=NONE] --> <string name="callHistoryIconLabel">Call history</string> - <!-- Text for a menu item to report a call as having been incorrectly identified. - [CHAR LIMIT=30] --> - <string name="call_detail_menu_report">Report inaccurate number</string> + <!-- Text for a menu item to report a call as having been incorrectly identified. [CHAR LIMIT=48] --> + <string name="action_report_number">Report inaccurate number</string> - <!-- Option displayed in context menu to copy long pressed phone number to clipboard [CHAR LIMIT=64] --> - <string name="copy_number_text">Copy number to clipboard</string> + <!-- Option displayed in context menu to copy long pressed phone number. [CHAR LIMIT=48] --> + <string name="action_copy_number_text">Copy number</string> - <!-- Option displayed in context menu to copy long pressed voicemail transcription to clipboard [CHAR LIMIT=64] --> - <string name="copy_transcript_text">Copy transcription to clipboard</string> + <!-- Option displayed in context menu to copy long pressed voicemail transcription. [CHAR LIMIT=48] --> + <string name="copy_transcript_text">Copy transcription</string> - <!-- Menu item used to block a number from the call log [CHAR LIMIT=64] --> - <string name="call_log_block_number">Block number</string> + <!-- Label for action to block a number. [CHAR LIMIT=48] --> + <string name="action_block_number">Block number</string> <!-- Text for snackbar to undo blocking a number. [CHAR LIMIT=64] --> <string name="snackbar_number_blocked"> <xliff:g id="number" example="(555) 555-5555">%1$s</xliff:g> added to block list</string> - <!-- Menu item used to unblock a number from the call log [CHAR LIMIT=64]--> - <string name="call_log_unblock_number">Unblock number</string> + <!-- Label for action to unblock a number [CHAR LIMIT=48]--> + <string name="action_unblock_number">Unblock number</string> <!-- Text for snackbar to undo unblocking a number. [CHAR LIMIT=64] --> <string name="snackbar_number_unblocked"> @@ -73,11 +72,8 @@ <!-- Menu item in call details used to remove a call or voicemail from the call log. --> <string name="call_details_delete">Delete</string> - <!-- Menu item used to copy a number from the call log to the dialer so it can be edited before calling it --> - <string name="call_log_edit_number_before_call">Edit number before call</string> - - <!-- Menu item used to remove a single call from the call log --> - <string name="call_log_remove_from_call_log">Delete from call history</string> + <!-- Label for action to edit a number before calling it. [CHAR LIMIT=48] --> + <string name="action_edit_number_before_call">Edit number before call</string> <!-- Menu item used to remove all calls from the call log --> <string name="call_log_delete_all">Clear call history</string> @@ -260,9 +256,6 @@ [CHAR LIMIT=NONE] --> <string name="action_menu_dialpad_button">dial pad</string> - <!-- Menu item to copy something [CHAR_LIMIT=10] --> - <string name="menu_copy">Copy</string> - <!-- Menu item used to show only outgoing in the call log. [CHAR LIMIT=30] --> <string name="menu_show_outgoing_only">Show outgoing only</string> @@ -830,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 005fd4587..7c81e52fb 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -146,6 +146,15 @@ <item name="android:actionOverflowButtonStyle">@style/DialtactsActionBarOverflowWhite</item> </style> + <style name="CallDetailActionItemStyle"> + <item name="android:foreground">?android:attr/selectableItemBackground</item> + <item name="android:clickable">true</item> + <item name="android:paddingStart">@dimen/call_detail_action_item_padding_horizontal</item> + <item name="android:paddingEnd">@dimen/call_detail_action_item_padding_horizontal</item> + <item name="android:paddingTop">@dimen/call_detail_action_item_padding_vertical</item> + <item name="android:paddingBottom">@dimen/call_detail_action_item_padding_vertical</item> + </style> + <style name="DialtactsActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse"> <!-- Styles that require AppCompat compatibility, remember to update both sets --> @@ -241,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/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java index 12849f416..73622bf9b 100644 --- a/src/com/android/dialer/CallDetailActivity.java +++ b/src/com/android/dialer/CallDetailActivity.java @@ -28,6 +28,7 @@ import android.telecom.PhoneAccountHandle; import android.text.BidiFormatter; import android.text.TextDirectionHeuristics; import android.text.TextUtils; +import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -39,6 +40,7 @@ import android.widget.TextView; import android.widget.Toast; import com.android.contacts.common.CallUtil; +import com.android.contacts.common.ClipboardUtils; import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; import com.android.contacts.common.ContactPhotoManager; import com.android.contacts.common.GeoUtil; @@ -52,6 +54,10 @@ import com.android.dialer.calllog.CallLogAsyncTaskUtil; import com.android.dialer.calllog.CallTypeHelper; import com.android.dialer.calllog.ContactInfoHelper; import com.android.dialer.calllog.PhoneAccountUtils; +import com.android.dialer.database.FilteredNumberAsyncQueryHandler; +import com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnCheckBlockedListener; +import com.android.dialer.filterednumber.FilterNumberDialogFragment; +import com.android.dialer.util.DialerUtils; import com.android.dialer.util.IntentUtil.CallIntentBuilder; import com.android.dialer.util.PhoneNumberUtil; import com.android.dialer.util.TelecomUtil; @@ -64,8 +70,10 @@ import com.android.incallui.Call.LogState; * {@link #EXTRA_CALL_LOG_IDS} extra to specify a group of call log entries. */ public class CallDetailActivity extends AppCompatActivity - implements MenuItem.OnMenuItemClickListener { - private static final String TAG = "CallDetail"; + implements MenuItem.OnMenuItemClickListener, View.OnClickListener, + FilterNumberDialogFragment.OnBlockListener, + FilterNumberDialogFragment.OnUndoBlockListener { + private static final String TAG = CallDetailActivity.class.getSimpleName(); /** A long array extra containing ids of call log entries to display. */ public static final String EXTRA_CALL_LOG_IDS = "EXTRA_CALL_LOG_IDS"; @@ -97,31 +105,28 @@ public class CallDetailActivity extends AppCompatActivity return; } - // We know that all calls are from the same number and the same contact, so pick the - // first. - PhoneCallDetails firstDetails = details[0]; - mNumber = TextUtils.isEmpty(firstDetails.number) ? - null : firstDetails.number.toString(); - final int numberPresentation = firstDetails.numberPresentation; - final Uri contactUri = firstDetails.contactUri; - final Uri photoUri = firstDetails.photoUri; - final PhoneAccountHandle accountHandle = firstDetails.accountHandle; + // All calls are from the same number and same contact, so pick the first detail. + mDetails = details[0]; + mNumber = TextUtils.isEmpty(mDetails.number) ? + null : mDetails.number.toString(); + mDisplayNumber = mDetails.displayNumber; + final int numberPresentation = mDetails.numberPresentation; + final Uri contactUri = mDetails.contactUri; + final Uri photoUri = mDetails.photoUri; + final PhoneAccountHandle accountHandle = mDetails.accountHandle; // Cache the details about the phone number. - final boolean canPlaceCallsTo = - PhoneNumberUtil.canPlaceCallsTo(mNumber, numberPresentation); mIsVoicemailNumber = PhoneNumberUtil.isVoicemailNumber(mContext, accountHandle, mNumber); - final boolean isSipNumber = PhoneNumberUtil.isSipNumber(mNumber); - final CharSequence callLocationOrType = getNumberTypeOrLocation(firstDetails); + final CharSequence callLocationOrType = getNumberTypeOrLocation(mDetails); - final CharSequence displayNumber = firstDetails.displayNumber; + final CharSequence displayNumber = mDetails.displayNumber; final String displayNumberStr = mBidiFormatter.unicodeWrap( displayNumber.toString(), TextDirectionHeuristics.LTR); - if (!TextUtils.isEmpty(firstDetails.name)) { - mCallerName.setText(firstDetails.name); + if (!TextUtils.isEmpty(mDetails.name)) { + mCallerName.setText(mDetails.name); mCallerNumber.setText(callLocationOrType + " " + displayNumberStr); } else { mCallerName.setText(displayNumberStr); @@ -133,8 +138,6 @@ public class CallDetailActivity extends AppCompatActivity } } - mCallButton.setVisibility(canPlaceCallsTo ? View.VISIBLE : View.GONE); - String accountLabel = PhoneAccountUtils.getAccountLabel(mContext, accountHandle); if (!TextUtils.isEmpty(accountLabel)) { mAccountLabel.setText(accountLabel); @@ -143,20 +146,31 @@ public class CallDetailActivity extends AppCompatActivity mAccountLabel.setVisibility(View.GONE); } - mHasEditNumberBeforeCallOption = + final boolean canPlaceCallsTo = + PhoneNumberUtil.canPlaceCallsTo(mNumber, mDetails.numberPresentation); + mCallButton.setVisibility(canPlaceCallsTo ? View.VISIBLE : View.GONE); + + final boolean isSipNumber = PhoneNumberUtil.isSipNumber(mNumber); + final boolean showEditNumberBeforeCallAction = canPlaceCallsTo && !isSipNumber && !mIsVoicemailNumber; - mHasReportMenuOption = mContactInfoHelper.canReportAsInvalid( - firstDetails.sourceType, firstDetails.objectId); + mEditBeforeCallActionItem.setVisibility( + showEditNumberBeforeCallAction ? View.VISIBLE : View.GONE); + + final boolean showReportAction = mContactInfoHelper.canReportAsInvalid( + mDetails.sourceType, mDetails.objectId); + mReportActionItem.setVisibility( + showReportAction ? View.VISIBLE : View.GONE); + + updateBlockActionItem(); invalidateOptionsMenu(); - ListView historyList = (ListView) findViewById(R.id.history); - historyList.setAdapter( + mHistoryList.setAdapter( new CallDetailHistoryAdapter(mContext, mInflater, mCallTypeHelper, details)); String lookupKey = contactUri == null ? null : UriUtils.getLookupKeyFromUri(contactUri); - final boolean isBusiness = mContactInfoHelper.isBusiness(firstDetails.sourceType); + final boolean isBusiness = mContactInfoHelper.isBusiness(mDetails.sourceType); final int contactType = mIsVoicemailNumber ? ContactPhotoManager.TYPE_VOICEMAIL : @@ -164,10 +178,10 @@ public class CallDetailActivity extends AppCompatActivity ContactPhotoManager.TYPE_DEFAULT; String nameForDefaultImage; - if (TextUtils.isEmpty(firstDetails.name)) { - nameForDefaultImage = firstDetails.displayNumber; + if (TextUtils.isEmpty(mDetails.name)) { + nameForDefaultImage = mDetails.displayNumber; } else { - nameForDefaultImage = firstDetails.name.toString(); + nameForDefaultImage = mDetails.name.toString(); } loadContactPhotos( @@ -193,29 +207,34 @@ public class CallDetailActivity extends AppCompatActivity }; private Context mContext; - private CallTypeHelper mCallTypeHelper; - private QuickContactBadge mQuickContactBadge; - private TextView mCallerName; - private TextView mCallerNumber; - private TextView mAccountLabel; - private View mCallButton; private ContactInfoHelper mContactInfoHelper; + private CallTypeHelper mCallTypeHelper; + private ContactPhotoManager mContactPhotoManager; + private FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler; + private BidiFormatter mBidiFormatter = BidiFormatter.getInstance(); + private LayoutInflater mInflater; + private Resources mResources; + private PhoneCallDetails mDetails; protected String mNumber; + private Uri mVoicemailUri; private boolean mIsVoicemailNumber; private String mDefaultCountryIso; + private String mDisplayNumber; - /* package */ LayoutInflater mInflater; - /* package */ Resources mResources; - /** Helper to load contact photos. */ - private ContactPhotoManager mContactPhotoManager; + private ListView mHistoryList; + private QuickContactBadge mQuickContactBadge; + private TextView mCallerName; + private TextView mCallerNumber; + private TextView mAccountLabel; + private View mCallButton; - private Uri mVoicemailUri; - private BidiFormatter mBidiFormatter = BidiFormatter.getInstance(); + private View mBlockNumberActionItem; + private TextView mBlockNumberActionItemText; + private View mEditBeforeCallActionItem; + private View mReportActionItem; - /** Whether we should show "edit number before call" in the options menu. */ - private boolean mHasEditNumberBeforeCallOption; - private boolean mHasReportMenuOption; + private Integer mBlockedNumberId; @Override protected void onCreate(Bundle icicle) { @@ -227,18 +246,23 @@ public class CallDetailActivity extends AppCompatActivity } mContext = this; - - setContentView(R.layout.call_detail); - - mInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); mResources = getResources(); - + mContactInfoHelper = new ContactInfoHelper(this, GeoUtil.getCurrentCountryIso(this)); mCallTypeHelper = new CallTypeHelper(getResources()); + mFilteredNumberAsyncQueryHandler = + new FilteredNumberAsyncQueryHandler(getContentResolver()); mVoicemailUri = getIntent().getParcelableExtra(EXTRA_VOICEMAIL_URI); - ListView historyList = (ListView) findViewById(R.id.history); - historyList.addHeaderView(mInflater.inflate(R.layout.call_detail_header, null)); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + setContentView(R.layout.call_detail); + mInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); + + mHistoryList = (ListView) findViewById(R.id.history); + mHistoryList.addHeaderView(mInflater.inflate(R.layout.call_detail_header, null)); + mHistoryList.addFooterView( + mInflater.inflate(R.layout.call_detail_footer, null), null, false); mQuickContactBadge = (QuickContactBadge) findViewById(R.id.quick_contact_photo); mQuickContactBadge.setOverlay(null); @@ -260,8 +284,16 @@ public class CallDetailActivity extends AppCompatActivity } }); - mContactInfoHelper = new ContactInfoHelper(this, GeoUtil.getCurrentCountryIso(this)); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); + mBlockNumberActionItem = findViewById(R.id.call_detail_action_block); + mBlockNumberActionItem.setOnClickListener(this); + mBlockNumberActionItemText = (TextView) findViewById(R.id.call_detail_action_block_text); + mEditBeforeCallActionItem = findViewById(R.id.call_detail_action_edit_before_call); + mEditBeforeCallActionItem.setOnClickListener(this); + mReportActionItem = findViewById(R.id.call_detail_action_report); + mReportActionItem.setOnClickListener(this); + + View copyActionItem = findViewById(R.id.call_detail_action_copy); + copyActionItem.setOnClickListener(this); if (getIntent().getBooleanExtra(EXTRA_FROM_NOTIFICATION, false)) { closeSystemDialogs(); @@ -275,6 +307,16 @@ public class CallDetailActivity extends AppCompatActivity } @Override + public void onBlockComplete(Uri uri) { + updateBlockActionItem(); + } + + @Override + public void onUndoBlockComplete() { + updateBlockActionItem(); + } + + @Override public boolean dispatchTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { TouchPointManager.getInstance().setPoint((int) ev.getRawX(), (int) ev.getRawY()); @@ -286,11 +328,6 @@ public class CallDetailActivity extends AppCompatActivity CallLogAsyncTaskUtil.getCallDetails(this, getCallLogEntryUris(), mCallLogAsyncTaskListener); } - @NeededForTesting - public boolean hasVoicemail() { - return mVoicemailUri != null; - } - /** * Returns the list of URIs to show. * <p> @@ -341,22 +378,10 @@ public class CallDetailActivity extends AppCompatActivity deleteMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); deleteMenuItem.setOnMenuItemClickListener(this); - getMenuInflater().inflate(R.menu.call_details_options, menu); return super.onCreateOptionsMenu(menu); } @Override - public boolean onPrepareOptionsMenu(Menu menu) { - menu.findItem(R.id.menu_edit_number_before_call) - .setVisible(mHasEditNumberBeforeCallOption) - .setOnMenuItemClickListener(this); - menu.findItem(R.id.menu_report) - .setVisible(mHasReportMenuOption) - .setOnMenuItemClickListener(this); - return super.onPrepareOptionsMenu(menu); - } - - @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.call_detail_delete_menu_item: @@ -375,14 +400,65 @@ public class CallDetailActivity extends AppCompatActivity this, callIds.toString(), mCallLogAsyncTaskListener); } break; - case R.id.menu_edit_number_before_call: - startActivity(new Intent(Intent.ACTION_DIAL, CallUtil.getCallUri(mNumber))); - break; } return true; } + @Override + public void onClick(View view) { + switch(view.getId()) { + case R.id.call_detail_action_block: + // TODO: Use helper, this code is repeated in several places. + FilterNumberDialogFragment newFragment = + FilterNumberDialogFragment.newInstance( + mBlockedNumberId, null, mNumber, null, mDisplayNumber); + // TODO: Cleanup this listener pattern. This only works correctly for undoing + // blocking, not undoing unblocking. + newFragment.setOnBlockListener(this); + newFragment.setOnUndoBlockListener(this); + newFragment.setParentView(findViewById(R.id.call_detail)); + newFragment.show( + getFragmentManager(), FilterNumberDialogFragment.BLOCK_DIALOG_FRAGMENT); + break; + case R.id.call_detail_action_copy: + ClipboardUtils.copyText(mContext, null, mNumber, true); + break; + case R.id.call_detail_action_edit_before_call: + Intent dialIntent = new Intent(Intent.ACTION_DIAL, CallUtil.getCallUri(mNumber)); + DialerUtils.startActivityWithErrorToast(mContext, dialIntent); + break; + default: + Log.wtf(TAG, "Unexpected onClick event from " + view); + break; + } + } + + private void updateBlockActionItem() { + if (mDetails == null) { + return; + } + + mFilteredNumberAsyncQueryHandler.startBlockedQuery(new OnCheckBlockedListener() { + @Override + public void onCheckComplete(Integer id) { + mBlockedNumberId = id; + if (mBlockedNumberId == null) { + mBlockNumberActionItemText.setText(R.string.action_block_number); + } else { + mBlockNumberActionItemText.setText(R.string.action_unblock_number); + } + + mBlockNumberActionItem.setVisibility(View.VISIBLE); + } + }, null, mNumber, mDetails.countryIso); + } + private void closeSystemDialogs() { sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); } + + @NeededForTesting + public boolean hasVoicemail() { + return mVoicemailUri != null; + } } diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 316864fe2..703b18f8f 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.PhoneCallDetails; 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 @@ public class CallLogAdapter extends GroupingListAdapter private final FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler; protected ContactInfoCache mContactInfoCache; + protected final Map<NumberWithCountryIso, Integer> mBlockedIdCache; private boolean mIsCallLogActivity; @@ -248,6 +252,7 @@ public class CallLogAdapter extends GroupingListAdapter 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 class CallLogAdapter extends GroupingListAdapter public void invalidateCache() { mContactInfoCache.invalidate(); + mBlockedIdCache.clear(); } public void startCache() { @@ -456,7 +462,7 @@ public class CallLogAdapter extends GroupingListAdapter 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,8 +498,28 @@ public class CallLogAdapter extends GroupingListAdapter mCurrentlyExpandedPosition = position; } + // 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 { + 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.showActions(mCurrentlyExpandedPosition == position); - views.updatePhoto(); mCallLogListItemHelper.setPhoneCallDetails(views, details); } diff --git a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java index 5b47d4477..0e234e345 100644 --- a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java +++ b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java @@ -268,7 +268,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } menu.add(ContextMenu.NONE, R.id.context_menu_copy_to_clipboard, ContextMenu.NONE, - R.string.copy_number_text) + R.string.action_copy_number_text) .setOnMenuItemClickListener(this); // The edit number before call does not show up if any of the conditions apply: @@ -280,7 +280,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder && !mTelecomCallLogCache.isVoicemailNumber(accountHandle, number) && !PhoneNumberUtil.isSipNumber(number)) { menu.add(ContextMenu.NONE, R.id.context_menu_edit_before_call, ContextMenu.NONE, - R.string.call_log_edit_number_before_call) + R.string.action_edit_number_before_call) .setOnMenuItemClickListener(this); } @@ -296,8 +296,8 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder @Override public void onCheckComplete(Integer id) { blockId = id; - int blockTitleId = blockId == null ? R.string.call_log_block_number - : R.string.call_log_unblock_number; + int blockTitleId = blockId == null ? R.string.action_block_number + : R.string.action_unblock_number; final MenuItem blockItem = menu.add( ContextMenu.NONE, R.id.context_menu_block_number, @@ -528,8 +528,13 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } public void updatePhoto() { - quickContactView.assignContactUri(info.lookupUri); 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; diff --git a/src/com/android/dialer/calllog/CallTypeIconsView.java b/src/com/android/dialer/calllog/CallTypeIconsView.java index cfd8f9748..d2be380a5 100644 --- a/src/com/android/dialer/calllog/CallTypeIconsView.java +++ b/src/com/android/dialer/calllog/CallTypeIconsView.java @@ -199,7 +199,7 @@ public class CallTypeIconsView extends View { 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 79e5861dc..e12fd6b38 100644 --- a/src/com/android/dialer/filterednumber/BlockedNumberFragment.java +++ b/src/com/android/dialer/filterednumber/BlockedNumberFragment.java @@ -27,7 +27,6 @@ import android.view.View; 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 @@ public class BlockedNumberFragment extends ListFragment implements @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 @@ public class BlockedNumberFragment extends ListFragment implements } @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 @@ public class BlockedNumberFragment extends ListFragment implements @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/ManageBlockedNumbersActivity.java index cfa404f05..356c55cee 100644 --- a/src/com/android/dialer/filterednumber/BlockedNumberSearchActivity.java +++ b/src/com/android/dialer/filterednumber/ManageBlockedNumbersActivity.java @@ -18,6 +18,7 @@ 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; @@ -26,6 +27,7 @@ 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; @@ -42,16 +44,23 @@ import com.android.dialer.list.BlockedListSearchFragment; import com.android.dialer.list.SearchFragment; import com.android.dialer.widget.SearchEditTextLayout; -public class BlockedNumberSearchActivity extends AppCompatActivity +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) { @@ -72,17 +81,93 @@ public class BlockedNumberSearchActivity extends AppCompatActivity } }; + 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()); - setContentView(R.layout.search_activity); + 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); @@ -90,49 +175,41 @@ public class BlockedNumberSearchActivity extends AppCompatActivity 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() { - } - }); + 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)); - - enterSearchUi(); } - private void enterSearchUi() { - if (mSearchFragment != null) { - return; + @Override + public void onAttachFragment(Fragment fragment) { + if (fragment instanceof BlockedNumberFragment) { + mManagementFragment = (BlockedNumberFragment) fragment; + } else if (fragment instanceof BlockedListSearchFragment) { + mSearchFragment = (BlockedListSearchFragment) fragment; } - 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); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getItemId() == android.R.id.home) { + onBackPressed(); + return true; } - fragment.setHasOptionsMenu(false); - fragment.setShowEmptyListForNullQuery(true); - fragment.setDirectorySearchEnabled(false); - transaction.commit(); + return false; } @Override - public void onAttachFragment(Fragment fragment) { - if (fragment instanceof BlockedListSearchFragment) { - mSearchFragment = (BlockedListSearchFragment) fragment; + public void onBackPressed() { + if (mIsShowingManagementUi) { + super.onBackPressed(); + } else { + showManagementUi(); } } @@ -158,6 +235,6 @@ public class BlockedNumberSearchActivity extends AppCompatActivity @Override public int getActionBarHeight() { - return getResources().getDimensionPixelSize(R.dimen.action_bar_height_large); + return getSupportActionBar().getHeight(); } } diff --git a/src/com/android/dialer/list/BlockedListSearchFragment.java b/src/com/android/dialer/list/BlockedListSearchFragment.java index 675081254..eef24afb1 100644 --- a/src/com/android/dialer/list/BlockedListSearchFragment.java +++ b/src/com/android/dialer/list/BlockedListSearchFragment.java @@ -86,13 +86,9 @@ public class BlockedListSearchFragment extends RegularSearchFragment { 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 @@ public class BlockedListSearchFragment extends RegularSearchFragment { 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 @@ public class BlockedListSearchFragment extends RegularSearchFragment { 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 @@ public class BlockedListSearchFragment extends RegularSearchFragment { } 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 1c895d3af..c8711e769 100644 --- a/src/com/android/dialer/list/SearchFragment.java +++ b/src/com/android/dialer/list/SearchFragment.java @@ -289,12 +289,12 @@ public class SearchFragment extends PhoneNumberPickerFragment { 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 58b0ab8e6..6fcd22195 100644 --- a/src/com/android/dialer/settings/DialerSettingsActivity.java +++ b/src/com/android/dialer/settings/DialerSettingsActivity.java @@ -28,7 +28,7 @@ import android.view.MenuItem; 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 @@ public class DialerSettingsActivity extends AppCompatPreferenceActivity { } 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/tests/src/com/android/dialer/CallDetailActivityTest.java b/tests/src/com/android/dialer/CallDetailActivityTest.java index eda74742b..c310c8870 100644 --- a/tests/src/com/android/dialer/CallDetailActivityTest.java +++ b/tests/src/com/android/dialer/CallDetailActivityTest.java @@ -16,7 +16,7 @@ package com.android.dialer; -import static com.android.dialer.calllog.CallLogAsyncTaskUtil.Tasks.GET_CALL_DETAILS; +import static com.android.dialer.calllog.CallLogAsyncTaskUtil.Tasks; import android.content.ContentResolver; import android.content.ContentUris; @@ -89,14 +89,20 @@ public class CallDetailActivityTest extends ActivityInstrumentationTestCase2<Cal public void testVoicemailDeleteButton() throws Throwable { setActivityIntentForTestVoicemailEntry(); startActivityUnderTest(); - mFakeAsyncTaskExecutor.runTask(GET_CALL_DETAILS); + mFakeAsyncTaskExecutor.runTask(Tasks.GET_CALL_DETAILS); Menu optionsMenu = (new PopupMenu(mActivityUnderTest, null)).getMenu(); mActivityUnderTest.onCreateOptionsMenu(optionsMenu); mActivityUnderTest.onPrepareOptionsMenu(optionsMenu); - assertTrue(optionsMenu.findItem(R.id.call_detail_delete_menu_item).isVisible()); assertTrue(mActivityUnderTest.hasVoicemail()); + mActivityUnderTest.runOnUiThread(new Runnable() { + public void run() { + mActivityUnderTest.findViewById(R.id.call_detail_delete_menu_item).performClick(); + } + }); + getInstrumentation().waitForIdleSync(); + mFakeAsyncTaskExecutor.runTask(Tasks.DELETE_VOICEMAIL); } /** @@ -105,14 +111,20 @@ public class CallDetailActivityTest extends ActivityInstrumentationTestCase2<Cal public void testRegularCallDoesHaveRemoveFromCallLog() throws Throwable { setActivityIntentForTestCallEntry(); startActivityUnderTest(); - mFakeAsyncTaskExecutor.runTask(GET_CALL_DETAILS); + mFakeAsyncTaskExecutor.runTask(Tasks.GET_CALL_DETAILS); Menu optionsMenu = (new PopupMenu(mActivityUnderTest, null)).getMenu(); mActivityUnderTest.onCreateOptionsMenu(optionsMenu); mActivityUnderTest.onPrepareOptionsMenu(optionsMenu); - assertTrue(optionsMenu.findItem(R.id.call_detail_delete_menu_item).isVisible()); assertFalse(mActivityUnderTest.hasVoicemail()); + mActivityUnderTest.runOnUiThread(new Runnable() { + public void run() { + mActivityUnderTest.findViewById(R.id.call_detail_delete_menu_item).performClick(); + } + }); + getInstrumentation().waitForIdleSync(); + mFakeAsyncTaskExecutor.runTask(Tasks.DELETE_CALL); } private void setActivityIntentForTestCallEntry() { |