diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-09-19 21:55:42 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-09-19 21:55:42 +0000 |
commit | 15c5ccfc3a76c89b047722b398e63889d900ec5e (patch) | |
tree | ccc4ba1be4af03ced6f837b0dc86bb9800ce9370 /java/com/android | |
parent | 06d4df10f100b9bbfcf119aef376770eeb6eb82c (diff) | |
parent | 791f820f5108b3ea914690145ef261d6c01bf41a (diff) |
Merge changes I3f26d915,I59500877,Ia08ce56f
* changes:
Perform remote reachability query if caller is not in contacts
Only enable voicemail transcription on android O and later
Removed zero suggest from dialpad search in new search fragment.
Diffstat (limited to 'java/com/android')
8 files changed, 89 insertions, 13 deletions
diff --git a/java/com/android/dialer/app/DialtactsActivity.java b/java/com/android/dialer/app/DialtactsActivity.java index 588f9d77e..74bf98dae 100644 --- a/java/com/android/dialer/app/DialtactsActivity.java +++ b/java/com/android/dialer/app/DialtactsActivity.java @@ -173,6 +173,7 @@ public class DialtactsActivity extends TransactionSafeActivity private static final String KEY_FIRST_LAUNCH = "first_launch"; private static final String KEY_WAS_CONFIGURATION_CHANGE = "was_configuration_change"; private static final String KEY_IS_DIALPAD_SHOWN = "is_dialpad_shown"; + private static final String KEY_FAB_VISIBLE = "fab_visible"; private static final String TAG_NEW_SEARCH_FRAGMENT = "new_search"; private static final String TAG_REGULAR_SEARCH_FRAGMENT = "search"; private static final String TAG_SMARTDIAL_SEARCH_FRAGMENT = "smartdial"; @@ -435,6 +436,7 @@ public class DialtactsActivity extends TransactionSafeActivity mFirstLaunch = savedInstanceState.getBoolean(KEY_FIRST_LAUNCH); mWasConfigurationChange = savedInstanceState.getBoolean(KEY_WAS_CONFIGURATION_CHANGE); mShowDialpadOnResume = savedInstanceState.getBoolean(KEY_IS_DIALPAD_SHOWN); + mFloatingActionButtonController.setVisible(savedInstanceState.getBoolean(KEY_FAB_VISIBLE)); mActionBarController.restoreInstanceState(savedInstanceState); } @@ -629,6 +631,7 @@ public class DialtactsActivity extends TransactionSafeActivity outState.putBoolean(KEY_IN_NEW_SEARCH_UI, mInNewSearch); outState.putBoolean(KEY_FIRST_LAUNCH, mFirstLaunch); outState.putBoolean(KEY_IS_DIALPAD_SHOWN, mIsDialpadShown); + outState.putBoolean(KEY_FAB_VISIBLE, mFloatingActionButtonController.isVisible()); outState.putBoolean(KEY_WAS_CONFIGURATION_CHANGE, isChangingConfigurations()); mActionBarController.saveInstanceState(outState); mStateSaved = true; @@ -1180,7 +1183,7 @@ public class DialtactsActivity extends TransactionSafeActivity Fragment fragment = getFragmentManager().findFragmentByTag(tag); if (fragment == null) { if (useNewSearch) { - fragment = new NewSearchFragment(); + fragment = NewSearchFragment.newInstance(!isDialpadShown()); } else if (smartDialSearch) { fragment = new SmartDialSearchFragment(); } else { diff --git a/java/com/android/dialer/app/voicemail/error/VoicemailTosMessageCreator.java b/java/com/android/dialer/app/voicemail/error/VoicemailTosMessageCreator.java index 9b3bbd08e..f5ea95d35 100644 --- a/java/com/android/dialer/app/voicemail/error/VoicemailTosMessageCreator.java +++ b/java/com/android/dialer/app/voicemail/error/VoicemailTosMessageCreator.java @@ -22,6 +22,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; +import android.os.Build; import android.preference.PreferenceManager; import android.support.annotation.Nullable; import android.telecom.PhoneAccountHandle; @@ -139,7 +140,8 @@ public class VoicemailTosMessageCreator { } private boolean isVoicemailTranscriptionEnabled() { - return ConfigProviderBindings.get(context).getBoolean("voicemail_transcription_enabled", false); + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O + && ConfigProviderBindings.get(context).getBoolean("voicemail_transcription_enabled", false); } private void showDeclineTosDialog(final PhoneAccountHandle handle) { diff --git a/java/com/android/dialer/lightbringer/Lightbringer.java b/java/com/android/dialer/lightbringer/Lightbringer.java index fa57b0166..2318ef5fd 100644 --- a/java/com/android/dialer/lightbringer/Lightbringer.java +++ b/java/com/android/dialer/lightbringer/Lightbringer.java @@ -25,6 +25,9 @@ import android.support.annotation.Nullable; import android.support.annotation.StringRes; import android.telecom.Call; import android.telecom.PhoneAccountHandle; +import com.google.auto.value.AutoValue; +import com.google.common.base.Optional; +import java.util.List; public interface Lightbringer { @@ -33,8 +36,12 @@ public interface Lightbringer { @MainThread boolean isReachable(@NonNull Context context, @Nullable String number); + /** @return {@code null} if result is unknown. */ @MainThread - boolean supportsUpgrade(@NonNull Context context, @Nullable String number); + Optional<Boolean> supportsUpgrade(@NonNull Context context, @Nullable String number); + + @MainThread + void updateReachability(@NonNull Context context, @NonNull List<String> numbers); @MainThread Intent getIntent(@NonNull Context context, @NonNull String number); @@ -67,4 +74,19 @@ public interface Lightbringer { @StringRes @MainThread int getIncomingCallTypeText(); + + /** Reachability information for a number. */ + @AutoValue + abstract class ReachabilityData { + public abstract String number(); + + public abstract boolean videoCallable(); + + public abstract boolean supportsUpgrade(); + + public static ReachabilityData create( + String number, boolean videoCallable, boolean supportsUpgrade) { + return new AutoValue_Lightbringer_ReachabilityData(number, videoCallable, supportsUpgrade); + } + } } diff --git a/java/com/android/dialer/lightbringer/stub/LightbringerStub.java b/java/com/android/dialer/lightbringer/stub/LightbringerStub.java index a0309220a..e66739113 100644 --- a/java/com/android/dialer/lightbringer/stub/LightbringerStub.java +++ b/java/com/android/dialer/lightbringer/stub/LightbringerStub.java @@ -28,6 +28,8 @@ import android.telecom.PhoneAccountHandle; import com.android.dialer.common.Assert; import com.android.dialer.lightbringer.Lightbringer; import com.android.dialer.lightbringer.LightbringerListener; +import com.google.common.base.Optional; +import java.util.List; import javax.inject.Inject; public class LightbringerStub implements Lightbringer { @@ -50,10 +52,17 @@ public class LightbringerStub implements Lightbringer { @MainThread @Override - public boolean supportsUpgrade(@NonNull Context context, @Nullable String number) { + public Optional<Boolean> supportsUpgrade(@NonNull Context context, @Nullable String number) { Assert.isMainThread(); Assert.isNotNull(context); - return false; + return Optional.of(false); + } + + @Override + public void updateReachability(@NonNull Context context, @NonNull List<String> numbers) { + Assert.isMainThread(); + Assert.isNotNull(context); + Assert.isNotNull(numbers); } @MainThread diff --git a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java index 036d53fb5..3cf8fb5b9 100644 --- a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java +++ b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java @@ -73,6 +73,8 @@ public final class NewSearchFragment extends Fragment // updates so they are bundled together private static final int ENRICHED_CALLING_CAPABILITIES_UPDATED_DELAY = 400; + private static final String KEY_SHOW_ZERO_SUGGEST = "use_zero_suggest"; + @VisibleForTesting public static final int READ_CONTACTS_PERMISSION_REQUEST_CODE = 1; private static final int CONTACTS_LOADER_ID = 0; @@ -99,6 +101,14 @@ public final class NewSearchFragment extends Fragment private Runnable updatePositionRunnable; + public static NewSearchFragment newInstance(boolean showZeroSuggest) { + NewSearchFragment fragment = new NewSearchFragment(); + Bundle args = new Bundle(); + args.putBoolean(KEY_SHOW_ZERO_SUGGEST, showZeroSuggest); + fragment.setArguments(args); + return fragment; + } + @Nullable @Override public View onCreateView( @@ -107,6 +117,7 @@ public final class NewSearchFragment extends Fragment adapter = new SearchAdapter(getActivity(), new SearchCursorManager()); adapter.setCallInitiationType(callInitiationType); adapter.setSearchActions(getActions()); + adapter.setZeroSuggestVisible(getArguments().getBoolean(KEY_SHOW_ZERO_SUGGEST)); emptyContentView = view.findViewById(R.id.empty_view); recyclerView = view.findViewById(R.id.recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); @@ -212,6 +223,7 @@ public final class NewSearchFragment extends Fragment adapter.setQuery(query); adapter.setCallInitiationType(callInitiationType); adapter.setSearchActions(getActions()); + adapter.setZeroSuggestVisible(isRegularSearch()); loadNearbyPlacesCursor(); loadRemoteContactsCursors(); } @@ -354,9 +366,7 @@ public final class NewSearchFragment extends Fragment * the list of supported actions, see {@link SearchActionViewHolder.Action}. */ private List<Integer> getActions() { - if (TextUtils.isEmpty(query) - || query.length() == 1 - || callInitiationType == CallInitiationType.Type.REGULAR_SEARCH) { + if (TextUtils.isEmpty(query) || query.length() == 1 || isRegularSearch()) { return Collections.emptyList(); } @@ -369,4 +379,8 @@ public final class NewSearchFragment extends Fragment } return actions; } + + private boolean isRegularSearch() { + return callInitiationType == CallInitiationType.Type.REGULAR_SEARCH; + } } diff --git a/java/com/android/dialer/searchfragment/list/SearchAdapter.java b/java/com/android/dialer/searchfragment/list/SearchAdapter.java index 3bfdd98f3..d4b5cf29d 100644 --- a/java/com/android/dialer/searchfragment/list/SearchAdapter.java +++ b/java/com/android/dialer/searchfragment/list/SearchAdapter.java @@ -21,6 +21,7 @@ import android.content.Intent; import android.support.annotation.VisibleForTesting; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView.ViewHolder; +import android.text.TextUtils; import android.view.LayoutInflater; import android.view.ViewGroup; import com.android.dialer.callcomposer.CallComposerActivity; @@ -50,6 +51,7 @@ public final class SearchAdapter extends RecyclerView.Adapter<ViewHolder> private final SearchCursorManager searchCursorManager; private final Activity activity; + private boolean showZeroSuggest; private String query; private CallInitiationType.Type callInitiationType = CallInitiationType.Type.UNKNOWN_INITIATION; @@ -124,9 +126,21 @@ public final class SearchAdapter extends RecyclerView.Adapter<ViewHolder> @Override public int getItemCount() { + if (TextUtils.isEmpty(query) && !showZeroSuggest) { + return 0; + } return searchCursorManager.getCount(); } + /** + * @param visible If true and query is empty, the adapter won't show any list elements. + * @see #setQuery(String) + * @see #getItemCount() + */ + public void setZeroSuggestVisible(boolean visible) { + showZeroSuggest = visible; + } + public void setQuery(String query) { this.query = query; if (searchCursorManager.setQuery(query)) { diff --git a/java/com/android/incallui/videotech/lightbringer/LightbringerTech.java b/java/com/android/incallui/videotech/lightbringer/LightbringerTech.java index a807759db..4b6f5ec5a 100644 --- a/java/com/android/incallui/videotech/lightbringer/LightbringerTech.java +++ b/java/com/android/incallui/videotech/lightbringer/LightbringerTech.java @@ -31,6 +31,8 @@ import com.android.incallui.video.protocol.VideoCallScreen; import com.android.incallui.video.protocol.VideoCallScreenDelegate; import com.android.incallui.videotech.VideoTech; import com.android.incallui.videotech.utils.SessionModificationState; +import com.google.common.base.Optional; +import com.google.common.collect.ImmutableList; public class LightbringerTech implements VideoTech, LightbringerListener { private final Lightbringer lightbringer; @@ -38,6 +40,7 @@ public class LightbringerTech implements VideoTech, LightbringerListener { private final Call call; private final String callingNumber; private int callState = Call.STATE_NEW; + private boolean isRemoteUpgradeAvailabilityQueried; public LightbringerTech( @NonNull Lightbringer lightbringer, @@ -69,13 +72,20 @@ public class LightbringerTech implements VideoTech, LightbringerListener { LogUtil.v("LightbringerTech.isAvailable", "upgrade unavailable, call must be active"); return false; } + Optional<Boolean> localResult = lightbringer.supportsUpgrade(context, callingNumber); + if (localResult.isPresent()) { + LogUtil.v( + "LightbringerTech.isAvailable", "upgrade supported in local cache: " + localResult.get()); + return localResult.get(); + } - if (!lightbringer.supportsUpgrade(context, callingNumber)) { - LogUtil.v("LightbringerTech.isAvailable", "upgrade unavailable, number does not support it"); - return false; + if (!isRemoteUpgradeAvailabilityQueried) { + LogUtil.v("LightbringerTech.isAvailable", "reachability unknown, starting remote query"); + isRemoteUpgradeAvailabilityQueried = true; + lightbringer.updateReachability(context, ImmutableList.of(callingNumber)); } - return true; + return false; } @Override diff --git a/java/com/android/voicemail/impl/transcribe/TranscriptionConfigProvider.java b/java/com/android/voicemail/impl/transcribe/TranscriptionConfigProvider.java index 83f04dab8..4bb9a261b 100644 --- a/java/com/android/voicemail/impl/transcribe/TranscriptionConfigProvider.java +++ b/java/com/android/voicemail/impl/transcribe/TranscriptionConfigProvider.java @@ -16,6 +16,7 @@ package com.android.voicemail.impl.transcribe; import android.content.Context; +import android.os.Build; import com.android.dialer.configprovider.ConfigProviderBindings; /** Provides configuration values needed to connect to the transcription server. */ @@ -27,7 +28,8 @@ public class TranscriptionConfigProvider { } public boolean isVoicemailTranscriptionEnabled() { - return ConfigProviderBindings.get(context).getBoolean("voicemail_transcription_enabled", false); + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O + && ConfigProviderBindings.get(context).getBoolean("voicemail_transcription_enabled", false); } public String getServerAddress() { |