From c5c42189eeab0389a94717de9a66c6d00068e8bf Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Tue, 22 May 2018 15:30:39 -0700 Subject: Began implementation of Dialer dark theme. - README on how to properly theme Dialer going forward. - Migrated all widgets to use global colors. - Removed all activity and application themes where it wasn't necessary. - Added themeing test rule for Espresso tests. Bug: 79883035 Test: tap PiperOrigin-RevId: 197634256 Change-Id: I4b7d94d45aeeb59d484b0069fdd1e200a654910b --- .../android/incallui/calllocation/impl/res/layout/location_fragment.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'java/com/android/incallui/calllocation/impl') 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 5d1e2baf7..771e1b868 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 @@ -145,7 +145,7 @@ android:layout_marginBottom="12dp" android:layout_gravity="center_horizontal" android:src="@drawable/quantum_ic_error_outline_vd_theme_36" - android:tint="#C53929"/> + android:tint="@color/dialer_red"/> 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 --- .../incallui/calllocation/impl/AndroidManifest.xml | 2 + .../calllocation/impl/DownloadMapImageTask.java | 78 ---------- .../calllocation/impl/LocationFragment.java | 70 +++++++-- .../calllocation/impl/LocationPresenter.java | 8 - .../impl/res/layout/location_fragment.xml | 163 --------------------- .../android/incallui/maps/impl/AndroidManifest.xml | 2 + 6 files changed, 65 insertions(+), 258 deletions(-) delete mode 100644 java/com/android/incallui/calllocation/impl/DownloadMapImageTask.java delete mode 100644 java/com/android/incallui/calllocation/impl/res/layout/location_fragment.xml (limited to 'java/com/android/incallui/calllocation/impl') diff --git a/java/com/android/incallui/calllocation/impl/AndroidManifest.xml b/java/com/android/incallui/calllocation/impl/AndroidManifest.xml index fda940483..3e5a6d04e 100644 --- a/java/com/android/incallui/calllocation/impl/AndroidManifest.xml +++ b/java/com/android/incallui/calllocation/impl/AndroidManifest.xml @@ -19,6 +19,8 @@ package="com.android.incallui.calllocation.impl"> + + { - - private static final String STATIC_MAP_SRC_NAME = "src"; - - private final WeakReference uiReference; - - public DownloadMapImageTask(WeakReference uiReference) { - this.uiReference = uiReference; - } - - @Override - protected Drawable doInBackground(Location... locations) { - LocationUi ui = uiReference.get(); - if (ui == null) { - return null; - } - if (locations == null || locations.length == 0) { - LogUtil.e("DownloadMapImageTask.doInBackground", "No location provided"); - return null; - } - - try { - URL mapUrl = new URL(LocationUrlBuilder.getStaticMapUrl(ui.getContext(), locations[0])); - TrafficStats.setThreadStatsTag(TrafficStatsTags.DOWNLOAD_LOCATION_MAP_TAG); - InputStream content = (InputStream) mapUrl.getContent(); - - return Drawable.createFromStream(content, STATIC_MAP_SRC_NAME); - } catch (Exception ex) { - LogUtil.e("DownloadMapImageTask.doInBackground", "Exception!!!", ex); - return null; - } finally { - TrafficStats.clearThreadStatsTag(); - } - } - - @Override - protected void onPostExecute(Drawable mapImage) { - LocationUi ui = uiReference.get(); - if (ui == null) { - return; - } - - try { - ui.setMap(mapImage); - } catch (Exception ex) { - LogUtil.e("DownloadMapImageTask.onPostExecute", "Exception!!!", ex); - } - } -} 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 implements LocationListener { private Location lastLocation; - private AsyncTask downloadMapTask; private AsyncTask reverseGeocodeTask; LocationPresenter() {} @@ -55,9 +53,6 @@ public class LocationPresenter extends Presenter LogUtil.i("LocationPresenter.onUiUnready", ""); super.onUiUnready(ui); - if (downloadMapTask != null) { - downloadMapTask.cancel(true); - } if (reverseGeocodeTask != null) { reverseGeocodeTask.cancel(true); } @@ -76,7 +71,6 @@ public class LocationPresenter extends Presenter int status = LocationHelper.checkLocation(location); LocationUi ui = getUi(); if (status == LocationHelper.LOCATION_STATUS_OK) { - downloadMapTask = new DownloadMapImageTask(new WeakReference<>(ui)).execute(location); reverseGeocodeTask = new ReverseGeocodeTask(new WeakReference<>(ui)).execute(location); if (ui != null) { ui.setLocation(location); @@ -103,8 +97,6 @@ public class LocationPresenter extends Presenter void setAddress(String address); - void setMap(Drawable mapImage); - void setLocation(Location location); Context getContext(); 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 deleted file mode 100644 index 771e1b868..000000000 --- a/java/com/android/incallui/calllocation/impl/res/layout/location_fragment.xml +++ /dev/null @@ -1,163 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/java/com/android/incallui/maps/impl/AndroidManifest.xml b/java/com/android/incallui/maps/impl/AndroidManifest.xml index bc921e906..4c17f33a4 100644 --- a/java/com/android/incallui/maps/impl/AndroidManifest.xml +++ b/java/com/android/incallui/maps/impl/AndroidManifest.xml @@ -19,6 +19,8 @@ package="com.android.incallui.maps.impl"> + +