From e39fbce599f71e3279e309a53607b13895fa64eb Mon Sep 17 00:00:00 2001 From: Michael W Date: Sat, 14 Jan 2023 22:39:00 +0100 Subject: [PATCH 01/65] Dialer: A little bit of You * ... Material You! * Round the elements in the call history, change the elevation and card color depending on the expanded state and animate the changes * Make the dialpad stick out a little more against the background * Round the search bar * Enlarge the spacing in the bottom navbar * Materialize various button colors Change-Id: Ia7c860e6e4bf2b085a6914191ad587fd4052855c --- .../calllog/CallLogListItemViewHolder.java | 86 ++++++++++++++++++- .../app/res/layout/call_log_list_item.xml | 1 - .../dialpadview/theme/res/values/styles.xml | 4 +- .../bottomnav/res/layout/bottom_nav_item.xml | 7 +- .../search_bar_background_rounded_corners.xml | 2 +- ...h_bar_background_rounded_corners_shape.xml | 2 +- .../theme/common/res/values-night/colors.xml | 5 ++ .../dialer/theme/common/res/values/colors.xml | 11 ++- .../dialer/theme/common/res/values/styles.xml | 5 +- 9 files changed, 105 insertions(+), 18 deletions(-) diff --git a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java index af4fb297b5..07e00f96a0 100644 --- a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java +++ b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java @@ -17,6 +17,12 @@ package com.android.dialer.app.calllog; import android.Manifest.permission; +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.AnimatorSet; +import android.animation.ArgbEvaluator; +import android.animation.TimeInterpolator; +import android.animation.ValueAnimator; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; @@ -44,8 +50,12 @@ import android.text.TextDirectionHeuristics; import android.text.TextUtils; import android.view.ContextMenu; import android.view.LayoutInflater; +import android.transition.TransitionManager; +import android.view.animation.AccelerateDecelerateInterpolator; +import android.view.animation.DecelerateInterpolator; import android.view.MenuItem; import android.view.View; +import android.view.ViewGroup; import android.view.ViewStub; import android.widget.ImageButton; import android.widget.ImageView; @@ -502,6 +512,8 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder sendVoicemailButtonView = actionsView.findViewById(R.id.share_voicemail); sendVoicemailButtonView.setOnClickListener(this); + + actionsView.setVisibility(View.GONE); } } @@ -887,22 +899,88 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder return; } + TransitionManager.beginDelayedTransition((ViewGroup) rootView); // Inflate the view stub if necessary, and wire up the event handlers. inflateActionViewStub(); bindActionButtons(); - actionsView.setVisibility(View.VISIBLE); - actionsView.setAlpha(1.0f); + animateActions(true); + TransitionManager.endTransitions((ViewGroup) rootView); } else { + TransitionManager.beginDelayedTransition((ViewGroup) rootView); // When recycling a view, it is possible the actionsView ViewStub was previously // inflated so we should hide it in this case. if (actionsView != null) { - actionsView.setVisibility(View.GONE); + animateActions(false); } + TransitionManager.endTransitions((ViewGroup) rootView); } - updatePrimaryActionButton(show); } + private void animateActions(boolean shouldExpand) { + boolean isExpanded = actionsView.getVisibility() == View.VISIBLE; + if (shouldExpand == isExpanded) { + return; + } + Resources res = context.getResources(); + actionsView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); + int currentHeight = callLogEntryView.getMeasuredHeight(); + int additionalHeight = actionsView.getMeasuredHeight(); + + int targetHeight; + int colorFrom, colorTo; + TimeInterpolator interpolator; + int targetVisibility; + float targetElevation; + if (shouldExpand) { + targetHeight = currentHeight + additionalHeight; + colorFrom = res.getColor(android.R.color.transparent, context.getTheme()); + colorTo = res.getColor(R.color.cardBackgroundColor, context.getTheme()); + interpolator = new AccelerateDecelerateInterpolator(); + targetVisibility = View.VISIBLE; + targetElevation = 4f; + } else { + targetHeight = currentHeight - additionalHeight; + colorFrom = res.getColor(R.color.cardBackgroundColor, context.getTheme()); + colorTo = res.getColor(android.R.color.transparent, context.getTheme()); + interpolator = new DecelerateInterpolator(); + targetVisibility = View.GONE; + targetElevation = 0f; + // need to do this before animating, otherwise the color changes are weird + callLogEntryView.setCardElevation(targetElevation); + } + + ValueAnimator heightAnimator = ValueAnimator.ofInt(currentHeight, targetHeight); + heightAnimator.addUpdateListener(animation -> { + callLogEntryView.getLayoutParams().height = (int) animation.getAnimatedValue(); + callLogEntryView.requestLayout(); + }); + heightAnimator.setInterpolator(interpolator); + heightAnimator.setDuration(200); + + ValueAnimator colorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); + colorAnimator.setDuration(200); + colorAnimator.addUpdateListener(animator -> callLogEntryView.setCardBackgroundColor( + (int) animator.getAnimatedValue())); + + AnimatorSet animatorSet = new AnimatorSet(); + animatorSet.playTogether(heightAnimator, colorAnimator); + animatorSet.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + super.onAnimationEnd(animation); + actionsView.setVisibility(targetVisibility); + callLogEntryView.setCardElevation(targetElevation); + + // we need to set this so we can expand again + ViewGroup.LayoutParams params = callLogEntryView.getLayoutParams(); + params.height = ViewGroup.LayoutParams.WRAP_CONTENT; + callLogEntryView.setLayoutParams(params); + } + }); + animatorSet.start(); + } + private void showOrHideVoicemailTranscriptionView(boolean isExpanded) { if (callType != Calls.VOICEMAIL_TYPE) { return; diff --git a/java/com/android/dialer/app/res/layout/call_log_list_item.xml b/java/com/android/dialer/app/res/layout/call_log_list_item.xml index c9c1a67397..46a49cc4c2 100644 --- a/java/com/android/dialer/app/res/layout/call_log_list_item.xml +++ b/java/com/android/dialer/app/res/layout/call_log_list_item.xml @@ -45,7 +45,6 @@ ?android:attr/textColorSecondary ?android:attr/colorPrimary ?android:attr/textColorSecondary - ?android:attr/colorBackgroundFloating + @*android:color/system_neutral1_50 - \ No newline at end of file + diff --git a/java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_item.xml b/java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_item.xml index 02874a9d8d..b4d564cba3 100644 --- a/java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_item.xml +++ b/java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_item.xml @@ -32,7 +32,8 @@ android:id="@+id/bottom_nav_item_image" android:layout_width="24dp" android:layout_height="24dp" - android:layout_marginTop="8dp"/> + android:layout_marginTop="8dp" + android:layout_marginBottom="4dp"/> - \ No newline at end of file + diff --git a/java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background_rounded_corners.xml b/java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background_rounded_corners.xml index 2130db443a..2acd72f1fe 100644 --- a/java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background_rounded_corners.xml +++ b/java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background_rounded_corners.xml @@ -20,7 +20,7 @@ - + diff --git a/java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background_rounded_corners_shape.xml b/java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background_rounded_corners_shape.xml index ee3219ec17..62f1e61348 100644 --- a/java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background_rounded_corners_shape.xml +++ b/java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background_rounded_corners_shape.xml @@ -17,5 +17,5 @@ - + diff --git a/java/com/android/dialer/theme/common/res/values-night/colors.xml b/java/com/android/dialer/theme/common/res/values-night/colors.xml index aa42d8b889..76de765cb0 100644 --- a/java/com/android/dialer/theme/common/res/values-night/colors.xml +++ b/java/com/android/dialer/theme/common/res/values-night/colors.xml @@ -18,4 +18,9 @@ #1C3AA9 + + #3ee0a0 + #ffb3ac + #b5c4ff + #adc6ff diff --git a/java/com/android/dialer/theme/common/res/values/colors.xml b/java/com/android/dialer/theme/common/res/values/colors.xml index 1831862b18..62684f40e4 100644 --- a/java/com/android/dialer/theme/common/res/values/colors.xml +++ b/java/com/android/dialer/theme/common/res/values/colors.xml @@ -16,11 +16,12 @@ --> - #00C853 - #BD2A2A + #006c49 + #b52425 #D8D8D8 #2A56C6 - #4285F4 + #005ac1 + #097138 @@ -31,4 +32,6 @@ #CFD8DC - \ No newline at end of file + + @*android:color/system_neutral1_50 + diff --git a/java/com/android/dialer/theme/common/res/values/styles.xml b/java/com/android/dialer/theme/common/res/values/styles.xml index 2c6446ca10..928acb1ef3 100644 --- a/java/com/android/dialer/theme/common/res/values/styles.xml +++ b/java/com/android/dialer/theme/common/res/values/styles.xml @@ -22,8 +22,9 @@ wrap_content 4dp false - 2dp - ?android:attr/colorBackgroundFloating + 28dp + ?android:attr/colorBackground + 0dp -- GitLab From cd2c1cffa99030b6a2134247e0f8af78461cce71 Mon Sep 17 00:00:00 2001 From: Michael W Date: Sun, 16 Jul 2023 15:31:48 +0200 Subject: [PATCH 02/65] Dialer: Show New Favorites * There is already a new speed dial activity - it's just not shown by default * It has a more modern design with rounded contact pictures * Testing shows it works just as well as the old one * Switch to it and remove the old one Change-Id: I62fb1db57e7ab027239bdaffcac77abbef7c7350 --- .../android/dialer/app/DialtactsActivity.java | 28 ------------------- .../dialer/main/impl/OldMainActivityPeer.java | 18 ++++-------- 2 files changed, 6 insertions(+), 40 deletions(-) diff --git a/java/com/android/dialer/app/DialtactsActivity.java b/java/com/android/dialer/app/DialtactsActivity.java index 318f9a138e..39e9570715 100644 --- a/java/com/android/dialer/app/DialtactsActivity.java +++ b/java/com/android/dialer/app/DialtactsActivity.java @@ -1431,22 +1431,6 @@ public class DialtactsActivity extends TransactionSafeActivity @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { // FAB does not move with the new favorites UI - if (newFavoritesIsEnabled()) { - return; - } - int tabIndex = listsFragment.getCurrentTabIndex(); - - // Scroll the button from center to end when moving from the Speed Dial to Call History tab. - // In RTL, scroll when the current tab is Call History instead, since the order of the tabs - // is reversed and the ViewPager returns the left tab position during scroll. - boolean isRtl = ViewUtil.isRtl(); - if (!isRtl && tabIndex == DialtactsPagerAdapter.TAB_INDEX_SPEED_DIAL && !isLandscape) { - floatingActionButtonController.onPageScrolled(positionOffset); - } else if (isRtl && tabIndex == DialtactsPagerAdapter.TAB_INDEX_HISTORY && !isLandscape) { - floatingActionButtonController.onPageScrolled(1 - positionOffset); - } else if (tabIndex != DialtactsPagerAdapter.TAB_INDEX_SPEED_DIAL) { - floatingActionButtonController.onPageScrolled(1); - } } @Override @@ -1484,12 +1468,6 @@ public class DialtactsActivity extends TransactionSafeActivity @VisibleForTesting public int getFabAlignment() { - if (!newFavoritesIsEnabled() - && !isLandscape - && !isInSearchUi() - && listsFragment.getCurrentTabIndex() == DialtactsPagerAdapter.TAB_INDEX_SPEED_DIAL) { - return FloatingActionButtonController.ALIGN_MIDDLE; - } return FloatingActionButtonController.ALIGN_END; } @@ -1622,10 +1600,4 @@ public class DialtactsActivity extends TransactionSafeActivity static void setVoiceSearchEnabledForTest(Optional enabled) { voiceSearchEnabledForTest = enabled; } - - private boolean newFavoritesIsEnabled() { - return ConfigProviderComponent.get(this) - .getConfigProvider() - .getBoolean("enable_new_favorites_tab", false); - } } diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index a1afc61643..78ed252677 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -1334,18 +1334,12 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen Logger.get(activity).logScreenView(ScreenEvent.Type.MAIN_SPEED_DIAL, activity); selectedTab = TabIndex.SPEED_DIAL; - if (ConfigProviderComponent.get(activity) - .getConfigProvider() - .getBoolean("enable_new_favorites_tab", false)) { - android.support.v4.app.Fragment supportFragment = - supportFragmentManager.findFragmentByTag(SPEED_DIAL_TAG); - showSupportFragment( - supportFragment == null ? SpeedDialFragment.newInstance() : supportFragment, - SPEED_DIAL_TAG); - } else { - Fragment fragment = fragmentManager.findFragmentByTag(SPEED_DIAL_TAG); - showFragment(fragment == null ? new OldSpeedDialFragment() : fragment, SPEED_DIAL_TAG); - } + android.support.v4.app.Fragment supportFragment = + supportFragmentManager.findFragmentByTag(SPEED_DIAL_TAG); + showSupportFragment( + supportFragment == null ? SpeedDialFragment.newInstance() : supportFragment, + SPEED_DIAL_TAG); + fab.show(); } -- GitLab From b1ec3d398aad9cbbcd0e61cf84d57f5c5fcf1180 Mon Sep 17 00:00:00 2001 From: Michael W Date: Sun, 16 Jul 2023 18:33:58 +0200 Subject: [PATCH 03/65] Dialer: Don't show the same number twice * There was already an attempt to hide duplicates but it operated on the basis that the results were exactly the same * In reality I get to choose the main number twice since it's somehow returned with and without spaces * Normalizing the numbers resolves that Change-Id: Iff89a668f0473e99cf4660927b495f7c5bfb1dfb --- java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java b/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java index 4d268f35bc..c6a6150869 100644 --- a/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java +++ b/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java @@ -23,6 +23,7 @@ import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Data; import android.support.annotation.Nullable; +import android.telephony.PhoneNumberUtils; import android.text.TextUtils; import android.util.ArraySet; import com.android.dialer.common.Assert; @@ -129,8 +130,9 @@ public abstract class SpeedDialUiItem { Set numbers = new ArraySet<>(); do { String number = cursor.getString(NUMBER); + String normalizedNumber = PhoneNumberUtils.normalizeNumber(number); // TODO(78492722): consider using lib phone number to compare numbers - if (!numbers.add(number)) { + if (!numbers.add(normalizedNumber)) { // Number is identical to an existing number, skip this number continue; } -- GitLab From 8a41b1a2387d80087793d3d80e9fdde9ce5d51dc Mon Sep 17 00:00:00 2001 From: Michael W Date: Sun, 16 Jul 2023 19:49:49 +0200 Subject: [PATCH 04/65] Dialer: Redesign DisambigDialog * Give it rounded corners * Don't use headers but just add the label to each item * Move the drawable to the right so it matches other views like callog * No divider required Change-Id: I3280af0a246250166bd3d302486a444a70da2de0 --- .../dialer/speeddial/DisambigDialog.java | 69 +++++-------------- .../res/drawable/dialog_background.xml | 22 ++++++ .../res/layout/disambig_dialog_divider.xml | 23 ------- .../res/layout/disambig_dialog_layout.xml | 5 +- .../layout/disambig_option_header_layout.xml | 26 ------- .../res/layout/disambig_option_layout.xml | 40 ++++++++--- 6 files changed, 72 insertions(+), 113 deletions(-) create mode 100644 java/com/android/dialer/speeddial/res/drawable/dialog_background.xml delete mode 100644 java/com/android/dialer/speeddial/res/layout/disambig_dialog_divider.xml delete mode 100644 java/com/android/dialer/speeddial/res/layout/disambig_option_header_layout.xml diff --git a/java/com/android/dialer/speeddial/DisambigDialog.java b/java/com/android/dialer/speeddial/DisambigDialog.java index 15b81098b8..93497da662 100644 --- a/java/com/android/dialer/speeddial/DisambigDialog.java +++ b/java/com/android/dialer/speeddial/DisambigDialog.java @@ -24,15 +24,15 @@ import android.support.annotation.WorkerThread; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentManager; import android.support.v7.app.AlertDialog; -import android.text.TextUtils; import android.util.ArraySet; import android.view.LayoutInflater; import android.view.View; import android.widget.CheckBox; import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.LinearLayout.LayoutParams; import android.widget.TextView; + +import com.android.dialer.R; import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.callintent.CallIntentBuilder; import com.android.dialer.common.Assert; @@ -86,11 +86,9 @@ public class DisambigDialog extends DialogFragment { @Override public void onResume() { super.onResume(); - getDialog() - .getWindow() - .setLayout( - getContext().getResources().getDimensionPixelSize(R.dimen.disambig_dialog_width), - LayoutParams.WRAP_CONTENT); + getDialog().getWindow().setBackgroundDrawable( + getActivity().getResources().getDrawable(R.drawable.dialog_background, + getActivity().getTheme())); } @Override @@ -112,63 +110,30 @@ public class DisambigDialog extends DialogFragment { */ private void insertOptions(LinearLayout container, List channels) { for (Channel channel : channels) { - // TODO(calderwoodra): use fuzzy number matcher - if (phoneNumbers.add(channel.number())) { - if (phoneNumbers.size() != 1) { - insertDivider(container); - } - insertHeader(container, channel.number(), channel.label()); - } insertOption(container, channel); } } - private void insertDivider(LinearLayout container) { - View view = - getActivity() - .getLayoutInflater() - .inflate(R.layout.disambig_dialog_divider, container, false); - container.addView(view); - } - - private void insertHeader(LinearLayout container, String number, String label) { - View view = - getActivity() - .getLayoutInflater() - .inflate(R.layout.disambig_option_header_layout, container, false); - String secondaryInfo = - TextUtils.isEmpty(label) - ? number - : getContext().getString(R.string.call_subject_type_and_number, label, number); - ((TextView) view.findViewById(R.id.disambig_header_phone_label)).setText(secondaryInfo); - container.addView(view); - } - - /** Inserts a group of options for a specific phone number. */ private void insertOption(LinearLayout container, Channel channel) { - View view = - getActivity() + View view = getActivity() .getLayoutInflater() .inflate(R.layout.disambig_option_layout, container, false); + View option = view.findViewById(R.id.option_container); if (channel.isVideoTechnology()) { - View videoOption = view.findViewById(R.id.option_container); - videoOption.setOnClickListener(v -> onVideoOptionClicked(channel)); - videoOption.setContentDescription( - getActivity().getString(R.string.disambig_option_video_call)); + option.setOnClickListener(v -> onVideoOptionClicked(channel)); + option.setContentDescription( + getActivity().getString(R.string.disambig_option_video_call)); ((ImageView) view.findViewById(R.id.disambig_option_image)) - .setImageResource(R.drawable.quantum_ic_videocam_vd_theme_24); - ((TextView) view.findViewById(R.id.disambig_option_text)) - .setText(R.string.disambig_option_video_call); + .setImageResource(R.drawable.quantum_ic_videocam_vd_theme_24); } else { - View voiceOption = view.findViewById(R.id.option_container); - voiceOption.setOnClickListener(v -> onVoiceOptionClicked(channel)); - voiceOption.setContentDescription( - getActivity().getString(R.string.disambig_option_voice_call)); + option.setOnClickListener(v -> onVoiceOptionClicked(channel)); + option.setContentDescription( + getActivity().getString(R.string.disambig_option_voice_call)); ((ImageView) view.findViewById(R.id.disambig_option_image)) - .setImageResource(R.drawable.quantum_ic_phone_vd_theme_24); - ((TextView) view.findViewById(R.id.disambig_option_text)) - .setText(R.string.disambig_option_voice_call); + .setImageResource(R.drawable.quantum_ic_phone_vd_theme_24); } + ((TextView) option.findViewById(R.id.speed_dial_label)).setText(channel.label()); + ((TextView) option.findViewById(R.id.speed_dial_number)).setText(channel.number()); container.addView(view); } diff --git a/java/com/android/dialer/speeddial/res/drawable/dialog_background.xml b/java/com/android/dialer/speeddial/res/drawable/dialog_background.xml new file mode 100644 index 0000000000..119b08b5d5 --- /dev/null +++ b/java/com/android/dialer/speeddial/res/drawable/dialog_background.xml @@ -0,0 +1,22 @@ + + + + + + + diff --git a/java/com/android/dialer/speeddial/res/layout/disambig_dialog_divider.xml b/java/com/android/dialer/speeddial/res/layout/disambig_dialog_divider.xml deleted file mode 100644 index a743cccff6..0000000000 --- a/java/com/android/dialer/speeddial/res/layout/disambig_dialog_divider.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - \ No newline at end of file diff --git a/java/com/android/dialer/speeddial/res/layout/disambig_dialog_layout.xml b/java/com/android/dialer/speeddial/res/layout/disambig_dialog_layout.xml index 0923c52670..f4b3f6d86d 100644 --- a/java/com/android/dialer/speeddial/res/layout/disambig_dialog_layout.xml +++ b/java/com/android/dialer/speeddial/res/layout/disambig_dialog_layout.xml @@ -39,7 +39,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="168dp" - app:maxHeight="256dp"> + app:maxHeight="256dp" + android:background="?android:attr/colorBackgroundFloating"> - \ No newline at end of file + diff --git a/java/com/android/dialer/speeddial/res/layout/disambig_option_header_layout.xml b/java/com/android/dialer/speeddial/res/layout/disambig_option_header_layout.xml deleted file mode 100644 index ffda3675e1..0000000000 --- a/java/com/android/dialer/speeddial/res/layout/disambig_option_header_layout.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - diff --git a/java/com/android/dialer/speeddial/res/layout/disambig_option_layout.xml b/java/com/android/dialer/speeddial/res/layout/disambig_option_layout.xml index 0388005482..25d3d3a14f 100644 --- a/java/com/android/dialer/speeddial/res/layout/disambig_option_layout.xml +++ b/java/com/android/dialer/speeddial/res/layout/disambig_option_layout.xml @@ -14,28 +14,48 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License --> - - + style="@style/Dialer.TextAppearance.Primary" + tools:text="Mobile"/> + + + - \ No newline at end of file + android:tint="?colorIcon" + android:layout_alignParentEnd="true" + android:layout_centerVertical="true"/> + -- GitLab From 826405cf1d0e185508e55d8fbe9725da2f0a804e Mon Sep 17 00:00:00 2001 From: Michael W Date: Sat, 8 Jul 2023 00:10:45 +0200 Subject: [PATCH 05/65] Dialer: Remove compatibility (1/x) * Now that we don't expect any more changes we can rip out all the unused stuff * Start with all the TargetApi-checks for N, O and P including version checks in code for those and remove the old number blocking - we have the provider since 2017 now... Change-Id: Ib9369476fa660c44d946b0e41b0d23a34ff14e7c --- AndroidManifest.xml | 2 +- .../contacts/common/compat/CallCompat.java | 5 +- .../compat/telecom/TelecomManagerCompat.java | 73 ---- .../android/dialer/app/AndroidManifest.xml | 12 - .../app/calllog/BlockReportSpamListener.java | 6 +- .../dialer/app/calllog/CallLogAdapter.java | 7 +- .../calllog/CallLogListItemViewHolder.java | 55 +-- .../CallLogNotificationsQueryHelper.java | 8 +- .../dialer/app/calllog/CallLogReceiver.java | 5 +- .../app/calllog/LegacyVoicemailNotifier.java | 6 - .../app/calllog/MissedCallNotifier.java | 13 +- .../app/calllog/PhoneCallDetailsHelper.java | 5 +- .../app/calllog/VisualVoicemailNotifier.java | 30 +- .../filterednumber/BlockedNumbersAdapter.java | 96 ----- .../BlockedNumbersFragment.java | 263 -------------- .../BlockedNumbersSettingsActivity.java | 97 ------ .../app/filterednumber/NumbersAdapter.java | 137 -------- .../ViewNumbersToImportAdapter.java | 57 --- .../ViewNumbersToImportFragment.java | 131 ------- .../dialer/app/list/ListsFragment.java | 5 - .../app/res/layout/blocked_number_footer.xml | 37 -- .../res/layout/blocked_number_fragment.xml | 30 -- .../app/res/layout/blocked_number_header.xml | 180 ---------- .../app/res/layout/blocked_number_item.xml | 67 ---- .../res/layout/blocked_numbers_activity.xml | 22 -- .../view_numbers_to_import_fragment.xml | 58 --- .../app/settings/DialerSettingsActivity.java | 42 +-- .../LegacyVoicemailNotificationReceiver.java | 17 - .../assisteddialing/ConcreteCreator.java | 60 +--- .../ui/AssistedDialingSettingFragment.java | 2 + .../binary/common/DialerApplication.java | 13 +- .../dialer/blocking/AndroidManifest.xml | 9 +- .../blocking/BlockNumberDialogFragment.java | 329 ------------------ .../blocking/BlockedNumbersAutoMigrator.java | 141 -------- .../blocking/BlockedNumbersMigrator.java | 151 -------- .../FilteredNumberAsyncQueryHandler.java | 107 ++---- .../dialer/blocking/FilteredNumberCompat.java | 312 ----------------- .../blocking/FilteredNumberProvider.java | 176 ---------- .../dialer/blocking/FilteredNumbersUtil.java | 276 +++------------ .../MigrateBlockedNumbersDialogFragment.java | 114 ------ .../BlockReportSpamDialogs.java | 11 +- .../CallDetailsEntryViewHolder.java | 11 +- .../contract/AnnotatedCallLogContract.java | 2 - .../SystemCallLogDataSource.java | 18 +- .../dialer/calllogutils/PhotoInfoBuilder.java | 5 +- .../callrecord/CallRecordingAutoMigrator.java | 6 - .../telephony/TelephonyManagerCompat.java | 37 +- .../android/dialer/constants/Constants.java | 3 - .../constants/aospdialer/ConstantsImpl.java | 6 - .../constants/googledialer/ConstantsImpl.java | 6 - .../dialer/database/DialerDatabaseHelper.java | 74 +--- .../database/FilteredNumberContract.java | 137 -------- .../databasepopulator/VoicemailPopulator.java | 7 +- .../dialer/dialpadview/DialpadFragment.java | 8 +- .../dialer/main/impl/OldMainActivityPeer.java | 5 +- .../DialerNotificationManager.java | 6 +- .../NotificationChannelManager.java | 8 +- .../notification/VoicemailChannelUtils.java | 15 +- .../SystemBlockedNumberPhoneLookup.java | 7 - .../dialer/phonenumbercache/CallLogQuery.java | 11 +- .../preferredsim/PreferredAccountUtil.java | 28 -- .../dialer/shortcuts/DialerShortcut.java | 3 - .../dialer/shortcuts/DynamicShortcuts.java | 3 - .../android/dialer/shortcuts/IconFactory.java | 42 +-- .../dialer/shortcuts/PeriodicJobService.java | 17 +- .../dialer/shortcuts/PinnedShortcuts.java | 5 +- .../shortcuts/RefreshShortcutsTask.java | 3 - .../dialer/shortcuts/ShortcutInfoFactory.java | 3 - .../dialer/shortcuts/ShortcutRefresher.java | 4 - .../shortcuts/ShortcutUsageReporter.java | 6 +- .../dialer/simulator/impl/RttChatBot.java | 2 - .../simulator/impl/SimulatorConnection.java | 7 +- .../spam/promo/SpamBlockingPromoHelper.java | 10 +- .../impl/SystemDialerStrictMode.java | 8 +- .../android/dialer/telecom/TelecomUtil.java | 8 +- .../error/VoicemailErrorMessageCreator.java | 6 - .../listui/error/VoicemailStatus.java | 24 +- .../VoicemailStatusCorruptionHandler.java | 116 ------ .../error/Vvm3VoicemailMessageCreator.java | 5 +- .../settings/VoicemailChangePinActivity.java | 5 +- .../settings/VoicemailSettingsFragment.java | 5 +- .../voicemailstatus/VoicemailStatusQuery.java | 33 +- .../incallui/ExternalCallNotifier.java | 17 +- .../com/android/incallui/InCallPresenter.java | 162 +-------- .../android/incallui/InCallServiceImpl.java | 1 - .../NotificationBroadcastReceiver.java | 3 - .../android/incallui/RttCallPresenter.java | 2 - .../android/incallui/StatusBarNotifier.java | 32 +- .../incallui/answer/impl/AnswerFragment.java | 11 +- .../AudioRouteSelectorDialogFragment.java | 37 +- .../com/android/incallui/call/DialerCall.java | 54 +-- .../android/incallui/call/TelecomAdapter.java | 2 - .../VideoCallNotAvailablePrompt.java | 4 +- .../BlockedNumberContentObserver.java | 111 ------ .../legacyblocking/DeleteBlockedCallTask.java | 121 ------- .../incallui/spam/SpamCallListListener.java | 13 +- .../spam/SpamNotificationActivity.java | 50 +-- .../spam/SpamNotificationService.java | 2 +- .../bindings/VideoSurfaceBindings.java | 8 +- .../impl/VideoSurfaceTextureImpl.java | 13 +- .../voicemail/impl/ActivationTask.java | 5 - .../voicemail/impl/CarrierIdentifier.java | 3 - .../impl/DeviceProvisionedJobService.java | 3 - .../android/voicemail/impl/OmtpService.java | 3 - .../impl/OmtpVvmCarrierConfigHelper.java | 3 - .../voicemail/impl/PinChangerImpl.java | 3 - .../voicemail/impl/PreOMigrationHandler.java | 106 ------ .../voicemail/impl/StatusCheckJobService.java | 3 - .../voicemail/impl/StatusCheckTask.java | 3 - .../voicemail/impl/VoicemailClientImpl.java | 21 +- .../voicemail/impl/VoicemailModule.java | 6 - .../impl/VvmPackageInstallHandler.java | 3 - .../impl/fetch/FetchVoicemailReceiver.java | 7 - .../impl/mail/store/imap/DigestMd5Utils.java | 3 - .../voicemail/impl/protocol/Vvm3Protocol.java | 3 - .../impl/protocol/Vvm3Subscriber.java | 3 - .../impl/scheduling/TaskExecutor.java | 3 - .../impl/scheduling/TaskReceiver.java | 3 - .../scheduling/TaskSchedulerJobService.java | 3 - .../impl/sms/LegacyModeSmsHandler.java | 3 - .../impl/sms/OmtpMessageReceiver.java | 3 - .../voicemail/impl/sms/OmtpMessageSender.java | 3 - .../voicemail/impl/sms/StatusSmsFetcher.java | 3 - .../impl/sync/OmtpVvmSyncService.java | 7 - .../impl/sync/VvmAccountManager.java | 3 - .../impl/sync/VvmNetworkRequest.java | 3 - .../impl/sync/VvmNetworkRequestCallback.java | 3 - .../TranscriptionBackfillService.java | 22 +- .../TranscriptionConfigProvider.java | 4 +- .../transcribe/TranscriptionDbHelper.java | 6 - .../TranscriptionRatingService.java | 6 - .../impl/transcribe/TranscriptionService.java | 4 - .../impl/transcribe/TranscriptionUtils.java | 3 - 133 files changed, 283 insertions(+), 4502 deletions(-) delete mode 100644 java/com/android/contacts/common/compat/telecom/TelecomManagerCompat.java delete mode 100644 java/com/android/dialer/app/filterednumber/BlockedNumbersAdapter.java delete mode 100644 java/com/android/dialer/app/filterednumber/BlockedNumbersFragment.java delete mode 100644 java/com/android/dialer/app/filterednumber/BlockedNumbersSettingsActivity.java delete mode 100644 java/com/android/dialer/app/filterednumber/NumbersAdapter.java delete mode 100644 java/com/android/dialer/app/filterednumber/ViewNumbersToImportAdapter.java delete mode 100644 java/com/android/dialer/app/filterednumber/ViewNumbersToImportFragment.java delete mode 100644 java/com/android/dialer/app/res/layout/blocked_number_footer.xml delete mode 100644 java/com/android/dialer/app/res/layout/blocked_number_fragment.xml delete mode 100644 java/com/android/dialer/app/res/layout/blocked_number_header.xml delete mode 100644 java/com/android/dialer/app/res/layout/blocked_number_item.xml delete mode 100644 java/com/android/dialer/app/res/layout/blocked_numbers_activity.xml delete mode 100644 java/com/android/dialer/app/res/layout/view_numbers_to_import_fragment.xml delete mode 100644 java/com/android/dialer/blocking/BlockNumberDialogFragment.java delete mode 100644 java/com/android/dialer/blocking/BlockedNumbersAutoMigrator.java delete mode 100644 java/com/android/dialer/blocking/BlockedNumbersMigrator.java delete mode 100644 java/com/android/dialer/blocking/FilteredNumberCompat.java delete mode 100644 java/com/android/dialer/blocking/FilteredNumberProvider.java delete mode 100644 java/com/android/dialer/blocking/MigrateBlockedNumbersDialogFragment.java delete mode 100644 java/com/android/dialer/database/FilteredNumberContract.java delete mode 100644 java/com/android/dialer/voicemail/listui/error/VoicemailStatusCorruptionHandler.java delete mode 100644 java/com/android/incallui/legacyblocking/BlockedNumberContentObserver.java delete mode 100644 java/com/android/incallui/legacyblocking/DeleteBlockedCallTask.java delete mode 100644 java/com/android/voicemail/impl/PreOMigrationHandler.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 6243740997..8b4086cc35 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -20,7 +20,7 @@ android:versionName="23.0"> diff --git a/java/com/android/contacts/common/compat/CallCompat.java b/java/com/android/contacts/common/compat/CallCompat.java index 641f7b1bd4..55a1df3a03 100644 --- a/java/com/android/contacts/common/compat/CallCompat.java +++ b/java/com/android/contacts/common/compat/CallCompat.java @@ -16,8 +16,6 @@ package com.android.contacts.common.compat; -import android.os.Build.VERSION; -import android.os.Build.VERSION_CODES; import android.support.annotation.NonNull; import android.telecom.Call; @@ -25,8 +23,7 @@ import android.telecom.Call; public class CallCompat { public static boolean canPullExternalCall(@NonNull android.telecom.Call call) { - return VERSION.SDK_INT >= VERSION_CODES.N_MR1 - && ((call.getDetails().getCallCapabilities() & Details.CAPABILITY_CAN_PULL_CALL) + return ((call.getDetails().getCallCapabilities() & Details.CAPABILITY_CAN_PULL_CALL) == Details.CAPABILITY_CAN_PULL_CALL); } diff --git a/java/com/android/contacts/common/compat/telecom/TelecomManagerCompat.java b/java/com/android/contacts/common/compat/telecom/TelecomManagerCompat.java deleted file mode 100644 index a1dc89d75d..0000000000 --- a/java/com/android/contacts/common/compat/telecom/TelecomManagerCompat.java +++ /dev/null @@ -1,73 +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.contacts.common.compat.telecom; - -import android.os.Build.VERSION; -import android.os.Build.VERSION_CODES; -import android.support.annotation.Nullable; -import android.telecom.PhoneAccountHandle; -import android.telecom.TelecomManager; -import java.lang.reflect.Field; - -/** Compatibility class for {@link android.telecom.TelecomManager}. */ -public class TelecomManagerCompat { - - // Constants from http://cs/android/frameworks/base/telecomm/java/android/telecom/Call.java. - public static final String EVENT_REQUEST_HANDOVER = "android.telecom.event.REQUEST_HANDOVER"; - public static final String EXTRA_HANDOVER_PHONE_ACCOUNT_HANDLE = - "android.telecom.extra.HANDOVER_PHONE_ACCOUNT_HANDLE"; - public static final String EXTRA_HANDOVER_VIDEO_STATE = - "android.telecom.extra.HANDOVER_VIDEO_STATE"; - - // This is a hidden constant in android.telecom.DisconnectCause. Telecom sets this as a disconnect - // reason if it wants us to prompt the user that the video call is not available. - // TODO(wangqi): Reference it to constant in android.telecom.DisconnectCause. - public static final String REASON_IMS_ACCESS_BLOCKED = "REASON_IMS_ACCESS_BLOCKED"; - - /** - * Returns the current SIM call manager. Apps must be prepared for this method to return null, - * indicating that there currently exists no registered SIM call manager. - * - * @param telecomManager the {@link TelecomManager} to use to fetch the SIM call manager. - * @return The phone account handle of the current sim call manager. - */ - @Nullable - public static PhoneAccountHandle getSimCallManager(TelecomManager telecomManager) { - if (telecomManager != null) { - return telecomManager.getSimCallManager(); - } - return null; - } - - /** Returns true if the Android version supports Handover. */ - public static boolean supportsHandover() { - // Starting with Android P, handover is supported via a public API. - if (VERSION.SDK_INT >= VERSION_CODES.P) { - return true; - } - // Handovers are supported from Android O-DR onward. Since there is no API - // bump from O to O-DR, we need to use reflection to check the existence - // of TelecomManager.EXTRA_IS_HANDOVER in - // http://cs/android/frameworks/base/telecomm/java/android/telecom/TelecomManager.java. - try { - Field field = TelecomManager.class.getDeclaredField("EXTRA_IS_HANDOVER"); - return "android.telecom.extra.IS_HANDOVER".equals(field.get(null /* obj (static field) */)); - } catch (Exception e) { - // Do nothing - } - return false; - } -} diff --git a/java/com/android/dialer/app/AndroidManifest.xml b/java/com/android/dialer/app/AndroidManifest.xml index 93dedb6992..8cc8f9eaa7 100644 --- a/java/com/android/dialer/app/AndroidManifest.xml +++ b/java/com/android/dialer/app/AndroidManifest.xml @@ -60,18 +60,6 @@ - - - - - - - = VERSION_CODES.O) - ? cursor.getInt(CallLogQuery.TRANSCRIPTION_STATE) - : VoicemailCompat.TRANSCRIPTION_NOT_STARTED; + final int transcriptionState = cursor.getInt(CallLogQuery.TRANSCRIPTION_STATE); final PhoneCallDetails details = new PhoneCallDetails(number, numberPresentation, postDialDigits); details.viaNumber = viaNumber; diff --git a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java index 07e00f96a0..e1ffaea476 100644 --- a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java +++ b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java @@ -66,8 +66,6 @@ import com.android.dialer.app.calllog.CallLogAdapter.OnActionModeStateChangedLis import com.android.dialer.app.calllog.calllogcache.CallLogCache; import com.android.dialer.app.voicemail.VoicemailPlaybackLayout; import com.android.dialer.app.voicemail.VoicemailPlaybackPresenter; -import com.android.dialer.blocking.BlockedNumbersMigrator; -import com.android.dialer.blocking.FilteredNumberCompat; import com.android.dialer.blocking.FilteredNumbersUtil; import com.android.dialer.callcomposer.CallComposerActivity; import com.android.dialer.calldetails.CallDetailsEntries; @@ -418,24 +416,12 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } else if (resId == R.id.context_menu_block_report_spam) { Logger.get(context) .logImpression(DialerImpression.Type.CALL_LOG_CONTEXT_MENU_BLOCK_REPORT_SPAM); - maybeShowBlockNumberMigrationDialog( - new BlockedNumbersMigrator.Listener() { - @Override - public void onComplete() { - blockReportListener.onBlockReportSpam( - displayNumber, number, countryIso, callType, info.sourceType); - } - }); + blockReportListener.onBlockReportSpam( + displayNumber, number, countryIso, callType, info.sourceType); } else if (resId == R.id.context_menu_block) { Logger.get(context).logImpression(DialerImpression.Type.CALL_LOG_CONTEXT_MENU_BLOCK_NUMBER); - maybeShowBlockNumberMigrationDialog( - new BlockedNumbersMigrator.Listener() { - @Override - public void onComplete() { - blockReportListener.onBlock( - displayNumber, number, countryIso, callType, info.sourceType); - } - }); + blockReportListener.onBlock( + displayNumber, number, countryIso, callType, info.sourceType); } else if (resId == R.id.context_menu_unblock) { Logger.get(context).logImpression(DialerImpression.Type.CALL_LOG_CONTEXT_MENU_UNBLOCK_NUMBER); blockReportListener.onUnblock( @@ -1073,27 +1059,15 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder if (view.getId() == R.id.block_report_action) { Logger.get(context).logImpression(DialerImpression.Type.CALL_LOG_BLOCK_REPORT_SPAM); - maybeShowBlockNumberMigrationDialog( - new BlockedNumbersMigrator.Listener() { - @Override - public void onComplete() { - blockReportListener.onBlockReportSpam( - displayNumber, number, countryIso, callType, info.sourceType); - } - }); + blockReportListener.onBlockReportSpam( + displayNumber, number, countryIso, callType, info.sourceType); return; } if (view.getId() == R.id.block_action) { Logger.get(context).logImpression(DialerImpression.Type.CALL_LOG_BLOCK_NUMBER); - maybeShowBlockNumberMigrationDialog( - new BlockedNumbersMigrator.Listener() { - @Override - public void onComplete() { - blockReportListener.onBlock( - displayNumber, number, countryIso, callType, info.sourceType); - } - }); + blockReportListener.onBlock( + displayNumber, number, countryIso, callType, info.sourceType); return; } @@ -1251,13 +1225,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } } - private void maybeShowBlockNumberMigrationDialog(BlockedNumbersMigrator.Listener listener) { - if (!FilteredNumberCompat.maybeShowBlockNumberMigrationDialog( - context, ((Activity) context).getFragmentManager(), listener)) { - listener.onComplete(); - } - } - private void updateBlockReportActions(boolean canPlaceCallToNumber, boolean isVoicemailNumber) { // Set block/spam actions. blockReportView.setVisibility(View.GONE); @@ -1267,8 +1234,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder String e164Number = PhoneNumberUtils.formatNumberToE164(number, countryIso); if (!canPlaceCallToNumber || isVoicemailNumber - || !FilteredNumbersUtil.canBlockNumber(context, e164Number, number) - || !FilteredNumberCompat.canAttemptBlockOperations(context)) { + || !FilteredNumbersUtil.canBlockNumber(context, e164Number, number)) { return; } boolean isBlocked = blockId != null; @@ -1350,8 +1316,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder boolean canPlaceCallToNumber = PhoneNumberHelper.canPlaceCallsTo(number, numberPresentation); if (canPlaceCallToNumber && !isVoicemailNumber - && FilteredNumbersUtil.canBlockNumber(context, e164Number, number) - && FilteredNumberCompat.canAttemptBlockOperations(context)) { + && FilteredNumbersUtil.canBlockNumber(context, e164Number, number)) { boolean isBlocked = blockId != null; if (isBlocked) { menu.add( diff --git a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java index 03b824eb63..126b7a128b 100644 --- a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java +++ b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java @@ -389,7 +389,7 @@ public class CallLogNotificationsQueryHelper { try (Cursor cursor = contentResolver.query( Calls.CONTENT_URI_WITH_VOICEMAIL, - (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) ? PROJECTION_O : PROJECTION, + PROJECTION_O, selection.getSelection(), selection.getSelectionArgs(), Calls.DEFAULT_SORT_ORDER)) { @@ -428,7 +428,7 @@ public class CallLogNotificationsQueryHelper { try (Cursor cursor = contentResolver.query( Calls.CONTENT_URI_WITH_VOICEMAIL, - (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) ? PROJECTION_O : PROJECTION, + PROJECTION_O, selection.getSelection(), selection.getSelectionArgs(), null)) { @@ -459,9 +459,7 @@ public class CallLogNotificationsQueryHelper { cursor.getString(TRANSCRIPTION_COLUMN_INDEX), cursor.getString(COUNTRY_ISO_COLUMN_INDEX), cursor.getLong(DATE_COLUMN_INDEX), - Build.VERSION.SDK_INT >= Build.VERSION_CODES.O - ? cursor.getInt(TRANSCRIPTION_STATE_COLUMN_INDEX) - : VoicemailCompat.TRANSCRIPTION_NOT_STARTED); + cursor.getInt(TRANSCRIPTION_STATE_COLUMN_INDEX)); } } } diff --git a/java/com/android/dialer/app/calllog/CallLogReceiver.java b/java/com/android/dialer/app/calllog/CallLogReceiver.java index 654436c073..5d8d13039e 100644 --- a/java/com/android/dialer/app/calllog/CallLogReceiver.java +++ b/java/com/android/dialer/app/calllog/CallLogReceiver.java @@ -23,8 +23,6 @@ import android.database.Cursor; import android.provider.VoicemailContract; import com.android.dialer.common.LogUtil; import com.android.dialer.database.CallLogQueryHandler; -import com.android.dialer.voicemail.listui.error.VoicemailStatusCorruptionHandler; -import com.android.dialer.voicemail.listui.error.VoicemailStatusCorruptionHandler.Source; /** * Receiver for call log events. @@ -55,8 +53,7 @@ public class CallLogReceiver extends BroadcastReceiver { new CallLogQueryHandler.Listener() { @Override public void onVoicemailStatusFetched(Cursor statusCursor) { - VoicemailStatusCorruptionHandler.maybeFixVoicemailStatus( - context, statusCursor, Source.Notification); + // Do nothing } @Override diff --git a/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java b/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java index 62ae748ded..4925c725f5 100644 --- a/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java +++ b/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java @@ -16,14 +16,11 @@ package com.android.dialer.app.calllog; -import android.annotation.TargetApi; import android.app.Notification; import android.app.PendingIntent; import android.content.Context; -import android.os.Build.VERSION_CODES; import android.os.PersistableBundle; import android.support.annotation.NonNull; -import android.support.v4.os.BuildCompat; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; @@ -41,7 +38,6 @@ import com.android.dialer.telecom.TelecomUtil; import com.android.dialer.theme.base.ThemeComponent; /** Shows a notification in the status bar for legacy vociemail. */ -@TargetApi(VERSION_CODES.O) public final class LegacyVoicemailNotifier { private static final String NOTIFICATION_TAG_PREFIX = "LegacyVoicemail_"; private static final String NOTIFICATION_TAG = "LegacyVoicemail"; @@ -62,7 +58,6 @@ public final class LegacyVoicemailNotifier { boolean isRefresh) { LogUtil.enterBlock("LegacyVoicemailNotifier.showNotification"); Assert.isNotNull(handle); - Assert.checkArgument(BuildCompat.isAtLeastO()); TelephonyManager pinnedTelephonyManager = context.getSystemService(TelephonyManager.class).createForPhoneAccountHandle(handle); @@ -159,7 +154,6 @@ public final class LegacyVoicemailNotifier { public static void cancelNotification( @NonNull Context context, @NonNull PhoneAccountHandle phoneAccountHandle) { LogUtil.enterBlock("LegacyVoicemailNotifier.cancelNotification"); - Assert.checkArgument(BuildCompat.isAtLeastO()); Assert.isNotNull(phoneAccountHandle); if ("null".equals(phoneAccountHandle.getId())) { // while PhoneAccountHandle itself will never be null, telephony may still construct a "null" diff --git a/java/com/android/dialer/app/calllog/MissedCallNotifier.java b/java/com/android/dialer/app/calllog/MissedCallNotifier.java index f2d2af8344..5e90492fd6 100644 --- a/java/com/android/dialer/app/calllog/MissedCallNotifier.java +++ b/java/com/android/dialer/app/calllog/MissedCallNotifier.java @@ -33,7 +33,6 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.annotation.WorkerThread; -import android.support.v4.os.BuildCompat; import android.support.v4.os.UserManagerCompat; import android.support.v4.util.Pair; import android.telecom.PhoneAccount; @@ -219,10 +218,8 @@ public class MissedCallNotifier implements Worker, Void> { CallLogNotificationsService.createCancelAllMissedCallsPendingIntent(context)) .setGroupSummary(useCallList) .setOnlyAlertOnce(useCallList) - .setPublicVersion(publicSummaryBuilder.build()); - if (BuildCompat.isAtLeastO()) { - groupSummary.setChannelId(NotificationChannelId.MISSED_CALL); - } + .setPublicVersion(publicSummaryBuilder.build()) + .setChannelId(NotificationChannelId.MISSED_CALL); Notification notification = groupSummary.build(); configureLedOnNotification(notification); @@ -417,10 +414,8 @@ public class MissedCallNotifier implements Worker, Void> { .setDeleteIntent( CallLogNotificationsService.createCancelSingleMissedCallPendingIntent( context, call.callsUri)) - .setContentIntent(createCallLogPendingIntent(call.callsUri)); - if (BuildCompat.isAtLeastO()) { - builder.setChannelId(NotificationChannelId.MISSED_CALL); - } + .setContentIntent(createCallLogPendingIntent(call.callsUri)) + .setChannelId(NotificationChannelId.MISSED_CALL); return builder; } diff --git a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java index 9d04cb2c88..e6b94fc1f9 100644 --- a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java +++ b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java @@ -25,7 +25,6 @@ import android.net.Uri; import android.provider.CallLog.Calls; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.support.v4.content.ContextCompat; -import android.support.v4.os.BuildCompat; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telephony.PhoneNumberUtils; @@ -173,9 +172,7 @@ public class PhoneCallDetailsHelper views.callTypeIcons.setShowAssistedDialed( (details.features & TelephonyManagerCompat.FEATURES_ASSISTED_DIALING) == TelephonyManagerCompat.FEATURES_ASSISTED_DIALING); - if (BuildCompat.isAtLeastP()) { - views.callTypeIcons.setShowRtt((details.features & Calls.FEATURES_RTT) == Calls.FEATURES_RTT); - } + views.callTypeIcons.setShowRtt((details.features & Calls.FEATURES_RTT) == Calls.FEATURES_RTT); views.callTypeIcons.requestLayout(); views.callTypeIcons.setVisibility(View.VISIBLE); diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java b/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java index 7fc104bb21..b0f26700b1 100644 --- a/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java +++ b/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java @@ -23,8 +23,6 @@ import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; -import android.os.Build.VERSION; -import android.os.Build.VERSION_CODES; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.NotificationCompat; @@ -90,19 +88,17 @@ final class VisualVoicemailNotifier { .setGroupSummary(true) .setContentIntent(newVoicemailIntent(context, null)); - if (VERSION.SDK_INT >= VERSION_CODES.O) { - if (shouldAlert) { - groupSummary.setOnlyAlertOnce(false); - // Group summary will alert when posted/updated - groupSummary.setGroupAlertBehavior(Notification.GROUP_ALERT_ALL); - } else { - // Only children will alert. but since all children are set to "only alert summary" it is - // effectively silenced. - groupSummary.setGroupAlertBehavior(Notification.GROUP_ALERT_CHILDREN); - } - PhoneAccountHandle handle = getAccountForCall(context, newCalls.get(0)); - groupSummary.setChannelId(NotificationChannelManager.getVoicemailChannelId(context, handle)); + if (shouldAlert) { + groupSummary.setOnlyAlertOnce(false); + // Group summary will alert when posted/updated + groupSummary.setGroupAlertBehavior(Notification.GROUP_ALERT_ALL); + } else { + // Only children will alert. but since all children are set to "only alert summary" it is + // effectively silenced. + groupSummary.setGroupAlertBehavior(Notification.GROUP_ALERT_CHILDREN); } + PhoneAccountHandle handle = getAccountForCall(context, newCalls.get(0)); + groupSummary.setChannelId(NotificationChannelManager.getVoicemailChannelId(context, handle)); DialerNotificationManager.notify( context, GROUP_SUMMARY_NOTIFICATION_TAG, NOTIFICATION_ID, groupSummary.build()); @@ -214,10 +210,8 @@ final class VisualVoicemailNotifier { context, voicemail.voicemailUri)); } - if (VERSION.SDK_INT >= VERSION_CODES.O) { - builder.setChannelId(NotificationChannelManager.getVoicemailChannelId(context, handle)); - builder.setGroupAlertBehavior(Notification.GROUP_ALERT_SUMMARY); - } + builder.setChannelId(NotificationChannelManager.getVoicemailChannelId(context, handle)); + builder.setGroupAlertBehavior(Notification.GROUP_ALERT_SUMMARY); ContactPhotoLoader loader = new ContactPhotoLoader(context, contactInfo); Bitmap photoIcon = loader.loadPhotoIcon(); diff --git a/java/com/android/dialer/app/filterednumber/BlockedNumbersAdapter.java b/java/com/android/dialer/app/filterednumber/BlockedNumbersAdapter.java deleted file mode 100644 index 603c06fd30..0000000000 --- a/java/com/android/dialer/app/filterednumber/BlockedNumbersAdapter.java +++ /dev/null @@ -1,96 +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.app.filterednumber; - -import android.app.FragmentManager; -import android.content.Context; -import android.database.Cursor; -import android.view.View; -import com.android.dialer.app.R; -import com.android.dialer.blocking.BlockNumberDialogFragment; -import com.android.dialer.contactphoto.ContactPhotoManager; -import com.android.dialer.database.FilteredNumberContract.FilteredNumberColumns; -import com.android.dialer.location.GeoUtil; -import com.android.dialer.logging.InteractionEvent; -import com.android.dialer.logging.Logger; -import com.android.dialer.phonenumbercache.ContactInfoHelper; -import com.android.dialer.phonenumberutil.PhoneNumberHelper; - -/** TODO(calderwoodra): documentation */ -public class BlockedNumbersAdapter extends NumbersAdapter { - - private BlockedNumbersAdapter( - Context context, - FragmentManager fragmentManager, - ContactInfoHelper contactInfoHelper, - ContactPhotoManager contactPhotoManager) { - super(context, fragmentManager, contactInfoHelper, contactPhotoManager); - } - - public static BlockedNumbersAdapter newBlockedNumbersAdapter( - Context context, FragmentManager fragmentManager) { - return new BlockedNumbersAdapter( - context, - fragmentManager, - new ContactInfoHelper(context, GeoUtil.getCurrentCountryIso(context)), - ContactPhotoManager.getInstance(context)); - } - - @Override - public void bindView(View view, final Context context, Cursor cursor) { - super.bindView(view, context, cursor); - final Integer id = cursor.getInt(cursor.getColumnIndex(FilteredNumberColumns._ID)); - final String countryIso = - cursor.getString(cursor.getColumnIndex(FilteredNumberColumns.COUNTRY_ISO)); - final String number = cursor.getString(cursor.getColumnIndex(FilteredNumberColumns.NUMBER)); - - final View deleteButton = view.findViewById(R.id.delete_button); - deleteButton.setOnClickListener( - new View.OnClickListener() { - @Override - public void onClick(View view) { - BlockNumberDialogFragment.show( - id, - number, - countryIso, - PhoneNumberHelper.formatNumber(getContext(), number, countryIso), - R.id.blocked_numbers_activity_container, - getFragmentManager(), - new BlockNumberDialogFragment.Callback() { - @Override - public void onFilterNumberSuccess() {} - - @Override - public void onUnfilterNumberSuccess() { - Logger.get(context) - .logInteraction(InteractionEvent.Type.UNBLOCK_NUMBER_MANAGEMENT_SCREEN); - } - - @Override - public void onChangeFilteredNumberUndo() {} - }); - } - }); - - updateView(view, number, countryIso); - } - - @Override - public boolean isEmpty() { - // Always return false, so that the header with blocking-related options always shows. - return false; - } -} diff --git a/java/com/android/dialer/app/filterednumber/BlockedNumbersFragment.java b/java/com/android/dialer/app/filterednumber/BlockedNumbersFragment.java deleted file mode 100644 index bf40fdf3ac..0000000000 --- a/java/com/android/dialer/app/filterednumber/BlockedNumbersFragment.java +++ /dev/null @@ -1,263 +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.app.filterednumber; - -import android.app.ListFragment; -import android.app.LoaderManager; -import android.content.Context; -import android.content.CursorLoader; -import android.content.Loader; -import android.database.Cursor; -import android.graphics.drawable.ColorDrawable; -import android.os.Bundle; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; -import com.android.dialer.app.R; -import com.android.dialer.blocking.BlockedNumbersMigrator; -import com.android.dialer.blocking.BlockedNumbersMigrator.Listener; -import com.android.dialer.blocking.FilteredNumberCompat; -import com.android.dialer.blocking.FilteredNumbersUtil; -import com.android.dialer.blocking.FilteredNumbersUtil.CheckForSendToVoicemailContactListener; -import com.android.dialer.blocking.FilteredNumbersUtil.ImportSendToVoicemailContactsListener; -import com.android.dialer.database.FilteredNumberContract; -import com.android.dialer.lettertile.LetterTileDrawable; -import com.android.dialer.theme.base.ThemeComponent; -import com.android.dialer.voicemailstatus.VisualVoicemailEnabledChecker; - -/** TODO(calderwoodra): documentation */ -public class BlockedNumbersFragment extends ListFragment - implements LoaderManager.LoaderCallbacks, - View.OnClickListener, - VisualVoicemailEnabledChecker.Callback { - - private static final char ADD_BLOCKED_NUMBER_ICON_LETTER = '+'; - protected View migratePromoView; - private BlockedNumbersMigrator blockedNumbersMigratorForTest; - private TextView blockedNumbersText; - private TextView footerText; - private BlockedNumbersAdapter adapter; - private VisualVoicemailEnabledChecker voicemailEnabledChecker; - private View importSettings; - private View blockedNumbersDisabledForEmergency; - private View blockedNumberListDivider; - - @Override - public Context getContext() { - return getActivity(); - } - - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - - LayoutInflater inflater = - (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - getListView().addHeaderView(inflater.inflate(R.layout.blocked_number_header, null)); - getListView().addFooterView(inflater.inflate(R.layout.blocked_number_footer, null)); - //replace the icon for add number with LetterTileDrawable(), so it will have identical style - LetterTileDrawable drawable = new LetterTileDrawable(getResources()); - drawable.setLetter(ADD_BLOCKED_NUMBER_ICON_LETTER); - drawable.setColor(ThemeComponent.get(getContext()).theme().getColorIcon()); - drawable.setIsCircular(true); - - if (adapter == null) { - adapter = - BlockedNumbersAdapter.newBlockedNumbersAdapter( - getContext(), getActivity().getFragmentManager()); - } - setListAdapter(adapter); - - blockedNumbersText = (TextView) getListView().findViewById(R.id.blocked_number_text_view); - migratePromoView = getListView().findViewById(R.id.migrate_promo); - getListView().findViewById(R.id.migrate_promo_allow_button).setOnClickListener(this); - importSettings = getListView().findViewById(R.id.import_settings); - blockedNumbersDisabledForEmergency = - getListView().findViewById(R.id.blocked_numbers_disabled_for_emergency); - blockedNumberListDivider = getActivity().findViewById(R.id.blocked_number_list_divider); - getListView().findViewById(R.id.import_button).setOnClickListener(this); - getListView().findViewById(R.id.view_numbers_button).setOnClickListener(this); - - footerText = (TextView) getActivity().findViewById(R.id.blocked_number_footer_textview); - voicemailEnabledChecker = new VisualVoicemailEnabledChecker(getContext(), this); - voicemailEnabledChecker.asyncUpdate(); - updateActiveVoicemailProvider(); - } - - @Override - public void onDestroy() { - setListAdapter(null); - super.onDestroy(); - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - getLoaderManager().initLoader(0, null, this); - } - - @Override - public void onResume() { - super.onResume(); - - ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); - ColorDrawable backgroundDrawable = - new ColorDrawable(ThemeComponent.get(getContext()).theme().getColorPrimary()); - actionBar.setBackgroundDrawable(backgroundDrawable); - actionBar.setDisplayShowCustomEnabled(false); - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - actionBar.setDisplayShowTitleEnabled(true); - actionBar.setTitle(R.string.manage_blocked_numbers_label); - - // If the device can use the framework blocking solution, users should not be able to add - // new blocked numbers from the Blocked Management UI. They will be shown a promo card - // asking them to migrate to new blocking instead. - if (FilteredNumberCompat.canUseNewFiltering()) { - migratePromoView.setVisibility(View.VISIBLE); - blockedNumbersText.setVisibility(View.GONE); - blockedNumberListDivider.setVisibility(View.GONE); - importSettings.setVisibility(View.GONE); - getListView().findViewById(R.id.import_button).setOnClickListener(null); - getListView().findViewById(R.id.view_numbers_button).setOnClickListener(null); - blockedNumbersDisabledForEmergency.setVisibility(View.GONE); - footerText.setVisibility(View.GONE); - } else { - FilteredNumbersUtil.checkForSendToVoicemailContact( - getActivity(), - new CheckForSendToVoicemailContactListener() { - @Override - public void onComplete(boolean hasSendToVoicemailContact) { - final int visibility = hasSendToVoicemailContact ? View.VISIBLE : View.GONE; - importSettings.setVisibility(visibility); - } - }); - } - - // All views except migrate and the block list are hidden when new filtering is available - if (!FilteredNumberCompat.canUseNewFiltering() - && FilteredNumbersUtil.hasRecentEmergencyCall(getContext())) { - blockedNumbersDisabledForEmergency.setVisibility(View.VISIBLE); - } else { - blockedNumbersDisabledForEmergency.setVisibility(View.GONE); - } - - voicemailEnabledChecker.asyncUpdate(); - } - - @Override - public View onCreateView( - LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return inflater.inflate(R.layout.blocked_number_fragment, container, false); - } - - @Override - public Loader onCreateLoader(int id, Bundle args) { - final String[] projection = { - FilteredNumberContract.FilteredNumberColumns._ID, - FilteredNumberContract.FilteredNumberColumns.COUNTRY_ISO, - FilteredNumberContract.FilteredNumberColumns.NUMBER, - FilteredNumberContract.FilteredNumberColumns.NORMALIZED_NUMBER - }; - final String selection = - FilteredNumberContract.FilteredNumberColumns.TYPE - + "=" - + FilteredNumberContract.FilteredNumberTypes.BLOCKED_NUMBER; - return new CursorLoader( - getContext(), - FilteredNumberContract.FilteredNumber.CONTENT_URI, - projection, - selection, - null, - null); - } - - @Override - public void onLoadFinished(Loader loader, Cursor data) { - adapter.swapCursor(data); - if (FilteredNumberCompat.canUseNewFiltering() || data.getCount() == 0) { - blockedNumberListDivider.setVisibility(View.INVISIBLE); - } else { - blockedNumberListDivider.setVisibility(View.VISIBLE); - } - } - - @Override - public void onLoaderReset(Loader loader) { - adapter.swapCursor(null); - } - - @Override - public void onClick(final View view) { - final BlockedNumbersSettingsActivity activity = (BlockedNumbersSettingsActivity) getActivity(); - if (activity == null) { - return; - } - - int resId = view.getId(); - if (resId == R.id.view_numbers_button) { - activity.showNumbersToImportPreviewUi(); - } else if (resId == R.id.import_button) { - FilteredNumbersUtil.importSendToVoicemailContacts( - activity, - new ImportSendToVoicemailContactsListener() { - @Override - public void onImportComplete() { - importSettings.setVisibility(View.GONE); - } - }); - } else if (resId == R.id.migrate_promo_allow_button) { - view.setEnabled(false); - (blockedNumbersMigratorForTest != null - ? blockedNumbersMigratorForTest - : new BlockedNumbersMigrator(getContext())) - .migrate( - new Listener() { - @Override - public void onComplete() { - getContext() - .startActivity( - FilteredNumberCompat.createManageBlockedNumbersIntent(getContext())); - // Remove this activity from the backstack - activity.finish(); - } - }); - } - } - - @Override - public void onVisualVoicemailEnabledStatusChanged(boolean newStatus) { - updateActiveVoicemailProvider(); - } - - private void updateActiveVoicemailProvider() { - if (getActivity() == null || getActivity().isFinishing()) { - return; - } - if (voicemailEnabledChecker.isVisualVoicemailEnabled()) { - footerText.setText(R.string.block_number_footer_message_vvm); - } else { - footerText.setText(R.string.block_number_footer_message_no_vvm); - } - } - - void setBlockedNumbersMigratorForTest(BlockedNumbersMigrator blockedNumbersMigrator) { - blockedNumbersMigratorForTest = blockedNumbersMigrator; - } -} diff --git a/java/com/android/dialer/app/filterednumber/BlockedNumbersSettingsActivity.java b/java/com/android/dialer/app/filterednumber/BlockedNumbersSettingsActivity.java deleted file mode 100644 index 5475b4ea3e..0000000000 --- a/java/com/android/dialer/app/filterednumber/BlockedNumbersSettingsActivity.java +++ /dev/null @@ -1,97 +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.app.filterednumber; - -import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; -import android.view.MenuItem; -import com.android.dialer.app.R; -import com.android.dialer.logging.Logger; -import com.android.dialer.logging.ScreenEvent; - -/** TODO(calderwoodra): documentation */ -public class BlockedNumbersSettingsActivity extends AppCompatActivity { - - private static final String TAG_BLOCKED_MANAGEMENT_FRAGMENT = "blocked_management"; - private static final String TAG_VIEW_NUMBERS_TO_IMPORT_FRAGMENT = "view_numbers_to_import"; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.blocked_numbers_activity); - - // If savedInstanceState != null, the Activity will automatically restore the last fragment. - if (savedInstanceState == null) { - showManagementUi(); - } - } - - /** Shows fragment with the list of currently blocked numbers and settings related to blocking. */ - public void showManagementUi() { - BlockedNumbersFragment fragment = - (BlockedNumbersFragment) - getFragmentManager().findFragmentByTag(TAG_BLOCKED_MANAGEMENT_FRAGMENT); - if (fragment == null) { - fragment = new BlockedNumbersFragment(); - } - - getFragmentManager() - .beginTransaction() - .replace(R.id.blocked_numbers_activity_container, fragment, TAG_BLOCKED_MANAGEMENT_FRAGMENT) - .commit(); - - Logger.get(this).logScreenView(ScreenEvent.Type.BLOCKED_NUMBER_MANAGEMENT, this); - } - - /** - * Shows fragment with UI to preview the numbers of contacts currently marked as send-to-voicemail - * in Contacts. These numbers can be imported into Dialer's blocked number list. - */ - public void showNumbersToImportPreviewUi() { - ViewNumbersToImportFragment fragment = - (ViewNumbersToImportFragment) - getFragmentManager().findFragmentByTag(TAG_VIEW_NUMBERS_TO_IMPORT_FRAGMENT); - if (fragment == null) { - fragment = new ViewNumbersToImportFragment(); - } - - getFragmentManager() - .beginTransaction() - .replace( - R.id.blocked_numbers_activity_container, fragment, TAG_VIEW_NUMBERS_TO_IMPORT_FRAGMENT) - .addToBackStack(null) - .commit(); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - if (item.getItemId() == android.R.id.home) { - onBackPressed(); - return true; - } - return false; - } - - @Override - public void onBackPressed() { - // TODO: Achieve back navigation without overriding onBackPressed. - if (getFragmentManager().getBackStackEntryCount() > 0) { - getFragmentManager().popBackStack(); - } else { - super.onBackPressed(); - } - } -} diff --git a/java/com/android/dialer/app/filterednumber/NumbersAdapter.java b/java/com/android/dialer/app/filterednumber/NumbersAdapter.java deleted file mode 100644 index 2c08558ec3..0000000000 --- a/java/com/android/dialer/app/filterednumber/NumbersAdapter.java +++ /dev/null @@ -1,137 +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.app.filterednumber; - -import android.app.FragmentManager; -import android.content.Context; -import android.provider.ContactsContract; -import android.provider.ContactsContract.CommonDataKinds.Phone; -import android.text.BidiFormatter; -import android.text.TextDirectionHeuristics; -import android.text.TextUtils; -import android.view.View; -import android.widget.QuickContactBadge; -import android.widget.SimpleCursorAdapter; -import android.widget.TextView; -import com.android.dialer.app.R; -import com.android.dialer.contactphoto.ContactPhotoManager; -import com.android.dialer.contactphoto.ContactPhotoManager.DefaultImageRequest; -import com.android.dialer.lettertile.LetterTileDrawable; -import com.android.dialer.phonenumbercache.ContactInfo; -import com.android.dialer.phonenumbercache.ContactInfoHelper; -import com.android.dialer.phonenumberutil.PhoneNumberHelper; -import com.android.dialer.util.UriUtils; - -/** TODO(calderwoodra): documentation */ -public class NumbersAdapter extends SimpleCursorAdapter { - - private final Context context; - private final FragmentManager fragmentManager; - private final ContactInfoHelper contactInfoHelper; - private final BidiFormatter bidiFormatter = BidiFormatter.getInstance(); - private final ContactPhotoManager contactPhotoManager; - - public NumbersAdapter( - Context context, - FragmentManager fragmentManager, - ContactInfoHelper contactInfoHelper, - ContactPhotoManager contactPhotoManager) { - super(context, R.layout.blocked_number_item, null, new String[] {}, new int[] {}, 0); - this.context = context; - this.fragmentManager = fragmentManager; - this.contactInfoHelper = contactInfoHelper; - this.contactPhotoManager = contactPhotoManager; - } - - public void updateView(View view, String number, String countryIso) { - final TextView callerName = (TextView) view.findViewById(R.id.caller_name); - final TextView callerNumber = (TextView) view.findViewById(R.id.caller_number); - final QuickContactBadge quickContactBadge = - (QuickContactBadge) view.findViewById(R.id.quick_contact_photo); - quickContactBadge.setOverlay(null); - quickContactBadge.setPrioritizedMimeType(Phone.CONTENT_ITEM_TYPE); - - ContactInfo info = contactInfoHelper.lookupNumber(number, countryIso); - if (info == null) { - info = new ContactInfo(); - info.number = number; - } - final CharSequence locationOrType = getNumberTypeOrLocation(info, countryIso); - final String displayNumber = getDisplayNumber(info); - final String displayNumberStr = - bidiFormatter.unicodeWrap(displayNumber, TextDirectionHeuristics.LTR); - - String nameForDefaultImage; - if (!TextUtils.isEmpty(info.name)) { - nameForDefaultImage = info.name; - callerName.setText(info.name); - callerNumber.setText(locationOrType + " " + displayNumberStr); - } else { - nameForDefaultImage = displayNumber; - callerName.setText(displayNumberStr); - if (!TextUtils.isEmpty(locationOrType)) { - callerNumber.setText(locationOrType); - callerNumber.setVisibility(View.VISIBLE); - } else { - callerNumber.setVisibility(View.GONE); - } - } - loadContactPhoto(info, nameForDefaultImage, quickContactBadge); - } - - private void loadContactPhoto(ContactInfo info, String displayName, QuickContactBadge badge) { - final String lookupKey = - info.lookupUri == null ? null : UriUtils.getLookupKeyFromUri(info.lookupUri); - final int contactType = - contactInfoHelper.isBusiness(info.sourceType) - ? LetterTileDrawable.TYPE_BUSINESS - : LetterTileDrawable.TYPE_DEFAULT; - final DefaultImageRequest request = - new DefaultImageRequest(displayName, lookupKey, contactType, true /* isCircular */); - badge.assignContactUri(info.lookupUri); - badge.setContentDescription( - context.getResources().getString(R.string.description_contact_details, displayName)); - contactPhotoManager.loadDirectoryPhoto( - badge, info.photoUri, false /* darkTheme */, true /* isCircular */, request); - } - - private String getDisplayNumber(ContactInfo info) { - if (!TextUtils.isEmpty(info.formattedNumber)) { - return info.formattedNumber; - } else if (!TextUtils.isEmpty(info.number)) { - return info.number; - } else { - return ""; - } - } - - private CharSequence getNumberTypeOrLocation(ContactInfo info, String countryIso) { - if (!TextUtils.isEmpty(info.name)) { - return ContactsContract.CommonDataKinds.Phone.getTypeLabel( - context.getResources(), info.type, info.label); - } else { - return PhoneNumberHelper.getGeoDescription(context, info.number, countryIso); - } - } - - protected Context getContext() { - return context; - } - - protected FragmentManager getFragmentManager() { - return fragmentManager; - } -} diff --git a/java/com/android/dialer/app/filterednumber/ViewNumbersToImportAdapter.java b/java/com/android/dialer/app/filterednumber/ViewNumbersToImportAdapter.java deleted file mode 100644 index 106c4fb711..0000000000 --- a/java/com/android/dialer/app/filterednumber/ViewNumbersToImportAdapter.java +++ /dev/null @@ -1,57 +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.app.filterednumber; - -import android.app.FragmentManager; -import android.content.Context; -import android.database.Cursor; -import android.view.View; -import com.android.dialer.app.R; -import com.android.dialer.blocking.FilteredNumbersUtil; -import com.android.dialer.contactphoto.ContactPhotoManager; -import com.android.dialer.location.GeoUtil; -import com.android.dialer.phonenumbercache.ContactInfoHelper; - -/** TODO(calderwoodra): documentation */ -public class ViewNumbersToImportAdapter extends NumbersAdapter { - - private ViewNumbersToImportAdapter( - Context context, - FragmentManager fragmentManager, - ContactInfoHelper contactInfoHelper, - ContactPhotoManager contactPhotoManager) { - super(context, fragmentManager, contactInfoHelper, contactPhotoManager); - } - - public static ViewNumbersToImportAdapter newViewNumbersToImportAdapter( - Context context, FragmentManager fragmentManager) { - return new ViewNumbersToImportAdapter( - context, - fragmentManager, - new ContactInfoHelper(context, GeoUtil.getCurrentCountryIso(context)), - ContactPhotoManager.getInstance(context)); - } - - @Override - public void bindView(View view, Context context, Cursor cursor) { - super.bindView(view, context, cursor); - - final String number = cursor.getString(FilteredNumbersUtil.PhoneQuery.NUMBER_COLUMN_INDEX); - - view.findViewById(R.id.delete_button).setVisibility(View.GONE); - updateView(view, number, null /* countryIso */); - } -} diff --git a/java/com/android/dialer/app/filterednumber/ViewNumbersToImportFragment.java b/java/com/android/dialer/app/filterednumber/ViewNumbersToImportFragment.java deleted file mode 100644 index be3ae79f97..0000000000 --- a/java/com/android/dialer/app/filterednumber/ViewNumbersToImportFragment.java +++ /dev/null @@ -1,131 +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.app.filterednumber; - -import android.app.ListFragment; -import android.app.LoaderManager; -import android.content.Context; -import android.content.CursorLoader; -import android.content.Loader; -import android.database.Cursor; -import android.os.Bundle; -import android.provider.ContactsContract.CommonDataKinds.Phone; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import com.android.dialer.app.R; -import com.android.dialer.blocking.FilteredNumbersUtil; -import com.android.dialer.blocking.FilteredNumbersUtil.ImportSendToVoicemailContactsListener; - -/** TODO(calderwoodra): documentation */ -public class ViewNumbersToImportFragment extends ListFragment - implements LoaderManager.LoaderCallbacks, View.OnClickListener { - - private ViewNumbersToImportAdapter adapter; - - @Override - public Context getContext() { - return getActivity(); - } - - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - - if (adapter == null) { - adapter = - ViewNumbersToImportAdapter.newViewNumbersToImportAdapter( - getContext(), getActivity().getFragmentManager()); - } - setListAdapter(adapter); - } - - @Override - public void onDestroy() { - setListAdapter(null); - super.onDestroy(); - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - getLoaderManager().initLoader(0, null, this); - } - - @Override - public void onResume() { - super.onResume(); - - ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); - actionBar.setTitle(R.string.import_send_to_voicemail_numbers_label); - actionBar.setDisplayShowCustomEnabled(false); - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - actionBar.setDisplayShowTitleEnabled(true); - - getActivity().findViewById(R.id.cancel_button).setOnClickListener(this); - getActivity().findViewById(R.id.import_button).setOnClickListener(this); - } - - @Override - public View onCreateView( - LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return inflater.inflate(R.layout.view_numbers_to_import_fragment, container, false); - } - - @Override - public Loader onCreateLoader(int id, Bundle args) { - final CursorLoader cursorLoader = - new CursorLoader( - getContext(), - Phone.CONTENT_URI, - FilteredNumbersUtil.PhoneQuery.PROJECTION, - FilteredNumbersUtil.PhoneQuery.SELECT_SEND_TO_VOICEMAIL_TRUE, - null, - null); - return cursorLoader; - } - - @Override - public void onLoadFinished(Loader loader, Cursor data) { - adapter.swapCursor(data); - } - - @Override - public void onLoaderReset(Loader loader) { - adapter.swapCursor(null); - } - - @Override - public void onClick(final View view) { - if (view.getId() == R.id.import_button) { - FilteredNumbersUtil.importSendToVoicemailContacts( - getContext(), - new ImportSendToVoicemailContactsListener() { - @Override - public void onImportComplete() { - if (getActivity() != null) { - getActivity().onBackPressed(); - } - } - }); - } else if (view.getId() == R.id.cancel_button) { - getActivity().onBackPressed(); - } - } -} diff --git a/java/com/android/dialer/app/list/ListsFragment.java b/java/com/android/dialer/app/list/ListsFragment.java index 93e89230ba..4a606bbb84 100644 --- a/java/com/android/dialer/app/list/ListsFragment.java +++ b/java/com/android/dialer/app/list/ListsFragment.java @@ -46,8 +46,6 @@ import com.android.dialer.logging.ScreenEvent; import com.android.dialer.logging.UiAction; import com.android.dialer.performancereport.PerformanceReport; import com.android.dialer.util.PermissionsUtil; -import com.android.dialer.voicemail.listui.error.VoicemailStatusCorruptionHandler; -import com.android.dialer.voicemail.listui.error.VoicemailStatusCorruptionHandler.Source; import com.android.dialer.voicemailstatus.VisualVoicemailEnabledChecker; import com.android.dialer.voicemailstatus.VoicemailStatusHelper; import java.util.ArrayList; @@ -333,9 +331,6 @@ public class ListsFragment extends Fragment return; } - VoicemailStatusCorruptionHandler.maybeFixVoicemailStatus( - getContext(), statusCursor, Source.Activity); - // Update hasActiveVoicemailProvider, which controls the number of tabs displayed. boolean hasActiveVoicemailProvider = VoicemailStatusHelper.getNumberActivityVoicemailSources(statusCursor) > 0; diff --git a/java/com/android/dialer/app/res/layout/blocked_number_footer.xml b/java/com/android/dialer/app/res/layout/blocked_number_footer.xml deleted file mode 100644 index 2d368605c9..0000000000 --- a/java/com/android/dialer/app/res/layout/blocked_number_footer.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - diff --git a/java/com/android/dialer/app/res/layout/blocked_number_fragment.xml b/java/com/android/dialer/app/res/layout/blocked_number_fragment.xml deleted file mode 100644 index 22dcfefa5c..0000000000 --- a/java/com/android/dialer/app/res/layout/blocked_number_fragment.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - diff --git a/java/com/android/dialer/app/res/layout/blocked_number_header.xml b/java/com/android/dialer/app/res/layout/blocked_number_header.xml deleted file mode 100644 index 27b624ccd5..0000000000 --- a/java/com/android/dialer/app/res/layout/blocked_number_header.xml +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -