Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/assets/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h2>RunnerUp</h2>

<h2>3rd party software</h2>

<p><a href="https://www.android-graphview.org/">GraphView</a></p>
<p><a href="https://www.github.com/PhilJay/MPAndroidChart/">MPAndroidChart</a></p>
<p><a href="https://www.mapbox.com/">MapBox</a></p>
<p><a href="https://www.thisisant.com/developer/ant/ant-in-android">Android ANT+ SDK</a></p>

Expand Down
15 changes: 3 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ android {
lint {
baseline = file('lint-baseline.xml')
checkReleaseBuilds = true
if (mapboxEnabled) {
if (rootProject.ext.mapboxEnabled) {
lintConfig = file('lint.xml')
} else {
lintConfig = file('lint-osmdroid.xml')
Expand Down Expand Up @@ -131,7 +131,7 @@ android {

repositories {
google()
mavenCentral() //MapBox GraphView
maven { url = 'https://jitpack.io' }
if (rootProject.ext.mapboxEnabled) {
maven {
url = 'https://api.mapbox.com/downloads/v2/releases/maven'
Expand Down Expand Up @@ -177,21 +177,12 @@ dependencies {
} else {
implementation 'org.osmdroid:osmdroid-android:6.1.20'
}
latestImplementation 'com.jjoe64:graphview:4.2.2'
latestImplementation 'com.github.AppDevNext:AndroidChart:5.2.1'

testImplementation "junit:junit:${rootProject.ext.junitVersion}"
testImplementation "org.mockito:mockito-core:${rootProject.ext.mockitoVersion}"
}

allprojects {
tasks.withType(JavaCompile).tap {
configureEach {
// options.compilerArgs << "-Xlint:deprecation";
options.compilerArgs << "-Xlint:unchecked"
}
}
}

def props = new Properties()
// For locally signed builds only, Google Play signs the bundle
if (rootProject.file("release.properties").exists()) {
Expand Down
13 changes: 1 addition & 12 deletions app/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 9.3.1" type="baseline" client="gradle" dependencies="false" name="AGP (9.3.1)" variant="all" version="9.3.1">
<issues format="6" by="lint 9.4.0" type="baseline" client="gradle" dependencies="false" name="AGP (9.4.0)" variant="all" version="9.4.0">

<issue
id="UnusedAttribute"
Expand All @@ -12,17 +12,6 @@
column="9"/>
</issue>

<issue
id="AppBundleLocaleChanges"
message="Found dynamic locale changes, but did not find corresponding Play Core library calls for downloading languages and splitting by language is not disabled in the `bundle` configuration"
errorLine1=" configuration.setLocale(locale);"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/org/runnerup/util/Formatter.java"
line="830"
column="7"/>
</issue>

<issue
id="SourceLockedOrientationActivity"
message="You should not lock orientation of your activities, so that you can support a good user experience for any device or orientation"
Expand Down
5 changes: 0 additions & 5 deletions app/proguard.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
#ref to com.garmin.fit
-dontwarn com.dsi.ant.**

############################
# GraphView

-dontnote com.jjoe64.graphview.LegendRenderer

############################
# other, unknown
-dontnote Object
Expand Down
8 changes: 4 additions & 4 deletions app/res/layout/detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,21 +190,21 @@
android:layout_height="match_parent" />
</LinearLayout>

<ScrollView
<LinearLayout
android:id="@+id/tab_graph"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:scrollbars="none">
android:orientation="vertical">

<LinearLayout
android:id="@+id/graphview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_margin="@dimen/activity_margin"
android:orientation="vertical"
android:weightSum="1" />
</ScrollView>
</LinearLayout>

<LinearLayout
android:id="@+id/tab_upload"
Expand Down
1 change: 1 addition & 0 deletions app/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<resources>
<dimen name="margin_for_fab">88dp</dimen>
<dimen name="activity_margin">16dp</dimen>
<dimen name="hr_settings_chart_height">112dp</dimen>
Comment thread
gerhardol marked this conversation as resolved.

<dimen name="fab_margin_44row">20dp</dimen>
<dimen name="fab_margin_68row">44dp</dimen>
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/org/runnerup/util/DataPoint.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.runnerup.util;

public class DataPoint {
private final double x;
private final double y;

public DataPoint(double x, double y) {
this.x = x;
this.y = y;
}

public double getX() {
return x;
}

public double getY() {
return y;
}
}
132 changes: 42 additions & 90 deletions app/src/main/org/runnerup/util/Formatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Objects;
import org.runnerup.R;
import org.runnerup.common.util.Constants;
import org.runnerup.workout.Dimension;
Expand Down Expand Up @@ -74,7 +75,7 @@
Resources res = ctx.getResources();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
if (prefs.contains(res.getString(R.string.pref_audio_lang))) {
return new Locale(prefs.getString(res.getString(R.string.pref_audio_lang), "en"));

Check warning on line 78 in app/src/main/org/runnerup/util/Formatter.java

View workflow job for this annotation

GitHub Actions / build

[deprecation] Locale(String) in Locale has been deprecated
}
return null;
}
Expand Down Expand Up @@ -163,13 +164,7 @@
sharedPreferences.getString(
resources.getString(R.string.pref_speedunit), SpeedUnit.PACE.getValue());
assert speedUnit != null; // may not happen
switch (speedUnit) {
case Constants.SPEED_UNIT.SPEED:
return SpeedUnit.SPEED;
case Constants.SPEED_UNIT.PACE:
default:
return SpeedUnit.PACE;
}
return speedUnit.equals(Constants.SPEED_UNIT.SPEED) ? SpeedUnit.SPEED : SpeedUnit.PACE;
}

public double getUnitMeters() {
Expand All @@ -181,45 +176,27 @@
}

public String format(Format target, Dimension dimension, double value) {
switch (dimension) {
case DISTANCE:
return formatDistance(target, Math.round(value));
case TIME:
return formatElapsedTime(target, Math.round(value));
case PACE:
return formatPace(target, value);
case HR:
return formatHeartRate(target, value);
case HRZ:
return formatHeartRateZone(target, value);
case SPEED:
return formatSpeed(target, value);
case CAD:
return formatCadence(target, value);
case TEMPERATURE:
return formatCadence(target, value); // TODO
case PRESSURE:
return formatCadence(target, value); // TODO
}
return "";
return switch (dimension) {
case DISTANCE -> formatDistance(target, Math.round(value));
case TIME -> formatElapsedTime(target, Math.round(value));
case PACE -> formatPace(target, value);
case HR -> formatHeartRate(target, value);
case HRZ -> formatHeartRateZone(target, value);
case SPEED -> formatSpeed(target, value);
case CAD -> formatCadence(target, value);
case TEMPERATURE -> formatCadence(target, value); // TODO
case PRESSURE -> formatCadence(target, value); // TODO
};
}

public String formatElapsedTime(Format target, long seconds) {
switch (target) {
case CUE:
case CUE_SHORT:
return cueElapsedTime(seconds, false);
case CUE_LONG:
return cueElapsedTime(seconds, true);
case TXT:
case TXT_SHORT:
return DateUtils.formatElapsedTime(seconds);
case TXT_LONG:
return txtElapsedTime(seconds);
case TXT_TIMESTAMP:
return formatTime(seconds);
}
return "";
return switch (target) {
case CUE, CUE_SHORT -> cueElapsedTime(seconds, false);
case CUE_LONG -> cueElapsedTime(seconds, true);
case TXT, TXT_SHORT -> DateUtils.formatElapsedTime(seconds);
case TXT_LONG -> txtElapsedTime(seconds);
case TXT_TIMESTAMP -> formatTime(seconds);
};
}

private String cueElapsedTime(long seconds, boolean includeDimension) {
Expand Down Expand Up @@ -393,22 +370,6 @@
return "";
}

/**
* Format pace from raw pace Most of RU handles pace separately instead of just storing speed and
* formatting
*
* @param target
* @param seconds_per_meter
* @return
*/
public String formatPace(Format target, double seconds_per_meter) {
double meters_per_second =
(seconds_per_meter == 0 || Double.isNaN(seconds_per_meter))
? Double.NaN
: 1 / seconds_per_meter;
return formatPaceSpeed(target, meters_per_second);
}

/**
* Returns either a formatted value in minutes per kilometer or kilometer per hour depending on
* the user's preference
Expand All @@ -418,12 +379,12 @@
* @return display value
*/
public String formatVelocityByPreferredUnit(Format target, double meters_per_second) {
String paceTextUnit =
this.sharedPreferences.getString(
resources.getString(R.string.pref_speedunit), SpeedUnit.PACE.getValue());
assert paceTextUnit != null;
if (paceTextUnit.contentEquals(SpeedUnit.PACE.getValue())) {
return this.formatPaceSpeed(target, meters_per_second);
return formatVelocity(target, meters_per_second, getPreferredSpeedUnit());
}

public String formatVelocity(Format target, double meters_per_second, SpeedUnit unit) {
if (unit == SpeedUnit.PACE) {
return this.formatPace(target, meters_per_second);
} else {
return this.formatSpeed(target, meters_per_second);
}
Expand All @@ -435,11 +396,11 @@
* @return value
*/
public String formatVelocityLabel() {
String paceTextUnit =
this.sharedPreferences.getString(
resources.getString(R.string.pref_speedunit), SpeedUnit.PACE.getValue());
assert paceTextUnit != null;
if (paceTextUnit.contentEquals(SpeedUnit.PACE.getValue())) {
return formatVelocityLabel(getPreferredSpeedUnit());
}

public String formatVelocityLabel(SpeedUnit unit) {
if (unit == SpeedUnit.PACE) {
return this.resources.getString(org.runnerup.common.R.string.Pace);
} else {
return this.resources.getString(org.runnerup.common.R.string.Speed);
Expand All @@ -453,32 +414,23 @@
* @param meters_per_second speed in m/s
* @return
*/
public String formatPaceSpeed(Format target, double meters_per_second) {
switch (target) {
case CUE:
case CUE_SHORT:
case CUE_LONG:
return cuePace(meters_per_second);
case TXT:
case TXT_SHORT:
return txtPace(meters_per_second, false);
case TXT_LONG:
return txtPace(meters_per_second, true);
}
return "";
public String formatPace(Format target, double meters_per_second) {
return switch (target) {
case CUE, CUE_SHORT, CUE_LONG -> cuePace(meters_per_second);
case TXT, TXT_SHORT -> txtPace(meters_per_second, false);
case TXT_LONG -> txtPace(meters_per_second, true);
default -> "";
};
}

/**
* @return pace/speed unit string
*/
String getVelocityUnit() { // Resources resources, SharedPreferences sharedPreferences) {
switch (getPreferredSpeedUnit()) {
case SPEED:
return getSpeedUnit();
case PACE:
default:
return getPaceUnit();
}
SpeedUnit preferredSpeedUnit = getPreferredSpeedUnit();
return Objects.requireNonNull(preferredSpeedUnit) == SpeedUnit.SPEED
? getSpeedUnit()
: getPaceUnit();
}

private String getPaceUnit() {
Expand Down
Loading
Loading