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

Merge branch 'api-29-and-other-updates' into 'master'

fixes some out-of-date code and warnings

Closes #32

See merge request !15
parents 0bf59634 5c1ed097
......@@ -26,7 +26,7 @@ public class AboutFragment extends Fragment {
}
@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);
}
}
\ No newline at end of file
......@@ -16,7 +16,7 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceManager;
import androidx.preference.PreferenceManager;
import android.provider.MediaStore;
import android.text.Editable;
import android.text.TextWatcher;
......
......@@ -52,7 +52,7 @@ public class BluetoothLeService extends Service {
for (BluetoothGattService s : btSensor.getServices()){
if (s.getUuid().equals(UUID_BLE_SENSOR_SERVICE)) {
BluetoothGattService gattService = btSensor.getService(UUID_BLE_SENSOR_SERVICE);
btSensor.setPrimaryService(gattService);
//btSensor.setPrimaryService(gattService);
btSensor.setCharacteristics(
gattService.getCharacteristic(UUID_BLE_SENSOR_REQUEST),
gattService.getCharacteristic(UUID_BLE_SENSOR_VALUE));
......
......@@ -9,6 +9,7 @@ import android.os.Parcelable;
import android.util.Log;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
public class BluetoothSensor implements Parcelable {
......@@ -59,8 +60,7 @@ public class BluetoothSensor implements Parcelable {
gattClient.readCharacteristic(readChar);
}
public void setPrimaryService(BluetoothGattService service){
}
//public void setPrimaryService(BluetoothGattService service){ }
public void setCharacteristics(BluetoothGattCharacteristic writeChar, BluetoothGattCharacteristic readChar){
this.writeChar = writeChar;
......@@ -135,7 +135,7 @@ public class BluetoothSensor implements Parcelable {
public static final Parcelable.Creator<BluetoothSensor> CREATOR = new Parcelable.Creator<BluetoothSensor>() {
public BluetoothSensor createFromParcel(Parcel in) {
BluetoothDevice bt = in.readParcelable(((Object) this).getClass().getClassLoader());
return new BluetoothSensor(bt);
return new BluetoothSensor(Objects.requireNonNull(bt));
}
public BluetoothSensor[] newArray(int size) {
return new BluetoothSensor[size];
......
......@@ -13,7 +13,7 @@ import android.database.Cursor;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import androidx.preference.PreferenceManager;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.format.Formatter;
......
......@@ -25,7 +25,7 @@ public class LabNotebookFragment extends Fragment {
}
@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.preference.PreferenceManager;
import androidx.preference.PreferenceManager;
import android.view.View;
import androidx.appcompat.app.AlertDialog;
......
......@@ -25,7 +25,7 @@ public class MainScreenFragment extends Fragment {
}
@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);
}
}
......@@ -11,7 +11,6 @@ import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Objects;
......@@ -48,8 +47,6 @@ public class MyDocumentViewer extends AppCompatActivity {
Bitmap pdf = Bitmap.createBitmap(page.getWidth(), page.getHeight(), Bitmap.Config.ARGB_8888);
page.render(pdf, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY);
docImageView.setImageBitmap(pdf);
} catch (FileNotFoundException e){
e.printStackTrace();
} catch (IOException e){
e.printStackTrace();
}
......
......@@ -7,7 +7,7 @@ import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceManager;
import androidx.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
......@@ -29,7 +29,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
......@@ -342,10 +341,7 @@ public class MyDocumentsActivity extends AppCompatActivity {
}
fileOutputStream.close();
}
} catch(MalformedURLException e) {
e.printStackTrace();
return false;
} catch (IOException e) {
} catch(IOException e) {
e.printStackTrace();
return false;
}
......
......@@ -26,7 +26,7 @@ import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.preference.PreferenceManager;
import androidx.preference.PreferenceManager;
import android.provider.MediaStore;
import android.text.Editable;
import android.text.TextWatcher;
......
......@@ -12,7 +12,9 @@ import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
public class SettingsFragment extends PreferenceFragmentCompat {
import java.util.Objects;
public class SettingsFragment extends PreferenceFragmentCompat {
static String shortDeviceID = (Build.SERIAL).substring((Build.SERIAL).length()-4);
private CheckBoxPreference writeWithoutGPS;
......@@ -23,8 +25,8 @@ import androidx.preference.PreferenceManager;
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
writeWithoutGPS = (CheckBoxPreference) findPreference("Only write file if GPS signal is present");
writeWithoutGPS.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
writeWithoutGPS = findPreference("Only write file if GPS signal is present");
Objects.requireNonNull(writeWithoutGPS).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
SharedPreferences prefs = getSettings(getActivity());
......@@ -39,8 +41,8 @@ import androidx.preference.PreferenceManager;
}
});
EditTextPreference transfer = (EditTextPreference) findPreference(getString(R.string.transfer_url_title));
transfer.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
EditTextPreference transfer = findPreference(getString(R.string.transfer_url_title));
Objects.requireNonNull(transfer).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String url = (String) newValue;
......@@ -65,13 +67,13 @@ import androidx.preference.PreferenceManager;
//Find and display current info.
Preference deviceModel = findPreference(getString(R.string.device_model));
deviceModel.setSummary(Build.MODEL);
Objects.requireNonNull(deviceModel).setSummary(Build.MODEL);
Preference deviceID = findPreference(getString(R.string.device_id));
deviceID.setSummary(Build.SERIAL);
Objects.requireNonNull(deviceID).setSummary(Build.SERIAL);
Preference buildInfo = findPreference(getString(R.string.build_info));
buildInfo.setSummary(BuildConfig.VERSION_NAME);
Objects.requireNonNull(buildInfo).setSummary(BuildConfig.VERSION_NAME);
}
@Override
......
......@@ -4,6 +4,8 @@ import android.hardware.Sensor;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.NonNull;
import static java.lang.Math.round;
public class aSensor implements Parcelable {
......@@ -47,6 +49,7 @@ public class aSensor implements Parcelable {
this.platform = platform;
}
@NonNull
public String toString() {
return sensor.toString();
}
......
......@@ -14,5 +14,5 @@
android:layout_height="wrap_content"
android:layout_below="@+id/textView"
android:layout_alignParentStart="true"
android:text="Contributors: Eli Ramthun, Charlie Peck, Kristin Muterspaw, Nic Arnold, Chau Pham, Jordan Christian, Porter Libby, Lillian Gray, Craig Earley, Roger Lu, Mubtasim Talha, Xunfei Jiang_Mac, Yanzhi Li" />
android:text="@string/contributor_list" />
</RelativeLayout>
\ No newline at end of file
......@@ -113,5 +113,6 @@
<string name="refresh">Refresh</string>
<string name="scan">Scan</string>
<string name="about_field_day">About Field Day</string>
<string name="contributor_list">Contributors: Eli Ramthun, Charlie Peck, Kristin Muterspaw, Nic Arnold, Chau Pham, Jordan Christian, Porter Libby, Lillian Gray, Craig Earley, Roger Lu, Mubtasim Talha, Xunfei Jiang_Mac, Yanzhi Li</string>
</resources>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment