From 810d43daa31bf481f09c9ed46ac020d6e7c685d3 Mon Sep 17 00:00:00 2001 From: wangqi Date: Wed, 9 May 2018 16:43:35 -0700 Subject: Add RTT after call promo bottomsheet. Bug: 67596257 Test: unit tests PiperOrigin-RevId: 196049621 Change-Id: I6f9c6292b1d56e3faf7808aa668b03d07230a70b --- .../dialer/calllog/ui/NewCallLogAdapter.java | 4 ++ .../layout/new_call_log_duo_disclosure_card.xml | 2 +- .../dialer/calllog/ui/res/values/strings.xml | 3 - .../android/dialer/common/res/values/strings.xml | 2 + .../dialer/main/impl/OldMainActivityPeer.java | 48 ++++++++++++- .../dialer/main/impl/res/layout/main_activity.xml | 3 + .../impl/res/layout/promotion_bottom_sheet.xml | 81 +++++++++++++++++++++ .../android/dialer/promotion/AndroidManifest.xml | 16 +++++ java/com/android/dialer/promotion/Promotion.java | 39 ++++++++++ .../com/android/dialer/promotion/RttPromotion.java | 84 ++++++++++++++++++++++ .../dialer/promotion/res/values/strings.xml | 26 +++++++ java/com/android/incallui/call/CallList.java | 4 ++ java/com/android/incallui/call/DialerCall.java | 10 ++- 13 files changed, 315 insertions(+), 7 deletions(-) create mode 100644 java/com/android/dialer/main/impl/res/layout/promotion_bottom_sheet.xml create mode 100644 java/com/android/dialer/promotion/AndroidManifest.xml create mode 100644 java/com/android/dialer/promotion/Promotion.java create mode 100644 java/com/android/dialer/promotion/RttPromotion.java create mode 100644 java/com/android/dialer/promotion/res/values/strings.xml (limited to 'java') diff --git a/java/com/android/dialer/calllog/ui/NewCallLogAdapter.java b/java/com/android/dialer/calllog/ui/NewCallLogAdapter.java index 7fd8132aa..69cc02be4 100644 --- a/java/com/android/dialer/calllog/ui/NewCallLogAdapter.java +++ b/java/com/android/dialer/calllog/ui/NewCallLogAdapter.java @@ -31,6 +31,7 @@ import com.android.dialer.common.Assert; import com.android.dialer.duo.Duo; import com.android.dialer.duo.DuoComponent; import com.android.dialer.logging.Logger; +import com.android.dialer.promotion.RttPromotion; import com.android.dialer.storage.StorageComponent; import com.android.dialer.time.Clock; import java.lang.annotation.Retention; @@ -173,6 +174,9 @@ final class NewCallLogAdapter extends RecyclerView.Adapter { } private boolean shouldShowDuoDisclosureCard() { + if (new RttPromotion(activity).shouldShow()) { + return false; + } // Don't show the Duo disclosure card if // (1) Duo integration is not enabled on the device, or // (2) Duo is not activated. diff --git a/java/com/android/dialer/calllog/ui/res/layout/new_call_log_duo_disclosure_card.xml b/java/com/android/dialer/calllog/ui/res/layout/new_call_log_duo_disclosure_card.xml index 1e24c8ba2..a28101c6f 100644 --- a/java/com/android/dialer/calllog/ui/res/layout/new_call_log_duo_disclosure_card.xml +++ b/java/com/android/dialer/calllog/ui/res/layout/new_call_log_duo_disclosure_card.xml @@ -68,7 +68,7 @@ android:layout_gravity="end" android:paddingLeft="14dp" android:paddingRight="14dp" - android:text="@string/new_call_log_duo_disclosure_card_ok" + android:text="@string/ok_got_it" android:textSize="14sp"/> diff --git a/java/com/android/dialer/calllog/ui/res/values/strings.xml b/java/com/android/dialer/calllog/ui/res/values/strings.xml index f04bffa3f..ec8d59503 100644 --- a/java/com/android/dialer/calllog/ui/res/values/strings.xml +++ b/java/com/android/dialer/calllog/ui/res/values/strings.xml @@ -36,7 +36,4 @@ Google Duo video calling lets you chat with friends and family face-to-face. Data charges may apply. %1$s - - OK, got it - diff --git a/java/com/android/dialer/common/res/values/strings.xml b/java/com/android/dialer/common/res/values/strings.xml index cc0594dee..3bd21d5c1 100644 --- a/java/com/android/dialer/common/res/values/strings.xml +++ b/java/com/android/dialer/common/res/values/strings.xml @@ -21,4 +21,6 @@ More options UNDO + + OK, got it diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index e426ed215..39a43718e 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -36,6 +36,7 @@ import android.provider.ContactsContract.QuickContact; import android.provider.VoicemailContract; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.design.bottomsheet.BottomSheetBehavior; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v4.content.ContextCompat; @@ -46,9 +47,11 @@ import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telephony.TelephonyManager; import android.text.TextUtils; +import android.text.method.LinkMovementMethod; import android.view.DragEvent; import android.view.View; import android.widget.ImageView; +import android.widget.TextView; import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; import com.android.dialer.animation.AnimUtils; import com.android.dialer.app.DialtactsActivity; @@ -104,6 +107,8 @@ import com.android.dialer.metrics.Metrics; import com.android.dialer.metrics.MetricsComponent; import com.android.dialer.postcall.PostCall; import com.android.dialer.precall.PreCall; +import com.android.dialer.promotion.Promotion; +import com.android.dialer.promotion.RttPromotion; import com.android.dialer.searchfragment.list.NewSearchFragment.SearchFragmentListener; import com.android.dialer.smartdial.util.SmartDialPrefix; import com.android.dialer.speeddial.SpeedDialFragment; @@ -196,6 +201,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen private MissedCallCountObserver missedCallCountObserver; private UiListener getLastOutgoingCallListener; private UiListener missedCallObserverUiListener; + private View bottomSheet; public static Intent getShowTabIntent(Context context, @TabIndex int tabIndex) { Intent intent = new Intent(context, MainActivity.class); @@ -240,6 +246,9 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen dialpadFragmentHostInterface = new MainDialpadFragmentHost(); snackbarContainer = activity.findViewById(R.id.coordinator_layout); + bottomSheet = activity.findViewById(R.id.promotion_bottom_sheet); + BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet); + bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); FloatingActionButton fab = activity.findViewById(R.id.fab); fab.setOnClickListener( @@ -255,7 +264,11 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen bottomNav = activity.findViewById(R.id.bottom_nav_bar); bottomNavTabListener = new MainBottomNavBarBottomNavTabListener( - activity, activity.getFragmentManager(), activity.getSupportFragmentManager(), fab); + activity, + activity.getFragmentManager(), + activity.getSupportFragmentManager(), + fab, + bottomSheet); bottomNav.addOnTabSelectedListener(bottomNavTabListener); // TODO(uabdullah): Handle case of when a sim is inserted/removed while the activity is open. boolean showVoicemailTab = canVoicemailTabBeShown(activity); @@ -1245,6 +1258,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen private final FragmentManager fragmentManager; private final android.support.v4.app.FragmentManager supportFragmentManager; private final FloatingActionButton fab; + private final View bottomSheet; @TabIndex private int selectedTab = -1; @@ -1252,11 +1266,13 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen TransactionSafeActivity activity, FragmentManager fragmentManager, android.support.v4.app.FragmentManager supportFragmentManager, - FloatingActionButton fab) { + FloatingActionButton fab, + View bottomSheet) { this.activity = activity; this.fragmentManager = fragmentManager; this.supportFragmentManager = supportFragmentManager; this.fab = fab; + this.bottomSheet = bottomSheet; } @Override @@ -1300,6 +1316,34 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen showFragment(fragment == null ? new CallLogFragment() : fragment, CALL_LOG_TAG); } fab.show(); + showPromotionBottomSheet(activity, bottomSheet); + } + + private static void showPromotionBottomSheet(Context context, View view) { + // TODO(a bug): Use a promotion manager to get promotion to show. + Promotion promotion = new RttPromotion(context); + BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(view); + + if (!promotion.shouldShow()) { + bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); + return; + } + ImageView icon = view.findViewById(R.id.promotion_icon); + icon.setImageResource(promotion.getIconRes()); + TextView details = view.findViewById(R.id.promotion_details); + details.setText(promotion.getDetails()); + // Required to make link clickable. + details.setMovementMethod(LinkMovementMethod.getInstance()); + TextView title = view.findViewById(R.id.promotion_title); + title.setText(promotion.getTitle()); + view.findViewById(R.id.ok_got_it) + .setOnClickListener( + v -> { + promotion.dismiss(); + bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); + }); + view.setVisibility(View.VISIBLE); + bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); } void disableNewCallLogFragment() { diff --git a/java/com/android/dialer/main/impl/res/layout/main_activity.xml b/java/com/android/dialer/main/impl/res/layout/main_activity.xml index a1d6e5372..b47806ece 100644 --- a/java/com/android/dialer/main/impl/res/layout/main_activity.xml +++ b/java/com/android/dialer/main/impl/res/layout/main_activity.xml @@ -63,6 +63,9 @@ android:src="@drawable/quantum_ic_dialpad_white_24" android:contentDescription="@string/dialpad_button_content_description" app:backgroundTint="?android:attr/colorAccent"/> + + diff --git a/java/com/android/dialer/main/impl/res/layout/promotion_bottom_sheet.xml b/java/com/android/dialer/main/impl/res/layout/promotion_bottom_sheet.xml new file mode 100644 index 000000000..b608cd535 --- /dev/null +++ b/java/com/android/dialer/main/impl/res/layout/promotion_bottom_sheet.xml @@ -0,0 +1,81 @@ + + + + + + + + + +