Skip to content

Commit

Permalink
Merge pull request #299 from enviroCar/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
dewall committed Jun 3, 2016
2 parents ea73483 + 9bea6bd commit d32f12e
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 86 deletions.
9 changes: 4 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {

dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.2.3'
classpath 'com.android.tools.build:gradle:2.0.0-beta6'
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7+'
classpath "gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.12.1"
}
Expand All @@ -31,18 +31,17 @@ allprojects {
maven { url "https://jitpack.io" }
mavenCentral()
jcenter()

}
}

ext {
androidPlugin = 'com.android.tools.build:gradle:2.0.0-beta6'
androidPlugin = 'com.android.tools.build:gradle:2.1.0'
minSdkVersion = 16
compileSdkVersion = 23
targetSdkVersion = 23
buildToolsVersion = '23.0.2'
versionCode = 29
versionName = "0.22.0"
versionCode = 30
versionName = "0.22.1"

javaCompileVersion = JavaVersion.VERSION_1_8

Expand Down
12 changes: 12 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Tue Jan 26 12:51:21 CET 2016
sdk.dir=/home/matthes/opt/android/sdk
org.gradle.jvmargs=-Xmx2048M
4 changes: 2 additions & 2 deletions org.envirocar.app/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
package="org.envirocar.app"
android:installLocation="internalOnly"
android:versionCode="29"
android:versionName="0.22.0">
android:versionCode="30"
android:versionName="0.22.1">

<uses-sdk
android:minSdkVersion="16"
Expand Down
1 change: 1 addition & 0 deletions org.envirocar.app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ android {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
zipAlignEnabled true
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,15 @@ public void onCreate() {
mTTS = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
mIsTTSAvailable = true;
mTTS.setLanguage(Locale.ENGLISH);
} else {
LOG.warn("TextToSpeech is not available.");
try {
if (status == TextToSpeech.SUCCESS) {
mTTS.setLanguage(Locale.ENGLISH);
mIsTTSAvailable = true;
} else {
LOG.warn("TextToSpeech is not available.");
}
} catch(IllegalArgumentException e){
LOG.warn("TextToSpeech is not available");
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ public static String carToStringWithLinebreak(Car car){
* @return true if the car has been uploaded.
*/
public static boolean isCarUploaded(Car car) {
return !car.getId().startsWith(Car.TEMPORARY_SENSOR_ID);
if(car.getId() != null) {
return !car.getId().startsWith(Car.TEMPORARY_SENSOR_ID);
}
return false;
}

}
1 change: 1 addition & 0 deletions org.envirocar.storage/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ dependencies {

testCompile 'junit:junit:4.12'
compile project(':org.envirocar.core')
androidTestCompile 'junit:junit:4.12'
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Copyright (C) 2013 - 2015 the enviroCar community
*
* This file is part of the enviroCar app.
*
* The enviroCar app 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.
*
* The enviroCar app 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 the enviroCar app. If not, see http://www.gnu.org/licenses/.
*/
package org.envirocar.storage;

import android.content.ContentValues;
import android.test.InstrumentationTestCase;

import org.envirocar.core.entity.Measurement;
import org.envirocar.core.entity.MeasurementImpl;
import org.envirocar.core.entity.Track;
import org.hamcrest.CoreMatchers;
import org.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;

/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class MeasurementTableTest extends InstrumentationTestCase {

@Test
public void testInfinityValuePassing() throws Exception {
MeasurementImpl m = new MeasurementImpl();
m.setTrackId(new Track.TrackId(1));
m.setProperty(Measurement.PropertyKey.CALCULATED_MAF, Double.POSITIVE_INFINITY);
m.setProperty(Measurement.PropertyKey.CO2, Double.POSITIVE_INFINITY);
m.setProperty(Measurement.PropertyKey.SPEED, Double.MAX_VALUE);
m.setProperty(Measurement.PropertyKey.CONSUMPTION, 1.1);
ContentValues vals = MeasurementTable.toContentValues(m);

Object props = vals.get(MeasurementTable.KEY_PROPERTIES);

JSONObject obj = new JSONObject(props.toString());

Assert.assertThat(obj.get(Measurement.PropertyKey.CONSUMPTION.name()), CoreMatchers.is(1.1));
Assert.assertThat(obj.get(Measurement.PropertyKey.SPEED.name()), CoreMatchers.is(Double.MAX_VALUE));
Assert.assertThat(obj.has(Measurement.PropertyKey.CALCULATED_MAF.name()), CoreMatchers.is(false));
Assert.assertThat(obj.has(Measurement.PropertyKey.CO2.name()), CoreMatchers.is(false));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,19 @@ public static ContentValues toContentValues(Measurement measurement) throws
values.put(KEY_LONGITUDE, measurement.getLongitude());
values.put(KEY_TIME, measurement.getTime());
values.put(KEY_TRACK, measurement.getTrackId().getId());

try {
values.put(KEY_PROPERTIES, createPropertiesString(measurement));
} catch (JSONException e) {
LOG.error("Error while parsing measurement properties.", e);
throw new MeasurementSerializationException(e);
}
values.put(KEY_PROPERTIES, createPropertiesString(measurement));
return values;
}

private static String createPropertiesString(Measurement measurement) throws JSONException {
private static String createPropertiesString(Measurement measurement) {
JSONObject result = new JSONObject();
Map<Measurement.PropertyKey, Double> properties = measurement.getAllProperties();
for (Measurement.PropertyKey key : properties.keySet()) {
result.put(key.name(), properties.get(key));
try {
result.put(key.name(), properties.get(key));
} catch (JSONException e) {
LOG.warn("Error while parsing measurement property "+key.name() +"="+properties.get(key) + "; "+e.getMessage());
}
}
return result.toString();
}
Expand Down

This file was deleted.

0 comments on commit d32f12e

Please sign in to comment.