diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index fd03c4a4..f6672b76 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -67,7 +67,6 @@
-
diff --git a/res/layout/heat_map2.xml b/res/layout/heat_map2.xml
deleted file mode 100644
index 24d28527..00000000
--- a/res/layout/heat_map2.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/res/layout/map.xml b/res/layout/map.xml
index d1e19881..98124bb6 100644
--- a/res/layout/map.xml
+++ b/res/layout/map.xml
@@ -20,11 +20,13 @@
-
.
-
- You can contact the authors by email at
- */
-package pl.llp.aircasting.screens.stream.base;
-
-import android.app.Dialog;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Handler;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.View;
-import android.widget.Toast;
-
-import com.google.common.eventbus.Subscribe;
-import com.google.inject.Inject;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import pl.llp.aircasting.Intents;
-import pl.llp.aircasting.R;
-import pl.llp.aircasting.event.measurements.MobileMeasurementEvent;
-import pl.llp.aircasting.event.sensor.AudioReaderErrorEvent;
-import pl.llp.aircasting.event.sensor.FixedSensorEvent;
-import pl.llp.aircasting.event.sensor.SensorConnectedEvent;
-import pl.llp.aircasting.event.sensor.SensorEvent;
-import pl.llp.aircasting.event.sensor.ThresholdSetEvent;
-import pl.llp.aircasting.event.session.VisibleSessionUpdatedEvent;
-import pl.llp.aircasting.event.ui.VisibleStreamUpdatedEvent;
-import pl.llp.aircasting.model.Note;
-import pl.llp.aircasting.screens.common.ToastHelper;
-import pl.llp.aircasting.screens.common.helpers.PhotoHelper;
-import pl.llp.aircasting.screens.common.helpers.ResourceHelper;
-import pl.llp.aircasting.screens.common.helpers.SelectSensorHelper;
-import pl.llp.aircasting.screens.common.sessionState.SessionDataAccessor;
-import pl.llp.aircasting.screens.common.sessionState.VisibleSession;
-import pl.llp.aircasting.screens.stream.GaugeHelper;
-import pl.llp.aircasting.screens.stream.NoteViewerActivity;
-import pl.llp.aircasting.screens.stream.TopBarHelper;
-import roboguice.inject.InjectView;
-
-public abstract class AirCastingActivityForMap extends AirCastingBaseActivityForMap implements View.OnClickListener {
- public static final String NOTE_INDEX = "noteIndex";
- public static final String VISIBLE_SESSION_ID = "visibleSessionId";
- public static final String VISIBLE_SENSOR_ID = "visibleSensorId";
-
- protected GaugeHelper mGaugeHelper;
- protected View mGauges;
-
- @InjectView(R.id.top_bar) View topBar;
-
- @Inject public VisibleSession visibleSession;
- @Inject public ResourceHelper resourceHelper;
-
- @Inject SelectSensorHelper selectSensorHelper;
- @Inject TopBarHelper topBarHelper;
- @Inject PhotoHelper photoHelper;
- @Inject
- SessionDataAccessor sessionData;
-
- private boolean initialized = false;
- Note currentNote;
-
- final AtomicBoolean noUpdateInProgress = new AtomicBoolean(true);
-
- private Handler handler = new Handler();
-
- private Thread pollServerTask = new Thread(new Runnable() {
- @Override
- public void run() {
- Intents.triggerStreamingSessionsSync(context);
-
- handler.postDelayed(pollServerTask, 60000);
- }
- });
-
- @Override
- protected void onResume() {
- super.onResume();
-
- initialize();
-
- startUpdatingFixedSessions();
-
- updateGauges();
- updateKeepScreenOn();
- topBarHelper.updateTopBar(visibleSession.getSensor(), topBar);
- Intents.startIOIO(context);
- Intents.startDatabaseWriterService(context);
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- handler.removeCallbacks(pollServerTask);
- }
-
- private void initialize() {
- if (!initialized) {
- mGauges = findViewById(R.id.gauge_container);
-
- if (mGaugeHelper == null) {
- mGaugeHelper = new GaugeHelper(this, mGauges, resourceHelper, visibleSession, sessionData);
- }
-
- zoomOut.setOnClickListener(this);
- zoomIn.setOnClickListener(this);
- topBar.setOnClickListener(this);
-
- mGauges.setOnClickListener(this);
-
- initialized = true;
- }
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
-
- outState.putInt(VISIBLE_SESSION_ID, (int) visibleSession.getVisibleSessionId());
- outState.putString(VISIBLE_SENSOR_ID, visibleSession.getSensor().getSensorName());
- }
-
- @Override
- protected void onRestoreInstanceState(Bundle savedInstanceState) {
- super.onRestoreInstanceState(savedInstanceState);
-
- int visibleSessionId = savedInstanceState.getInt(VISIBLE_SESSION_ID);
- String visibleSensorName = savedInstanceState.getString(VISIBLE_SENSOR_ID);
-
- sessionData.setVisibleSession(visibleSessionId);
- sessionData.setVisibleSensorFromName(visibleSessionId, visibleSensorName);
- }
-
- private void startUpdatingFixedSessions() {
- if (viewingSessionsManager.isAnySessionFixed()) {
- handler.post(pollServerTask);
- }
- }
-
- private void updateKeepScreenOn() {
- if (settingsHelper.isKeepScreenOn()) {
- getWindow().addFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- } else {
- getWindow().clearFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- }
- }
-
- protected void updateGauges() {
- if (noUpdateInProgress.get()) {
- noUpdateInProgress.set(false);
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- mGaugeHelper.updateGaugesFromSensor();
- noUpdateInProgress.set(true);
- }
- });
- }
- }
-
- @Subscribe
- public void onEvent(MobileMeasurementEvent event) {
- updateGauges();
- }
-
- @Subscribe
- public void onEvent(VisibleSessionUpdatedEvent event) {
- updateGauges();
- }
-
- @Subscribe
- public void onEvent(SensorEvent event) {
- updateGauges();
- }
-
- @Subscribe
- public void onEvent(FixedSensorEvent event) {
- updateGauges();
- }
-
- @Subscribe
- public void onEvent(ThresholdSetEvent event)
- {
- updateGauges();
- }
-
- @Subscribe
- public void onEvent(SensorConnectedEvent event) {
- invalidateOptionsMenu();
- }
-
- @Subscribe
- public void onEvent(AudioReaderErrorEvent event) {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- ToastHelper.show(context, R.string.mic_error, Toast.LENGTH_LONG);
- }
- });
- }
-
- @Subscribe
- public void onEvent(VisibleStreamUpdatedEvent event) {
- topBarHelper.updateTopBar(event.getSensor(), topBar);
- updateGauges();
- }
-
- @Override
- public boolean onPrepareOptionsMenu(Menu menu) {
- super.onPrepareOptionsMenu(menu);
-
- MenuInflater inflater = getDelegate().getMenuInflater();
-
- if (currentSessionManager.isSessionIdle()) {
- inflater.inflate(R.menu.toolbar_start_recording, menu);
- } else if (currentSessionManager.isSessionRecording()){
- inflater.inflate(R.menu.toolbar_stop_recording, menu);
- inflater.inflate(R.menu.toolbar_make_note, menu);
- } else {
- return true;
- }
-
- return true;
- }
-
- @Override
- public void onClick(View view) {
- switch (view.getId()) {
- case R.id.top_bar:
- Intents.thresholdsEditor(this, visibleSession.getSensor());
- break;
- case R.id.gauge_container:
- showDialog(SelectSensorHelper.DIALOG_ID);
- break;
- default:
- break;
- }
- }
-
- @Override
- protected Dialog onCreateDialog(int id) {
- switch(id){
- case SelectSensorHelper.DIALOG_ID: return selectSensorHelper.chooseSensor(this);
- default: return super.onCreateDialog(id);
- }
- }
-
- public void noteClicked(int index) {
- showNoteViewer(index);
- }
-
- private void showNoteViewer(int index) {
- Intent intent = new Intent(this, NoteViewerActivity.class);
- intent.putExtra(NOTE_INDEX, index);
- startActivity(intent);
- }
-
- protected abstract void refreshNotes();
-}
diff --git a/src/main/java/pl/llp/aircasting/screens/stream/base/AirCastingBaseActivityForMap.java b/src/main/java/pl/llp/aircasting/screens/stream/base/AirCastingBaseActivityForMap.java
deleted file mode 100644
index 9cd8829e..00000000
--- a/src/main/java/pl/llp/aircasting/screens/stream/base/AirCastingBaseActivityForMap.java
+++ /dev/null
@@ -1,187 +0,0 @@
-package pl.llp.aircasting.screens.stream.base;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.AsyncTask;
-import android.view.View;
-import android.widget.Button;
-import android.widget.Toast;
-
-import com.google.common.eventbus.EventBus;
-import com.google.inject.Inject;
-import com.google.inject.internal.Nullable;
-
-import java.util.concurrent.TimeUnit;
-
-import pl.llp.aircasting.Intents;
-import pl.llp.aircasting.R;
-import pl.llp.aircasting.model.Session;
-import pl.llp.aircasting.screens.common.ApplicationState;
-import pl.llp.aircasting.screens.common.ToastHelper;
-import pl.llp.aircasting.screens.common.ToggleAircastingManager;
-import pl.llp.aircasting.screens.common.ToggleAircastingManagerFactory;
-import pl.llp.aircasting.screens.common.base.RoboMapActivityWithProgress;
-import pl.llp.aircasting.screens.common.helpers.LocationHelper;
-import pl.llp.aircasting.screens.common.helpers.SettingsHelper;
-import pl.llp.aircasting.screens.common.sessionState.CurrentSessionManager;
-import pl.llp.aircasting.screens.common.sessionState.ViewingSessionsManager;
-import pl.llp.aircasting.screens.dashboard.DashboardActivity;
-import pl.llp.aircasting.screens.stream.MeasurementPresenter;
-import pl.llp.aircasting.sessionSync.SyncBroadcastReceiver;
-import pl.llp.aircasting.storage.UnfinishedSessionChecker;
-import roboguice.inject.InjectView;
-
-import static pl.llp.aircasting.Intents.startSensors;
-import static pl.llp.aircasting.screens.common.helpers.LocationHelper.REQUEST_CHECK_SETTINGS;
-
-/**
- * A common superclass for activities that want to display left/right
- * navigation arrows
- */
-
-public abstract class AirCastingBaseActivityForMap extends RoboMapActivityWithProgress implements View.OnClickListener, LocationHelper.LocationSettingsListener {
- public static final long DELTA = TimeUnit.SECONDS.toMillis(15);
-
- @Inject public Context context;
- @Inject public LocationHelper locationHelper;
- @Inject public SettingsHelper settingsHelper;
- @Inject public CurrentSessionManager currentSessionManager;
- @Inject public MeasurementPresenter measurementPresenter;
-
- @Inject UnfinishedSessionChecker checker;
- @Inject ApplicationState state;
- @Inject ViewingSessionsManager viewingSessionsManager;
- @Inject EventBus eventBus;
- @Inject ToggleAircastingManagerFactory aircastingHelperFactory;
-
- @Inject
- SyncBroadcastReceiver syncBroadcastReceiver;
- SyncBroadcastReceiver registeredReceiver;
-
- @Nullable
- @InjectView(R.id.zoom_in) public Button zoomIn;
-
- @Nullable
- @InjectView(R.id.zoom_out) public Button zoomOut;
-
- private ToggleAircastingManager toggleAircastingManager;
- private boolean initialized = false;
- private long lastChecked = 0;
-
- @Override
- protected void onResume() {
- super.onResume();
-
- initialize();
-
- registerReceiver(syncBroadcastReceiver, SyncBroadcastReceiver.INTENT_FILTER);
- registeredReceiver = syncBroadcastReceiver;
-
- eventBus.register(this);
- checkForUnfinishedSessions();
-
- if (viewingSessionsManager.anySessionPresent() || currentSessionManager.anySensorConnected()) {
- startSensors(context);
- }
- }
-
- @Override
- protected void onPause() {
- super.onPause();
-
- if (viewingSessionsManager.sessionsEmpty() && !currentSessionManager.isSessionRecording()) {
- Intents.stopSensors(this);
- }
-
-// if (!currentSessionManager.isSessionRecording()) {
-// locationHelper.stopLocationUpdates();
-// }
-
- if (registeredReceiver != null) {
- unregisterReceiver(syncBroadcastReceiver);
- registeredReceiver = null;
- }
- eventBus.unregister(this);
- }
-
- @Override
- protected boolean isRouteDisplayed() {
- // The maps server needs to know if we are displaying any routes
- return false;
- }
-
- private void initialize() {
- toggleAircastingManager = aircastingHelperFactory.getAircastingHelper(this, getDelegate());
-
- if (!initialized) {
- initialized = true;
- }
- }
-
- @Override
- public void onProfileClick(View view) {
- super.onProfileClick(view);
- }
-
- public synchronized void toggleAirCasting() {
- toggleAircastingManager.toggleAirCasting();
- getDelegate().invalidateOptionsMenu();
-
- measurementPresenter.reset();
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- switch (requestCode) {
- case Intents.SAVE_DIALOG:
- startActivity(new Intent(getApplicationContext(), DashboardActivity.class));
- break;
- case Intents.EDIT_SESSION:
- if (resultCode == R.id.save_button) {
- Session session = Intents.editSessionResult(data);
- currentSessionManager.updateSession(session);
- }
- break;
- case REQUEST_CHECK_SETTINGS:
- if (resultCode != RESULT_OK) {
- ToastHelper.showText(this, "You need to enable location settings to record an AirCasting session", Toast.LENGTH_LONG);
- } else {
- locationHelper.startLocationUpdates();
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- }
- onLocationSettingsSatisfied();
- }
- break;
- default:
- super.onActivityResult(requestCode, resultCode, data);
- }
- }
-
- private void checkForUnfinishedSessions() {
- if (shouldCheckForUnfinishedSessions()) {
- new AsyncTask() {
- @Override
- protected Void doInBackground(Void... voids) {
- checker.finishIfNeeded(AirCastingBaseActivityForMap.this);
- lastChecked = System.currentTimeMillis();
- return null;
- }
- }.execute();
- }
- }
-
- private boolean shouldCheckForUnfinishedSessions() {
- if (currentSessionManager.isSessionRecording()) {
- return false;
- }
-
- if (state.saving().isSaving()) {
- return false;
- }
-
- long timeout = System.currentTimeMillis() - lastChecked;
- return timeout > DELTA;
- }
-}
diff --git a/src/main/java/pl/llp/aircasting/screens/stream/map/AirCastingMapActivity.java b/src/main/java/pl/llp/aircasting/screens/stream/map/AirCastingMapActivity.java
index daf0b52d..727507fa 100644
--- a/src/main/java/pl/llp/aircasting/screens/stream/map/AirCastingMapActivity.java
+++ b/src/main/java/pl/llp/aircasting/screens/stream/map/AirCastingMapActivity.java
@@ -38,6 +38,12 @@
import android.widget.ImageView;
import android.widget.Toast;
+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.GeoPoint;
import com.google.android.maps.MapController;
import com.google.android.maps.OverlayItem;
@@ -65,7 +71,6 @@
import pl.llp.aircasting.screens.common.sessionState.VisibleSession;
import pl.llp.aircasting.screens.stream.MeasurementPresenter;
import pl.llp.aircasting.screens.stream.base.AirCastingActivity;
-import pl.llp.aircasting.screens.stream.base.AirCastingActivityForMap;
import roboguice.inject.InjectResource;
import roboguice.inject.InjectView;
@@ -81,12 +86,10 @@
* Date: 10/17/11
* Time: 5:04 PM
*/
-public class AirCastingMapActivity extends AirCastingActivityForMap implements MapIdleDetector.MapIdleListener, MeasurementPresenter.Listener, LocationHelper.LocationSettingsListener {
+public class AirCastingMapActivity extends AirCastingActivity implements MapIdleDetector.MapIdleListener, MeasurementPresenter.Listener, LocationHelper.LocationSettingsListener, OnMapReadyCallback {
private static final String HEAT_MAP_VISIBLE = "heat_map_visible";
- @InjectView(R.id.mapview)
- AirCastingMapView mapView;
@InjectView(R.id.spinner) ImageView spinner;
@InjectView(R.id.locate) Button centerMap;
@InjectResource(R.anim.spinner) Animation spinnerAnimation;
@@ -105,6 +108,7 @@ public class AirCastingMapActivity extends AirCastingActivityForMap implements M
private static final int ACTION_TOGGLE = 1;
private static final int ACTION_CENTER = 2;
+ private GoogleMap map;
private boolean soundTraceComplete = true;
private boolean heatMapVisible = false;
private int requestsOutstanding = 0;
@@ -129,6 +133,10 @@ protected void onCreate(Bundle savedInstanceState) {
initNavigationDrawer();
centerMap.setOnClickListener(this);
+ SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
+ .findFragmentById(R.id.mapview);
+ mapFragment.getMapAsync(this);
+
mapView.getOverlays().add(routeOverlay);
mapView.getOverlays().add(traceOverlay);
@@ -137,6 +145,18 @@ protected void onCreate(Bundle savedInstanceState) {
}
}
+ @Override
+ public void onMapReady(GoogleMap googleMap) {
+ map = googleMap;
+
+ // Add a marker in Sydney and move the camera
+ LatLng sydney = new LatLng(-34, 151);
+ map.addMarker(new MarkerOptions()
+ .position(sydney)
+ .title("Marker in Sydney"));
+ map.moveCamera(CameraUpdateFactory.newLatLng(sydney));
+ }
+
@Override
public void onPostResume() {
super.onPostResume();
diff --git a/src/main/java/pl/llp/aircasting/screens/stream/map/AirCastingMapActivity2.java b/src/main/java/pl/llp/aircasting/screens/stream/map/AirCastingMapActivity2.java
deleted file mode 100644
index e2cd2feb..00000000
--- a/src/main/java/pl/llp/aircasting/screens/stream/map/AirCastingMapActivity2.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- 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 .
-
- You can contact the authors by email at
-*/
-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));
- }
-}