diff options
author | wangqi <wangqi@google.com> | 2018-05-09 16:43:35 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-05-11 11:41:42 -0700 |
commit | 810d43daa31bf481f09c9ed46ac020d6e7c685d3 (patch) | |
tree | aba0fa666de36284aed5fd2a709e76e0ad32ac07 /java | |
parent | ced93f2d22bffce3b4cfb9c3bfce862b385537dd (diff) |
Add RTT after call promo bottomsheet.
Bug: 67596257
Test: unit tests
PiperOrigin-RevId: 196049621
Change-Id: I6f9c6292b1d56e3faf7808aa668b03d07230a70b
Diffstat (limited to 'java')
13 files changed, 315 insertions, 7 deletions
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<ViewHolder> { } 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"/> </LinearLayout> </LinearLayout> 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. <xliff:g example="Learn More">%1$s</xliff:g> </string> - <!-- Text on the button on the Duo disclosure card. [CHAR_LIMIT=30] --> - <string name="new_call_log_duo_disclosure_card_ok">OK, got it</string> - </resources> 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 @@ <string name="content_description_overflow">More options</string> <!-- Text for undo button in snackbar for voicemail deletion/blocking/unblocking number. [CHAR LIMIT=10] --> <string name="snackbar_undo">UNDO</string> + <!-- Text on button of "OK, got it". [CHAR_LIMIT=30] --> + <string name="ok_got_it">OK, got it</string> </resources> 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<String> getLastOutgoingCallListener; private UiListener<Integer> 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<View> 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<View> 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"/> + + <include android:id="@+id/promotion_bottom_sheet" + layout="@layout/promotion_bottom_sheet"/> </android.support.design.widget.CoordinatorLayout> <!-- BottomNavBar --> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2018 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 + --> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="24dp" + android:paddingBottom="8dp" + android:paddingStart="16dp" + android:paddingEnd="24dp" + android:background="#FAFAFA" + android:clickable="true" + android:elevation="8dp" + android:orientation="horizontal" + android:visibility="gone" + app:behavior_hideable="true" + app:behavior_skipCollapsed="true" + app:layout_behavior="android.support.design.bottomsheet.BottomSheetBehavior" + app:layout_insetEdge="bottom"> + + <ImageView + android:id="@+id/promotion_icon" + android:layout_width="36dp" + android:layout_height="36dp" + android:tint="@color/dialer_theme_color"/> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingStart="32dp" + android:orientation="vertical"> + <TextView + android:id="@+id/promotion_title" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:fontFamily="sans-serif-medium" + android:textColor="#DD000000" + android:textSize="16sp" + /> + <TextView + android:id="@+id/promotion_details" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:layout_marginBottom="16dp" + android:lineSpacingMultiplier="1.5" + android:textColor="#DD000000" + android:textSize="14sp"/> + <Button + android:id="@+id/ok_got_it" + style="@style/Widget.AppCompat.Button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:layout_marginBottom="8dp" + android:layout_gravity="end" + android:paddingStart="16dp" + android:paddingEnd="16dp" + android:backgroundTint="@color/dialer_theme_color" + android:fontFamily="sans-serif-medium" + android:stateListAnimator="@null" + android:text="@string/ok_got_it" + android:textColor="@android:color/white" + android:textSize="16sp"/> + </LinearLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/java/com/android/dialer/promotion/AndroidManifest.xml b/java/com/android/dialer/promotion/AndroidManifest.xml new file mode 100644 index 000000000..bd85b104f --- /dev/null +++ b/java/com/android/dialer/promotion/AndroidManifest.xml @@ -0,0 +1,16 @@ +<!-- + ~ Copyright (C) 2018 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 + --> +<manifest package="com.android.dialer.promotion"/> diff --git a/java/com/android/dialer/promotion/Promotion.java b/java/com/android/dialer/promotion/Promotion.java new file mode 100644 index 000000000..3cd16d4a6 --- /dev/null +++ b/java/com/android/dialer/promotion/Promotion.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2018 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.promotion; + +import android.support.annotation.DrawableRes; + +/** Interface for promotion bottom sheet. */ +public interface Promotion { + + /** Returns if this promotion should be shown. */ + boolean shouldShow(); + + /** Sets to show this promotion. */ + void setShouldShow(boolean shouldShow); + + /** Dismisses this promotion. This is called when user acknowledged the promotion. */ + void dismiss(); + + CharSequence getTitle(); + + CharSequence getDetails(); + + @DrawableRes + int getIconRes(); +} diff --git a/java/com/android/dialer/promotion/RttPromotion.java b/java/com/android/dialer/promotion/RttPromotion.java new file mode 100644 index 000000000..feb6e4734 --- /dev/null +++ b/java/com/android/dialer/promotion/RttPromotion.java @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2018 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.promotion; + +import android.content.Context; +import android.content.SharedPreferences; +import android.support.annotation.DrawableRes; +import com.android.dialer.common.LogUtil; +import com.android.dialer.configprovider.ConfigProviderBindings; +import com.android.dialer.spannable.ContentWithLearnMoreSpanner; +import com.android.dialer.storage.StorageComponent; + +/** RTT promotion. */ +public final class RttPromotion implements Promotion { + private static final String SHARED_PREFERENCE_KEY_ENABLED = "rtt_promotion_enabled"; + private static final String SHARED_PREFERENCE_KEY_DISMISSED = "rtt_promotion_dismissed"; + private final Context appContext; + + public RttPromotion(Context context) { + appContext = context.getApplicationContext(); + } + + @Override + public boolean shouldShow() { + SharedPreferences sharedPreferences = StorageComponent.get(appContext).unencryptedSharedPrefs(); + return sharedPreferences.getBoolean(SHARED_PREFERENCE_KEY_ENABLED, false) + && !sharedPreferences.getBoolean(SHARED_PREFERENCE_KEY_DISMISSED, false); + } + + @Override + public CharSequence getTitle() { + return appContext.getString(R.string.rtt_promotion_title); + } + + @Override + public CharSequence getDetails() { + return new ContentWithLearnMoreSpanner(appContext) + .create( + appContext.getString(R.string.rtt_promotion_details), + ConfigProviderBindings.get(appContext) + .getString( + "rtt_promo_learn_more_link_full_url", + "http://support.google.com/pixelphone/?p=dialer_rtt")); + } + + @Override + @DrawableRes + public int getIconRes() { + return R.drawable.quantum_ic_rtt_vd_theme_24; + } + + @Override + public void setShouldShow(boolean shouldShow) { + LogUtil.i("RttPromotion.setShouldShow", "shouldShow: %b", shouldShow); + StorageComponent.get(appContext) + .unencryptedSharedPrefs() + .edit() + .putBoolean(SHARED_PREFERENCE_KEY_ENABLED, shouldShow) + .apply(); + } + + @Override + public void dismiss() { + StorageComponent.get(appContext) + .unencryptedSharedPrefs() + .edit() + .putBoolean(SHARED_PREFERENCE_KEY_DISMISSED, true) + .apply(); + } +} diff --git a/java/com/android/dialer/promotion/res/values/strings.xml b/java/com/android/dialer/promotion/res/values/strings.xml new file mode 100644 index 000000000..633671546 --- /dev/null +++ b/java/com/android/dialer/promotion/res/values/strings.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2018 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 + --> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- Title for RTT promotion dialog. [CHAR LIMIT=NONE] --> + <string name="rtt_promotion_title">Real-time text messaging within a call</string> + + <!-- Details for RTT promotion dialog. [CHAR LIMIT=NONE] --> + <string name="rtt_promotion_details">RTT assists callers who are deaf, hard of hearing, have a speech + disability, or need more than voice alone. RTT messaging transcripts are stored on your device + in the call history. <xliff:g exmaple="Learn More">%1$s</xliff:g></string> + +</resources> diff --git a/java/com/android/incallui/call/CallList.java b/java/com/android/incallui/call/CallList.java index 0e89ac75d..4d737e544 100644 --- a/java/com/android/incallui/call/CallList.java +++ b/java/com/android/incallui/call/CallList.java @@ -39,6 +39,7 @@ import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.metrics.Metrics; import com.android.dialer.metrics.MetricsComponent; +import com.android.dialer.promotion.RttPromotion; import com.android.dialer.shortcuts.ShortcutUsageReporter; import com.android.dialer.spam.Spam; import com.android.dialer.spam.SpamComponent; @@ -226,6 +227,9 @@ public class CallList implements DialerCallDelegate { if (call.getState() == DialerCallState.INCOMING || call.getState() == DialerCallState.CALL_WAITING) { if (call.isActiveRttCall()) { + if (!call.isPhoneAccountRttCapable()) { + new RttPromotion(context).setShouldShow(true); + } Logger.get(context) .logCallImpression( DialerImpression.Type.INCOMING_RTT_CALL, diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java index 77e2ea30b..4db55478f 100644 --- a/java/com/android/incallui/call/DialerCall.java +++ b/java/com/android/incallui/call/DialerCall.java @@ -1067,7 +1067,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa } @TargetApi(28) - public boolean canUpgradeToRttCall() { + public boolean isPhoneAccountRttCapable() { PhoneAccount phoneAccount = getPhoneAccount(); if (phoneAccount == null) { return false; @@ -1075,6 +1075,14 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa if (!phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_RTT)) { return false; } + return true; + } + + @TargetApi(28) + public boolean canUpgradeToRttCall() { + if (!isPhoneAccountRttCapable()) { + return false; + } if (isActiveRttCall()) { return false; } |