diff --git a/app/build.gradle b/app/build.gradle
index b8b8d60..8ef8625 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -12,7 +12,7 @@ android {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
moduleName "sensor-logger"
- abiFilters 'armeabi-v7a', 'arm64-v8a'
+ abiFilters 'armeabi-v7a'//, 'arm64-v8a'
}
}
buildTypes {
diff --git a/app/src/main/assets/defaults.properties b/app/src/main/assets/defaults.properties
index d2c66a5..6226ad2 100644
--- a/app/src/main/assets/defaults.properties
+++ b/app/src/main/assets/defaults.properties
@@ -53,8 +53,8 @@ pref_ftp_user =user
pref_ftp_pw =francesco
pref_ftp_address =192.168.1.1
-# transferring by streaming (0=nothing, 1=images)
-pref_streaming =0
+# transferring by streaming
+pref_streaming =false
pref_streaming_port =8080
diff --git a/app/src/main/java/it/francescogabbrielli/apps/sensorlogger/LogFtp.java b/app/src/main/java/it/francescogabbrielli/apps/sensorlogger/LogFtp.java
index 2c4ba88..adfdd8a 100644
--- a/app/src/main/java/it/francescogabbrielli/apps/sensorlogger/LogFtp.java
+++ b/app/src/main/java/it/francescogabbrielli/apps/sensorlogger/LogFtp.java
@@ -30,15 +30,6 @@ public LogFtp(SharedPreferences prefs) {
password = prefs.getString(Util.PREF_FTP_PW, "");
}
- @Override
- protected OutputStream openOutputStream(String folder, String filename) throws IOException {
- if (!folderCreated) {
- client.makeDirectory(folder);
- folderCreated = client.changeWorkingDirectory(folder);
- }
- return client.storeFileStream(filename);
- }
-
/**
* Connects to the FTP server
*/
@@ -53,6 +44,15 @@ public void connect() throws IOException {
}
}
+ @Override
+ protected OutputStream openOutputStream(String folder, String filename) throws IOException {
+ if (!folderCreated) {
+ client.makeDirectory(folder);
+ folderCreated = client.changeWorkingDirectory(folder);
+ }
+ return client.storeFileStream(filename);
+ }
+
@Override
public void close() throws IOException {
super.close();
diff --git a/app/src/main/java/it/francescogabbrielli/apps/sensorlogger/MainActivity.java b/app/src/main/java/it/francescogabbrielli/apps/sensorlogger/MainActivity.java
index 9ac6fc4..259f191 100644
--- a/app/src/main/java/it/francescogabbrielli/apps/sensorlogger/MainActivity.java
+++ b/app/src/main/java/it/francescogabbrielli/apps/sensorlogger/MainActivity.java
@@ -347,7 +347,7 @@ protected void onPermissionDenied(String permission) {
if (Manifest.permission.CAMERA.equals(permission)) {
prefs.edit()
.putBoolean(Util.PREF_CAPTURE_CAMERA, false)
- .putString(Util.PREF_STREAMING, "0").apply();
+ .putBoolean(Util.PREF_STREAMING, false).apply();
} else if (Manifest.permission.INTERNET.equals(permission)) {
prefs.edit().putString(Util.PREF_FTP, "0").apply();
} else if (Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permission)) {
diff --git a/app/src/main/java/it/francescogabbrielli/apps/sensorlogger/SettingsActivity.java b/app/src/main/java/it/francescogabbrielli/apps/sensorlogger/SettingsActivity.java
index 50dda65..596f9cd 100644
--- a/app/src/main/java/it/francescogabbrielli/apps/sensorlogger/SettingsActivity.java
+++ b/app/src/main/java/it/francescogabbrielli/apps/sensorlogger/SettingsActivity.java
@@ -71,25 +71,23 @@ public boolean onPreferenceChange(Preference preference, Object value) {
Log.d(TAG, "Preference "+preference.getKey()+" -> "+value+" ["+value.getClass()+"]");
String stringValue = value.toString();
Context ctx = preference.getContext();
+ int descriptionId = ctx.getResources().getIdentifier(
+ preference.getKey() + "_description", "string", ctx.getPackageName());
if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list.
ListPreference listPreference = (ListPreference) preference;
int index = listPreference.findIndexOfValue(stringValue);
-
if (index < 0) {
preference.setSummary(null);
} else {
listPreference.setValueIndex(index);
CharSequence val = listPreference.getEntries()[index];
- int descriptionId = ctx.getResources().getIdentifier(
- preference.getKey() + "_description", "string", ctx.getPackageName());
- // Set the summary to reflect the new value.
preference.setSummary(descriptionId != 0
? ctx.getString(descriptionId, val)
- : val);
+ : val
+ );
}
-
} else if(preference instanceof EditTextPreference &&
(((EditTextPreference) preference).getEditText().getInputType() & InputType.TYPE_TEXT_VARIATION_PASSWORD)!=0) {
@@ -97,8 +95,8 @@ public boolean onPreferenceChange(Preference preference, Object value) {
} else {
// For all other preferences, set the summary to the value's
- // simple string representation.
- preference.setSummary(stringValue);
+ // simple string representation (plus optional description).
+ preference.setSummary(descriptionId!=0 ? ctx.getString(descriptionId, stringValue) : stringValue);
}
return true;
}
@@ -224,7 +222,7 @@ public static class StreamingPreferenceFragment extends AppCompatPreferenceFragm
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_streaming);
- bindPreferenceSummaryToValue(findPreference(Util.PREF_STREAMING));
+// bindPreferenceSummaryToValue(findPreference(Util.PREF_STREAMING));
bindPreferenceSummaryToValue(findPreference(Util.PREF_STREAMING_PORT));
}
}
diff --git a/app/src/main/java/it/francescogabbrielli/apps/sensorlogger/Util.java b/app/src/main/java/it/francescogabbrielli/apps/sensorlogger/Util.java
index 7bb4c75..68b5ada 100644
--- a/app/src/main/java/it/francescogabbrielli/apps/sensorlogger/Util.java
+++ b/app/src/main/java/it/francescogabbrielli/apps/sensorlogger/Util.java
@@ -94,9 +94,10 @@ public void run() {
if (!prefs.contains(key)) {
String val = defaults.getProperty(key);
//TODO: manage different types?
- if ("TRUE".equalsIgnoreCase(val) || "FALSE".equalsIgnoreCase(val))
+ if ("TRUE".equalsIgnoreCase(val) || "FALSE".equalsIgnoreCase(val)) {
editor.putBoolean(key, Boolean.parseBoolean(val.toLowerCase()));
- else
+ Log.d("Defaults", key+"="+val);
+ } else
editor.putString(key, val);
}
}
@@ -162,7 +163,11 @@ public static int getSensorMaxLength(Sensor sensor) {
}
public static int getIntPref(SharedPreferences prefs, String prefKey) {
- return Integer.valueOf(prefs.getString(prefKey, "0"));
+ Object val = prefs.getAll().get(prefKey);
+ if (val instanceof Boolean)
+ return prefs.getBoolean(prefKey, false) ? 1 : 0;
+ else
+ return val!=null ? Integer.valueOf(val.toString()) : 0;
}
public static long getLongPref(SharedPreferences prefs, String prefKey) {
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 27f5203..0558ed6 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -36,8 +36,9 @@
Streaming
Enable Image Streaming
- [EXPERIMENTAL] The images will be streamed over HTTP: %s
- Start server on port
+ [EXPERIMENTAL] The images will be streamed over HTTP
+ Port
+ Start streaming server on port %s
Logging
diff --git a/app/src/main/res/xml/pref_streaming.xml b/app/src/main/res/xml/pref_streaming.xml
index a299772..60dff6d 100644
--- a/app/src/main/res/xml/pref_streaming.xml
+++ b/app/src/main/res/xml/pref_streaming.xml
@@ -1,19 +1,17 @@
-