Skip to content
Open
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
32 changes: 22 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 30
compileSdkVersion 33
namespace 'org.emstrack.ambulance'
// buildToolsVersion '27.0.3'
defaultConfig {
applicationId 'org.emstrack.ambulance'
minSdkVersion 17
targetSdkVersion 30
minSdkVersion 19
targetSdkVersion 33
versionCode 10
versionName "0.6.5"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -25,25 +26,36 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

buildFeatures {
buildConfig true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
productFlavors {
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')

androidTestImplementation 'androidx.test:core:1.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test:core:1.6.1'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})

implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-location:21.3.0'
implementation 'com.google.android.gms:play-services-maps:19.2.0'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
// implementation 'com.google.android.gms:play-services-ads:17.1.3'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
Expand All @@ -69,5 +81,5 @@ dependencies {

implementation project(':models')
implementation project(':mqtt')
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13.2'
}
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package="org.emstrack.ambulance">
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Expand All @@ -25,7 +26,8 @@
tools:ignore="GoogleAppIndexingWarning">

<activity android:name="org.emstrack.ambulance.LoginActivity"
android:screenOrientation="nosensor">
android:screenOrientation="nosensor"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,20 +359,20 @@ public int onStartCommand(Intent intent, int flags, int startId) {
Intent notificationIntent = new Intent(AmbulanceForegroundService.this, LoginActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(AmbulanceForegroundService.this, 0,
notificationIntent, 0);
notificationIntent, PendingIntent.FLAG_IMMUTABLE);

// Restart intent
Intent restartServiceIntent = new Intent(AmbulanceForegroundService.this, LoginActivity.class);
restartServiceIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
restartServiceIntent.setAction(LoginActivity.LOGOUT);
PendingIntent restartServicePendingIntent = PendingIntent.getActivity(AmbulanceForegroundService.this, 0,
restartServiceIntent, 0);
restartServiceIntent, PendingIntent.FLAG_IMMUTABLE);

// Stop intent
Intent stopServiceIntent = new Intent(AmbulanceForegroundService.this, AmbulanceForegroundService.class);
stopServiceIntent.setAction(Actions.STOP_SERVICE);
PendingIntent stopServicePendingIntent = PendingIntent.getService(AmbulanceForegroundService.this, 0,
stopServiceIntent, 0);
stopServiceIntent, PendingIntent.FLAG_IMMUTABLE);

// Icon
Bitmap icon = BitmapFactory.decodeResource(getResources(),
Expand Down Expand Up @@ -1328,15 +1328,15 @@ public void updateNotification(String message) {
LoginActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(AmbulanceForegroundService.this, 0,
notificationIntent, 0);
notificationIntent, PendingIntent.FLAG_IMMUTABLE);

// Stop intent
Intent stopServiceIntent = new Intent(AmbulanceForegroundService.this,
LoginActivity.class);
stopServiceIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
stopServiceIntent.setAction(LoginActivity.LOGOUT);
PendingIntent stopServicePendingIntent = PendingIntent.getActivity(AmbulanceForegroundService.this, 0,
stopServiceIntent, 0);
stopServiceIntent, PendingIntent.FLAG_IMMUTABLE);

Notification notification =
new NotificationCompat.Builder(this,
Expand Down Expand Up @@ -3047,7 +3047,7 @@ public void subscribeToWebRTC() throws MqttException {
Intent notificationIntent = new Intent(AmbulanceForegroundService.this, LoginActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(AmbulanceForegroundService.this, 0,
notificationIntent, 0);
notificationIntent, PendingIntent.FLAG_IMMUTABLE);

// Create notification
NotificationCompat.Builder mBuilder =
Expand Down Expand Up @@ -4382,7 +4382,7 @@ public void processNextCall() {
Intent notificationIntent = new Intent(AmbulanceForegroundService.this, LoginActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(AmbulanceForegroundService.this, 0,
notificationIntent, 0);
notificationIntent, PendingIntent.FLAG_IMMUTABLE);

// Create notification
NotificationCompat.Builder mBuilder =
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.android.tools.build:gradle:8.9.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -16,7 +16,7 @@ buildscript {
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Jun 01 15:24:31 PDT 2020
#Tue Apr 29 17:54:58 PDT 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
28 changes: 14 additions & 14 deletions models/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 29
compileSdkVersion 33
namespace 'org.emstrack.models'

defaultConfig {
minSdkVersion 17
targetSdkVersion 29
versionCode 1
versionName "1.0"
minSdkVersion 19
targetSdkVersion 33

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand All @@ -20,8 +19,8 @@ android {
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
testOptions {
unitTests {
Expand All @@ -33,13 +32,14 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.0'
testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:4.6'
testImplementation 'androidx.test:core:1.0.0'

androidTestImplementation 'androidx.test:core:1.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation 'androidx.test:rules:1.6.1'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.robolectric:robolectric:4.14'
testImplementation 'androidx.test:core:1.6.1'

androidTestImplementation 'androidx.test:core:1.6.1'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
api 'com.google.code.gson:gson:2.8.0'

api 'com.squareup.retrofit2:retrofit:2.5.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import android.content.Context;

import androidx.test.annotation.UiThreadTest;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import android.test.UiThreadTest;

import android.util.Log;

import org.emstrack.models.api.APIService;
Expand Down Expand Up @@ -47,7 +48,7 @@ public void test_retrofit() throws Exception {
Log.d(TAG, "api");

String username = "admin";
String password = "cruzrojaadmin";
String password = "cruzr0j4";
String serverURI = "https://cruzroja.ucsd.edu/";
Credentials credentials = new Credentials(username, password, serverURI, "");

Expand Down
1 change: 1 addition & 0 deletions models/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<resources>
<string name="app_name" translatable="false">models</string>
<string name="loginpassword">cruzr0j4</string>
</resources>
8 changes: 4 additions & 4 deletions models/src/test/java/org/emstrack/models/TestAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void testApi() throws Exception {
APIService service = APIServiceGenerator.createService(APIService.class);

String username = "admin";
String password = "cruzrojaadmin";
String password = "cruzr0j4";
String serverURI = "https://cruzroja.ucsd.edu/en/";
Credentials credentials = new Credentials(username, password, serverURI, "");

Expand Down Expand Up @@ -101,7 +101,7 @@ public void testAsyncApi() throws InterruptedException {
APIService service = APIServiceGenerator.createService(APIService.class);

String username = "admin";
String password = "cruzrojaadmin";
String password = "cruzr0j4";
String serverURI = "https://cruzroja.ucsd.edu/";
Credentials credentials = new Credentials(username, password, serverURI, "");

Expand Down Expand Up @@ -132,7 +132,7 @@ public void testAsyncApiCascaded() throws InterruptedException {
APIService service = APIServiceGenerator.createService(APIService.class);

String username = "admin";
String password = "cruzrojaadmin";
String password = "cruzr0j4";
String serverURI = "https://cruzroja.ucsd.edu/";
Credentials credentials = new Credentials(username, password, serverURI, "");

Expand Down Expand Up @@ -197,7 +197,7 @@ public void onSuccess(Profile p) {
public void testAsyncApiCascaded2() throws InterruptedException {

String username = "admin";
String password = "cruzrojaadmin";
String password = "cruzr0j4";
String serverURI = "https://cruzroja.ucsd.edu/";
Credentials credentials = new Credentials(username, password, serverURI, "");

Expand Down
6 changes: 5 additions & 1 deletion models/src/test/java/org/emstrack/models/TestModels.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public void test_profile() {
profile.setHospitals(hospitals);

GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.setDateFormat("MMM d, y K:mm:ss a");
gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
Gson gson = gsonBuilder.create();

Expand Down Expand Up @@ -316,6 +317,7 @@ public void test_settings() {
defaults);

GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.setDateFormat("MMM d, y K:mm:ss a");
gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
Gson gson = gsonBuilder.create();

Expand Down Expand Up @@ -500,7 +502,7 @@ public void test_ambulance() {
assertEquals(df.format(expectedDate), df.format(answerDate));

// Test partial serialization
gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
gson = new GsonBuilder().setDateFormat("MMM d, y K:mm:ss a").excludeFieldsWithoutExposeAnnotation().create();

to_json = gson.toJson(ambulance);

Expand Down Expand Up @@ -804,6 +806,7 @@ public void test_ambulance_call() {
AmbulanceCall ambulanceCall = new AmbulanceCall(1,2,AmbulanceCall.STATUS_SUSPENDED, "", 1, new Date(), waypointSet);

GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.setDateFormat("MMM d, y K:mm:ss a");
gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
Gson gson = gsonBuilder.create();

Expand Down Expand Up @@ -922,6 +925,7 @@ public void test_call() {
double epsilon = 1e-4;

GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.setDateFormat("MMM d, y K:mm:ss a");
gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
Gson gson = gsonBuilder.create();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import android.os.Build;
import android.os.Bundle;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import android.os.Looper;
import android.util.Log;

import org.emstrack.models.util.BroadcastActions;
Expand All @@ -26,6 +28,7 @@
import static junit.framework.Assert.assertNotNull;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertSame;
import static org.robolectric.Shadows.shadowOf;

@RunWith(RobolectricTestRunner.class)
@Config(sdk=Build.VERSION_CODES.P)
Expand Down Expand Up @@ -73,6 +76,7 @@ public void onReceive(Context context, Intent intent) {
instance.sendBroadcast(new Intent("com.bar"));
assertFalse(called[0]);
instance.sendBroadcast(new Intent("com.foo"));
shadowOf(Looper.getMainLooper()).idle();
assertTrue(called[0]);
}

Expand Down
4 changes: 2 additions & 2 deletions models/src/test/java/org/emstrack/models/TestRetrofit.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void test_retrofit() throws Exception {
System.out.println("servers = " + servers);

String username = "admin";
String password = "cruzrojaadmin";
String password = "cruzr0j4";
String serverURI = "https://cruzroja.ucsd.edu/";
Credentials credentials = new Credentials(username, password, serverURI, "");

Expand Down Expand Up @@ -73,7 +73,7 @@ public void test_retrofit_with_credentials() throws Exception {

System.out.println("test_retrofit_with_credentials()");

Credentials credentials = new Credentials("admin", "cruzrojaadmin",
Credentials credentials = new Credentials("admin", "cruzr0j4",
"https://cruzroja.ucsd.edu", "");

// Retrieve token
Expand Down
Loading