From 50ba08e56682700007a818e96790a1a1f4385518 Mon Sep 17 00:00:00 2001 From: erfanian Date: Tue, 5 Jun 2018 14:54:02 -0700 Subject: Update a few interfaces. Bug: 73773964 Test: unit PiperOrigin-RevId: 199362698 Change-Id: I4b0ab4a3c07ad8fa206753c4826b42037b8a06be --- .../incallui/answer/impl/AnswerFragment.java | 40 +++++++++----------- .../impl/res/drawable/shape_chip_drawable.xml | 44 ---------------------- .../impl/res/layout/fragment_incoming_call.xml | 18 --------- .../incallui/answer/impl/res/values/strings.xml | 2 - .../android/incallui/speakeasy/Annotations.java | 12 ++---- .../incallui/speakeasy/SpeakEasyComponent.java | 7 +--- .../incallui/speakeasy/StubSpeakEasyModule.java | 10 +---- 7 files changed, 26 insertions(+), 107 deletions(-) delete mode 100644 java/com/android/incallui/answer/impl/res/drawable/shape_chip_drawable.xml diff --git a/java/com/android/incallui/answer/impl/AnswerFragment.java b/java/com/android/incallui/answer/impl/AnswerFragment.java index 18e0e9864..8d8b08791 100644 --- a/java/com/android/incallui/answer/impl/AnswerFragment.java +++ b/java/com/android/incallui/answer/impl/AnswerFragment.java @@ -50,7 +50,6 @@ 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; @@ -84,8 +83,7 @@ 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.Annotations.SpeakEasyChipResourceId; import com.android.incallui.speakeasy.SpeakEasyComponent; import com.android.incallui.util.AccessibilityUtil; import com.android.incallui.video.protocol.VideoCallScreen; @@ -148,10 +146,8 @@ 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; + private LinearLayout chipContainer; // 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, // and then user is stuck in the incoming call view until it times out. Two flags at least give @@ -467,22 +463,23 @@ public class AnswerFragment extends Fragment /** Initialize chip buttons */ private void initChips() { + if (!allowSpeakEasy()) { - chipLayout.setVisibility(View.GONE); + chipContainer.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(); + 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); } } @@ -721,13 +718,12 @@ 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); + chipContainer = view.findViewById(R.id.incall_data_container_chip_container); + importanceBadge = view.findViewById(R.id.incall_important_call_badge); importanceBadge .getViewTreeObserver() 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 deleted file mode 100644 index adb153f6d..000000000 --- a/java/com/android/incallui/answer/impl/res/drawable/shape_chip_drawable.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - 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 944d290b1..1672bf984 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 @@ -157,26 +157,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal|bottom" - android:background="@drawable/shape_chip_drawable" - android:clickable="true" android:orientation="horizontal" android:visibility="gone"> - - 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 61400bdc8..2bc9ca09f 100644 --- a/java/com/android/incallui/answer/impl/res/values/strings.xml +++ b/java/com/android/incallui/answer/impl/res/values/strings.xml @@ -40,6 +40,4 @@ Two finger swipe up to answer. Two finger swipe down to decline. Important - - Answer as RTT diff --git a/java/com/android/incallui/speakeasy/Annotations.java b/java/com/android/incallui/speakeasy/Annotations.java index 5d513fc9b..4128532c3 100644 --- a/java/com/android/incallui/speakeasy/Annotations.java +++ b/java/com/android/incallui/speakeasy/Annotations.java @@ -21,14 +21,6 @@ import javax.inject.Qualifier; /** Annotations for Speakeasy providers. */ public final class Annotations { - /** A Speakeasy icon */ - @Qualifier - public @interface SpeakEasyIcon {} - - /** Speakeasy text */ - @Qualifier - public @interface SpeakEasyText {} - /** A Speakeasy settings fragment */ @Qualifier public @interface SpeakEasySettingsFragment {} @@ -36,4 +28,8 @@ public final class Annotations { /** A Speakeasy settings object */ @Qualifier public @interface SpeakEasySettingsObject {} + + /** A Speakeasy chip */ + @Qualifier + public @interface SpeakEasyChipResourceId {} } diff --git a/java/com/android/incallui/speakeasy/SpeakEasyComponent.java b/java/com/android/incallui/speakeasy/SpeakEasyComponent.java index ab6438077..19e25edbe 100644 --- a/java/com/android/incallui/speakeasy/SpeakEasyComponent.java +++ b/java/com/android/incallui/speakeasy/SpeakEasyComponent.java @@ -19,10 +19,9 @@ package com.android.incallui.speakeasy; import android.content.Context; import android.preference.PreferenceFragment; import com.android.dialer.inject.HasRootComponent; -import com.android.incallui.speakeasy.Annotations.SpeakEasyIcon; +import com.android.incallui.speakeasy.Annotations.SpeakEasyChipResourceId; import com.android.incallui.speakeasy.Annotations.SpeakEasySettingsFragment; import com.android.incallui.speakeasy.Annotations.SpeakEasySettingsObject; -import com.android.incallui.speakeasy.Annotations.SpeakEasyText; import com.google.common.base.Optional; import dagger.Subcomponent; @@ -37,9 +36,7 @@ public abstract class SpeakEasyComponent { public abstract @SpeakEasySettingsObject Optional speakEasySettingsObject(); - public abstract @SpeakEasyIcon Optional speakEasyIcon(); - - public abstract @SpeakEasyText Optional speakEasyText(); + public abstract @SpeakEasyChipResourceId Optional speakEasyChip(); 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 e844ad348..87d407d32 100644 --- a/java/com/android/incallui/speakeasy/StubSpeakEasyModule.java +++ b/java/com/android/incallui/speakeasy/StubSpeakEasyModule.java @@ -19,10 +19,9 @@ package com.android.incallui.speakeasy; import android.preference.PreferenceFragment; 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.SpeakEasyChipResourceId; import com.android.incallui.speakeasy.Annotations.SpeakEasySettingsFragment; import com.android.incallui.speakeasy.Annotations.SpeakEasySettingsObject; -import com.android.incallui.speakeasy.Annotations.SpeakEasyText; import com.google.common.base.Optional; import dagger.Binds; import dagger.Module; @@ -48,12 +47,7 @@ public abstract class StubSpeakEasyModule { } @Provides - static @SpeakEasyIcon Optional provideSpeakEasyIcon() { - return Optional.absent(); - } - - @Provides - static @SpeakEasyText Optional provideSpeakEasyText() { + static @SpeakEasyChipResourceId Optional provideSpeakEasyChip() { return Optional.absent(); } } -- cgit v1.2.3