From 936127cee87e53ce6705ca574ff156f9cf412f10 Mon Sep 17 00:00:00 2001 From: erfanian Date: Fri, 25 May 2018 11:44:35 -0700 Subject: Some improvements to the answer fragment layouts. Test: unit PiperOrigin-RevId: 198080186 Change-Id: I0ecc1f918b2c62e42b287e4fc9ea38fafaf1e6c9 --- .../incallui/answer/impl/AnswerFragment.java | 56 +++++++++++++--------- .../impl/res/drawable/shape_chip_drawable.xml | 44 +++++++++++++++++ .../impl/res/layout/fragment_incoming_call.xml | 54 +++++++++++++++------ .../android/incallui/speakeasy/Annotations.java | 35 ++++++++++++++ .../incallui/speakeasy/SpeakEasyComponent.java | 9 +++- .../incallui/speakeasy/StubSpeakEasyModule.java | 12 ++++- 6 files changed, 169 insertions(+), 41 deletions(-) create mode 100644 java/com/android/incallui/answer/impl/res/drawable/shape_chip_drawable.xml create mode 100644 java/com/android/incallui/speakeasy/Annotations.java (limited to 'java') diff --git a/java/com/android/incallui/answer/impl/AnswerFragment.java b/java/com/android/incallui/answer/impl/AnswerFragment.java index d44a5daa2..18e0e9864 100644 --- a/java/com/android/incallui/answer/impl/AnswerFragment.java +++ b/java/com/android/incallui/answer/impl/AnswerFragment.java @@ -49,6 +49,8 @@ import android.view.accessibility.AccessibilityEvent; 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; @@ -82,6 +84,8 @@ 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.SpeakEasyIcon; +import com.android.incallui.speakeasy.Annotations.SpeakEasyText; import com.android.incallui.speakeasy.SpeakEasyComponent; import com.android.incallui.util.AccessibilityUtil; import com.android.incallui.video.protocol.VideoCallScreen; @@ -144,6 +148,9 @@ public class AnswerFragment extends Fragment private View importanceBadge; private SwipeButtonView secondaryButton; private SwipeButtonView answerAndReleaseButton; + private LinearLayout chipLayout; + private ImageView chipIcon; + private TextView chipText; private AffordanceHolderLayout affordanceHolderLayout; // Use these flags to prevent user from clicking accept/reject buttons multiple times. // We use separate flags because in some rare cases accepting a call may fail to join the room, @@ -195,17 +202,6 @@ public class AnswerFragment extends Fragment public void performAction(AnswerFragment fragment) { fragment.performAnswerAndRelease(); } - }, - - SPEAKEASY( - R.drawable.quantum_ic_rtt_vd_theme_24, - R.string.speakeasy_secondary_button_hint, - R.string.speakeasy_secondary_button_hint, - R.string.speakeasy_secondary_button_hint) { - @Override - public void performAction(AnswerFragment fragment) { - fragment.performSpeakEasy(); - } }; @DrawableRes public int icon; @@ -232,8 +228,7 @@ public class AnswerFragment extends Fragment } } - private void performSpeakEasy() { - restoreAnswerAndReleaseButtonAnimation(); + private void performSpeakEasy(View unused) { answerScreenDelegate.onSpeakEasyCall(); buttonAcceptClicked = true; } @@ -457,16 +452,6 @@ public class AnswerFragment extends Fragment if (allowAnswerAndRelease()) { answerAndReleaseButton.setVisibility(View.VISIBLE); answerScreenDelegate.onAnswerAndReleaseButtonEnabled(); - } else if (allowSpeakEasy()) { - Optional alternativeIcon = SpeakEasyComponent.get(getContext()).speakEasyIcon(); - if (alternativeIcon.isPresent()) { - // TODO(erfanian): Replace enum hack when we have a dedicated button. - SecondaryBehavior.SPEAKEASY.icon = alternativeIcon.get(); - } - answerAndReleaseBehavior = SecondaryBehavior.SPEAKEASY; - answerAndReleaseBehavior.applyToView(answerAndReleaseButton); - answerAndReleaseButton.setVisibility(View.VISIBLE); - answerScreenDelegate.onAnswerAndReleaseButtonEnabled(); } else { answerAndReleaseButton.setVisibility(View.INVISIBLE); answerScreenDelegate.onAnswerAndReleaseButtonDisabled(); @@ -480,6 +465,27 @@ public class AnswerFragment extends Fragment }); } + /** Initialize chip buttons */ + private void initChips() { + if (!allowSpeakEasy()) { + chipLayout.setVisibility(View.GONE); + return; + } + chipLayout.setVisibility(View.VISIBLE); + chipLayout.setOnClickListener(this::performSpeakEasy); + + @SpeakEasyIcon + Optional alternativeIcon = SpeakEasyComponent.get(getContext()).speakEasyIcon(); + @SpeakEasyText + Optional alternativeText = SpeakEasyComponent.get(getContext()).speakEasyText(); + if (alternativeIcon.isPresent() && alternativeText.isPresent()) { + chipIcon.setImageDrawable(getContext().getDrawable(alternativeIcon.get())); + chipText.setText(alternativeText.get()); + // The button needs to override normal swipe up/down behavior. + chipLayout.bringToFront(); + } + } + @Override public boolean allowAnswerAndRelease() { return getArguments().getBoolean(ARG_ALLOW_ANSWER_AND_RELEASE); @@ -715,6 +721,9 @@ public class AnswerFragment extends Fragment View view = inflater.inflate(R.layout.fragment_incoming_call, container, false); secondaryButton = (SwipeButtonView) view.findViewById(R.id.incoming_secondary_button); answerAndReleaseButton = (SwipeButtonView) view.findViewById(R.id.incoming_secondary_button2); + chipLayout = view.findViewById(R.id.incall_data_container_chip_container); + chipIcon = view.findViewById(R.id.incall_data_container_chip_icon); + chipText = view.findViewById(R.id.incall_data_container_chip_text); affordanceHolderLayout = (AffordanceHolderLayout) view.findViewById(R.id.incoming_container); affordanceHolderLayout.setAffordanceCallback(affordanceCallback); @@ -755,6 +764,7 @@ public class AnswerFragment extends Fragment .newAnswerScreenDelegate(this); initSecondaryButton(); + initChips(); int flags = View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; if (!isInMultiWindowMode diff --git a/java/com/android/incallui/answer/impl/res/drawable/shape_chip_drawable.xml b/java/com/android/incallui/answer/impl/res/drawable/shape_chip_drawable.xml new file mode 100644 index 000000000..3740f3d1b --- /dev/null +++ b/java/com/android/incallui/answer/impl/res/drawable/shape_chip_drawable.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml b/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml index a2319b9c0..944d290b1 100644 --- a/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml +++ b/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml @@ -53,6 +53,13 @@ android:layout_height="match_parent" android:fitsSystemWindows="true"> + + + android:textSize="14sp"/> + android:clipToPadding="false"> + + + + + @@ -153,14 +187,6 @@ android:layout_height="220dp"/> - - - speakEasySettingsFragment(); + public abstract @SpeakEasySettingsFragment Optional speakEasySettingsFragment(); - public abstract Optional speakEasyIcon(); + public abstract @SpeakEasyIcon Optional speakEasyIcon(); + + public abstract @SpeakEasyText Optional speakEasyText(); public static SpeakEasyComponent get(Context context) { return ((SpeakEasyComponent.HasComponent) diff --git a/java/com/android/incallui/speakeasy/StubSpeakEasyModule.java b/java/com/android/incallui/speakeasy/StubSpeakEasyModule.java index 67b564cb0..9f23ddd37 100644 --- a/java/com/android/incallui/speakeasy/StubSpeakEasyModule.java +++ b/java/com/android/incallui/speakeasy/StubSpeakEasyModule.java @@ -19,6 +19,9 @@ package com.android.incallui.speakeasy; import android.support.v4.app.Fragment; import com.android.dialer.inject.DialerVariant; import com.android.dialer.inject.InstallIn; +import com.android.incallui.speakeasy.Annotations.SpeakEasyIcon; +import com.android.incallui.speakeasy.Annotations.SpeakEasySettingsFragment; +import com.android.incallui.speakeasy.Annotations.SpeakEasyText; import com.google.common.base.Optional; import dagger.Binds; import dagger.Module; @@ -33,12 +36,17 @@ public abstract class StubSpeakEasyModule { abstract SpeakEasyCallManager bindsSpeakEasy(SpeakEasyCallManagerStub stub); @Provides - static Optional provideSpeakEasySettingsFragment() { + static @SpeakEasySettingsFragment Optional provideSpeakEasySettingsFragment() { return Optional.absent(); } @Provides - static Optional provideSpeakEasyIcon() { + static @SpeakEasyIcon Optional provideSpeakEasyIcon() { + return Optional.absent(); + } + + @Provides + static @SpeakEasyText Optional provideSpeakEasyText() { return Optional.absent(); } } -- cgit v1.2.3