Skip to content

Commit

Permalink
bugfix, version 1.5.19
Browse files Browse the repository at this point in the history
  • Loading branch information
sztyler committed Dec 7, 2016
1 parent 46a3ae3 commit 505bec9
Show file tree
Hide file tree
Showing 43 changed files with 440 additions and 224 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.android.tools.build:gradle:2.2.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
19 changes: 9 additions & 10 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
compileSdkVersion 24
buildToolsVersion "23.0.3"

defaultConfig {
applicationId "de.unima.ar.collector"
minSdkVersion 16
targetSdkVersion 23
versionCode 19
versionName "1.5.17"
multiDexEnabled true
targetSdkVersion 24
versionCode 20
versionName "1.5.19"
}
buildTypes {
release {
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.google.android.gms:play-services:8.3.0'
//compile 'com.android.support:appcompat-v7:24.1.1'
//compile 'com.android.support:support-v4:24.1.1'
compile 'com.google.android.gms:play-services:9.2.1'
compile 'com.google.guava:guava:18.0'
wearApp project(':wear')
compile project(':shared')
Expand Down
3 changes: 3 additions & 0 deletions mobile/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

-dontwarn javax.annotation.**
-dontwarn sun.misc.Unsafe
10 changes: 4 additions & 6 deletions mobile/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
android:name="de.unima.ar.collector.ui.SettingActivity"
android:label="@string/prefTitle"
android:screenOrientation="nosensor">
<intent-filer>
<action android:name=".Preferences"/>
<category android:name="android.intent.cetagory.PREFERENCE"/>
</intent-filer>
</activity>

<service
Expand All @@ -58,9 +54,11 @@
<action android:name="de.unima.ar.collector.service"/>
</intent-filter>
</service>
<service android:name=".api.ListenerService">
<service android:name=".api.ListenerService" android:exported="true">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER"/>
<action android:name="com.google.android.gms.wearable.MESSAGE_RECEIVED" />
<action android:name="com.google.android.gms.wearable.DATA_CHANGED" />
<data android:scheme="wear" android:host="*" />
</intent-filter>
</service>

Expand Down
101 changes: 26 additions & 75 deletions mobile/src/main/java/de/unima/ar/collector/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,12 @@
import com.androidplot.xy.XYStepMode;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand All @@ -87,11 +78,13 @@
import de.unima.ar.collector.shared.Settings;
import de.unima.ar.collector.shared.database.SQLTableName;
import de.unima.ar.collector.shared.util.DeviceID;
import de.unima.ar.collector.shared.util.Utils;
import de.unima.ar.collector.ui.ActivityListRowAdapter;
import de.unima.ar.collector.ui.ActivityOnItemClickListener;
import de.unima.ar.collector.ui.AnalyzeRowAdapter;
import de.unima.ar.collector.ui.CorrectionHistoryAdapter;
import de.unima.ar.collector.ui.DataPlotZoomListener;
import de.unima.ar.collector.ui.DrawPointsMap;
import de.unima.ar.collector.ui.OverviewRowAdapter;
import de.unima.ar.collector.ui.SensorenRowAdapter;
import de.unima.ar.collector.ui.SeparatedListAdapter;
Expand Down Expand Up @@ -122,9 +115,7 @@ private class ScreenInfo

private final static ArrayList<ScreenInfo> lastScreens = new ArrayList<>();

private View GPSView;
private ArrayList<Marker> positionMarkers;
private Polyline polyline;
private View GPSView;

private SensorSelfTest lastSensorSelfTest = null;

Expand Down Expand Up @@ -331,7 +322,6 @@ public void showAnalyzeDatabase()
final Map<String, PlotConfiguration> showConfigs = new HashMap<>();
StringBuilder query = new StringBuilder();
for(PlotConfiguration configuration : configurations) {
// TODO My result in a crash after a update if a new table is
query.append("SELECT * FROM (SELECT '").append(configuration.sensorName).append("' AS Name, '").append(configuration.deviceID).append("' AS Device, id AS Count FROM ").append(SQLTableName.PREFIX).append(configuration.deviceID).append(configuration.tableName).append(" ORDER BY id DESC LIMIT 1) UNION ");
showConfigs.put(configuration.sensorName + configuration.deviceID, configuration);
}
Expand Down Expand Up @@ -418,49 +408,11 @@ public void showAnalyzeDatabaseGPS(String start, String end)
GPSView = this.getLayoutInflater().inflate(R.layout.googlemaplayout, null);
}

if(polyline != null) {
polyline.remove();

polyline = null;
}

if(positionMarkers != null) {
for(int i = 0; i < positionMarkers.size(); i++) {
positionMarkers.get(i).remove();
}

positionMarkers = null;
}

setContentView(GPSView);

DrawPointsMap dpm = new DrawPointsMap(this, start, end);
final SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

GoogleMap map = mapFragment.getMap();

positionMarkers = new ArrayList<>();

PolylineOptions polyOptions = new PolylineOptions();

List<String[]> result = SQLDBController.getInstance().query("SELECT attr_time, attr_lat, attr_lng FROM " + SQLTableName.PREFIX + DeviceID.get(MainActivity.this) + SQLTableName.GPS + " WHERE attr_time > ? AND attr_time < ?", new String[]{ String.valueOf(start), String.valueOf(end) }, false);

LatLng pos = null;

for(String[] row : result) {
pos = new LatLng(Float.valueOf(row[1]), Float.valueOf(row[2]));
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");

polyOptions.add(pos);

positionMarkers.add(map.addMarker(new MarkerOptions().title(sdf.format(new Date(Long.valueOf(row[0])))).position(pos)));
}

if(pos == null) {
return;
}

polyline = map.addPolyline(polyOptions);
map.moveCamera(CameraUpdateFactory.newLatLngZoom(pos, 15));
mapFragment.getMapAsync(dpm);
}


Expand Down Expand Up @@ -894,20 +846,6 @@ public void showGPSAnalyze()
GPSView = this.getLayoutInflater().inflate(R.layout.googlemaplayout, null);
}

if(polyline != null) {
polyline.remove();

polyline = null;
}

if(positionMarkers != null) {
for(int i = 0; i < positionMarkers.size(); i++) {
positionMarkers.get(i).remove();
}

positionMarkers = null;
}

setContentView(GPSView);

final SupportMapFragment map = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
Expand All @@ -916,7 +854,7 @@ public void showGPSAnalyze()

for(CustomCollector cc : ccs) {
if(SensorDataUtil.getSensorType(cc.getType()).equals("TYPE_GPS")) {
((GPSCollector) cc).setMap(map.getMap());
map.getMapAsync((GPSCollector) cc);
break;
}
}
Expand Down Expand Up @@ -948,7 +886,7 @@ public void showAnalyze()
for(String device : devices) {
if(enabledSensor > 0) {
SensorCollector sc = SensorDataCollectorService.getInstance().getSCM().getSensorCollectors().get(enabledSensor);
if(sc.isRegistered && sc.getPlotter(device) != null) {
if(sc.isRegistered) {
activeSensors.add(new Triple<>(StringUtils.formatSensorName(name), getString(R.string.analyze_analyzelive_collecting), device));
}
} else {
Expand Down Expand Up @@ -1031,10 +969,12 @@ public void showAnalyzeLive(String deviceID, int sensorId)
addScreen(Screens.ANALYZE_LIVE, new Object[]{ deviceID, sensorId, plotter });
plotter.startPlotting(sensorLevelsPlot, sensorHistoryPlot);

if(de.unima.ar.collector.shared.Settings.LIVE_PLOTTER_ENABLED) {
if(de.unima.ar.collector.shared.Settings.LIVE_PLOTTER_ENABLED && (de.unima.ar.collector.shared.Settings.WEARTRANSFERDIRECT || DeviceID.get(this).equals(deviceID))) {
plotter.setPlotting(true);
} else {
} else if(!de.unima.ar.collector.shared.Settings.LIVE_PLOTTER_ENABLED) {
Toast.makeText(this, R.string.analyze_analyzelive_disabled, Toast.LENGTH_SHORT).show();
} else if(!de.unima.ar.collector.shared.Settings.WEARTRANSFERDIRECT) {
Toast.makeText(this, R.string.analyze_analyzelive_wearcache, Toast.LENGTH_SHORT).show();
}
} else {
Collection<CustomCollector> sensors = SensorDataCollectorService.getInstance().getSCM().getCustomCollectors().values();
Expand All @@ -1052,10 +992,12 @@ public void showAnalyzeLive(String deviceID, int sensorId)
addScreen(Screens.ANALYZE_LIVE, new Object[]{ deviceID, sensorId, plotter });
plotter.startPlotting(sensorLevelsPlot, sensorHistoryPlot);

if(de.unima.ar.collector.shared.Settings.LIVE_PLOTTER_ENABLED) {
if(de.unima.ar.collector.shared.Settings.LIVE_PLOTTER_ENABLED && (de.unima.ar.collector.shared.Settings.WEARTRANSFERDIRECT || DeviceID.get(this).equals(deviceID))) {
plotter.setPlotting(true);
} else {
} else if(!de.unima.ar.collector.shared.Settings.LIVE_PLOTTER_ENABLED) {
Toast.makeText(this, R.string.analyze_analyzelive_disabled, Toast.LENGTH_SHORT).show();
} else if(!de.unima.ar.collector.shared.Settings.WEARTRANSFERDIRECT) {
Toast.makeText(this, R.string.analyze_analyzelive_wearcache, Toast.LENGTH_SHORT).show();
}
break;
} else if(cc.isRegistered() && cc.getType() == sensorId) {
Expand Down Expand Up @@ -1220,7 +1162,7 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
}
} else {
String sensorName = txt2.getText().toString();
int sensorID = SensorDataUtil.getSensorTypeInt("TYPE_" + txt1.getText().toString().toUpperCase(Locale.ENGLISH).replace(" ", "_"));
final int sensorID = SensorDataUtil.getSensorTypeInt("TYPE_" + txt1.getText().toString().toUpperCase(Locale.ENGLISH).replace(" ", "_"));
SensorCollector sc = service.getSCM().getSensorCollectors().get(sensorID);
// Fall 1: Sensor läuft bereits dann removen wir ihn
if(chBx.isChecked()) {
Expand All @@ -1230,7 +1172,16 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
BroadcastService.getInstance().sendMessage("/sensor/unregister", String.valueOf(sensorID));
DBUtils.updateSensorStatus(sensorID, (1000 * 1000) / sc.getSensorRate(), 0); // microseconds -> hertz
chBx.setChecked(false);
SensorDataUtil.flushSensorDataCache(sensorID, DeviceID.get(MainActivity.this));

new Thread(new Runnable()
{
@Override
public void run()
{
Utils.makeToast2(MainActivity.this, R.string.sensor_cache_to_database, Toast.LENGTH_LONG);
SensorDataUtil.flushSensorDataCache(sensorID, null);
}
}).start();
}
} else {
if(!service.getSCM().enableCollectors(sensorID)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.util.Log;

import com.google.android.gms.common.ConnectionResult;
Expand Down Expand Up @@ -88,7 +89,7 @@ public void onConnectionSuspended(int cause)


@Override
public void onConnectionFailed(ConnectionResult connectionResult)
public void onConnectionFailed(@NonNull ConnectionResult connectionResult)
{
Log.d(LOG_TAG, "Failed!");
}
Expand Down
Loading

0 comments on commit 505bec9

Please sign in to comment.