diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-10-18 04:43:40 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-10-18 04:43:40 +0000 |
commit | 96a2f8ec018b6d49c0d198ba123d5488157fdf79 (patch) | |
tree | cdc5512d316fc67b09503f7b03cf051182684aa3 /java | |
parent | ef7a7eb0f103d41df55385267ac52dc3dcf603cb (diff) | |
parent | e1c4dc99304e117325bc8c92731c2c64f2c79400 (diff) |
Merge changes Ibc853aa4,I061e3b45,I31983153
* changes:
Update simulator to add emergency call
Allow voicemail transcription notifications to expand
Hide voice search button when exiting search if it is not available
Diffstat (limited to 'java')
4 files changed, 51 insertions, 24 deletions
diff --git a/java/com/android/dialer/app/DialtactsActivity.java b/java/com/android/dialer/app/DialtactsActivity.java index 56e0a95e5..b96b127e2 100644 --- a/java/com/android/dialer/app/DialtactsActivity.java +++ b/java/com/android/dialer/app/DialtactsActivity.java @@ -136,6 +136,7 @@ import com.android.dialer.util.TouchPointManager; import com.android.dialer.util.TransactionSafeActivity; import com.android.dialer.util.ViewUtil; import com.android.dialer.widget.FloatingActionButtonController; +import com.google.common.base.Optional; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -194,6 +195,8 @@ public class DialtactsActivity extends TransactionSafeActivity */ private static final long HISTORY_TAB_SEEN_TIMEOUT = TimeUnit.SECONDS.toMillis(3); + private static Optional<Boolean> sVoiceSearchEnabledForTest = Optional.absent(); + /** Fragment containing the dialpad that slides into view */ protected DialpadFragment mDialpadFragment; @@ -242,6 +245,7 @@ public class DialtactsActivity extends TransactionSafeActivity private PopupMenu mOverflowMenu; private EditText mSearchView; + private SearchEditTextLayout mSearchEditTextLayout; private View mVoiceSearchButton; private String mSearchQuery; private String mDialpadQuery; @@ -397,20 +401,19 @@ public class DialtactsActivity extends TransactionSafeActivity actionBar.setDisplayShowCustomEnabled(true); actionBar.setBackgroundDrawable(null); - SearchEditTextLayout searchEditTextLayout = - actionBar.getCustomView().findViewById(R.id.search_view_container); + mSearchEditTextLayout = actionBar.getCustomView().findViewById(R.id.search_view_container); - mActionBarController = new ActionBarController(this, searchEditTextLayout); + mActionBarController = new ActionBarController(this, mSearchEditTextLayout); - mSearchView = searchEditTextLayout.findViewById(R.id.search_view); + mSearchView = mSearchEditTextLayout.findViewById(R.id.search_view); mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener); mSearchView.setHint(getSearchBoxHint()); - mVoiceSearchButton = searchEditTextLayout.findViewById(R.id.voice_search_button); - searchEditTextLayout + mVoiceSearchButton = mSearchEditTextLayout.findViewById(R.id.voice_search_button); + mSearchEditTextLayout .findViewById(R.id.search_box_collapsed) .setOnClickListener(mSearchViewOnClickListener); - searchEditTextLayout + mSearchEditTextLayout .findViewById(R.id.search_back_button) .setOnClickListener(v -> exitSearchUi()); @@ -423,7 +426,7 @@ public class DialtactsActivity extends TransactionSafeActivity new FloatingActionButtonController(this, floatingActionButton); ImageButton optionsMenuButton = - searchEditTextLayout.findViewById(R.id.dialtacts_options_menu_button); + mSearchEditTextLayout.findViewById(R.id.dialtacts_options_menu_button); optionsMenuButton.setOnClickListener(this); mOverflowMenu = buildOptionsMenu(optionsMenuButton); optionsMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener()); @@ -1015,13 +1018,15 @@ public class DialtactsActivity extends TransactionSafeActivity } private void prepareVoiceSearchButton() { - final Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); - if (canIntentBeHandled(voiceIntent)) { - mVoiceSearchButton.setVisibility(View.VISIBLE); - mVoiceSearchButton.setOnClickListener(this); - } else { - mVoiceSearchButton.setVisibility(View.GONE); + mSearchEditTextLayout.setVoiceSearchEnabled(isVoiceSearchEnabled()); + mVoiceSearchButton.setOnClickListener(this); + } + + private boolean isVoiceSearchEnabled() { + if (sVoiceSearchEnabledForTest.isPresent()) { + return sVoiceSearchEnabledForTest.get(); } + return canIntentBeHandled(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)); } public boolean isNearbyPlacesSearchEnabled() { @@ -1034,10 +1039,7 @@ public class DialtactsActivity extends TransactionSafeActivity /** Sets the hint text for the contacts search box */ private void setSearchBoxHint() { - SearchEditTextLayout searchEditTextLayout = - (SearchEditTextLayout) - getActionBarSafely().getCustomView().findViewById(R.id.search_view_container); - ((TextView) searchEditTextLayout.findViewById(R.id.search_box_start_search)) + ((TextView) mSearchEditTextLayout.findViewById(R.id.search_box_start_search)) .setHint(getSearchBoxHint()); } @@ -1714,4 +1716,9 @@ public class DialtactsActivity extends TransactionSafeActivity return true; } } + + @VisibleForTesting + static void setVoiceSearchEnabledForTest(Optional<Boolean> enabled) { + sVoiceSearchEnabledForTest = enabled; + } } diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java b/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java index 1836416a7..2fd9a2161 100644 --- a/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java +++ b/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java @@ -27,6 +27,7 @@ import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.v4.app.NotificationCompat; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telephony.TelephonyManager; @@ -76,7 +77,7 @@ final class VisualVoicemailNotifier { .getResources() .getQuantityString( R.plurals.notification_voicemail_title, newCalls.size(), newCalls.size()); - Notification.Builder groupSummary = + NotificationCompat.Builder groupSummary = createNotificationBuilder(context) .setContentTitle(contentTitle) .setContentText(callers) @@ -127,8 +128,8 @@ final class VisualVoicemailNotifier { return NOTIFICATION_TAG_PREFIX + voicemailUri; } - private static Notification.Builder createNotificationBuilder(@NonNull Context context) { - return new Notification.Builder(context) + private static NotificationCompat.Builder createNotificationBuilder(@NonNull Context context) { + return new NotificationCompat.Builder(context) .setSmallIcon(android.R.drawable.stat_notify_voicemail) .setColor(context.getColor(R.color.dialer_theme_color)) .setGroup(GROUP_KEY) @@ -143,7 +144,7 @@ final class VisualVoicemailNotifier { PhoneAccountHandle handle = getAccountForCall(context, voicemail); ContactInfo contactInfo = contactInfos.get(voicemail.number); - Notification.Builder builder = + NotificationCompat.Builder builder = createNotificationBuilder(context) .setContentTitle( ContactDisplayUtils.getTtsSpannedPhoneNumber( @@ -157,7 +158,9 @@ final class VisualVoicemailNotifier { if (!TextUtils.isEmpty(voicemail.transcription)) { Logger.get(context) .logImpression(DialerImpression.Type.VVM_NOTIFICATION_CREATED_WITH_TRANSCRIPTION); - builder.setContentText(voicemail.transcription); + builder + .setContentText(voicemail.transcription) + .setStyle(new NotificationCompat.BigTextStyle().bigText(voicemail.transcription)); } else { switch (voicemail.transcriptionState) { case VoicemailCompat.TRANSCRIPTION_IN_PROGRESS: diff --git a/java/com/android/dialer/app/widget/SearchEditTextLayout.java b/java/com/android/dialer/app/widget/SearchEditTextLayout.java index 9da0e245f..e7a707feb 100644 --- a/java/com/android/dialer/app/widget/SearchEditTextLayout.java +++ b/java/com/android/dialer/app/widget/SearchEditTextLayout.java @@ -58,6 +58,8 @@ public class SearchEditTextLayout extends FrameLayout { private Callback mCallback; + private boolean mVoiceSearchEnabled; + public SearchEditTextLayout(Context context, AttributeSet attrs) { super(context, attrs); } @@ -70,6 +72,11 @@ public class SearchEditTextLayout extends FrameLayout { mCallback = listener; } + public void setVoiceSearchEnabled(boolean enabled) { + mVoiceSearchEnabled = enabled; + updateVisibility(mIsExpanded); + } + @Override protected void onFinishInflate() { MarginLayoutParams params = (MarginLayoutParams) getLayoutParams(); @@ -272,7 +279,11 @@ public class SearchEditTextLayout extends FrameLayout { mSearchIcon.setVisibility(collapsedViewVisibility); mCollapsedSearchBox.setVisibility(collapsedViewVisibility); - mVoiceSearchButtonView.setVisibility(collapsedViewVisibility); + if (mVoiceSearchEnabled) { + mVoiceSearchButtonView.setVisibility(collapsedViewVisibility); + } else { + mVoiceSearchButtonView.setVisibility(View.GONE); + } mOverflowButtonView.setVisibility(collapsedViewVisibility); // TODO: Prevents keyboard from jumping up in landscape mode after exiting the // SearchFragment when the query string is empty. More elegant fix? diff --git a/java/com/android/dialer/simulator/impl/SimulatorVoiceCall.java b/java/com/android/dialer/simulator/impl/SimulatorVoiceCall.java index f478d55d0..f2a1d0901 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorVoiceCall.java +++ b/java/com/android/dialer/simulator/impl/SimulatorVoiceCall.java @@ -39,6 +39,7 @@ final class SimulatorVoiceCall .addItem("Incoming call", () -> new SimulatorVoiceCall(context).addNewIncomingCall(false)) .addItem("Outgoing call", () -> new SimulatorVoiceCall(context).addNewOutgoingCall()) .addItem("Spam call", () -> new SimulatorVoiceCall(context).addNewIncomingCall(true)) + .addItem("Emergency call", () -> new SimulatorVoiceCall(context).addNewEmergencyCall()) .addItem( "GSM conference", () -> new SimulatorConferenceCreator(context, Simulator.CONFERENCE_TYPE_GSM).start(5)); @@ -64,6 +65,11 @@ final class SimulatorVoiceCall SimulatorSimCallManager.addNewOutgoingCall(context, callerId, false /* isVideo */); } + private void addNewEmergencyCall() { + String callerId = "911"; + connectionTag = SimulatorSimCallManager.addNewIncomingCall(context, callerId, false); + } + @Override public void onNewOutgoingConnection(@NonNull SimulatorConnection connection) { if (isMyConnection(connection)) { |