From c154bba553f276b879ab5d7c68e7425d16151231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=A4nge?= Date: Fri, 12 Jan 2024 12:48:25 +0100 Subject: [PATCH 1/7] Update backup api to v1.2.0 --- .../secuso/privacyfriendlypaindiary/backup/BackupCreator.kt | 4 +++- libs/privacy-friendly-backup-api | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/secuso/privacyfriendlypaindiary/backup/BackupCreator.kt b/app/src/main/java/org/secuso/privacyfriendlypaindiary/backup/BackupCreator.kt index e08767d..0c11b77 100644 --- a/app/src/main/java/org/secuso/privacyfriendlypaindiary/backup/BackupCreator.kt +++ b/app/src/main/java/org/secuso/privacyfriendlypaindiary/backup/BackupCreator.kt @@ -17,7 +17,7 @@ import java.io.OutputStreamWriter import kotlin.text.Charsets.UTF_8 class BackupCreator : IBackupCreator { - override fun writeBackup(context: Context, outputStream: OutputStream) { + override fun writeBackup(context: Context, outputStream: OutputStream): Boolean { Log.d("PFA BackupCreator", "createBackup() started") val outputStreamWriter = OutputStreamWriter(outputStream, UTF_8) val writer = JsonWriter(outputStreamWriter) @@ -45,8 +45,10 @@ class BackupCreator : IBackupCreator { } catch (e: Exception) { Log.e("PFA BackupCreator", "Error occurred", e) e.printStackTrace() + return false } Log.d("PFA BackupCreator", "Backup created successfully") + return true } } \ No newline at end of file diff --git a/libs/privacy-friendly-backup-api b/libs/privacy-friendly-backup-api index ec782fb..2548856 160000 --- a/libs/privacy-friendly-backup-api +++ b/libs/privacy-friendly-backup-api @@ -1 +1 @@ -Subproject commit ec782fb3ca894589a7be56af8acecad600b372b5 +Subproject commit 254885602ee4501a572f56306fbf2b3712cfc834 From deabfc0871a87a11cb3ec30ddb23f63812c8b3d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=A4nge?= Date: Fri, 12 Jan 2024 13:01:06 +0100 Subject: [PATCH 2/7] Fix unit tests --- app/build.gradle | 6 ++-- .../ApplicationTest.java | 17 +++++++---- .../DBServiceTest.java | 29 +++++++++---------- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 3a43c47..ac2b9db 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -28,14 +28,16 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) testImplementation 'junit:junit:4.12' androidTestImplementation 'junit:junit:4.12' - androidTestImplementation ('androidx.test.ext:junit:1.1.1') { + androidTestImplementation('androidx.test.ext:junit:1.1.1') { exclude group: 'com.android.support', module: 'support-annotations' } + androidTestImplementation('androidx.test:runner:1.5.2') + androidTestImplementation('androidx.test:core:1.5.0') implementation 'androidx.appcompat:appcompat:1.4.2' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'com.google.android.material:material:1.2.1' implementation 'com.prolificinteractive:material-calendarview:1.4.3' - implementation ("com.github.bumptech.glide:glide:4.6.1") { + implementation("com.github.bumptech.glide:glide:4.6.1") { exclude group: "com.android.support" } annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1' diff --git a/app/src/androidTest/java/org/secuso/privacyfriendlypaindiary/ApplicationTest.java b/app/src/androidTest/java/org/secuso/privacyfriendlypaindiary/ApplicationTest.java index 68c0611..543c823 100644 --- a/app/src/androidTest/java/org/secuso/privacyfriendlypaindiary/ApplicationTest.java +++ b/app/src/androidTest/java/org/secuso/privacyfriendlypaindiary/ApplicationTest.java @@ -16,14 +16,21 @@ License, or (at your option) any later version. */ package org.secuso.privacyfriendlypaindiary; -import android.app.Application; -import android.test.ApplicationTestCase; +import static org.junit.Assert.assertEquals; + +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; + +import org.junit.Test; +import org.junit.runner.RunWith; /** * Testing Fundamentals */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); +@RunWith(AndroidJUnit4.class) +public class ApplicationTest { + @Test + public void instrumentationTest() throws Exception { + assertEquals("org.secuso.privacyfriendlypaindiary", InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageName()); } } \ No newline at end of file diff --git a/app/src/androidTest/java/org/secuso/privacyfriendlypaindiary/DBServiceTest.java b/app/src/androidTest/java/org/secuso/privacyfriendlypaindiary/DBServiceTest.java index 0ad57a0..d8dddb5 100644 --- a/app/src/androidTest/java/org/secuso/privacyfriendlypaindiary/DBServiceTest.java +++ b/app/src/androidTest/java/org/secuso/privacyfriendlypaindiary/DBServiceTest.java @@ -16,14 +16,19 @@ License, or (at your option) any later version. */ package org.secuso.privacyfriendlypaindiary; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; +import static junit.framework.TestCase.assertNotNull; +import static junit.framework.TestCase.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.secuso.privacyfriendlypaindiary.database.DBService; +import org.secuso.privacyfriendlypaindiary.database.PainDiaryDatabaseService; import org.secuso.privacyfriendlypaindiary.database.entities.enums.BodyRegion; import org.secuso.privacyfriendlypaindiary.database.entities.enums.Condition; import org.secuso.privacyfriendlypaindiary.database.entities.enums.Gender; @@ -47,15 +52,9 @@ License, or (at your option) any later version. import java.util.List; import java.util.Set; -import static junit.framework.TestCase.assertNotNull; -import static junit.framework.TestCase.fail; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - /** * This class tests the basic database functionality, i.e. the methods of the class - * {@link DBService}. + * {@link PainDiaryDatabaseService}. * * @author Susanne Felsen * @version 20180110 @@ -65,17 +64,17 @@ License, or (at your option) any later version. @RunWith(AndroidJUnit4.class) public class DBServiceTest { - DBService service; + PainDiaryDatabaseService service; @Before public void setUp() { - service = DBService.getInstance(InstrumentationRegistry.getTargetContext()); - service.reinitializeDatabase(); + service = PainDiaryDatabaseService.getInstance(InstrumentationRegistry.getInstrumentation().getTargetContext()); + service.reinitializeDatabase(InstrumentationRegistry.getInstrumentation().getTargetContext()); } @After public void tearDown() throws Exception { - service.close(); + //service.close(); } @Test @@ -169,7 +168,7 @@ public void testDiaryEntryAndAssociatedObjects() { assertEquals("Times of Pain were incorrect.", timesOfPain, painDescription.getTimesOfPain()); Set intakes = entry.getDrugIntakes(); - assertEquals("Number of Drug Intakes was incorrect.", 1, intakes.size()); + assertEquals("Number of Drug Intakes was incorrect.", 1, intakes.size()); drugIntake = intakes.iterator().next(); assertEquals("Quantity Morning was incorrect.", quantityMorning, drugIntake.getQuantityMorning()); assertEquals("Quantity Noon was incorrect.", quantityNoon, drugIntake.getQuantityNoon()); From f8ef8d95cf39d59122ad98ed2d44c198f89c9a4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=A4nge?= Date: Fri, 12 Jan 2024 13:01:52 +0100 Subject: [PATCH 3/7] Replace WorkManagerInitializer with InitializationProvider in AndroidManifest.xml --- app/src/main/AndroidManifest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0a93aca..642617a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -21,8 +21,8 @@ android:theme="@style/AppTheme"> Date: Fri, 12 Jan 2024 13:05:57 +0100 Subject: [PATCH 4/7] Add ci workflow --- .github/workflows/ci.yml | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..99f0199 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,49 @@ +name: Continuous Integration +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: "recursive" + + - name: Set up JDK environment + uses: actions/setup-java@v3 + with: + distribution: "zulu" + java-version: 17 + + - name: Make gradlew executable + run: chmod +x ./gradlew + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Run local unit tests + run: bash ./gradlew test --stacktrace + + build: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: "recursive" + + - name: Set up JDK environment + uses: actions/setup-java@v3 + with: + distribution: "zulu" + java-version: 17 + + - name: Make gradlew executable + run: chmod +x ./gradlew + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Build the app + run: bash ./gradlew build --stacktrace \ No newline at end of file From 0ccc3da73677218c2093ade5a7269fa293f64ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=A4nge?= Date: Fri, 12 Jan 2024 13:24:03 +0100 Subject: [PATCH 5/7] Increase gradle heap size --- gradle.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 59d5aab..d5f83e7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,4 +17,5 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true android.useAndroidX=true -android.enableJetifier=true \ No newline at end of file +android.enableJetifier=true +org.gradle.jvmargs=-Xmx1536m \ No newline at end of file From 0d2bfdf61a041b2e4675d09eac1102bb473868b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=A4nge?= Date: Fri, 12 Jan 2024 15:14:32 +0100 Subject: [PATCH 6/7] Bump version to v1.3.1 (5) --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ac2b9db..fa7b016 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "org.secuso.privacyfriendlypaindiary" minSdkVersion 21 targetSdkVersion 31 - versionCode 4 - versionName "1.3.0" + versionCode 5 + versionName "1.3.1" testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } buildTypes { From 4cf6653dc2fced5da3271d14b77490fea77a11a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=A4nge?= Date: Fri, 12 Jan 2024 15:23:34 +0100 Subject: [PATCH 7/7] Add automatic apk file naming to build.gradle --- app/build.gradle | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index fa7b016..8666ad2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,6 +22,13 @@ android { lintOptions { abortOnError false } + + android.applicationVariants.configureEach { variant -> + variant.outputs.all { + def appName = "pfa-pain-diary" + outputFileName = appName + "-${variant.name}-v${variant.versionName}.apk" + } + } } dependencies {