Code cleanup using AndroidStudio's Analyze feature.

This commit is contained in:
Dennis Guse
2020-12-05 23:22:15 +01:00
parent be1b6ece9d
commit cea180f871
14 changed files with 28 additions and 30 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ cp "$CHANGELOG_DIR/next_release.txt" "$CHANGELOG_FILE"
sed -i "s/(versionName)/$VERSIONNAME/" "$CHANGELOG_FILE" sed -i "s/(versionName)/$VERSIONNAME/" "$CHANGELOG_FILE"
echo -e "\nGit commit since last release\n------------" echo -e "\nGit commit since last release\n------------"
git log $(git describe --tags --abbrev=0)..HEAD --no-merges --oneline git log "$(git describe --tags --abbrev=0)..HEAD" --no-merges --oneline
echo -e "\nPlease edit the changelog for the new release" echo -e "\nPlease edit the changelog for the new release"
gedit -w "$CHANGELOG_FILE" gedit -w "$CHANGELOG_FILE"
@@ -9,7 +9,7 @@ import org.junit.Test;
*/ */
public class ElevationSumManagerTest { public class ElevationSumManagerTest {
private ElevationSumManager elevationSumManager = new ElevationSumManager(); private final ElevationSumManager elevationSumManager = new ElevationSumManager();
private static void addSensorValue(ElevationSumManager elevationSumManager, float[] values) { private static void addSensorValue(ElevationSumManager elevationSumManager, float[] values) {
for (float f : values) { for (float f : values) {
@@ -73,7 +73,7 @@ public class MarkerEditActivity extends AbstractActivity {
private Uri photoUri; private Uri photoUri;
private Uri photoUriOriginal; private Uri photoUriOriginal;
private List<Uri> photoUriDeleteList = new ArrayList<>(); private final List<Uri> photoUriDeleteList = new ArrayList<>();
private boolean hasCamera; private boolean hasCamera;
private boolean isNewMarker; private boolean isNewMarker;
@@ -360,7 +360,7 @@ public class ExportActivity extends FragmentActivity implements ExportServiceRes
public boolean resolve() { public boolean resolve() {
if (autoConflict == CONFLICT_NONE) { if (autoConflict == CONFLICT_NONE) {
Track track = contentProviderUtils.getTrack(trackId); Track track = contentProviderUtils.getTrack(trackId);
viewBinding.exportProgressAlertIcon.setImageDrawable(getDrawable(R.drawable.ic_report_problem_24)); viewBinding.exportProgressAlertIcon.setImageDrawable(ContextCompat.getDrawable(ExportActivity.this, R.drawable.ic_report_problem_24));
viewBinding.exportProgressAlertMsg.setText(getString(R.string.export_track_already_exists_msg, track.getName())); viewBinding.exportProgressAlertMsg.setText(getString(R.string.export_track_already_exists_msg, track.getName()));
setConflictVisibility(View.VISIBLE); setConflictVisibility(View.VISIBLE);
return false; return false;
@@ -53,7 +53,7 @@ public class KmzTrackExporter implements TrackExporter {
private final FileTrackExporter fileTrackExporter; private final FileTrackExporter fileTrackExporter;
private final boolean exportPhotos; private final boolean exportPhotos;
private Context context; private final Context context;
/** /**
* Constructor. * Constructor.
@@ -24,6 +24,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.documentfile.provider.DocumentFile; import androidx.documentfile.provider.DocumentFile;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
@@ -161,12 +162,12 @@ public class ImportActivity extends FragmentActivity {
viewBinding.importProgressLeftButton.setVisibility(View.VISIBLE); viewBinding.importProgressLeftButton.setVisibility(View.VISIBLE);
viewBinding.importProgressLeftButton.setText(getString(R.string.generic_show_errors)); viewBinding.importProgressLeftButton.setText(getString(R.string.generic_show_errors));
viewBinding.importProgressLeftButton.setOnClickListener((view) -> ErrorListDialog.showDialog(getSupportFragmentManager(), getString(R.string.import_error_list_dialog_title), summary.getFileErrors())); viewBinding.importProgressLeftButton.setOnClickListener((view) -> ErrorListDialog.showDialog(getSupportFragmentManager(), getString(R.string.import_error_list_dialog_title), summary.getFileErrors()));
viewBinding.importProgressAlertIcon.setImageDrawable(getDrawable(R.drawable.ic_report_problem_24)); viewBinding.importProgressAlertIcon.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_report_problem_24));
String msg = getResources().getQuantityString(R.plurals.generic_completed_with_errors, summary.getErrorCount(), summary.getErrorCount()); String msg = getResources().getQuantityString(R.plurals.generic_completed_with_errors, summary.getErrorCount(), summary.getErrorCount());
viewBinding.importProgressAlertMsg.setText(msg); viewBinding.importProgressAlertMsg.setText(msg);
} else { } else {
viewBinding.importProgressLeftButton.setVisibility(View.GONE); viewBinding.importProgressLeftButton.setVisibility(View.GONE);
viewBinding.importProgressAlertIcon.setImageDrawable(getDrawable(R.drawable.ic_dialog_success_24dp)); viewBinding.importProgressAlertIcon.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_dialog_success_24dp));
viewBinding.importProgressAlertMsg.setText(getString(R.string.generic_completed)); viewBinding.importProgressAlertMsg.setText(getString(R.string.generic_completed));
} }
} }
@@ -63,12 +63,12 @@ public class KmlFileTrackImporter extends AbstractFileTrackImporter {
private boolean trackStarted = false; private boolean trackStarted = false;
private String extendedDataType; private String extendedDataType;
private ArrayList<TrackPoint> trackPoints = new ArrayList<>(); private final ArrayList<TrackPoint> trackPoints = new ArrayList<>();
private ArrayList<Float> speedList = new ArrayList<>(); private final ArrayList<Float> speedList = new ArrayList<>();
private ArrayList<Float> cadenceList = new ArrayList<>(); private final ArrayList<Float> cadenceList = new ArrayList<>();
private ArrayList<Float> heartRateList = new ArrayList<>(); private final ArrayList<Float> heartRateList = new ArrayList<>();
private ArrayList<Float> powerList = new ArrayList<>(); private final ArrayList<Float> powerList = new ArrayList<>();
private ArrayList<Float> elevationGainList = new ArrayList<>(); private final ArrayList<Float> elevationGainList = new ArrayList<>();
public KmlFileTrackImporter(Context context) { public KmlFileTrackImporter(Context context) {
this(context, new ContentProviderUtils(context)); this(context, new ContentProviderUtils(context));
@@ -25,7 +25,7 @@ class GpsStatus {
private GpsStatusValue gpsStatus = GpsStatusValue.GPS_NONE; private GpsStatusValue gpsStatus = GpsStatusValue.GPS_NONE;
private GpsStatusListener client; private GpsStatusListener client;
private Context context; private final Context context;
// Last location. It can be null. // Last location. It can be null.
private Location lastLocation = null; private Location lastLocation = null;
@@ -51,7 +51,7 @@ class GpsStatus {
} }
} }
private Handler gpsStatusHandler; private final Handler gpsStatusHandler;
private GpsStatusRunner gpsStatusRunner = null; private GpsStatusRunner gpsStatusRunner = null;
/** /**
@@ -12,7 +12,7 @@ import de.dennisguse.opentracks.content.data.TrackPoint;
public class HandlerServer { public class HandlerServer {
private static String TAG = HandlerServer.class.getSimpleName(); private static final String TAG = HandlerServer.class.getSimpleName();
private final LocationHandler locationHandler; private final LocationHandler locationHandler;
private final HandlerServerInterface service; private final HandlerServerInterface service;
@@ -5,18 +5,18 @@ import android.hardware.SensorManager;
public class PressureSensorUtils { public class PressureSensorUtils {
//Everything above is considered a meaningful change in elevation. //Everything above is considered a meaningful change in elevation.
private static float ELEVATION_CHANGE_DIFF_M = 3.0f; private static final float ELEVATION_CHANGE_DIFF_M = 3.0f;
private static float EXPONENTIAL_SMOOTHING = 0.3f; private static final float EXPONENTIAL_SMOOTHING = 0.3f;
private PressureSensorUtils() { private PressureSensorUtils() {
} }
public static class ElevationChange { public static class ElevationChange {
private float currentSensorValue_hPa; private final float currentSensorValue_hPa;
private float elevationChange_m; private final float elevationChange_m;
public ElevationChange(float currentSensorValue_hPa, float elevationChange_m) { public ElevationChange(float currentSensorValue_hPa, float elevationChange_m) {
this.currentSensorValue_hPa = currentSensorValue_hPa; this.currentSensorValue_hPa = currentSensorValue_hPa;
@@ -8,7 +8,7 @@ import de.dennisguse.opentracks.util.LocationUtils;
import de.dennisguse.opentracks.util.UnitConversions; import de.dennisguse.opentracks.util.UnitConversions;
public class IntervalStatistics { public class IntervalStatistics {
private List<Interval> intervalList = new ArrayList<>(); private final List<Interval> intervalList = new ArrayList<>();
private float distanceInterval_m; private float distanceInterval_m;
/** /**
+4 -7
View File
@@ -20,21 +20,18 @@
<View <View
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent" />
android:layout_weight="1" />
<TextView <TextView
style="@style/TextLarge" style="@style/TextLarge"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="4"
android:gravity="center_horizontal|center_vertical" android:gravity="center_horizontal|center_vertical"
android:text="@string/aggregated_stats_empty_message" /> android:text="@string/aggregated_stats_empty_message" />
<View <View
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent" />
android:layout_weight="1" />
</RelativeLayout> </RelativeLayout>
+1 -1
View File
@@ -14,7 +14,7 @@
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_weight="1" android:layout_weight="1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="0dp">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_weight="1" android:layout_weight="1"
+1 -1
View File
@@ -12,7 +12,7 @@
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_weight="1" android:layout_weight="1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="0dp">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_weight="1" android:layout_weight="1"