diff --git a/app/build.gradle b/app/build.gradle index 22a54dd7..8e30b7c6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "com.secuso.privacyFriendlyCodeScanner" minSdkVersion 17 targetSdkVersion 29 - versionCode 19 - versionName "3.0.4" + versionCode 20 + versionName "3.1.0" testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' buildFeatures.dataBinding = true vectorDrawables.useSupportLibrary = true @@ -42,9 +42,9 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'com.google.android.material:material:1.2.1' - implementation 'androidx.constraintlayout:constraintlayout:2.0.1' + implementation 'androidx.constraintlayout:constraintlayout:2.0.2' implementation 'androidx.cardview:cardview:1.0.0' - testImplementation 'junit:junit:4.12' + testImplementation 'junit:junit:4.13.1' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' diff --git a/app/src/androidTest/java/com/secuso/privacyfriendlycodescanner/qrscanner/DatabaseMigrationInstrumentedTest.java b/app/src/androidTest/java/com/secuso/privacyfriendlycodescanner/qrscanner/DatabaseMigrationInstrumentedTest.java index 3e1d9045..4e50f38b 100644 --- a/app/src/androidTest/java/com/secuso/privacyfriendlycodescanner/qrscanner/DatabaseMigrationInstrumentedTest.java +++ b/app/src/androidTest/java/com/secuso/privacyfriendlycodescanner/qrscanner/DatabaseMigrationInstrumentedTest.java @@ -1,12 +1,13 @@ package com.secuso.privacyfriendlycodescanner.qrscanner; -import android.arch.persistence.db.SupportSQLiteDatabase; -import android.arch.persistence.db.framework.FrameworkSQLiteOpenHelperFactory; -import android.arch.persistence.room.Room; -import android.arch.persistence.room.testing.MigrationTestHelper; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; + +import androidx.room.Room; +import androidx.room.testing.MigrationTestHelper; +import androidx.sqlite.db.SupportSQLiteDatabase; +import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory; +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; import com.secuso.privacyfriendlycodescanner.qrscanner.database.AppDatabase; import com.secuso.privacyfriendlycodescanner.qrscanner.database.DBHandler; @@ -49,26 +50,26 @@ public class DatabaseMigrationInstrumentedTest { @Test public void useAppContext() throws Exception { // Context of the app under test. - Context appContext = InstrumentationRegistry.getTargetContext(); + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); assertEquals("com.secuso.privacyfriendlycodescanner.qrscanner", appContext.getPackageName()); } @Before public void prepareDatabase() { - InstrumentationRegistry.getTargetContext().deleteDatabase(TEST_DB_NAME); + InstrumentationRegistry.getInstrumentation().getTargetContext().deleteDatabase(TEST_DB_NAME); } @After public void deleteDatabase() { - InstrumentationRegistry.getTargetContext().deleteDatabase(TEST_DB_NAME); + InstrumentationRegistry.getInstrumentation().getTargetContext().deleteDatabase(TEST_DB_NAME); } @Test public void testMigrationToRoomDatabase_1_2() throws Exception { // Create the old database with version 1 - DBHandler dbHandler = new DBHandler(InstrumentationRegistry.getTargetContext(), TEST_DB_NAME); + DBHandler dbHandler = new DBHandler(InstrumentationRegistry.getInstrumentation().getTargetContext(), TEST_DB_NAME); dbHandler.addContent(data1); dbHandler.addContent(data2); @@ -107,7 +108,7 @@ public void testMigrationToRoomDatabase_1_2() throws Exception { } private AppDatabase getMigratedRoomDatabase() { - AppDatabase database = Room.databaseBuilder(InstrumentationRegistry.getTargetContext(), + AppDatabase database = Room.databaseBuilder(InstrumentationRegistry.getInstrumentation().getTargetContext(), AppDatabase.class, TEST_DB_NAME) .addMigrations(AppDatabase.MIGRATIONS) .build(); diff --git a/app/src/main/java/com/secuso/privacyFriendlyCodeScanner/qrscanner/ui/viewmodel/HistoryViewModel.java b/app/src/main/java/com/secuso/privacyFriendlyCodeScanner/qrscanner/ui/viewmodel/HistoryViewModel.java index bcdd44ab..f40c36ea 100644 --- a/app/src/main/java/com/secuso/privacyFriendlyCodeScanner/qrscanner/ui/viewmodel/HistoryViewModel.java +++ b/app/src/main/java/com/secuso/privacyFriendlyCodeScanner/qrscanner/ui/viewmodel/HistoryViewModel.java @@ -6,6 +6,7 @@ import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.MediatorLiveData; +import androidx.lifecycle.MutableLiveData; import com.secuso.privacyfriendlycodescanner.qrscanner.database.AppRepository; import com.secuso.privacyfriendlycodescanner.qrscanner.database.HistoryItem; @@ -18,7 +19,7 @@ public class HistoryViewModel extends AndroidViewModel { private ExecutorService executorService = Executors.newSingleThreadExecutor(); - private MediatorLiveData> historyItemsLiveData = new MediatorLiveData<>(); + private final MediatorLiveData> historyItemsLiveData = new MediatorLiveData<>(); public HistoryViewModel(@NonNull final Application application) { super(application); @@ -31,14 +32,7 @@ public LiveData> getHistoryItems() { } private void loadHistories() { - executorService.execute(() -> { - LiveData> historyEntries = AppRepository.getInstance(getApplication()).getHistoryEntriesLiveData(); - - //TODO: this has to be done on the ui thread - historyItemsLiveData.addSource(historyEntries, data -> { - //Log.d("HistoryViewModel", "### \t\t ### \t Number of History Items: \t" + data.size()); - historyItemsLiveData.setValue((List) data); - }); - }); + LiveData> historyEntries = AppRepository.getInstance(getApplication()).getHistoryEntriesLiveData(); + historyItemsLiveData.addSource(historyEntries, historyItemsLiveData::setValue); } } diff --git a/build.gradle b/build.gradle index 2deb66dd..0ae0de5c 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:4.0.1' + classpath 'com.android.tools.build:gradle:4.1.0' // NOTE: Do not place your application dependencies here; they belong diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 514b0fe5..3287d83d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Oct 06 16:40:04 CEST 2020 +#Wed Oct 21 09:18:59 CEST 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip