summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authoryueg <yueg@google.com>2018-03-21 12:14:04 -0700
committerCopybara-Service <copybara-piper@google.com>2018-03-21 13:01:22 -0700
commit7642b8011e00bf353504440754ffa3f3a7cd8f8c (patch)
tree8c1601b2c250506df8aaf94dad89b5df2fb277d0 /java
parentab661fe03bd570bf713e8f040784fba3a504ec9d (diff)
Show error when finding location time out.
If we get no location data for emergency call, we used to show spinner forever. This change shows error after 5s with no data, but still tries to get location. Test: LocationFragmentTest PiperOrigin-RevId: 189946803 Change-Id: Iaa0b429eec806337b9ab9cae3ca95e737fc667bf
Diffstat (limited to 'java')
-rw-r--r--java/com/android/incallui/calllocation/impl/LocationFragment.java28
-rw-r--r--java/com/android/incallui/calllocation/impl/res/layout/location_fragment.xml30
-rw-r--r--java/com/android/incallui/calllocation/impl/res/values/strings.xml3
-rw-r--r--java/com/android/incallui/calllocation/impl/res/values/styles.xml23
4 files changed, 77 insertions, 7 deletions
diff --git a/java/com/android/incallui/calllocation/impl/LocationFragment.java b/java/com/android/incallui/calllocation/impl/LocationFragment.java
index 77e4f7f7d..6b2c876b0 100644
--- a/java/com/android/incallui/calllocation/impl/LocationFragment.java
+++ b/java/com/android/incallui/calllocation/impl/LocationFragment.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * 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.
@@ -47,10 +47,12 @@ public class LocationFragment extends BaseFragment<LocationPresenter, LocationPr
private static final String ADDRESS_DELIMITER = ",";
- // Indexes used to animate fading between views
- private static final int LOADING_VIEW_INDEX = 0;
+ // Indexes used to animate fading between views, 0 for LOADING_VIEW_INDEX
private static final int LOCATION_VIEW_INDEX = 1;
- private static final long TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(5);
+ private static final int LOCATION_ERROR_INDEX = 2;
+
+ private static final long FIND_LOCATION_SPINNING_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(5);
+ private static final long LOAD_DATA_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(5);
private ViewAnimator viewAnimator;
private ImageView locationMap;
@@ -75,6 +77,14 @@ public class LocationFragment extends BaseFragment<LocationPresenter, LocationPr
showLocationNow();
};
+ private final Runnable spinningTimeoutRunnable =
+ () -> {
+ if (!(isAddressSet || isLocationSet || isMapSet)) {
+ // No data received, show error
+ viewAnimator.setDisplayedChild(LOCATION_ERROR_INDEX);
+ }
+ };
+
@Override
public LocationPresenter createPresenter() {
return new LocationPresenter();
@@ -100,9 +110,16 @@ public class LocationFragment extends BaseFragment<LocationPresenter, LocationPr
}
@Override
+ public void onStart() {
+ super.onStart();
+ handler.postDelayed(spinningTimeoutRunnable, FIND_LOCATION_SPINNING_TIMEOUT_MILLIS);
+ }
+
+ @Override
public void onDestroy() {
super.onDestroy();
handler.removeCallbacks(dataTimeoutRunnable);
+ handler.removeCallbacks(spinningTimeoutRunnable);
}
@Override
@@ -167,13 +184,14 @@ public class LocationFragment extends BaseFragment<LocationPresenter, LocationPr
if (isMapSet && isAddressSet && isLocationSet) {
showLocationNow();
} else if (!hasTimeoutStarted) {
- handler.postDelayed(dataTimeoutRunnable, TIMEOUT_MILLIS);
+ handler.postDelayed(dataTimeoutRunnable, LOAD_DATA_TIMEOUT_MILLIS);
hasTimeoutStarted = true;
}
}
private void showLocationNow() {
handler.removeCallbacks(dataTimeoutRunnable);
+ handler.removeCallbacks(spinningTimeoutRunnable);
if (viewAnimator.getDisplayedChild() != LOCATION_VIEW_INDEX) {
viewAnimator.setDisplayedChild(LOCATION_VIEW_INDEX);
viewAnimator.setOnClickListener(v -> launchMap());
diff --git a/java/com/android/incallui/calllocation/impl/res/layout/location_fragment.xml b/java/com/android/incallui/calllocation/impl/res/layout/location_fragment.xml
index b1601f9fd..d20e32b3f 100644
--- a/java/com/android/incallui/calllocation/impl/res/layout/location_fragment.xml
+++ b/java/com/android/incallui/calllocation/impl/res/layout/location_fragment.xml
@@ -130,4 +130,34 @@
</GridLayout>
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/location_error_layout"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:orientation="vertical">
+
+ <ImageView
+ android:id="@+id/location_error_icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="32dp"
+ android:layout_marginBottom="12dp"
+ android:layout_gravity="center_horizontal"
+ android:src="@drawable/quantum_ic_error_outline_vd_theme_36"
+ android:tint="#C53929"/>
+
+ <TextView
+ android:id="@+id/location_error_text"
+ style="@style/LocationErrorTextStyle"
+ android:layout_width="match_parent"
+ android:layout_height="24sp"
+ android:layout_marginBottom="20dp"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="16dp"
+ android:gravity="center"
+ android:text="@string/location_error"/>
+
+ </LinearLayout>
+
</ViewAnimator>
diff --git a/java/com/android/incallui/calllocation/impl/res/values/strings.xml b/java/com/android/incallui/calllocation/impl/res/values/strings.xml
index 573f33cda..732b4efbd 100644
--- a/java/com/android/incallui/calllocation/impl/res/values/strings.xml
+++ b/java/com/android/incallui/calllocation/impl/res/values/strings.xml
@@ -29,4 +29,7 @@
<!-- Progress indicator loading text. [CHAR LIMIT=20] -->
<string name="location_loading">Finding your location&#8230;</string>
+ <!-- Error message shown when we can't get device location. [CHAR LIMIT=NONE] -->
+ <string name="location_error">Error, could not retrieve your location</string>
+
</resources>
diff --git a/java/com/android/incallui/calllocation/impl/res/values/styles.xml b/java/com/android/incallui/calllocation/impl/res/values/styles.xml
index 866a4edb6..45e9c98d4 100644
--- a/java/com/android/incallui/calllocation/impl/res/values/styles.xml
+++ b/java/com/android/incallui/calllocation/impl/res/values/styles.xml
@@ -1,5 +1,18 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright 2015 Google Inc. All Rights Reserved. -->
+<!--
+ ~ 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>
<style name="LocationAddressTitleTextStyle">
@@ -25,4 +38,10 @@
<item name="android:textColor">#dd000000</item>
<item name="android:fontFamily">sans-serif</item>
</style>
+
+ <style name="LocationErrorTextStyle">
+ <item name="android:textSize">14sp</item>
+ <item name="android:textColor">#dd000000</item>
+ <item name="android:fontFamily">sans-serif</item>
+ </style>
</resources>