Skip to content
This repository has been archived by the owner on May 2, 2021. It is now read-only.

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
unneccessary strings, visibility, etc

rm unneeded imports
  • Loading branch information
tjanson committed Mar 15, 2015
1 parent 75d53d8 commit 5993153
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;

Expand All @@ -24,9 +23,6 @@
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.JsonHttpResponseHandler;

import java.text.DateFormat;
import java.util.Date;
Expand All @@ -53,7 +49,8 @@ public class MainActivity extends Activity implements
Logger dataLog; // sensor data (geo, wifi) for debugging (verbose)
Logger diskLog; // pretty CSV output, i.e., the "product" of this app

static final String UPLOAD_SECRET = "sLlx6PaL"; // anti-spam filter on server
// anti-spam filter on server
static final String UPLOAD_SECRET = "sLlx6PaL";

// unique ID sent to server to distinguish clients
// changes everytime logging is enabled
Expand Down Expand Up @@ -83,16 +80,16 @@ public class MainActivity extends Activity implements
Location currentLocation;

// Wifi scan stuff
static WifiManager wifiManager;
static IntentFilter wifiIntentFilter;
static WifiBroadcastReceiver wifiBroadcastReceiver;
static WifiManager wifiManager;
private static IntentFilter wifiIntentFilter;
private static WifiBroadcastReceiver wifiBroadcastReceiver;

// toggles logging location+wifi to file
// debug logs may be created regardless of this
boolean loggingEnabled = false;

// wake-lock to (hopefully) continue logging while screen is off
PowerManager.WakeLock wakeLock;
private PowerManager.WakeLock wakeLock;

// UI Elements
Button loggingButton;
Expand All @@ -107,9 +104,13 @@ public class MainActivity extends Activity implements
String wifiListString;
Date lastWifiScanTime;

// keys for saving user preferences
private final static String SSID_FILTER_PREFERENCE_KEY = "ssid-filter-preference-key";
private final static String UPLOAD_URL_PREFERENCE_KEY = "upload-url-preference-key";

// will be incremented when log format changes
final static int LOG_FORMAT_VERSION = 1;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import java.io.FileNotFoundException;
import java.util.UUID;

public class Uploader {
private static AsyncHttpClient client = new AsyncHttpClient();
class Uploader {
private static final AsyncHttpClient client = new AsyncHttpClient();

private static void get(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
client.get(url, params, responseHandler);
Expand All @@ -26,7 +26,7 @@ private static void post(String url, RequestParams params, AsyncHttpResponseHand
public static void upload(final MainActivity m, String pathToFile) {
File file = new File(pathToFile);
UUID uploadUuid = UUID.randomUUID();
String targetFilename = m.UPLOAD_SECRET + "." + uploadUuid.toString();
String targetFilename = MainActivity.UPLOAD_SECRET + "." + uploadUuid.toString();
m.log.info("Upload UUID: {}", uploadUuid);

RequestParams params = new RequestParams();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ private Pattern makeFilter() {
}
}

public static int convertFrequencyToChannel(int freq) {
private static int convertFrequencyToChannel(int freq) {
if (freq >= 2412 && freq <= 2484) {
return (freq - 2412) / 5 + 1;
} else if (freq >= 5170 && freq <= 5825) {
return (freq - 5170) / 5 + 34;
} else {
throw new IllegalArgumentException();
throw new IllegalArgumentException(Integer.toString(freq));
}
}

Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
<string name="ssid_filter_hint">regulärer Ausdruck</string>
<string name="wifi">WLAN</string>
<string name="wifis_list">WLAN-Liste</string>
<string name="remote_log">An Server senden</string>
<string name="remote_log_warning">Bitte beachte: Die Datenübertragung zum Server erfolgt momentan unverschlüsselt und ist damit potentiell für Dritte lesbar.\nRemote Logging ist in einer frühen Versuchsphase.</string>
<string name="upload_to_server">An Server hochladen</string>
<string name="upload_explanation">Der Upload beinhaltet die vollständige aktuelle Logdatei, d.h. alle heute gesammelten Daten.\nWenn Du nur Auszüge des Logs hochladen möchtest, musst du es vor dem Upload manuell bearbeiten.\nÄltere Logs hochzuladen ist (noch) nicht möglich.</string>
<string name="server">Server</string>
<string name="server_url">Server URL</string>
<string name="upload_failed">Fehler: Upload fehlgeschlagen!</string>
<string name="upload_file_not_found">Fehler: Logdatei wurde nicht gefunden</string>
<string name="upload_successful">Upload erfolgreich</string>
</resources>
7 changes: 2 additions & 5 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
<string name="unknown" translatable="false">—</string>
<string name="logging_start">Start logging</string>
<string name="logging_stop">Pause logging</string>
<string name="remote_log">Send to server</string>
<string name="remote_log_warning">Note: The remote logging connection is currently unencrypted. Data may be intercepted by third parties.\nRemote logging is experimental.</string>
<!--string name="delete_logs">Delete logs</string-->
<string name="location">Location</string>
<string name="latitude_longitude">Lat-/Longitude</string>
<string name="accuracy">Accuracy</string>
Expand All @@ -19,9 +16,9 @@
<string name="upload_url_default" translatable="false">http://niobe.tomjanson.com:34570/</string>
<string name="upload_to_server">Upload to server</string>
<string name="upload_explanation">Pressing upload will upload the entire current log file, i.e., all data logged today.\nIf you wish to exclude data, you must remove it from the log file before uploading.\nUploading older log files is not yet supported.</string>
<string name="upload_file_not_found">FileNotFoundException</string>
<string name="upload_file_not_found">Error: Log file was not found!</string>
<string name="upload_successful">Upload successful</string>
<string name="upload_failed">Upload failed!</string>
<string name="upload_failed">Error: Upload failed!</string>
<string name="server">Server</string>
<string name="server_url">Server URL</string>
</resources>

0 comments on commit 5993153

Please sign in to comment.