From 19e85a54d723bbe23e51bed70df89bd3861570d7 Mon Sep 17 00:00:00 2001 From: wangqi Date: Mon, 25 Jun 2018 14:43:18 -0700 Subject: Change reply with sms to chip. Bug: 79878432 Test: manual PiperOrigin-RevId: 202022343 Change-Id: I7239b13e53a537e20af4b2684a53108aeea16025 --- .../dialer/theme/common/res/values/colors.xml | 4 +- .../hidden/res/values/colors_dialer_light.xml | 2 +- java/com/android/incallui/StatusBarNotifier.java | 2 +- .../incallui/answer/impl/AnswerFragment.java | 64 ++++++++++++++-------- .../drawable/secondary_action_chip_background.xml | 33 +++++++++++ .../impl/res/layout/secondary_action_chip.xml | 37 +++++++++++++ .../incallui/answer/impl/res/values/strings.xml | 2 + .../android/incallui/speakeasy/Annotations.java | 4 +- .../incallui/speakeasy/SpeakEasyComponent.java | 9 ++- .../incallui/speakeasy/StubSpeakEasyModule.java | 14 ++--- 10 files changed, 130 insertions(+), 41 deletions(-) create mode 100644 java/com/android/incallui/answer/impl/res/drawable/secondary_action_chip_background.xml create mode 100644 java/com/android/incallui/answer/impl/res/layout/secondary_action_chip.xml (limited to 'java') 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 770aa8c15..207d29c80 100644 --- a/java/com/android/dialer/theme/common/res/values/colors.xml +++ b/java/com/android/dialer/theme/common/res/values/colors.xml @@ -18,7 +18,7 @@ #34A853 #D93025 - #D8D8D8 + #DADCE0 #2A56C6 #4285F4 @@ -31,4 +31,4 @@ #CFD8DC - \ No newline at end of file + diff --git a/java/com/android/dialer/theme/hidden/res/values/colors_dialer_light.xml b/java/com/android/dialer/theme/hidden/res/values/colors_dialer_light.xml index 0ed8e7566..4621be115 100644 --- a/java/com/android/dialer/theme/hidden/res/values/colors_dialer_light.xml +++ b/java/com/android/dialer/theme/hidden/res/values/colors_dialer_light.xml @@ -15,7 +15,7 @@ --> - #2A56C6 + @color/google_blue_600 #332A56C6 #1C3AA9 #F50057 diff --git a/java/com/android/incallui/StatusBarNotifier.java b/java/com/android/incallui/StatusBarNotifier.java index 8316d76ee..439f6cf66 100644 --- a/java/com/android/incallui/StatusBarNotifier.java +++ b/java/com/android/incallui/StatusBarNotifier.java @@ -93,8 +93,8 @@ import com.android.incallui.ringtone.InCallTonePlayer; import com.android.incallui.ringtone.ToneGeneratorFactory; import com.android.incallui.speakeasy.SpeakEasyComponent; import com.android.incallui.videotech.utils.SessionModificationState; -import com.google.common.base.Optional; import java.util.Objects; +import java.util.Optional; /** This class adds Notifications to the status bar for the in-call experience. */ public class StatusBarNotifier diff --git a/java/com/android/incallui/answer/impl/AnswerFragment.java b/java/com/android/incallui/answer/impl/AnswerFragment.java index f5da3effd..8bfdcbaf6 100644 --- a/java/com/android/incallui/answer/impl/AnswerFragment.java +++ b/java/com/android/incallui/answer/impl/AnswerFragment.java @@ -50,11 +50,12 @@ import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.TextView; import com.android.dialer.common.Assert; import com.android.dialer.common.FragmentUtils; import com.android.dialer.common.LogUtil; import com.android.dialer.common.MathUtil; -import com.android.dialer.logging.DialerImpression; +import com.android.dialer.logging.DialerImpression.Type; import com.android.dialer.logging.Logger; import com.android.dialer.multimedia.MultimediaData; import com.android.dialer.telecom.TelecomUtil; @@ -83,15 +84,15 @@ import com.android.incallui.incalluilock.InCallUiLock; import com.android.incallui.maps.MapsComponent; import com.android.incallui.sessiondata.AvatarPresenter; import com.android.incallui.sessiondata.MultimediaFragment; -import com.android.incallui.speakeasy.Annotations.SpeakEasyChipResourceId; +import com.android.incallui.sessiondata.MultimediaFragment.Holder; import com.android.incallui.speakeasy.SpeakEasyComponent; import com.android.incallui.util.AccessibilityUtil; import com.android.incallui.video.protocol.VideoCallScreen; import com.android.incallui.videotech.utils.VideoUtils; -import com.google.common.base.Optional; import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.Optional; /** The new version of the incoming call screen. */ @SuppressLint("ClickableViewAccessibility") @@ -101,7 +102,7 @@ public class AnswerFragment extends Fragment SmsSheetHolder, CreateCustomSmsHolder, AnswerMethodHolder, - MultimediaFragment.Holder { + Holder { @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) static final String ARG_CALL_ID = "call_id"; @@ -432,6 +433,11 @@ public class AnswerFragment extends Fragment secondaryButton.setFocusable(AccessibilityUtil.isAccessibilityEnabled(getContext())); secondaryButton.setAccessibilityDelegate(accessibilityDelegate); + // TODO(wangqi): Remove this when all secondary behavior is migrated to chip button. + if (secondaryBehavior.equals(SecondaryBehavior.REJECT_WITH_SMS)) { + secondaryButton.setVisibility(View.INVISIBLE); + } + if (isVideoUpgradeRequest()) { secondaryButton.setVisibility(View.INVISIBLE); } else if (isVideoCall()) { @@ -461,26 +467,39 @@ public class AnswerFragment extends Fragment }); } + private void addSecondaryActionChip( + @DrawableRes int iconRes, @StringRes int textRes, OnClickListener onClickListener) { + LinearLayout button = + (LinearLayout) + getLayoutInflater().inflate(R.layout.secondary_action_chip, chipContainer, false); + + ImageView icon = button.findViewById(R.id.secondary_action_icon); + icon.setImageResource(iconRes); + TextView text = button.findViewById(R.id.secondary_action_text); + text.setText(textRes); + button.setOnClickListener(onClickListener); + chipContainer.addView(button); + } + /** Initialize chip buttons */ private void initChips() { - - if (!allowSpeakEasy()) { - chipContainer.setVisibility(View.GONE); - return; + if (allowSpeakEasy()) { + Optional speakEasyIconOptional = + SpeakEasyComponent.get(getContext()).speakEasyIconResource(); + Optional speakEasyTextOptional = + SpeakEasyComponent.get(getContext()).speakEasyTextResource(); + if (speakEasyIconOptional.isPresent() && speakEasyTextOptional.isPresent()) { + addSecondaryActionChip( + speakEasyIconOptional.get(), speakEasyTextOptional.get(), this::performSpeakEasy); + } } - chipContainer.setVisibility(View.VISIBLE); - - @SpeakEasyChipResourceId - Optional chipLayoutOptional = SpeakEasyComponent.get(getContext()).speakEasyChip(); - if (chipLayoutOptional.isPresent()) { - - LinearLayout chipLayout = - (LinearLayout) getLayoutInflater().inflate(chipLayoutOptional.get(), null); - - chipLayout.setOnClickListener(this::performSpeakEasy); - - chipContainer.addView(chipLayout); + if (!isVideoCall() && !isVideoUpgradeRequest()) { + addSecondaryActionChip( + R.drawable.quantum_ic_message_white_24, + R.string.call_incoming_reply_with_sms, + v -> performSecondaryButtonAction()); } + chipContainer.setVisibility(chipContainer.getChildCount() > 0 ? View.VISIBLE : View.GONE); } @Override @@ -986,8 +1005,7 @@ public class AnswerFragment extends Fragment "AnswerFragment.rejectCall", "Null context when rejecting call. Logger call was skipped"); } else { - Logger.get(context) - .logImpression(DialerImpression.Type.REJECT_INCOMING_CALL_FROM_ANSWER_SCREEN); + Logger.get(context).logImpression(Type.REJECT_INCOMING_CALL_FROM_ANSWER_SCREEN); } buttonRejectClicked = true; answerScreenDelegate.onReject(); @@ -1138,7 +1156,7 @@ public class AnswerFragment extends Fragment public void onViewCreated(View view, @Nullable Bundle bundle) { super.onViewCreated(view, bundle); avatarImageView = ((ImageView) view.findViewById(R.id.contactgrid_avatar)); - FragmentUtils.getParentUnsafe(this, MultimediaFragment.Holder.class).updateAvatar(this); + FragmentUtils.getParentUnsafe(this, Holder.class).updateAvatar(this); } @NonNull diff --git a/java/com/android/incallui/answer/impl/res/drawable/secondary_action_chip_background.xml b/java/com/android/incallui/answer/impl/res/drawable/secondary_action_chip_background.xml new file mode 100644 index 000000000..a185ebb3c --- /dev/null +++ b/java/com/android/incallui/answer/impl/res/drawable/secondary_action_chip_background.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + diff --git a/java/com/android/incallui/answer/impl/res/layout/secondary_action_chip.xml b/java/com/android/incallui/answer/impl/res/layout/secondary_action_chip.xml new file mode 100644 index 000000000..dd4199b0c --- /dev/null +++ b/java/com/android/incallui/answer/impl/res/layout/secondary_action_chip.xml @@ -0,0 +1,37 @@ + + + + + + diff --git a/java/com/android/incallui/answer/impl/res/values/strings.xml b/java/com/android/incallui/answer/impl/res/values/strings.xml index 2bc9ca09f..ac56460f1 100644 --- a/java/com/android/incallui/answer/impl/res/values/strings.xml +++ b/java/com/android/incallui/answer/impl/res/values/strings.xml @@ -20,6 +20,8 @@ Swipe up to answer and hold ongoing call Swipe up to answer and end call on hold Swipe from icon to answer and end ongoing call + + Reply Write your own… Write your own… diff --git a/java/com/android/incallui/speakeasy/Annotations.java b/java/com/android/incallui/speakeasy/Annotations.java index c66fe94c3..0d420a457 100644 --- a/java/com/android/incallui/speakeasy/Annotations.java +++ b/java/com/android/incallui/speakeasy/Annotations.java @@ -29,9 +29,9 @@ public final class Annotations { @Qualifier public @interface SpeakEasySettingsObject {} - /** A Speakeasy chip */ + /** A Speakeasy icon resource */ @Qualifier - public @interface SpeakEasyChipResourceId {} + public @interface SpeakEasyIconResourceId {} /** A Speakeasy text resource */ @Qualifier diff --git a/java/com/android/incallui/speakeasy/SpeakEasyComponent.java b/java/com/android/incallui/speakeasy/SpeakEasyComponent.java index 422ebd6da..84a21f3d1 100644 --- a/java/com/android/incallui/speakeasy/SpeakEasyComponent.java +++ b/java/com/android/incallui/speakeasy/SpeakEasyComponent.java @@ -19,20 +19,19 @@ package com.android.incallui.speakeasy; import android.content.Context; import android.preference.PreferenceActivity; import com.android.dialer.inject.HasRootComponent; -import com.android.incallui.speakeasy.Annotations.SpeakEasyChipResourceId; +import com.android.incallui.speakeasy.Annotations.SpeakEasyIconResourceId; import com.android.incallui.speakeasy.Annotations.SpeakEasySettingsActivity; import com.android.incallui.speakeasy.Annotations.SpeakEasySettingsObject; import com.android.incallui.speakeasy.Annotations.SpeakEasyTextResourceId; -import com.google.common.base.Optional; import dagger.Subcomponent; +import java.util.Optional; /** Dagger component to get SpeakEasyCallManager. */ @Subcomponent public abstract class SpeakEasyComponent { public static SpeakEasyComponent get(Context context) { - return ((SpeakEasyComponent.HasComponent) - ((HasRootComponent) context.getApplicationContext()).component()) + return ((HasComponent) ((HasRootComponent) context.getApplicationContext()).component()) .speakEasyComponent(); } @@ -43,7 +42,7 @@ public abstract class SpeakEasyComponent { public abstract @SpeakEasySettingsObject Optional speakEasySettingsObject(); - public abstract @SpeakEasyChipResourceId Optional speakEasyChip(); + public abstract @SpeakEasyIconResourceId Optional speakEasyIconResource(); public abstract @SpeakEasyTextResourceId Optional speakEasyTextResource(); diff --git a/java/com/android/incallui/speakeasy/StubSpeakEasyModule.java b/java/com/android/incallui/speakeasy/StubSpeakEasyModule.java index 5441075ef..781eee030 100644 --- a/java/com/android/incallui/speakeasy/StubSpeakEasyModule.java +++ b/java/com/android/incallui/speakeasy/StubSpeakEasyModule.java @@ -19,14 +19,14 @@ package com.android.incallui.speakeasy; import android.preference.PreferenceActivity; import com.android.dialer.inject.DialerVariant; import com.android.dialer.inject.InstallIn; -import com.android.incallui.speakeasy.Annotations.SpeakEasyChipResourceId; +import com.android.incallui.speakeasy.Annotations.SpeakEasyIconResourceId; import com.android.incallui.speakeasy.Annotations.SpeakEasySettingsActivity; import com.android.incallui.speakeasy.Annotations.SpeakEasySettingsObject; import com.android.incallui.speakeasy.Annotations.SpeakEasyTextResourceId; -import com.google.common.base.Optional; import dagger.Binds; import dagger.Module; import dagger.Provides; +import java.util.Optional; /** Module which binds {@link SpeakEasyCallManagerStub}. */ @InstallIn(variants = {DialerVariant.DIALER_TEST}) @@ -39,21 +39,21 @@ public abstract class StubSpeakEasyModule { @Provides static @SpeakEasySettingsActivity Optional provideSpeakEasySettingsActivity() { - return Optional.absent(); + return Optional.empty(); } @Provides static @SpeakEasySettingsObject Optional provideSpeakEasySettingsObject() { - return Optional.absent(); + return Optional.empty(); } @Provides - static @SpeakEasyChipResourceId Optional provideSpeakEasyChip() { - return Optional.absent(); + static @SpeakEasyIconResourceId Optional provideSpeakEasyIconResource() { + return Optional.empty(); } @Provides static @SpeakEasyTextResourceId Optional provideSpeakEasyTextResource() { - return Optional.absent(); + return Optional.empty(); } } -- cgit v1.2.3