diff options
author | mdooley <mdooley@google.com> | 2017-10-03 19:52:22 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-10-03 19:52:22 +0000 |
commit | 95d9fc132d6f9f9f0e86debf0bc0e27ae0e000b6 (patch) | |
tree | 8e7b250195e6037b48699d8108b33eeeac9ae1b4 | |
parent | 6154238fb632936eae3490189050c0ba01756bc1 (diff) | |
parent | 40a59d307038709ed489f0ed61ba94b224416743 (diff) |
Merge changes Ib6415145,Ifde98a8c
am: 40a59d3070
Change-Id: I9833ad954c352f648186945e30576c017fee5c39
5 files changed, 69 insertions, 4 deletions
diff --git a/java/com/android/incallui/calllocation/impl/LocationHelper.java b/java/com/android/incallui/calllocation/impl/LocationHelper.java index 48baa020a..7fbd60d04 100644 --- a/java/com/android/incallui/calllocation/impl/LocationHelper.java +++ b/java/com/android/incallui/calllocation/impl/LocationHelper.java @@ -39,7 +39,8 @@ import java.util.List; /** Uses the Fused location service to get location and pass updates on to listeners. */ public class LocationHelper { - private static final int MIN_UPDATE_INTERVAL_MS = 20 * 1000; + private static final int FAST_MIN_UPDATE_INTERVAL_MS = 5 * 1000; + private static final int SLOW_MIN_UPDATE_INTERVAL_MS = 30 * 1000; private static final int LAST_UPDATE_THRESHOLD_MS = 60 * 1000; private static final int LOCATION_ACCURACY_THRESHOLD_METERS = 100; @@ -159,6 +160,7 @@ public class LocationHelper { private final FusedLocationProviderClient locationClient; private final ConnectivityManager connectivityManager; private final Handler mainThreadHandler = new Handler(); + private boolean gotGoodLocation; @MainThread LocationHelperInternal(Context context) { @@ -178,11 +180,12 @@ public class LocationHelper { private void requestUpdates() { LogUtil.enterBlock("LocationHelperInternal.requestUpdates"); + int interval = gotGoodLocation ? SLOW_MIN_UPDATE_INTERVAL_MS : FAST_MIN_UPDATE_INTERVAL_MS; LocationRequest locationRequest = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) - .setInterval(MIN_UPDATE_INTERVAL_MS) - .setFastestInterval(MIN_UPDATE_INTERVAL_MS); + .setInterval(interval) + .setFastestInterval(interval); locationClient .requestLocationUpdates(locationRequest, this) @@ -202,6 +205,7 @@ public class LocationHelper { LogUtil.i("LocationHelperInternal.getLocation", "onSuccess"); Assert.isMainThread(); LocationHelper.this.onLocationChanged(location, isConnected()); + maybeAdjustUpdateInterval(location); }) .addOnFailureListener( e -> LogUtil.e("LocationHelperInternal.getLocation", "onFailure", e)); @@ -215,10 +219,19 @@ public class LocationHelper { @Override public void run() { LocationHelper.this.onLocationChanged(location, isConnected()); + maybeAdjustUpdateInterval(location); } }); } + private void maybeAdjustUpdateInterval(Location location) { + if (!gotGoodLocation && checkLocation(location) == LOCATION_STATUS_OK) { + LogUtil.i("LocationHelperInternal.maybeAdjustUpdateInterval", "got good location"); + gotGoodLocation = true; + requestUpdates(); + } + } + /** @return Whether the phone is connected to data. */ private boolean isConnected() { if (connectivityManager == null) { diff --git a/java/com/android/incallui/contactgrid/ContactGridManager.java b/java/com/android/incallui/contactgrid/ContactGridManager.java index 18bab6ab3..c0ab9609f 100644 --- a/java/com/android/incallui/contactgrid/ContactGridManager.java +++ b/java/com/android/incallui/contactgrid/ContactGridManager.java @@ -27,6 +27,7 @@ import android.view.View; import android.view.accessibility.AccessibilityEvent; import android.widget.Chronometer; import android.widget.ImageView; +import android.widget.Space; import android.widget.TextView; import android.widget.ViewAnimator; import com.android.contacts.common.compat.PhoneNumberUtilsCompat; @@ -74,6 +75,7 @@ public class ContactGridManager { private final ViewAnimator bottomTextSwitcher; private final TextView bottomTextView; private final Chronometer bottomTimerView; + private final Space topRowSpace; private int avatarSize; private boolean hideAvatar; private boolean showAnonymousAvatar; @@ -104,6 +106,7 @@ public class ContactGridManager { bottomTextSwitcher = view.findViewById(R.id.contactgrid_bottom_text_switcher); bottomTextView = view.findViewById(R.id.contactgrid_bottom_text); bottomTimerView = view.findViewById(R.id.contactgrid_bottom_timer); + topRowSpace = view.findViewById(R.id.contactgrid_top_row_space); contactGridLayout = (View) contactNameTextView.getParent(); letterTile = new LetterTileDrawable(context.getResources()); @@ -229,9 +232,16 @@ public class ContactGridManager { if (info.icon == null) { connectionIconImageView.setVisibility(View.GONE); + topRowSpace.setVisibility(View.GONE); } else { connectionIconImageView.setVisibility(View.VISIBLE); connectionIconImageView.setImageDrawable(info.icon); + if (statusTextView.getVisibility() == View.VISIBLE + && !TextUtils.isEmpty(statusTextView.getText())) { + topRowSpace.setVisibility(View.VISIBLE); + } else { + topRowSpace.setVisibility(View.GONE); + } } } diff --git a/java/com/android/incallui/contactgrid/res/layout/incall_contactgrid_top_row.xml b/java/com/android/incallui/contactgrid/res/layout/incall_contactgrid_top_row.xml index 59359c9c1..42066f286 100644 --- a/java/com/android/incallui/contactgrid/res/layout/incall_contactgrid_top_row.xml +++ b/java/com/android/incallui/contactgrid/res/layout/incall_contactgrid_top_row.xml @@ -1,4 +1,19 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2017 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:tools="http://schemas.android.com/tools" @@ -11,11 +26,15 @@ android:id="@id/contactgrid_connection_icon" android:layout_width="24dp" android:layout_height="24dp" - android:layout_marginEnd="10dp" android:scaleType="fitCenter" tools:src="@android:drawable/sym_def_app_icon" tools:visibility="visible" /> + <Space + android:id="@id/contactgrid_top_row_space" + android:layout_height="match_parent" + android:layout_width="@dimen/contactgrid_connection_icon_margin_end" + /> <TextView android:id="@id/contactgrid_status_text" android:layout_width="wrap_content" diff --git a/java/com/android/incallui/contactgrid/res/values/dimens.xml b/java/com/android/incallui/contactgrid/res/values/dimens.xml new file mode 100644 index 000000000..82bae43b0 --- /dev/null +++ b/java/com/android/incallui/contactgrid/res/values/dimens.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2017 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> + + <!-- Dimensions for connection icons --> + <dimen name="contactgrid_connection_icon_margin_end">10dp</dimen> +</resources>
\ No newline at end of file diff --git a/java/com/android/incallui/contactgrid/res/values/ids.xml b/java/com/android/incallui/contactgrid/res/values/ids.xml index 821dc9d98..f3b111a16 100644 --- a/java/com/android/incallui/contactgrid/res/values/ids.xml +++ b/java/com/android/incallui/contactgrid/res/values/ids.xml @@ -28,4 +28,5 @@ <item name="contactgrid_avatar" type="id"/> <item name="contactgrid_top_row" type="id"/> <item name="contactgrid_bottom_row" type="id"/> + <item name="contactgrid_top_row_space" type="id"/> </resources> |