summaryrefslogtreecommitdiff
path: root/java/com/android/incallui/maps/impl
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/android/incallui/maps/impl')
-rw-r--r--java/com/android/incallui/maps/impl/AndroidManifest.xml26
-rw-r--r--java/com/android/incallui/maps/impl/MapsImpl.java40
-rw-r--r--java/com/android/incallui/maps/impl/MapsModule.java31
-rw-r--r--java/com/android/incallui/maps/impl/StaticMapFragment.java76
-rw-r--r--java/com/android/incallui/maps/impl/res/layout/static_map_fragment.xml29
5 files changed, 202 insertions, 0 deletions
diff --git a/java/com/android/incallui/maps/impl/AndroidManifest.xml b/java/com/android/incallui/maps/impl/AndroidManifest.xml
new file mode 100644
index 000000000..4ad0b3b7e
--- /dev/null
+++ b/java/com/android/incallui/maps/impl/AndroidManifest.xml
@@ -0,0 +1,26 @@
+<!--
+ ~ Copyright (C) 2016 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
+ -->
+
+<manifest
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.incallui.maps.impl">
+
+ <application>
+ <meta-data
+ android:name="com.google.android.gms.version"
+ android:value="@integer/google_play_services_version"/>
+ </application>
+</manifest>
diff --git a/java/com/android/incallui/maps/impl/MapsImpl.java b/java/com/android/incallui/maps/impl/MapsImpl.java
new file mode 100644
index 000000000..2cecee93e
--- /dev/null
+++ b/java/com/android/incallui/maps/impl/MapsImpl.java
@@ -0,0 +1,40 @@
+/*
+ * 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
+ */
+
+package com.android.incallui.maps.impl;
+
+import android.location.Location;
+import android.support.annotation.NonNull;
+import android.support.v4.app.Fragment;
+import com.android.incallui.maps.Maps;
+import javax.inject.Inject;
+
+/** Uses Google Play Services APIs to create a static map fragment. */
+final class MapsImpl implements Maps {
+ @Inject
+ public MapsImpl() {}
+
+ @Override
+ public boolean isAvailable() {
+ return true;
+ }
+
+ @Override
+ @NonNull
+ public Fragment createStaticMapFragment(@NonNull Location location) {
+ return StaticMapFragment.newInstance(location);
+ }
+}
diff --git a/java/com/android/incallui/maps/impl/MapsModule.java b/java/com/android/incallui/maps/impl/MapsModule.java
new file mode 100644
index 000000000..22f2f32a7
--- /dev/null
+++ b/java/com/android/incallui/maps/impl/MapsModule.java
@@ -0,0 +1,31 @@
+/*
+ * 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
+ */
+
+package com.android.incallui.maps.impl;
+
+import com.android.incallui.maps.Maps;
+import dagger.Binds;
+import dagger.Module;
+import javax.inject.Singleton;
+
+/** This module provides an instance of maps. */
+@Module
+public abstract class MapsModule {
+
+ @Binds
+ @Singleton
+ public abstract Maps bindMaps(MapsImpl maps);
+}
diff --git a/java/com/android/incallui/maps/impl/StaticMapFragment.java b/java/com/android/incallui/maps/impl/StaticMapFragment.java
new file mode 100644
index 000000000..38a4c156b
--- /dev/null
+++ b/java/com/android/incallui/maps/impl/StaticMapFragment.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2016 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
+ */
+
+package com.android.incallui.maps.impl;
+
+import android.location.Location;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import com.android.dialer.common.Assert;
+import com.android.dialer.common.LogUtil;
+import com.google.android.gms.maps.CameraUpdateFactory;
+import com.google.android.gms.maps.GoogleMap;
+import com.google.android.gms.maps.OnMapReadyCallback;
+import com.google.android.gms.maps.SupportMapFragment;
+import com.google.android.gms.maps.model.LatLng;
+import com.google.android.gms.maps.model.MarkerOptions;
+
+/** Shows a static map centered on a specified location */
+public class StaticMapFragment extends Fragment implements OnMapReadyCallback {
+
+ private static final String ARG_LOCATION = "location";
+
+ public static StaticMapFragment newInstance(@NonNull Location location) {
+ Bundle args = new Bundle();
+ args.putParcelable(ARG_LOCATION, Assert.isNotNull(location));
+ StaticMapFragment fragment = new StaticMapFragment();
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @Nullable
+ @Override
+ public View onCreateView(
+ LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
+ return layoutInflater.inflate(R.layout.static_map_fragment, viewGroup, false);
+ }
+
+ @Override
+ public void onViewCreated(View view, @Nullable Bundle bundle) {
+ super.onViewCreated(view, bundle);
+ SupportMapFragment mapFragment =
+ (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.static_map);
+ if (mapFragment != null) {
+ mapFragment.getMapAsync(this);
+ } else {
+ LogUtil.w("StaticMapFragment.onViewCreated", "No map fragment found!");
+ }
+ }
+
+ @Override
+ public void onMapReady(GoogleMap googleMap) {
+ Location location = getArguments().getParcelable(ARG_LOCATION);
+ LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
+ googleMap.addMarker(new MarkerOptions().position(latLng).flat(true).draggable(false));
+ googleMap.getUiSettings().setMapToolbarEnabled(false);
+ googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15f));
+ }
+}
diff --git a/java/com/android/incallui/maps/impl/res/layout/static_map_fragment.xml b/java/com/android/incallui/maps/impl/res/layout/static_map_fragment.xml
new file mode 100644
index 000000000..54f41cb6e
--- /dev/null
+++ b/java/com/android/incallui/maps/impl/res/layout/static_map_fragment.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2016 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
+ -->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:map="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <fragment
+ android:id="@+id/static_map"
+ class="com.google.android.gms.maps.SupportMapFragment"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ map:liteMode="true"
+ map:mapType="normal"/>
+</FrameLayout>