Skip to content

Commit

Permalink
Merge pull request #37 from SecUSo/development
Browse files Browse the repository at this point in the history
Update to version 1.3.1
  • Loading branch information
udenr authored Jan 17, 2024
2 parents 81b614f + 4cf6653 commit f680a0d
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 29 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 13 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -22,20 +22,29 @@ 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 {
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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -169,7 +168,7 @@ public void testDiaryEntryAndAssociatedObjects() {
assertEquals("Times of Pain were incorrect.", timesOfPain, painDescription.getTimesOfPain());

Set<DrugIntakeInterface> 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());
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
android:theme="@style/AppTheme">

<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="${applicationId}.workmanager-init"
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
tools:node="remove" />

<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
}
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
android.enableJetifier=true
org.gradle.jvmargs=-Xmx1536m

0 comments on commit f680a0d

Please sign in to comment.