Commit c7e60df9 authored by Craig Earley's avatar Craig Earley
Browse files

applies Lint fixes, first of a few iterations

parent 87afa023
......@@ -473,7 +473,7 @@ public class BenchSampleActivity extends Activity {
File picture = new File(picturesDir, pictureName + ".png");
if (picture.exists()) {
if (count > 0) {
picture = new File(picturesDir, pictureName + "-" + Integer.toString(count) + ".png");
picture = new File(picturesDir, pictureName + "-" + count + ".png");
}
}
......
......@@ -16,8 +16,6 @@ public class BluetoothLeService extends Service {
private final static String TAG = BluetoothLeService.class.getSimpleName();
private BluetoothManager mBluetoothManager;
private BluetoothAdapter mBluetoothAdapter;
private int mConnectionState = STATE_DISCONNECTED;
private BluetoothSensor btSensor;
private static final int STATE_DISCONNECTED = 0;
......@@ -43,8 +41,6 @@ public class BluetoothLeService extends Service {
.fromString(GattAttributes.BLE_SENSOR_SERVICE);
public static String CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb";
private BluetoothGattService gattService;
private final BluetoothSensor.Listener listener = new BluetoothSensor.Listener() {
@Override
public void onCharacteristicRead(UUID characteristicUUID, String data) {
......@@ -55,7 +51,7 @@ public class BluetoothLeService extends Service {
public void onServiceInformation() {
for (BluetoothGattService s : btSensor.getServices()){
if (s.getUuid().equals(UUID_BLE_SENSOR_SERVICE)) {
gattService = btSensor.getService(UUID_BLE_SENSOR_SERVICE);
BluetoothGattService gattService = btSensor.getService(UUID_BLE_SENSOR_SERVICE);
btSensor.setPrimaryService(gattService);
btSensor.setCharacteristics(
gattService.getCharacteristic(UUID_BLE_SENSOR_REQUEST),
......@@ -113,7 +109,7 @@ public class BluetoothLeService extends Service {
}
}
mBluetoothAdapter = mBluetoothManager.getAdapter();
BluetoothAdapter mBluetoothAdapter = mBluetoothManager.getAdapter();
if (mBluetoothAdapter == null) {
Log.e(TAG, "Unable to obtain a BluetoothAdapter.");
return false;
......@@ -123,7 +119,7 @@ public class BluetoothLeService extends Service {
public boolean connect(BluetoothSensor bluetoothSensor) {
btSensor = bluetoothSensor;
mConnectionState = STATE_CONNECTING;
int mConnectionState = STATE_CONNECTING;
btSensor.setListener(listener);
return btSensor.connect(this);
}
......
......@@ -8,7 +8,6 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.UUID;
......@@ -20,7 +19,6 @@ public class BluetoothSensor implements Parcelable {
private GattClient gattClient;
private Listener mListener;
private BluetoothGattCharacteristic readChar, writeChar;
private BluetoothGattService sensorService;
public BluetoothSensor(BluetoothDevice device){
Log.d("Bluetooth Sensor", device.toString());
......@@ -61,7 +59,7 @@ public class BluetoothSensor implements Parcelable {
}
public void setPrimaryService(BluetoothGattService service){
sensorService = service;
BluetoothGattService sensorService = service;
}
public void setCharacteristics(BluetoothGattCharacteristic writeChar, BluetoothGattCharacteristic readChar){
......
......@@ -472,7 +472,7 @@ public class DatabaseActionsActivity extends Activity {
while(rs.next()) {
count += 1;
for (String column : columns){
publishProgress(new Integer[]{index, count});
publishProgress(index, count);
switch(db.getColumnType(column)){
case ReadingsDatabase.FLOAT:
cv.put(column, rs.getFloat(column));
......@@ -562,7 +562,7 @@ public class DatabaseActionsActivity extends Activity {
int count = 0;
for (String table : tables) {
String columns[] = db.getColumns(table);
String[] columns = db.getColumns(table);
// Query local sqlite table, all columns, all rows
Cursor c = db.query(table, null, null);
int index = Arrays.asList(tables).indexOf(table);
......@@ -582,7 +582,7 @@ public class DatabaseActionsActivity extends Activity {
while (c.moveToNext()) {
count += 1;
Log.d("Progress (row count):", Integer.toString(count));
publishProgress(new Integer[] {index, (int) ((((double) count)/((double) totalCount))*100.0)});
publishProgress(index, (int) ((((double) count)/((double) totalCount))*100.0));
String q = String.format(res.getString(
R.string.spotQuery),
Integer.toString(c.getInt(c.getColumnIndex("tripID"))),
......@@ -625,7 +625,7 @@ public class DatabaseActionsActivity extends Activity {
count += 1;
Log.d("Progress (row count):", Integer.toString(count));
float countFraction = ((float) count / (float) totalCount);
publishProgress(new Integer[]{index, (int) (countFraction) * 100});
publishProgress(index, (int) (countFraction) * 100);
for (int i = 0; i < columns.length; i++) {
String piece = getColumn(c, columns[i]);
if (piece.length() > 0) {
......@@ -661,8 +661,8 @@ public class DatabaseActionsActivity extends Activity {
+ "'" + hostid + "'" + ","
+ "'" + startTS + "'" + ","
+ "'" + endTS + "'" + ","
+ Integer.toString(readingCount) + ","
+ Integer.toString(streamingCount)
+ readingCount + ","
+ streamingCount
+ "); ";
Log.d("UPLOADREC Full query", uploadRecordQuery);
st.executeUpdate(uploadRecordQuery);
......@@ -757,21 +757,21 @@ public class DatabaseActionsActivity extends Activity {
break;
case 1:
if (readRows == 1){readRowStr = "reading";}
message = "Initialized, " + Integer.toString(readRows) + " " + readRowStr;
message = "Initialized, " + readRows + " " + readRowStr;
break;
case 2:
if (readRows == 1){readRowStr = "reading";}
if (streamRows == 1){streamRowStr = "stream entry";}
message = "Initialized, "
+ Integer.toString(readRows) + " " + readRowStr + " and "
+ Integer.toString(streamRows) + " " + streamRowStr;
+ readRows + " " + readRowStr + " and "
+ streamRows + " " + streamRowStr;
break;
case 3:
message = "Initialized, no readings or streaming data.";
break;
case 4:
if (streamRows == 1){streamRowStr = "stream entry";}
message = "Initialized, " + Integer.toString(streamRows) + " " + streamRowStr;
message = "Initialized, " + streamRows + " " + streamRowStr;
break;
default:
break;
......
package fieldscience.cs.earlham.edu.fieldday;
import android.app.Activity;
import android.content.Context;
import android.util.Pair;
import android.view.LayoutInflater;
......
......@@ -61,12 +61,10 @@ public abstract class GoogleDriveConnect extends Activity implements GoogleApiCl
@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data){
super.onActivityResult(requestCode,resultCode,data);
switch (requestCode) {
case REQUEST_CODE_RESOLUTION:
if (resultCode == RESULT_OK){
googleApiClient.connect();
}
break;
if (requestCode == REQUEST_CODE_RESOLUTION) {
if (resultCode == RESULT_OK) {
googleApiClient.connect();
}
}
}
......
......@@ -26,9 +26,7 @@ import java.io.OutputStreamWriter;
import java.io.Writer;
public class GoogleDriveFileBrowser extends GoogleDriveConnect {
private ListView filesListView;
private DriveResultsAdapter filesAdapter;
private Button fileButton, folderButton;
private String fileName;
private DriveId folderId;
private static final String TAG = "GoogleDriveFileBrowser";
......@@ -39,7 +37,7 @@ public class GoogleDriveFileBrowser extends GoogleDriveConnect {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_drive);
filesListView = (ListView) findViewById(R.id.listFileResults);
ListView filesListView = (ListView) findViewById(R.id.listFileResults);
filesAdapter = new DriveResultsAdapter(this);
filesListView.setAdapter(filesAdapter);
filesListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
......@@ -60,7 +58,7 @@ public class GoogleDriveFileBrowser extends GoogleDriveConnect {
fileName = "";
fileButton = (Button) findViewById(R.id.createFileButton);
Button fileButton = (Button) findViewById(R.id.createFileButton);
fileButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -68,7 +66,7 @@ public class GoogleDriveFileBrowser extends GoogleDriveConnect {
}
});
folderButton = (Button) findViewById(R.id.createFolderButton);
Button folderButton = (Button) findViewById(R.id.createFolderButton);
folderButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......
......@@ -17,7 +17,6 @@ import java.io.IOException;
public class MyDocumentViewer extends Activity {
File fileToOpen;
private static int index = 0;
private ImageView docImageView;
@Override
......@@ -41,6 +40,7 @@ public class MyDocumentViewer extends Activity {
try {
ParcelFileDescriptor fileDescriptor = ParcelFileDescriptor.open(fileToOpen, ParcelFileDescriptor.MODE_READ_ONLY);
PdfRenderer pdfRenderer = new PdfRenderer(fileDescriptor);
int index = 0;
PdfRenderer.Page page = pdfRenderer.openPage(index);
int count = pdfRenderer.getPageCount();
Bitmap pdf = Bitmap.createBitmap(page.getWidth(), page.getHeight(), Bitmap.Config.ARGB_8888);
......
......@@ -43,7 +43,6 @@ public class MyDocumentsActivity extends Activity {
public static ArrayList<File> localDirList;
private Boolean firstPage = true;
private String baseURL = "", currentPath = "", currentDir = "", initialDir = "";
private ListView filesListView;
private MyDocumentsAdapter myDocumentsAdapter;
SharedPreferences settings;
SharedPreferences.Editor editor;
......@@ -80,7 +79,7 @@ public class MyDocumentsActivity extends Activity {
firstPage = true;
context = this;
filesListView = (ListView) findViewById(R.id.listFileResults);
ListView filesListView = (ListView) findViewById(R.id.listFileResults);
myDocumentsAdapter = new MyDocumentsAdapter(context, localDirList);
filesListView.setAdapter(myDocumentsAdapter);
filesListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
......@@ -252,7 +251,7 @@ public class MyDocumentsActivity extends Activity {
if (!localDirList.contains(dir)){
localDirList.add(dir);
}
new GetListOfFiles().execute(new String[] {currentPath, file});
new GetListOfFiles().execute(currentPath, file);
} else {
Log.d("On click", currentPath);
if (currentPath.endsWith(currentDir)) {
......@@ -270,13 +269,13 @@ public class MyDocumentsActivity extends Activity {
// Delete any files in that subdirectory from the list.
for (String item : fileArray){
if (item.contains(file)){
downloadList.remove(downloadList.indexOf(item));
downloadList.remove(item);
}
}
}
File dir = createDirectory(fileArray[which]);
localDirList.remove(localDirList.indexOf(dir));
localDirList.remove(dir);
downloadList.remove(fileArray[which]);
}
}
......
......@@ -16,8 +16,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
......@@ -307,7 +305,7 @@ public class ReadingsDatabase extends SQLiteOpenHelper {
{
Log.d("ReadingsDatabase", " sensorValues ["+ i+ "] = " + sensorValues[i]);
if(sensorValues[i] != 0.0f){
c_value_i = C_VALUE + Integer.toString(i+1);
c_value_i = C_VALUE + (i + 1);
Log.d("ReadingsDatabase", "c_value_i = " + c_value_i);
cv.put(c_value_i, Double.valueOf(d.format(sensorValues[i])));
}
......@@ -618,9 +616,9 @@ public class ReadingsDatabase extends SQLiteOpenHelper {
public int getStatus() {
int readings = query(T_READING, null, null).getCount();
Log.d("ReadingsDatabase", "Readings Counts:" + Integer.toString(readings));
Log.d("ReadingsDatabase", "Readings Counts:" + readings);
int streaming = query(T_STREAM, null, null).getCount();
Log.d("ReadingsDatabase", "Streamings Counts:" + Integer.toString(streaming));
Log.d("ReadingsDatabase", "Streamings Counts:" + streaming);
// Empty database
if (getSize() == 0){
......
......@@ -43,7 +43,6 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
......@@ -402,7 +401,7 @@ public class SensorSampleActivity extends Activity {
break;
}
sampleService.onLoggingTimeChanged(logInterval);
Log.d("Changing Interval", "New Interval Time: " + String.valueOf(logInterval));
Log.d("Changing Interval", "New Interval Time: " + logInterval);
}
public void changeStreamButton() {
......@@ -673,7 +672,7 @@ public class SensorSampleActivity extends Activity {
File picture = new File(picturesDir, pictureName + ".png");
if (picture.exists()) {
if (count > 0) {
picture = new File(picturesDir, pictureName + "-" + Integer.toString(count) + ".png");
picture = new File(picturesDir, pictureName + "-" + count + ".png");
}
}
......
......@@ -9,7 +9,6 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
......@@ -38,7 +37,11 @@ public class SensorSampleService extends Service implements SensorEventListener
private BluetoothLeService btService;
private String sensorType, response;
private boolean sampleOnce, registered = false, streaming = false, calibrating = false, connected = false, clear = false;
private boolean sampleOnce;
private boolean registered = false;
private boolean streaming = false;
private boolean calibrating = false;
private boolean connected = false;
private long loggingInterval;
private Handler dbHandler, btHandler;
private Runnable dbRunner, btRunNames, btRunValues;
......@@ -46,8 +49,6 @@ public class SensorSampleService extends Service implements SensorEventListener
private ArrayList<aSensor> sensorList;
public ReadingsDatabase db;
private SensorManager mSensorManager;
private LocationManager locationManager;
private LocationListener locationListener;
private ArrayList<Sensor> builtinList;
public static double lastLongitude, lastLatitude, lastElevation;
public static int lastSatellites;
......@@ -112,7 +113,7 @@ public class SensorSampleService extends Service implements SensorEventListener
if (!registered) {
btHandler.postDelayed(btRunNames, 5000);
btHandler.removeCallbacksAndMessages(btRunNames);
clear = false;
boolean clear = false;
} else {
getSensorValues();
}
......@@ -176,8 +177,8 @@ public class SensorSampleService extends Service implements SensorEventListener
builtinList = new ArrayList<Sensor>();
db = ReadingsDatabase.getInstance(this);
locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
locationListener = new myLocationListener();
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListener = new myLocationListener();
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
......
......@@ -14,11 +14,8 @@ import android.preference.PreferenceManager;
public class SettingsFragment extends PreferenceFragment {
static String shortDeviceID = (Build.SERIAL).substring((Build.SERIAL).length()-4);
private EditTextPreference transfer;
private CheckBoxPreference writeWithoutGPS;
private Preference deviceModel, deviceID, buildInfo;
public int info = BuildConfig.VERSION_CODE;
@Override
......@@ -42,7 +39,7 @@ import android.preference.PreferenceManager;
}
});
transfer = (EditTextPreference) findPreference(getString(R.string.transfer_url_title));
EditTextPreference transfer = (EditTextPreference) findPreference(getString(R.string.transfer_url_title));
transfer.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
......@@ -67,16 +64,16 @@ import android.preference.PreferenceManager;
//Find and display current info.
deviceModel = findPreference(getString(R.string.device_model));
Preference deviceModel = findPreference(getString(R.string.device_model));
deviceModel.setSummary(Build.MODEL);
deviceID = findPreference(getString(R.string.device_id));
Preference deviceID = findPreference(getString(R.string.device_id));
deviceID.setSummary(Build.SERIAL);
buildInfo = findPreference(getString(R.string.build_info));
Preference buildInfo = findPreference(getString(R.string.build_info));
buildInfo.setSummary(BuildConfig.VERSION_NAME);
}
public static final SharedPreferences getSettings(final ContextWrapper context) {
public static SharedPreferences getSettings(final ContextWrapper context) {
return PreferenceManager.getDefaultSharedPreferences(context);
}
}
\ No newline at end of file
......@@ -3,7 +3,6 @@ package fieldscience.cs.earlham.edu.fieldday;
import android.hardware.Sensor;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
import static java.lang.Math.round;
......@@ -68,7 +67,7 @@ public class aSensor implements Parcelable {
StringBuilder result = new StringBuilder(Float.toString(round(lastValues[0] * displayWidth) / displayWidth));
for (int i=1; i<numberValues; i++) {
result.append(",").append(Float.toString(round(lastValues[i] * displayWidth) / displayWidth));
result.append(",").append(round(lastValues[i] * displayWidth) / displayWidth);
}
return result.toString();
......
......@@ -10,16 +10,15 @@ public class mDocument {
private static final String baseDirectory = Environment.getExternalStorageDirectory().toString() +
File.separator + "FieldDay" + File.separator + "myDocuments";
private String name, parentDirectory;
private String parentDirectory;
private URL url;
private File path;
public mDocument(String name) {
this.name = name;
String name1 = name;
}
public void setPath(File path){
this.path = path;
File path1 = path;
}
}
......@@ -14,7 +14,8 @@
android:textColorHint="@color/dark_gray_blue"
android:textColor="@color/dark_gray_blue"
android:textCursorDrawable="@null"
android:layout_centerHorizontal="true" />
android:layout_centerHorizontal="true"
android:inputType="" />
<EditText
android:layout_width="wrap_content"
......@@ -29,7 +30,8 @@
android:layout_below="@+id/serverIp"
android:layout_alignStart="@id/serverIp"
android:layout_alignEnd="@id/serverIp"
android:layout_centerHorizontal="true" />
android:layout_centerHorizontal="true"
android:inputType="" />
<EditText
android:layout_width="wrap_content"
......@@ -44,7 +46,8 @@
android:layout_below="@+id/database"
android:layout_alignStart="@id/serverIp"
android:layout_alignEnd="@id/serverIp"
android:layout_centerHorizontal="true" />
android:layout_centerHorizontal="true"
android:inputType="" />
<EditText
android:layout_width="wrap_content"
......@@ -75,7 +78,8 @@
android:fontFamily="sans-serif"
android:layout_alignStart="@id/serverIp"
android:layout_alignEnd="@id/serverIp"
android:layout_centerHorizontal="true" />
android:layout_centerHorizontal="true"
android:inputType="" />
<Button
android:layout_width="wrap_content"
......
......@@ -14,7 +14,8 @@
android:textColorHint="@color/dark_gray_blue"
android:textColor="@color/dark_gray_blue"
android:textCursorDrawable="@null"
android:layout_centerHorizontal="true" />
android:layout_centerHorizontal="true"
android:inputType="" />
<EditText
android:layout_width="wrap_content"
......@@ -29,7 +30,8 @@
android:layout_below="@+id/serverIp"
android:layout_alignStart="@id/serverIp"
android:layout_alignEnd="@id/serverIp"
android:layout_centerHorizontal="true" />
android:layout_centerHorizontal="true"
android:inputType="" />
<EditText
android:layout_width="wrap_content"
......@@ -44,7 +46,8 @@
android:layout_below="@+id/database"
android:layout_alignStart="@id/serverIp"
android:layout_alignEnd="@id/serverIp"
android:layout_centerHorizontal="true" />
android:layout_centerHorizontal="true"
android:inputType="" />
<EditText
android:layout_width="wrap_content"
......@@ -75,7 +78,8 @@
android:fontFamily="sans-serif"
android:layout_alignStart="@id/serverIp"
android:layout_alignEnd="@id/serverIp"
android:layout_centerHorizontal="true" />
android:layout_centerHorizontal="true"
android:inputType="" />
<Button
android:layout_width="wrap_content"
......
......@@ -135,7 +135,8 @@
android:background="@android:color/transparent"
android:hint="@string/readingNotes"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"/>
android:layout_marginTop="10dp"
android:inputType="" />
<Button
android:layout_width="153dp"
......
......@@ -16,7 +16,8 @@
android:layout_alignStart="@id/serverIp"
android:layout_alignEnd="@id/serverIp"
android:textCursorDrawable="@null"
android:layout_centerHorizontal="true" />
android:layout_centerHorizontal="true"
android:inputType="" />
<EditText
android:layout_width="wrap_content"
......@@ -31,7 +32,8 @@
android:layout_alignStart="@id/serverIp"
android:layout_alignEnd="@id/serverIp"
android:layout_below="@+id/serverIp"
android:layout_centerHorizontal="true" />
android:layout_centerHorizontal="true"
android:inputType="" />
<EditText
android:layout_width="wrap_content"
......@@ -46,7 +48,8 @@
android:layout_alignEnd="@id/serverIp"
android:hint="@string/username"
android:layout_below="@+id/database"
android:layout_centerHorizontal="true" />
android:layout_centerHorizontal="true"
android:inputType="" />
<EditText
android:layout_width="wrap_content"
......@@ -78,7 +81,8 @@
android:singleLine="true"
android:fontFamily="sans-serif"
android:layout_below="@+id/password"
android:layout_centerHorizontal="true" />