Skip to content
This repository has been archived by the owner on Feb 22, 2021. It is now read-only.

Commit

Permalink
Add DecSync synchronization (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
39aldo39 committed Oct 1, 2020
1 parent 2ee43af commit 4124202
Show file tree
Hide file tree
Showing 19 changed files with 1,099 additions and 43 deletions.
7 changes: 5 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ androidExtensions {
}

android {
compileSdkVersion 30
compileSdkVersion 29
defaultConfig {
applicationId "net.frju.flym"
minSdkVersion 21
targetSdkVersion 30
targetSdkVersion 29 // Allows for legacy storage on Android 11
versionCode 36
versionName "2.5.2"
}
Expand Down Expand Up @@ -122,4 +122,7 @@ dependencies {
implementation 'net.dankito.readability4j:readability4j:1.0.5'
implementation 'pub.devrel:easypermissions:3.0.0'
implementation 'com.rometools:rome-opml:1.15.0'
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-RC'
implementation 'org.decsync:libdecsync:1.7.1'
implementation 'com.nononsenseapps:filepicker:4.1.0'
}
301 changes: 301 additions & 0 deletions app/schemas/net.frju.flym.data.AppDatabase/4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,301 @@
{
"formatVersion": 1,
"database": {
"version": 4,
"identityHash": "68944b920ee4a639a67bc8f29472e1b7",
"entities": [
{
"tableName": "feeds",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`feedId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `feedLink` TEXT NOT NULL, `feedTitle` TEXT, `feedImageLink` TEXT, `fetchError` INTEGER NOT NULL, `retrieveFullText` INTEGER NOT NULL, `isGroup` INTEGER NOT NULL, `groupId` INTEGER, `displayPriority` INTEGER NOT NULL, `lastManualActionUid` TEXT NOT NULL, FOREIGN KEY(`groupId`) REFERENCES `feeds`(`feedId`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
"columnName": "feedId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "link",
"columnName": "feedLink",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "title",
"columnName": "feedTitle",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "imageLink",
"columnName": "feedImageLink",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "fetchError",
"columnName": "fetchError",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "retrieveFullText",
"columnName": "retrieveFullText",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "isGroup",
"columnName": "isGroup",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "groupId",
"columnName": "groupId",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "displayPriority",
"columnName": "displayPriority",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "lastManualActionUid",
"columnName": "lastManualActionUid",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"feedId"
],
"autoGenerate": true
},
"indices": [
{
"name": "index_feeds_groupId",
"unique": false,
"columnNames": [
"groupId"
],
"createSql": "CREATE INDEX IF NOT EXISTS `index_feeds_groupId` ON `${TABLE_NAME}` (`groupId`)"
},
{
"name": "index_feeds_feedId_feedLink",
"unique": true,
"columnNames": [
"feedId",
"feedLink"
],
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_feeds_feedId_feedLink` ON `${TABLE_NAME}` (`feedId`, `feedLink`)"
}
],
"foreignKeys": [
{
"table": "feeds",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"groupId"
],
"referencedColumns": [
"feedId"
]
}
]
},
{
"tableName": "entries",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `feedId` INTEGER NOT NULL, `link` TEXT, `uri` TEXT, `fetchDate` INTEGER NOT NULL, `publicationDate` INTEGER NOT NULL, `title` TEXT, `description` TEXT, `mobilizedContent` TEXT, `imageLink` TEXT, `author` TEXT, `read` INTEGER NOT NULL, `favorite` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`feedId`) REFERENCES `feeds`(`feedId`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "feedId",
"columnName": "feedId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "link",
"columnName": "link",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "uri",
"columnName": "uri",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "fetchDate",
"columnName": "fetchDate",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "publicationDate",
"columnName": "publicationDate",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "description",
"columnName": "description",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "mobilizedContent",
"columnName": "mobilizedContent",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "imageLink",
"columnName": "imageLink",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "author",
"columnName": "author",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "read",
"columnName": "read",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "favorite",
"columnName": "favorite",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [
{
"name": "index_entries_feedId",
"unique": false,
"columnNames": [
"feedId"
],
"createSql": "CREATE INDEX IF NOT EXISTS `index_entries_feedId` ON `${TABLE_NAME}` (`feedId`)"
},
{
"name": "index_entries_link",
"unique": true,
"columnNames": [
"link"
],
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_entries_link` ON `${TABLE_NAME}` (`link`)"
},
{
"name": "index_entries_uri",
"unique": true,
"columnNames": [
"uri"
],
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_entries_uri` ON `${TABLE_NAME}` (`uri`)"
}
],
"foreignKeys": [
{
"table": "feeds",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"feedId"
],
"referencedColumns": [
"feedId"
]
}
]
},
{
"tableName": "tasks",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`entryId` TEXT NOT NULL, `imageLinkToDl` TEXT NOT NULL, `numberAttempt` INTEGER NOT NULL, PRIMARY KEY(`entryId`, `imageLinkToDl`), FOREIGN KEY(`entryId`) REFERENCES `entries`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "entryId",
"columnName": "entryId",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "imageLinkToDl",
"columnName": "imageLinkToDl",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "numberAttempt",
"columnName": "numberAttempt",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"entryId",
"imageLinkToDl"
],
"autoGenerate": false
},
"indices": [
{
"name": "index_tasks_entryId",
"unique": false,
"columnNames": [
"entryId"
],
"createSql": "CREATE INDEX IF NOT EXISTS `index_tasks_entryId` ON `${TABLE_NAME}` (`entryId`)"
}
],
"foreignKeys": [
{
"table": "entries",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"entryId"
],
"referencedColumns": [
"id"
]
}
]
}
],
"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, '68944b920ee4a639a67bc8f29472e1b7')"
]
}
}
17 changes: 16 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
android:usesCleartextTraffic="true"
android:requestLegacyExternalStorage="true">
<activity
android:name="net.frju.flym.ui.main.MainActivity"
android:configChanges="orientation|screenSize"
Expand Down Expand Up @@ -118,6 +119,10 @@
android:label="@string/discover_search_label"
android:launchMode="singleTask"
android:parentActivityName="net.frju.flym.ui.main.MainActivity" />
<activity
android:name="com.nononsenseapps.filepicker.FilePickerActivity"
android:label="@string/app_name"
android:theme="@style/NNF_BaseTheme" />

<meta-data
android:name="com.samsung.android.icon_container.has_icon_container"
Expand All @@ -132,6 +137,16 @@
android:resource="@xml/file_paths" />
</provider>

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/nnf_provider_paths" />
</provider>

<service
android:name="net.frju.flym.service.AutoRefreshJobService"
android:exported="true"
Expand Down
12 changes: 11 additions & 1 deletion app/src/main/java/net/frju/flym/data/AppDatabase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import net.frju.flym.data.entities.Task
import org.jetbrains.anko.doAsync


@Database(entities = [Feed::class, Entry::class, Task::class], version = 3)
@Database(entities = [Feed::class, Entry::class, Task::class], version = 4)
@TypeConverters(Converters::class)
abstract class AppDatabase : RoomDatabase() {

Expand Down Expand Up @@ -71,10 +71,20 @@ abstract class AppDatabase : RoomDatabase() {
}
}

private val MIGRATION_3_4: Migration = object : Migration(3, 4) {
override fun migrate(database: SupportSQLiteDatabase) {
database.run {
execSQL("ALTER TABLE entries ADD COLUMN uri TEXT")
execSQL("CREATE UNIQUE INDEX index_entries_uri ON entries (uri)")
}
}
}

fun createDatabase(context: Context): AppDatabase {
return Room.databaseBuilder(context.applicationContext, AppDatabase::class.java, DATABASE_NAME)
.addMigrations(MIGRATION_1_2)
.addMigrations(MIGRATION_2_3)
.addMigrations(MIGRATION_3_4)
.addCallback(object : Callback() {
override fun onCreate(db: SupportSQLiteDatabase) {
super.onCreate(db)
Expand Down
Loading

0 comments on commit 4124202

Please sign in to comment.