summaryrefslogtreecommitdiff
path: root/java/com/android/incallui/calllocation/impl/LocationFragment.java
diff options
context:
space:
mode:
authorEric Erfanian <erfanian@google.com>2018-05-30 16:17:27 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-05-30 16:17:27 +0000
commit2c3d81eeac82472d06027bc65d661e16735c8608 (patch)
tree293aeb0012d8db8f3f4606a75a422cf4da328477 /java/com/android/incallui/calllocation/impl/LocationFragment.java
parent4efd0ebf003e985e7cbe40d8ffd9f7ff227a9611 (diff)
parent152c3fd58f83a1882bcdc8bc55f46bbb8f3173c9 (diff)
Merge changes Ica13ee39,I5e0fedc8,I8e7efad0,I0ecc1f91,Iee1e658a, ...
* changes: Drop maps.impl from packages.mk Check if ID column is null before retrieving data from the smart dial database. Rename theme/private to theme/hidden. Some improvements to the answer fragment layouts. Better a11y for the bottom sheet. Fix a few UI bugs. Log IMS video call available state Better a11y for contact badge in the new call log. Use lookup key to determine the letter tile color Use Dialer Light Theme for SpeakEasyFragment Better a11y for new call log entries. Use Maps SDK lite mode instead of static API for emergency call. Updating locations where PrimaryInfo#setPhoto is used to also PrimaryInfo#setPhotoUri for new GlidePhotoManager implementation. As part of this addition, we also are cleaning the setPhoto(null) because this is not explicitly needed. Converted ThemeUtil into a DaggerModule. Delete AppCompatConstants Remove photo support in PhoneNumberService Began implementation of Dialer dark theme.
Diffstat (limited to 'java/com/android/incallui/calllocation/impl/LocationFragment.java')
-rw-r--r--java/com/android/incallui/calllocation/impl/LocationFragment.java70
1 files changed, 61 insertions, 9 deletions
diff --git a/java/com/android/incallui/calllocation/impl/LocationFragment.java b/java/com/android/incallui/calllocation/impl/LocationFragment.java
index 6b2c876b0..760829da2 100644
--- a/java/com/android/incallui/calllocation/impl/LocationFragment.java
+++ b/java/com/android/incallui/calllocation/impl/LocationFragment.java
@@ -18,21 +18,26 @@ package com.android.incallui.calllocation.impl;
import android.animation.LayoutTransition;
import android.content.Context;
-import android.graphics.drawable.Drawable;
import android.location.Location;
import android.os.Bundle;
import android.os.Handler;
+import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.ImageView;
import android.widget.TextView;
import android.widget.ViewAnimator;
+import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.android.dialer.logging.DialerImpression;
import com.android.dialer.logging.Logger;
import com.android.incallui.baseui.BaseFragment;
+import com.google.android.gms.maps.CameraUpdateFactory;
+import com.google.android.gms.maps.GoogleMap;
+import com.google.android.gms.maps.MapView;
+import com.google.android.gms.maps.model.LatLng;
+import com.google.android.gms.maps.model.MarkerOptions;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
@@ -54,13 +59,16 @@ public class LocationFragment extends BaseFragment<LocationPresenter, LocationPr
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 static final float MAP_ZOOM_LEVEL = 15f;
+
private ViewAnimator viewAnimator;
- private ImageView locationMap;
+ private MapView locationMapView;
private TextView addressLine1;
private TextView addressLine2;
private TextView latLongLine;
private Location location;
private ViewGroup locationLayout;
+ private GoogleMap savedGoogleMap;
private boolean isMapSet;
private boolean isAddressSet;
@@ -101,11 +109,12 @@ public class LocationFragment extends BaseFragment<LocationPresenter, LocationPr
LogUtil.enterBlock("LocationFragment.onCreateView");
final View view = inflater.inflate(R.layout.location_fragment, container, false);
viewAnimator = (ViewAnimator) view.findViewById(R.id.location_view_animator);
- locationMap = (ImageView) view.findViewById(R.id.location_map);
addressLine1 = (TextView) view.findViewById(R.id.address_line_one);
addressLine2 = (TextView) view.findViewById(R.id.address_line_two);
latLongLine = (TextView) view.findViewById(R.id.lat_long_line);
locationLayout = (ViewGroup) view.findViewById(R.id.location_layout);
+ locationMapView = (MapView) view.findViewById(R.id.location_map_view);
+ locationMapView.onCreate(savedInstanceState);
return view;
}
@@ -122,16 +131,46 @@ public class LocationFragment extends BaseFragment<LocationPresenter, LocationPr
handler.removeCallbacks(spinningTimeoutRunnable);
}
- @Override
- public void setMap(Drawable mapImage) {
+ private void setMap(@NonNull Location location) {
LogUtil.enterBlock("LocationFragment.setMap");
- isMapSet = true;
- locationMap.setVisibility(View.VISIBLE);
- locationMap.setImageDrawable(mapImage);
+ Assert.isNotNull(location);
+
+ if (savedGoogleMap == null) {
+ locationMapView.getMapAsync(
+ (googleMap) -> {
+ LogUtil.enterBlock("LocationFragment.onMapReady");
+ savedGoogleMap = googleMap;
+ savedGoogleMap.getUiSettings().setMapToolbarEnabled(false);
+ updateMap(location);
+ isMapSet = true;
+ locationMapView.setVisibility(View.VISIBLE);
+
+ // Hide Google logo
+ View child = locationMapView.getChildAt(0);
+ if (child instanceof ViewGroup) {
+ // Only the first child (View) is useful.
+ // Google logo can be in any other child (ViewGroup).
+ for (int i = 1; i < ((ViewGroup) child).getChildCount(); ++i) {
+ ((ViewGroup) child).getChildAt(i).setVisibility(View.GONE);
+ }
+ }
+ });
+ } else {
+ updateMap(location);
+ }
displayWhenReady();
Logger.get(getContext()).logImpression(DialerImpression.Type.EMERGENCY_GOT_MAP);
}
+ private void updateMap(@NonNull Location location) {
+ Assert.isNotNull(location);
+ Assert.isNotNull(savedGoogleMap);
+ LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
+ savedGoogleMap.clear();
+ savedGoogleMap.addMarker(new MarkerOptions().position(latLng).flat(true).draggable(false));
+ savedGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, MAP_ZOOM_LEVEL));
+ }
+
@Override
public void setAddress(String address) {
LogUtil.i("LocationFragment.setAddress", address);
@@ -175,6 +214,7 @@ public class LocationFragment extends BaseFragment<LocationPresenter, LocationPr
R.string.lat_long_format, location.getLatitude(), location.getLongitude()));
Logger.get(getContext()).logImpression(DialerImpression.Type.EMERGENCY_GOT_LOCATION);
+ setMap(location);
}
displayWhenReady();
}
@@ -218,4 +258,16 @@ public class LocationFragment extends BaseFragment<LocationPresenter, LocationPr
view.setText(text);
}
}
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ locationMapView.onResume();
+ }
+
+ @Override
+ public void onPause() {
+ locationMapView.onPause();
+ super.onPause();
+ }
}