From c917dc13dabe7781a097383ae89f2d00f32fffcb Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 5 Mar 2019 18:31:47 -0500 Subject: Create initial room models --- gradle.properties | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gradle.properties') diff --git a/gradle.properties b/gradle.properties index f95fed2b..98f29dbe 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,7 @@ APP_ID=Frost APP_GROUP=com.pitchedapps KAU=4.0.0-alpha02 -KOTLIN=1.3.11 +KOTLIN=1.3.21 # https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google ANDROID_GRADLE=3.2.1 @@ -57,6 +57,8 @@ MATERIAL_DRAWER_KT=2.0.1 OKHTTP=3.12.1 # http://robolectric.org/getting-started/ ROBOELECTRIC=4.1 +# https://developer.android.com/jetpack/androidx/releases/room +ROOM=2.1.0-alpha04 # https://github.com/davemorrissey/subsampling-scale-image-view#quick-start SCALE_IMAGE_VIEW=3.10.0 # https://github.com/umano/AndroidSlidingUpPanel#importing-the-library -- cgit v1.2.3 From f1878133d8af686ce8c27acffe28f26e9dda5165 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 7 Mar 2019 04:00:20 -0500 Subject: Add koin test --- app/build.gradle | 1 + .../com/pitchedapps/frost/db/DatabaseTest.kt | 38 ++++++++++++++++++++++ .../kotlin/com/pitchedapps/frost/db/CacheDb.kt | 3 +- .../kotlin/com/pitchedapps/frost/db/Database.kt | 2 ++ .../kotlin/com/pitchedapps/frost/db/FbTabsDb.kt | 5 --- .../1.json | 36 ++++++++++++++++++-- gradle.properties | 2 +- 7 files changed, 78 insertions(+), 9 deletions(-) create mode 100644 app/src/androidTest/kotlin/com/pitchedapps/frost/db/DatabaseTest.kt (limited to 'gradle.properties') diff --git a/app/build.gradle b/app/build.gradle index d5dcf87e..74e8015c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -178,6 +178,7 @@ dependencies { androidTestImplementation kauDependency.espresso androidTestImplementation kauDependency.testRules androidTestImplementation kauDependency.testRunner + androidTestImplementation "org.jetbrains.kotlin:kotlin-reflect:${KOTLIN}" testImplementation kauDependency.kotlinTest testImplementation "org.jetbrains.kotlin:kotlin-reflect:${KOTLIN}" diff --git a/app/src/androidTest/kotlin/com/pitchedapps/frost/db/DatabaseTest.kt b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/DatabaseTest.kt new file mode 100644 index 00000000..1f1a201b --- /dev/null +++ b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/DatabaseTest.kt @@ -0,0 +1,38 @@ +package com.pitchedapps.frost.db + +import androidx.test.ext.junit.runners.AndroidJUnit4 +import org.junit.runner.RunWith +import org.koin.error.NoBeanDefFoundException +import org.koin.standalone.get +import org.koin.test.KoinTest +import kotlin.reflect.KClass +import kotlin.reflect.full.functions +import kotlin.test.Test +import kotlin.test.assertTrue + +@RunWith(AndroidJUnit4::class) +class DatabaseTest : KoinTest { + + inline fun hasKoin() = hasKoin(T::class) + + fun hasKoin(klazz: KClass): Boolean = + try { + get(clazz = klazz) + true + } catch (e: NoBeanDefFoundException) { + false + } + + /** + * Database and all daos should be loaded as components + */ + @Test + fun testKoins() { + hasKoin() + val members = FrostDatabase::class.java.kotlin.functions.filter { it.name.endsWith("Dao") } + .mapNotNull { it.returnType.classifier as? KClass<*> } + assertTrue(members.isNotEmpty(), "Failed to find dao interfaces") + val missingKoins = (members + FrostDatabase::class).filter { !hasKoin(it) } + assertTrue(missingKoins.isEmpty(), "Missing koins: $missingKoins") + } +} \ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/db/CacheDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/db/CacheDb.kt index bd6bff4b..4d6bc938 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/db/CacheDb.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/db/CacheDb.kt @@ -53,4 +53,5 @@ interface CacheDao { suspend fun deleteById(id: Long) } -suspend fun CacheDao.save(id: String, contents: String) = insertCache(CacheEntity(id, System.currentTimeMillis(), contents)) \ No newline at end of file +suspend fun CacheDao.save(id: String, contents: String) = + insertCache(CacheEntity(id, System.currentTimeMillis(), contents)) \ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt b/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt index b83fce52..29296494 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt @@ -71,6 +71,8 @@ class FrostDatabase(private val privateDb: FrostPrivateDatabase, private val pub single { create(context) } single { get().cookieDao() } single { get().tabDao() } + single { get().cacheDao() } + single { get().notifDao() } } /** diff --git a/app/src/main/kotlin/com/pitchedapps/frost/db/FbTabsDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/db/FbTabsDb.kt index c2bb0837..f4e74509 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/db/FbTabsDb.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/db/FbTabsDb.kt @@ -24,14 +24,9 @@ import androidx.room.Query import androidx.room.Transaction import com.pitchedapps.frost.facebook.FbItem import com.pitchedapps.frost.facebook.defaultTabs -import com.pitchedapps.frost.utils.L import com.raizlabs.android.dbflow.annotation.Database import com.raizlabs.android.dbflow.annotation.PrimaryKey import com.raizlabs.android.dbflow.annotation.Table -import com.raizlabs.android.dbflow.kotlinextensions.database -import com.raizlabs.android.dbflow.kotlinextensions.fastSave -import com.raizlabs.android.dbflow.kotlinextensions.from -import com.raizlabs.android.dbflow.kotlinextensions.select import com.raizlabs.android.dbflow.structure.BaseModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext diff --git a/app/src/schemas/com.pitchedapps.frost.db.FrostPrivateDatabase/1.json b/app/src/schemas/com.pitchedapps.frost.db.FrostPrivateDatabase/1.json index c382bce7..72b86db3 100644 --- a/app/src/schemas/com.pitchedapps.frost.db.FrostPrivateDatabase/1.json +++ b/app/src/schemas/com.pitchedapps.frost.db.FrostPrivateDatabase/1.json @@ -2,7 +2,7 @@ "formatVersion": 1, "database": { "version": 1, - "identityHash": "77eff76407f59b690b8877cc22fac42f", + "identityHash": "099ffebd0f0fe80199c0f6413a549ebb", "entities": [ { "tableName": "cookies", @@ -127,12 +127,44 @@ ] } ] + }, + { + "tableName": "frost_cache", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `lastUpdated` INTEGER NOT NULL, `contents` TEXT NOT NULL, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "lastUpdated", + "columnName": "lastUpdated", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "contents", + "columnName": "contents", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": false + }, + "indices": [], + "foreignKeys": [] } ], "views": [], "setupQueries": [ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", - "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"77eff76407f59b690b8877cc22fac42f\")" + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"099ffebd0f0fe80199c0f6413a549ebb\")" ] } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 98f29dbe..146591bb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,7 +18,7 @@ KAU=4.0.0-alpha02 KOTLIN=1.3.21 # https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google -ANDROID_GRADLE=3.2.1 +ANDROID_GRADLE=3.3.2 # https://github.com/diffplug/spotless/blob/master/plugin-gradle/CHANGES.md SPOTLESS=3.17.0 -- cgit v1.2.3 From 4739e6f58df1116babac69896764e83db551f583 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 21 Apr 2019 20:26:01 -0400 Subject: Merge properties --- docs/Changelog.md | 6 ------ gradle.properties | 8 -------- 2 files changed, 14 deletions(-) (limited to 'gradle.properties') diff --git a/docs/Changelog.md b/docs/Changelog.md index 3d72ec4f..7a6bbfab 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -1,10 +1,5 @@ # Changelog -<<<<<<< HEAD -## v2.2.3 -* Add ability to hide stories -* Remove fbclid from urls -======= ## v2.2.4 * Show top bar to allow sharing posts * Fix unmuting videos when autoplay is enabled @@ -18,7 +13,6 @@ * Remove round icon settings as they are the default in Facebook * Update theme * Update translations ->>>>>>> dev ## v2.2.2 * New marketplace shortcut diff --git a/gradle.properties b/gradle.properties index c080daa0..4c0ace29 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,11 +14,7 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro APP_ID=Frost APP_GROUP=com.pitchedapps -<<<<<<< HEAD -KAU=4.0.0-alpha02 -======= KAU=4.0.0 ->>>>>>> dev KOTLIN=1.3.21 # https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google @@ -60,13 +56,9 @@ MATERIAL_DRAWER_KT=2.0.1 # https://github.com/square/okhttp/releases OKHTTP=3.14.0 # http://robolectric.org/getting-started/ -<<<<<<< HEAD -ROBOELECTRIC=4.1 # https://developer.android.com/jetpack/androidx/releases/room ROOM=2.1.0-alpha04 -======= ROBOELECTRIC=4.2 ->>>>>>> dev # https://github.com/davemorrissey/subsampling-scale-image-view#quick-start SCALE_IMAGE_VIEW=3.10.0 # https://github.com/umano/AndroidSlidingUpPanel#importing-the-library -- cgit v1.2.3