Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/main' into rahul-40228461
Browse files Browse the repository at this point in the history
  • Loading branch information
dinesh-07 committed Oct 13, 2023
2 parents 97fcc67 + 6c7496d commit 7a93708
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 21 deletions.
27 changes: 26 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
apply plugin: 'com.android.application'

buildscript {
ext {
agp_version = '8.1.1'
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.2.0-beta01'
classpath "com.android.tools.build:gradle:$agp_version"
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.7.1"

}
}

Expand All @@ -17,6 +22,26 @@ allprojects {
}
}

apply plugin: "org.sonarqube"

sonarqube {
properties {
property "sonar.projectName", "OpenTracksConcordia"
property "sonar.projectKey", "OpenTracksConcordia"
property "sonar.tests", ["src/androidTest/java"]
property "sonar.test.inclusions", "*/*Test/**"
property "sonar.sourceEncoding", "UTF-8"
property "sonar.sources", "src/main/java"
property "sonar.exclusions", '*/*Test/**,' +
'*.json,' +
'*/*test/**,' +
'**/.gradle/**,' +
'**/R.class'
}
}



def getVersionName = { ->
try {
def stdout = new ByteArrayOutputStream()
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1024m
systemProp.sonar.host.url=http://localhost:9000
systemProp.sonar.login=sqp_61650630da8d6ff10b29db5c39ba42ef7feed25e

3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Sun Oct 08 22:27:07 EDT 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public void getAnnouncement_heart_rate_and_sensor_statistics() {
lastInterval = intervalStatistics.getIntervalList().get(intervalStatistics.getIntervalList().size() - 1);
}

SensorStatistics sensorStatistics = new SensorStatistics(HeartRate.of(180f), HeartRate.of(180f), null, null, null);
SensorStatistics sensorStatistics = new SensorStatistics(HeartRate.of(180f), HeartRate.of(180f), null, null, null, null);

// when
String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.METRIC, true, lastInterval, sensorStatistics).toString();
Expand Down Expand Up @@ -342,7 +342,7 @@ public void getAnnouncement_only_lap_heart_rate() {
lastInterval = intervalStatistics.getIntervalList().get(intervalStatistics.getIntervalList().size() - 1);
}

SensorStatistics sensorStatistics = new SensorStatistics(HeartRate.of(180f), HeartRate.of(180f), null, null, null);
SensorStatistics sensorStatistics = new SensorStatistics(HeartRate.of(180f), HeartRate.of(180f), null, null, null, null);

// when
String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.METRIC, true, lastInterval, sensorStatistics).toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,11 @@ public void testEditCustomLayout() {
// then only updated profile is modified in the custom layouts
List<RecordingLayout> layoutsAfter = PreferencesUtils.getAllCustomLayouts();

assertEquals(layoutsBefore.size(), 2);
assertEquals(layoutsAfter.size(), 2);
assertEquals(2, layoutsBefore.size());
assertEquals(2, layoutsAfter.size());

assertEquals(layoutsBefore.get(0).getFields().stream().filter(DataField::isVisible).count(), 4);
assertEquals(layoutsAfter.get(0).getFields().stream().filter(DataField::isVisible).count(), 1);
assertEquals(4, layoutsBefore.get(0).getFields().stream().filter(DataField::isVisible).count());
assertEquals(1, layoutsAfter.get(0).getFields().stream().filter(DataField::isVisible).count());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,16 @@ void writePace(Speed speed, StringBuilder builder, int resId, String lineBreak)
}

/**
* @param altitude_m altitude_m in meters
* @param altitudeM altitude_m in meters
* @param builder StringBuilder to append
* @param resId resource id of altitude string
* @param lineBreak line break string
*/
@VisibleForTesting
void writeAltitude(double altitude_m, StringBuilder builder, int resId, String lineBreak) {
long altitudeInM = Math.round(altitude_m);
long altitudeInFt = Math.round(Distance.of(altitude_m).toFT());
void writeAltitude(double altitudeM, StringBuilder builder, int resId, String lineBreak) {
long altitudeInM = Math.round(altitudeM);
long altitudeInFt = Math.round(Distance.of(altitudeM).toFT());
builder.append(context.getString(resId, altitudeInM, altitudeInFt));
builder.append(lineBreak);
}
}
}
23 changes: 20 additions & 3 deletions src/main/java/de/dennisguse/opentracks/share/ShareUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@
import de.dennisguse.opentracks.io.file.TrackFileFormat;
import de.dennisguse.opentracks.settings.PreferencesUtils;

class NoTracksToShareException extends RuntimeException{
public NoTracksToShareException()
{
super("Did not find any tracks to share.");
}
public NoTracksToShareException(String message)
{
super(message);
}
}

class NoMarkersToShareException extends RuntimeException {
public NoMarkersToShareException() {
super("Need to share at least one marker.");
}
}

public class ShareUtils {

private static final String TAG = ShareUtils.class.getSimpleName();
Expand All @@ -34,7 +51,7 @@ private ShareUtils() {
*/
public static Intent newShareFileIntent(Context context, Track.Id... trackIds) {
if (trackIds.length == 0) {
throw new RuntimeException("Need to share at least one track.");
throw new NoTracksToShareException("Need to share at least one track.");
}

ContentProviderUtils contentProviderUtils = new ContentProviderUtils(context);
Expand Down Expand Up @@ -80,7 +97,7 @@ public static Intent newShareFileIntent(Context context, Track.Id... trackIds) {
@Nullable
public static Intent newShareFileIntent(Context context, Marker.Id... markerIds) {
if (markerIds.length == 0) {
throw new RuntimeException("Need to share at least one marker.");
throw new NoMarkersToShareException();
}

String mime = null;
Expand All @@ -95,7 +112,7 @@ public static Intent newShareFileIntent(Context context, Marker.Id... markerIds)
}
if (marker.getPhotoURI() == null) {
Log.e(TAG, "MarkerId " + markerId.id() + " has no picture.");
continue;

}

mime = context.getContentResolver().getType(marker.getPhotoURI());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ private void requestPermission(ActivityResultCaller context, @Nullable Runnable

static {
//TODO ACCESS_BACKGROUND_LOCATION is required for API, but the permission is not properly granted. See #1653.
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// GPS_PERMISSION = List.of(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION);
// } else {
GPS_PERMISSION = List.of(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION);
// }
GPS_PERMISSION = List.of(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION);
}

private static final List<String> BLUETOOTH_PERMISSIONS;
Expand Down

0 comments on commit 7a93708

Please sign in to comment.