Skip to content

Commit

Permalink
Added Google Maps v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Anna Ślimak committed Sep 9, 2020
1 parent 83c5156 commit ddb8428
Show file tree
Hide file tree
Showing 8 changed files with 241 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ local.properties
proguard_logs
*.apk
*.keystore
secure.properties
gen
gen-external-apklibs/
release/
Expand Down
6 changes: 4 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@
android:usesCleartextTraffic="true"
android:largeHeap="true">
<!-- Libraries -->
<uses-library android:name="com.google.android.maps"/>

<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/com.google.android.geo.API_KEY"/>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/maps_api_key" />

<!-- Activities -->
<activity android:label="@string/app_name" android:name=".screens.SplashActivity" android:noHistory="true" android:theme="@style/AirCastingTheme">
Expand Down Expand Up @@ -66,6 +67,7 @@
<activity android:label="@string/session_options" android:name=".screens.sessions.OpenFixedSessionActivity" android:theme="@style/Dialog"/>

<activity android:name=".screens.stream.map.AirCastingMapActivity" android:theme="@style/AirCastingTheme" android:launchMode="singleTask" android:screenOrientation="portrait"/>
<activity android:name=".screens.stream.map.AirCastingMapActivity2" android:theme="@style/AirCastingTheme" android:launchMode="singleTask" android:screenOrientation="portrait"/>

<activity android:name=".screens.about.AboutActivity" android:theme="@style/AirCastingTheme"/>

Expand Down
10 changes: 10 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ android {
targetSdkVersion 28
versionCode 106
versionName "1.5.19"

// Read the API key from ./secure.properties into R.string.maps_api_key
def secureProps = new Properties()
if (file("./secure.properties").exists()) {
file("./secure.properties")?.withInputStream { secureProps.load(it) }
}
resValue "string", "maps_api_key", (secureProps.getProperty("MAPS_API_KEY") ?: "")
}

buildTypes {
Expand Down Expand Up @@ -79,6 +86,9 @@ dependencies {
testImplementation group: 'com.pivotallabs', name: 'robolectric', version:'1.0'
testImplementation group: 'org.mockito', name: 'mockito-all', version:'1.9.5'
testImplementation group: 'org.easytesting', name: 'fest-assert', version:'1.4'

implementation 'com.google.android.libraries.maps:maps:3.1.0-beta'
implementation files('libs/maps-7_r1.jar')

implementation files('libs/MPAndroidChart-v3.0.2.jar')
}
2 changes: 1 addition & 1 deletion res/layout/heat_map.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@
android:background="#FCFAFD"
app:menu="@menu/aircasting"/>

</android.support.v4.widget.DrawerLayout>
</android.support.v4.widget.DrawerLayout>
85 changes: 85 additions & 0 deletions res/layout/heat_map2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
AirCasting - Share your Air!
Copyright (C) 2011-2012 HabitatMap, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact the authors by email at <[email protected]>
-->
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<!--main content-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
>

<include layout="@layout/toolbar"/>

<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/background_light"
>

<fragment xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map"
android:name="com.google.android.libraries.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:uiZoomControls="true"
map:uiZoomGestures="true" />

<include layout="@layout/gauges"/>

<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/buttons"
>

<Button android:id="@+id/locate"
android:layout_width="38dp"
android:layout_height="38dp"
android:background="@drawable/center_map_button"
android:layout_marginBottom="96dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="5dp"
/>

</RelativeLayout>
</RelativeLayout>


</LinearLayout>

<!--navigation drawer-->
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_height="match_parent"
android:layout_width="280dp"
android:layout_gravity="start"
android:background="#FCFAFD"
app:menu="@menu/aircasting"/>

</android.support.v4.widget.DrawerLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import pl.llp.aircasting.screens.common.base.DialogActivity;
import pl.llp.aircasting.screens.stream.graph.GraphActivity;
import pl.llp.aircasting.screens.stream.map.AirCastingMapActivity;
import pl.llp.aircasting.screens.stream.map.AirCastingMapActivity2;
import roboguice.inject.InjectView;

/**
Expand Down Expand Up @@ -38,7 +39,7 @@ public void onClick(View view) {
finish();
break;
case R.id.map_button:
startActivity(new Intent(context, AirCastingMapActivity.class));
startActivity(new Intent(context, AirCastingMapActivity2.class));
finish();
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,48 +22,52 @@
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.view.*;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Animation;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapController;
import com.google.android.maps.OverlayItem;
import com.google.android.maps.Projection;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Inject;

import java.util.List;

import pl.llp.aircasting.Intents;
import pl.llp.aircasting.R;
import pl.llp.aircasting.screens.common.helpers.LocationHelper;
import pl.llp.aircasting.screens.stream.base.AirCastingActivity;
import pl.llp.aircasting.event.session.VisibleSessionUpdatedEvent;
import pl.llp.aircasting.networking.drivers.AveragesDriver;
import pl.llp.aircasting.event.sensor.LocationEvent;
import pl.llp.aircasting.event.session.NoteCreatedEvent;
import pl.llp.aircasting.event.session.VisibleSessionUpdatedEvent;
import pl.llp.aircasting.event.ui.DoubleTapEvent;
import pl.llp.aircasting.event.ui.VisibleStreamUpdatedEvent;
import pl.llp.aircasting.screens.common.ToastHelper;
import pl.llp.aircasting.screens.common.sessionState.VisibleSession;
import pl.llp.aircasting.model.Measurement;
import pl.llp.aircasting.model.Note;
import pl.llp.aircasting.model.Sensor;
import pl.llp.aircasting.model.internal.Region;
import pl.llp.aircasting.networking.drivers.AveragesDriver;
import pl.llp.aircasting.networking.httpUtils.HttpResult;
import pl.llp.aircasting.screens.common.ToastHelper;
import pl.llp.aircasting.screens.common.helpers.LocationHelper;
import pl.llp.aircasting.screens.common.sessionState.VisibleSession;
import pl.llp.aircasting.screens.stream.MeasurementPresenter;

import android.location.Location;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.Toast;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.Projection;
import com.google.inject.Inject;

import pl.llp.aircasting.screens.stream.base.AirCastingActivity;
import roboguice.inject.InjectResource;
import roboguice.inject.InjectView;

import java.util.List;

import static java.lang.Math.min;
import static pl.llp.aircasting.screens.common.helpers.LocationHelper.REQUEST_CHECK_SETTINGS;
import static pl.llp.aircasting.screens.stream.map.LocationConversionHelper.boundingBox;
Expand Down Expand Up @@ -579,4 +583,4 @@ public void run() {
});
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/**
AirCasting - Share your Air!
Copyright (C) 2011-2012 HabitatMap, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact the authors by email at <[email protected]>
*/
package pl.llp.aircasting.screens.stream.map;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.*;
import android.view.animation.Animation;
import android.widget.Button;
import android.widget.ImageView;

import com.google.android.libraries.maps.CameraUpdateFactory;
import com.google.android.libraries.maps.GoogleMap;
import com.google.android.libraries.maps.OnMapReadyCallback;
import com.google.android.libraries.maps.SupportMapFragment;
import com.google.android.libraries.maps.model.LatLng;
import com.google.android.libraries.maps.model.MarkerOptions;
import com.google.android.maps.MapController;
import com.google.android.maps.OverlayItem;
import com.google.common.eventbus.Subscribe;
import pl.llp.aircasting.Intents;
import pl.llp.aircasting.R;
import pl.llp.aircasting.screens.common.base.RoboActivityWithProgress;
import pl.llp.aircasting.screens.common.helpers.LocationHelper;
import pl.llp.aircasting.screens.stream.base.AirCastingActivity;
import pl.llp.aircasting.event.session.VisibleSessionUpdatedEvent;
import pl.llp.aircasting.networking.drivers.AveragesDriver;
import pl.llp.aircasting.event.sensor.LocationEvent;
import pl.llp.aircasting.event.session.NoteCreatedEvent;
import pl.llp.aircasting.event.ui.DoubleTapEvent;
import pl.llp.aircasting.event.ui.VisibleStreamUpdatedEvent;
import pl.llp.aircasting.screens.common.ToastHelper;
import pl.llp.aircasting.screens.common.sessionState.VisibleSession;
import pl.llp.aircasting.model.Measurement;
import pl.llp.aircasting.model.Note;
import pl.llp.aircasting.model.Sensor;
import pl.llp.aircasting.model.internal.Region;
import pl.llp.aircasting.networking.httpUtils.HttpResult;
import pl.llp.aircasting.screens.stream.MeasurementPresenter;

import android.location.Location;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.Toast;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.Projection;
import com.google.inject.Inject;

import roboguice.inject.InjectResource;
import roboguice.inject.InjectView;

import java.util.List;

import static java.lang.Math.min;
import static pl.llp.aircasting.screens.common.helpers.LocationHelper.REQUEST_CHECK_SETTINGS;
import static pl.llp.aircasting.screens.stream.map.LocationConversionHelper.boundingBox;
import static pl.llp.aircasting.screens.stream.map.LocationConversionHelper.geoPoint;
import static pl.llp.aircasting.screens.stream.map.MapIdleDetector.detectMapIdle;

/**
* Created by IntelliJ IDEA.
* User: obrok
* Date: 10/17/11
* Time: 5:04 PM
*/
public class AirCastingMapActivity2 extends AppCompatActivity implements OnMapReadyCallback {
private GoogleMap mMap;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.heat_map2);

SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}

@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;

// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions()
.position(sydney)
.title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}

0 comments on commit ddb8428

Please sign in to comment.