From 2ad3c08bc26edee0c721505e21c9764c10e3e5f7 Mon Sep 17 00:00:00 2001 From: yueg Date: Wed, 23 May 2018 16:36:49 -0700 Subject: Use Maps SDK lite mode instead of static API for emergency call. Test: manual PiperOrigin-RevId: 197810897 Change-Id: Ia9dff17333152763b6c644d4f89bc32eedcc2aab --- .../calllocation/impl/LocationFragment.java | 70 +++++++++++++++++++--- 1 file changed, 61 insertions(+), 9 deletions(-) (limited to 'java/com/android/incallui/calllocation/impl/LocationFragment.java') 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 { + 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