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

Merge branch 'system-updates' into 'master'

System updates

See merge request !9
parents 5091debf 47ca7177
......@@ -32,13 +32,14 @@ def computeVersionCode = { ->
return VersionCode
}
android {
compileSdkVersion 27
buildToolsVersion '28.0.3'
compileSdkVersion 29
buildToolsVersion '29.0.1'
defaultConfig {
applicationId "fieldscience.cs.earlham.edu.fieldday"
minSdkVersion 23
targetSdkVersion 27
targetSdkVersion 29
versionName "fieldDay_" + getGitHash() + "_" + getVersionCode() + ".apk"
}
buildTypes {
release {
......@@ -59,14 +60,16 @@ android {
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.gms:play-services-drive:11.0.0'
implementation 'com.google.android.gms:play-services-auth:11.0.0'
implementation 'com.google.android.gms:play-services-base:11.0.0'
implementation 'com.google.android.gms:play-services-basement:11.0.0'
implementation 'com.google.android.gms:play-services-drive:17.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.android.gms:play-services-base:17.0.0'
implementation 'com.google.android.gms:play-services-basement:17.0.0'
implementation 'androidx.preference:preference:1.0.0'
}
productFlavors {
}
}
dependencies {
implementation files('libs/jsoup-1.9.2.jar')
implementation 'com.android.support:appcompat-v7'
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fieldscience.cs.earlham.edu.fieldday">
package="fieldscience.cs.earlham.edu.fieldday"
android:versionCode="1"
>
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
......@@ -16,6 +18,7 @@
android:name="android.hardware.camera2"
android:required="false" />
<application
android:fullBackupContent="true"
android:allowBackup="true"
android:supportsRtl="true"
android:icon="@mipmap/ic_launcher"
......@@ -38,7 +41,7 @@
<activity
android:name=".SensorScanActivity"
android:label="Scan for devices"
android:theme="@android:style/Theme.Holo">
android:theme="@style/Theme.AppCompat">
</activity>
<activity
android:name=".DatabaseActionsActivity"
......
package fieldscience.cs.earlham.edu.fieldday;
import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
public class AboutFragment extends Fragment {
......@@ -30,15 +31,6 @@ public class AboutFragment extends Fragment {
Activity a;
if (context instanceof Activity){
a=(Activity) context;
}
}
@Override
public void onDetach() {
super.onDetach();
}
}
\ No newline at end of file
......@@ -3,7 +3,6 @@ package fieldscience.cs.earlham.edu.fieldday;
import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
......@@ -19,7 +18,6 @@ import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
......@@ -35,18 +33,22 @@ import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Locale;
import java.util.Map;
public class BenchSampleActivity extends Activity {
public class BenchSampleActivity extends AppCompatActivity {
private static final String TAG = BenchSampleActivity.class.getSimpleName();
public static final String REMOTE_DB = "Remote DB Connected";
......@@ -79,7 +81,7 @@ public class BenchSampleActivity extends Activity {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
tripName = settings.getString("trip", "");
Log.d("BenchSampleActivity", "tripName: "+tripName);
TextView trip_name = (TextView) findViewById(R.id.tripNameText);
TextView trip_name = findViewById(R.id.tripNameText);
trip_name.setText(String.format("Trip Name: %s", tripName));
siteList = new ArrayList<>();
......@@ -90,8 +92,8 @@ public class BenchSampleActivity extends Activity {
remote_db = getIntent().getBooleanExtra(REMOTE_DB, false);
readingNotes = "";
recordButton = (Button) findViewById(R.id.recordButton);
addPictureButton = (Button) findViewById(R.id.addPicture);
recordButton = findViewById(R.id.recordButton);
addPictureButton = findViewById(R.id.addPicture);
baseDir = new File(directory);
if (!baseDir.exists()){
baseDir.mkdir();
......@@ -100,21 +102,21 @@ public class BenchSampleActivity extends Activity {
// Site spinner, site adapter
if (remote_db) { siteList = db.getSites(null); }
siteList.add(0, new Pair<>("Site", "0"));
siteSpinner = (Spinner) findViewById(R.id.selectSite);
siteSpinner = findViewById(R.id.selectSite);
siteAdapter = new DropdownListAdapter(this);
siteAdapter.addItems(siteList);
siteSpinner.setAdapter(siteAdapter);
// Sector spinner, sector adapter
sectorSpinner = (Spinner) findViewById(R.id.selectSector);
sectorSpinner = findViewById(R.id.selectSector);
// Spot spinner, spot adapter
spotSpinner = (Spinner) findViewById(R.id.selectSpot);
spotSpinner = findViewById(R.id.selectSpot);
// Platform spinner, platform adapter
if (remote_db) { platformList.addAll(db.getPlatforms()); }
platformList.add(0, "Platform");
platformSpinner = (Spinner) findViewById(R.id.selectPlatform);
platformSpinner = findViewById(R.id.selectPlatform);
ArrayAdapter<String> platformAdapter = new ArrayAdapter<>(this,
android.R.layout.simple_spinner_item, platformList);
platformAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
......@@ -122,7 +124,7 @@ public class BenchSampleActivity extends Activity {
// Sensor spinner, sensor adapter
sensorList.add(0, new Pair<>("Sensor", "0"));
sensorSpinner = (Spinner) findViewById(R.id.selectSensor);
sensorSpinner = findViewById(R.id.selectSensor);
sensorAdapter = new DropdownListAdapter(this);
sensorAdapter.addItems(sensorList);
sensorSpinner.setAdapter(sensorAdapter);
......@@ -214,7 +216,7 @@ public class BenchSampleActivity extends Activity {
}
});
notesET = (EditText) findViewById(R.id.readingNotes);
notesET = findViewById(R.id.readingNotes);
notesET.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
......@@ -232,7 +234,7 @@ public class BenchSampleActivity extends Activity {
}
});
valueET = (EditText) findViewById(R.id.sensorValue);
valueET = findViewById(R.id.sensorValue);
valueET.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
......@@ -255,7 +257,7 @@ public class BenchSampleActivity extends Activity {
}
});
qualityET = (EditText) findViewById(R.id.sensorQuality);
qualityET = findViewById(R.id.sensorQuality);
qualityET.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
......@@ -369,10 +371,10 @@ public class BenchSampleActivity extends Activity {
super.onActivityResult(requestCode, resultCode, data);
LayoutInflater layoutInflater = this.getLayoutInflater();
final View dialog = layoutInflater.inflate(R.layout.alert_picture_name, null);
final EditText name = (EditText) dialog.findViewById(R.id.pictureName);
final EditText name = dialog.findViewById(R.id.pictureName);
if (resultCode != Activity.RESULT_CANCELED) {
Dialog d = new AlertDialog.Builder(BenchSampleActivity.this, AlertDialog.THEME_HOLO_LIGHT)
Dialog d = new AlertDialog.Builder(BenchSampleActivity.this)
.setTitle("Picture Name")
.setView(dialog)
.setNegativeButton("Discard Picture", null)
......
......@@ -117,11 +117,11 @@ public class BluetoothLeService extends Service {
return true;
}
public boolean connect(BluetoothSensor bluetoothSensor) {
public void connect(BluetoothSensor bluetoothSensor) {
btSensor = bluetoothSensor;
int mConnectionState = STATE_CONNECTING;
btSensor.setListener(listener);
return btSensor.connect(this);
btSensor.connect(this);
}
public void disconnect() {
......
package fieldscience.cs.earlham.edu.fieldday;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.ContentValues;
......@@ -25,6 +23,9 @@ import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
......@@ -37,7 +38,7 @@ import java.util.Date;
import java.util.List;
import java.util.Locale;
public class DatabaseActionsActivity extends Activity {
public class DatabaseActionsActivity extends AppCompatActivity {
private static final String DB_DRIVER = "org.postgresql.Driver";
private static final String[] uploadTables = {"fieldday_spot", "fieldday_reading", "fieldday_streaming"};
......@@ -85,20 +86,20 @@ public class DatabaseActionsActivity extends Activity {
uploadColumnCount += db.getColumns(table).length;
}
dbSizeTV = (TextView) findViewById(R.id.databaseSize);
dbSizeTV = findViewById(R.id.databaseSize);
dbSizeTV.setText(String.format(res.getString(R.string.databaseSize), Formatter.formatFileSize(this, db.getSize())));
dbStatusTV = (TextView) findViewById(R.id.databaseStatus);
dbStatusTV = findViewById(R.id.databaseStatus);
dbStatusTV.setText(String.format(res.getString(R.string.databaseStatus), ""));
displayDatabaseStatus(db.getStatus());
cleanTV = (TextView) findViewById(R.id.lastClean);
cleanTV = findViewById(R.id.lastClean);
cleanTV.setText(String.format(res.getString(R.string.lastClean), settings.getString("lastClean", "Never")));
uploadTV = (TextView) findViewById(R.id.lastUpload);
uploadTV = findViewById(R.id.lastUpload);
uploadTV.setText(String.format(res.getString(R.string.lastUpload), settings.getString("lastUpload", "Never")));
downloadTV = (TextView) findViewById(R.id.lastDownload);
downloadTV = findViewById(R.id.lastDownload);
downloadTV.setText(String.format(res.getString(R.string.lastDownload), settings.getString("lastDownload", "Never")));
server = (EditText) findViewById(R.id.serverIp);
server = findViewById(R.id.serverIp);
host = settings.getString("host", "cluster.earlham.edu");
server.setText(host);
editor.putString("host", host);
......@@ -122,7 +123,7 @@ public class DatabaseActionsActivity extends Activity {
}
});
dbName = (EditText) findViewById(R.id.database);
dbName = findViewById(R.id.database);
database = settings.getString("database_name", "field_science");
dbName.setText(database);
editor.putString("database_name", database);
......@@ -146,7 +147,7 @@ public class DatabaseActionsActivity extends Activity {
}
});
username = (EditText) findViewById(R.id.username);
username = findViewById(R.id.username);
uname = settings.getString("username", "fieldsci");
username.setText(uname);
editor.putString("username", uname);
......@@ -170,7 +171,7 @@ public class DatabaseActionsActivity extends Activity {
}
});
password = (EditText) findViewById(R.id.password);
password = findViewById(R.id.password);
pass = settings.getString("password", "skalanes");
password.setText(pass);
editor.putString("password", pass);
......@@ -194,7 +195,7 @@ public class DatabaseActionsActivity extends Activity {
}
});
port = (EditText) findViewById(R.id.port);
port = findViewById(R.id.port);
pNum = settings.getString("port", "5432");
port.setText(pNum);
editor.putString("port", pNum);
......@@ -218,7 +219,7 @@ public class DatabaseActionsActivity extends Activity {
}
});
setup = (Button) findViewById(R.id.setupDbButton);
setup = findViewById(R.id.setupDbButton);
setup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -226,7 +227,7 @@ public class DatabaseActionsActivity extends Activity {
}
});
clean = (Button) findViewById(R.id.wipeDatabase);
clean = findViewById(R.id.wipeDatabase);
clean.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v){
......@@ -234,7 +235,7 @@ public class DatabaseActionsActivity extends Activity {
}
});
cleanReadings = (Button) findViewById(R.id.wipeReadingsTable);
cleanReadings = findViewById(R.id.wipeReadingsTable);
cleanReadings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v){
......@@ -242,7 +243,7 @@ public class DatabaseActionsActivity extends Activity {
}
});
cleanStreaming = (Button) findViewById(R.id.wipeStreamingTable);
cleanStreaming = findViewById(R.id.wipeStreamingTable);
cleanStreaming.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v){
......@@ -250,7 +251,7 @@ public class DatabaseActionsActivity extends Activity {
}
});
cleanField = (Button) findViewById(R.id.wipeFieldData);
cleanField = findViewById(R.id.wipeFieldData);
cleanField.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v){
......@@ -258,7 +259,7 @@ public class DatabaseActionsActivity extends Activity {
}
});
upload = (Button) findViewById(R.id.uploadButton);
upload = findViewById(R.id.uploadButton);
upload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v){
......@@ -275,7 +276,7 @@ public class DatabaseActionsActivity extends Activity {
}
public void verify(final View view){
AlertDialog.Builder builder = new AlertDialog.Builder(DatabaseActionsActivity.this, AlertDialog.THEME_HOLO_LIGHT);
AlertDialog.Builder builder = new AlertDialog.Builder(DatabaseActionsActivity.this);
switch(view.getId()){
case R.id.setupDbButton:
builder.setMessage("Are you sure that you want to setup your local database?");
......@@ -411,7 +412,7 @@ public class DatabaseActionsActivity extends Activity {
DatabaseActionsActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
Dialog d = new AlertDialog.Builder(DatabaseActionsActivity.this, AlertDialog.THEME_HOLO_LIGHT)
Dialog d = new androidx.appcompat.app.AlertDialog.Builder(DatabaseActionsActivity.this)
.setTitle("Here are the trips I've discovered. Select your trip.")
.setNegativeButton("No trip!", null)
.setItems(tripArray, new DialogInterface.OnClickListener() {
......
......@@ -28,8 +28,8 @@ public class DriveResultsAdapter extends DataBufferAdapter<Metadata> {
}
Metadata metadata = getItem(position);
TextView titleTextView =
(TextView) convertView.findViewById(R.id.objectName);
ImageView objectType = (ImageView) convertView.findViewById(R.id.objectType);
convertView.findViewById(R.id.objectName);
ImageView objectType = convertView.findViewById(R.id.objectType);
Resources res = context.getResources();
switch(metadata.getMimeType()){
case DriveFolder.MIME_TYPE:
......
......@@ -64,7 +64,7 @@ public class DropdownListAdapter extends BaseAdapter {
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = Objects.requireNonNull(inflater).inflate(R.layout.dropdown_item, parent, false);
holder = new ViewHolderItem();
holder.itemName = (TextView) view.findViewById(R.id.itemName);
holder.itemName = view.findViewById(R.id.itemName);
view.setTag(holder);
} else {
......
package fieldscience.cs.earlham.edu.fieldday;
import android.app.Activity;
import android.content.Intent;
import android.content.IntentSender;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.Gravity;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.drive.Drive;
public abstract class GoogleDriveConnect extends Activity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
public abstract class GoogleDriveConnect extends AppCompatActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
private GoogleApiClient googleApiClient;
protected static final int REQUEST_CODE_RESOLUTION = 1;
......
package fieldscience.cs.earlham.edu.fieldday;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
......@@ -12,6 +11,8 @@ import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.drive.Drive;
import com.google.android.gms.drive.DriveApi;
......@@ -37,7 +38,7 @@ public class GoogleDriveFileBrowser extends GoogleDriveConnect {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_drive);
ListView filesListView = (ListView) findViewById(R.id.listFileResults);
ListView filesListView = findViewById(R.id.listFileResults);
filesAdapter = new DriveResultsAdapter(this);
filesListView.setAdapter(filesAdapter);
filesListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
......@@ -58,7 +59,7 @@ public class GoogleDriveFileBrowser extends GoogleDriveConnect {
fileName = "";
Button fileButton = (Button) findViewById(R.id.createFileButton);
Button fileButton = findViewById(R.id.createFileButton);
fileButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -66,7 +67,7 @@ public class GoogleDriveFileBrowser extends GoogleDriveConnect {
}
});
Button folderButton = (Button) findViewById(R.id.createFolderButton);
Button folderButton = findViewById(R.id.createFolderButton);
folderButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -114,7 +115,7 @@ public class GoogleDriveFileBrowser extends GoogleDriveConnect {
};
private void askForName(View v){
AlertDialog.Builder builder = new AlertDialog.Builder(GoogleDriveFileBrowser.this, AlertDialog.THEME_HOLO_LIGHT);
AlertDialog.Builder builder = new AlertDialog.Builder(GoogleDriveFileBrowser.this);
final EditText name = new EditText(this);
// name.setTextColor(getResources().getColor(R.color.text_green));
builder.setView(name);
......
package fieldscience.cs.earlham.edu.fieldday;
import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
public class LabNotebookFragment extends Fragment {
public LabNotebookFragment() {
......@@ -29,12 +30,6 @@ public class LabNotebookFragment extends Fragment {
Activity a;
if (context instanceof Activity){
a=(Activity) context;
}
}
@Override
public void onDetach() { super.onDetach(); }
}
\ No newline at end of file
package fieldscience.cs.earlham.edu.fieldday;
import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
......@@ -13,10 +9,15 @@ import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.ActivityCompat;
import android.view.View;
public class MainScreenActivity extends Activity {
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
public class MainScreenActivity extends AppCompatActivity {
FragmentManager fragman;
Fragment frag;
String tripName;
......@@ -33,7 +34,7 @@ public class MainScreenActivity extends Activity {
setContentView(R.layout.activity_mainscreen_frame);
context = this;
fragman = getFragmentManager();
fragman = getSupportFragmentManager();
frag = fragman.findFragmentById(R.id.mainButtonContainer);
// Check if fragment is null, and if it is, create a MainScreen fragment
......@@ -112,7 +113,7 @@ public class MainScreenActivity extends Activity {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
tripName = settings.getString("trip", "");
if (tripName.equals("")) {
Dialog d = new AlertDialog.Builder(MainScreenActivity.this, AlertDialog.THEME_HOLO_LIGHT)
Dialog d = new AlertDialog.Builder(MainScreenActivity.this)
.setTitle("No Remote Database Connection")
.setMessage("You haven't setup your database using a remote database. You won't be able " +
"to record any data, are you sure you want to continue?")
......