diff --git a/app/schemas/it.niedermann.owncloud.notes.persistence.NotesDatabase/29.json b/app/schemas/it.niedermann.owncloud.notes.persistence.NotesDatabase/29.json new file mode 100644 index 000000000..90ab3bd55 --- /dev/null +++ b/app/schemas/it.niedermann.owncloud.notes.persistence.NotesDatabase/29.json @@ -0,0 +1,756 @@ +{ + "formatVersion": 1, + "database": { + "version": 29, + "identityHash": "8945d8fc9edbc1283151e51c2e201541", + "entities": [ + { + "tableName": "Account", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `url` TEXT NOT NULL DEFAULT '', `userName` TEXT NOT NULL DEFAULT '', `accountName` TEXT NOT NULL DEFAULT '', `eTag` TEXT, `modified` INTEGER, `apiVersion` TEXT, `color` INTEGER NOT NULL DEFAULT -16743735, `textColor` INTEGER NOT NULL DEFAULT -16777216, `capabilitiesETag` TEXT, `displayName` TEXT, `directEditingAvailable` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "url", + "columnName": "url", + "affinity": "TEXT", + "notNull": true, + "defaultValue": "''" + }, + { + "fieldPath": "userName", + "columnName": "userName", + "affinity": "TEXT", + "notNull": true, + "defaultValue": "''" + }, + { + "fieldPath": "accountName", + "columnName": "accountName", + "affinity": "TEXT", + "notNull": true, + "defaultValue": "''" + }, + { + "fieldPath": "eTag", + "columnName": "eTag", + "affinity": "TEXT" + }, + { + "fieldPath": "modified", + "columnName": "modified", + "affinity": "INTEGER" + }, + { + "fieldPath": "apiVersion", + "columnName": "apiVersion", + "affinity": "TEXT" + }, + { + "fieldPath": "color", + "columnName": "color", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-16743735" + }, + { + "fieldPath": "textColor", + "columnName": "textColor", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-16777216" + }, + { + "fieldPath": "capabilitiesETag", + "columnName": "capabilitiesETag", + "affinity": "TEXT" + }, + { + "fieldPath": "displayName", + "columnName": "displayName", + "affinity": "TEXT" + }, + { + "fieldPath": "directEditingAvailable", + "columnName": "directEditingAvailable", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "IDX_ACCOUNT_MODIFIED", + "unique": false, + "columnNames": [ + "modified" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_ACCOUNT_MODIFIED` ON `${TABLE_NAME}` (`modified`)" + }, + { + "name": "IDX_ACCOUNT_URL", + "unique": false, + "columnNames": [ + "url" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_ACCOUNT_URL` ON `${TABLE_NAME}` (`url`)" + }, + { + "name": "IDX_ACCOUNT_USERNAME", + "unique": false, + "columnNames": [ + "userName" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_ACCOUNT_USERNAME` ON `${TABLE_NAME}` (`userName`)" + }, + { + "name": "IDX_ACCOUNT_ACCOUNTNAME", + "unique": false, + "columnNames": [ + "accountName" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_ACCOUNT_ACCOUNTNAME` ON `${TABLE_NAME}` (`accountName`)" + }, + { + "name": "IDX_ACCOUNT_ETAG", + "unique": false, + "columnNames": [ + "eTag" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_ACCOUNT_ETAG` ON `${TABLE_NAME}` (`eTag`)" + } + ] + }, + { + "tableName": "Note", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `remoteId` INTEGER, `accountId` INTEGER NOT NULL, `status` TEXT NOT NULL, `title` TEXT NOT NULL DEFAULT '', `category` TEXT NOT NULL DEFAULT '', `modified` INTEGER, `content` TEXT NOT NULL DEFAULT '', `favorite` INTEGER NOT NULL DEFAULT 0, `isShared` INTEGER NOT NULL DEFAULT 0, `readonly` INTEGER NOT NULL DEFAULT 0, `eTag` TEXT, `excerpt` TEXT NOT NULL DEFAULT '', `scrollY` INTEGER NOT NULL DEFAULT 0, FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "remoteId", + "columnName": "remoteId", + "affinity": "INTEGER" + }, + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "status", + "columnName": "status", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "title", + "columnName": "title", + "affinity": "TEXT", + "notNull": true, + "defaultValue": "''" + }, + { + "fieldPath": "category", + "columnName": "category", + "affinity": "TEXT", + "notNull": true, + "defaultValue": "''" + }, + { + "fieldPath": "modified", + "columnName": "modified", + "affinity": "INTEGER" + }, + { + "fieldPath": "content", + "columnName": "content", + "affinity": "TEXT", + "notNull": true, + "defaultValue": "''" + }, + { + "fieldPath": "favorite", + "columnName": "favorite", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "isShared", + "columnName": "isShared", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "readonly", + "columnName": "readonly", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "eTag", + "columnName": "eTag", + "affinity": "TEXT" + }, + { + "fieldPath": "excerpt", + "columnName": "excerpt", + "affinity": "TEXT", + "notNull": true, + "defaultValue": "''" + }, + { + "fieldPath": "scrollY", + "columnName": "scrollY", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "IDX_NOTE_ACCOUNTID", + "unique": false, + "columnNames": [ + "accountId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTE_ACCOUNTID` ON `${TABLE_NAME}` (`accountId`)" + }, + { + "name": "IDX_NOTE_CATEGORY", + "unique": false, + "columnNames": [ + "category" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTE_CATEGORY` ON `${TABLE_NAME}` (`category`)" + }, + { + "name": "IDX_NOTE_FAVORITE", + "unique": false, + "columnNames": [ + "favorite" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTE_FAVORITE` ON `${TABLE_NAME}` (`favorite`)" + }, + { + "name": "IDX_NOTE_IS_SHARED", + "unique": false, + "columnNames": [ + "isShared" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTE_IS_SHARED` ON `${TABLE_NAME}` (`isShared`)" + }, + { + "name": "IDX_READONLY", + "unique": false, + "columnNames": [ + "readonly" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_READONLY` ON `${TABLE_NAME}` (`readonly`)" + }, + { + "name": "IDX_NOTE_MODIFIED", + "unique": false, + "columnNames": [ + "modified" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTE_MODIFIED` ON `${TABLE_NAME}` (`modified`)" + }, + { + "name": "IDX_NOTE_REMOTEID", + "unique": false, + "columnNames": [ + "remoteId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTE_REMOTEID` ON `${TABLE_NAME}` (`remoteId`)" + }, + { + "name": "IDX_NOTE_STATUS", + "unique": false, + "columnNames": [ + "status" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTE_STATUS` ON `${TABLE_NAME}` (`status`)" + } + ], + "foreignKeys": [ + { + "table": "Account", + "onDelete": "CASCADE", + "onUpdate": "NO ACTION", + "columns": [ + "accountId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "CategoryOptions", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`accountId` INTEGER NOT NULL, `category` TEXT NOT NULL, `sortingMethod` INTEGER, PRIMARY KEY(`accountId`, `category`), FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "category", + "columnName": "category", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "sortingMethod", + "columnName": "sortingMethod", + "affinity": "INTEGER" + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "accountId", + "category" + ] + }, + "indices": [ + { + "name": "IDX_CATEGORIYOPTIONS_ACCOUNTID", + "unique": false, + "columnNames": [ + "accountId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_CATEGORIYOPTIONS_ACCOUNTID` ON `${TABLE_NAME}` (`accountId`)" + }, + { + "name": "IDX_CATEGORIYOPTIONS_CATEGORY", + "unique": false, + "columnNames": [ + "category" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_CATEGORIYOPTIONS_CATEGORY` ON `${TABLE_NAME}` (`category`)" + }, + { + "name": "IDX_CATEGORIYOPTIONS_SORTING_METHOD", + "unique": false, + "columnNames": [ + "sortingMethod" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_CATEGORIYOPTIONS_SORTING_METHOD` ON `${TABLE_NAME}` (`sortingMethod`)" + }, + { + "name": "IDX_UNIQUE_CATEGORYOPTIONS_ACCOUNT_CATEGORY", + "unique": true, + "columnNames": [ + "accountId", + "category" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `IDX_UNIQUE_CATEGORYOPTIONS_ACCOUNT_CATEGORY` ON `${TABLE_NAME}` (`accountId`, `category`)" + } + ], + "foreignKeys": [ + { + "table": "Account", + "onDelete": "CASCADE", + "onUpdate": "NO ACTION", + "columns": [ + "accountId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "SingleNoteWidgetData", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`noteId` INTEGER NOT NULL, `id` INTEGER NOT NULL, `accountId` INTEGER NOT NULL, `themeMode` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`noteId`) REFERENCES `Note`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "noteId", + "columnName": "noteId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "themeMode", + "columnName": "themeMode", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "IDX_SINGLENOTEWIDGETDATA_ACCOUNTID", + "unique": false, + "columnNames": [ + "accountId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_SINGLENOTEWIDGETDATA_ACCOUNTID` ON `${TABLE_NAME}` (`accountId`)" + }, + { + "name": "IDX_SINGLENOTEWIDGETDATA_NOTEID", + "unique": false, + "columnNames": [ + "noteId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_SINGLENOTEWIDGETDATA_NOTEID` ON `${TABLE_NAME}` (`noteId`)" + } + ], + "foreignKeys": [ + { + "table": "Account", + "onDelete": "CASCADE", + "onUpdate": "NO ACTION", + "columns": [ + "accountId" + ], + "referencedColumns": [ + "id" + ] + }, + { + "table": "Note", + "onDelete": "CASCADE", + "onUpdate": "NO ACTION", + "columns": [ + "noteId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "NotesListWidgetData", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`mode` INTEGER NOT NULL, `category` TEXT, `id` INTEGER NOT NULL, `accountId` INTEGER NOT NULL, `themeMode` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "mode", + "columnName": "mode", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "category", + "columnName": "category", + "affinity": "TEXT" + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "themeMode", + "columnName": "themeMode", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "IDX_NOTESLISTWIDGETDATA_ACCOUNTID", + "unique": false, + "columnNames": [ + "accountId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTESLISTWIDGETDATA_ACCOUNTID` ON `${TABLE_NAME}` (`accountId`)" + }, + { + "name": "IDX_NOTESLISTWIDGETDATA_CATEGORY", + "unique": false, + "columnNames": [ + "category" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTESLISTWIDGETDATA_CATEGORY` ON `${TABLE_NAME}` (`category`)" + }, + { + "name": "IDX_NOTESLISTWIDGETDATA_ACCOUNT_CATEGORY", + "unique": false, + "columnNames": [ + "accountId", + "category" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTESLISTWIDGETDATA_ACCOUNT_CATEGORY` ON `${TABLE_NAME}` (`accountId`, `category`)" + } + ], + "foreignKeys": [ + { + "table": "Account", + "onDelete": "CASCADE", + "onUpdate": "NO ACTION", + "columns": [ + "accountId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "share_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `note` TEXT, `path` TEXT, `file_target` TEXT, `share_with` TEXT, `share_with_displayname` TEXT, `uid_file_owner` TEXT, `displayname_file_owner` TEXT, `uid_owner` TEXT, `displayname_owner` TEXT, `url` TEXT, `expiration_date` INTEGER, `permissions` REAL, `attributes` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER" + }, + { + "fieldPath": "note", + "columnName": "note", + "affinity": "TEXT" + }, + { + "fieldPath": "path", + "columnName": "path", + "affinity": "TEXT" + }, + { + "fieldPath": "file_target", + "columnName": "file_target", + "affinity": "TEXT" + }, + { + "fieldPath": "share_with", + "columnName": "share_with", + "affinity": "TEXT" + }, + { + "fieldPath": "share_with_displayname", + "columnName": "share_with_displayname", + "affinity": "TEXT" + }, + { + "fieldPath": "uid_file_owner", + "columnName": "uid_file_owner", + "affinity": "TEXT" + }, + { + "fieldPath": "displayname_file_owner", + "columnName": "displayname_file_owner", + "affinity": "TEXT" + }, + { + "fieldPath": "uid_owner", + "columnName": "uid_owner", + "affinity": "TEXT" + }, + { + "fieldPath": "displayname_owner", + "columnName": "displayname_owner", + "affinity": "TEXT" + }, + { + "fieldPath": "url", + "columnName": "url", + "affinity": "TEXT" + }, + { + "fieldPath": "expiration_date", + "columnName": "expiration_date", + "affinity": "INTEGER" + }, + { + "fieldPath": "permissions", + "columnName": "permissions", + "affinity": "REAL" + }, + { + "fieldPath": "attributes", + "columnName": "attributes", + "affinity": "TEXT" + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + } + }, + { + "tableName": "capabilities", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `nextcloudMajorVersion` TEXT, `nextcloudMinorVersion` TEXT, `nextcloudMicroVersion` TEXT, `federationShare` INTEGER NOT NULL, `apiVersion` TEXT, `color` INTEGER NOT NULL, `textColor` INTEGER NOT NULL, `eTag` TEXT, `directEditingAvailable` INTEGER NOT NULL, `publicPasswordEnforced` INTEGER NOT NULL, `askForOptionalPassword` INTEGER NOT NULL, `isReSharingAllowed` INTEGER NOT NULL, `defaultPermission` INTEGER NOT NULL, `userStatusSupportsBusy` INTEGER, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "nextcloudMajorVersion", + "columnName": "nextcloudMajorVersion", + "affinity": "TEXT" + }, + { + "fieldPath": "nextcloudMinorVersion", + "columnName": "nextcloudMinorVersion", + "affinity": "TEXT" + }, + { + "fieldPath": "nextcloudMicroVersion", + "columnName": "nextcloudMicroVersion", + "affinity": "TEXT" + }, + { + "fieldPath": "federationShare", + "columnName": "federationShare", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "apiVersion", + "columnName": "apiVersion", + "affinity": "TEXT" + }, + { + "fieldPath": "color", + "columnName": "color", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "textColor", + "columnName": "textColor", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "eTag", + "columnName": "eTag", + "affinity": "TEXT" + }, + { + "fieldPath": "directEditingAvailable", + "columnName": "directEditingAvailable", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "publicPasswordEnforced", + "columnName": "publicPasswordEnforced", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "askForOptionalPassword", + "columnName": "askForOptionalPassword", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isReSharingAllowed", + "columnName": "isReSharingAllowed", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "defaultPermission", + "columnName": "defaultPermission", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "userStatusSupportsBusy", + "columnName": "userStatusSupportsBusy", + "affinity": "INTEGER" + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + } + } + ], + "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, '8945d8fc9edbc1283151e51c2e201541')" + ] + } +} \ No newline at end of file diff --git a/app/schemas/it.niedermann.owncloud.notes.persistence.NotesDatabase/30.json b/app/schemas/it.niedermann.owncloud.notes.persistence.NotesDatabase/30.json new file mode 100644 index 000000000..e1f360ebc --- /dev/null +++ b/app/schemas/it.niedermann.owncloud.notes.persistence.NotesDatabase/30.json @@ -0,0 +1,762 @@ +{ + "formatVersion": 1, + "database": { + "version": 30, + "identityHash": "2860d8a8ebbede8e07299d74bc27018b", + "entities": [ + { + "tableName": "Account", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `url` TEXT NOT NULL DEFAULT '', `userName` TEXT NOT NULL DEFAULT '', `accountName` TEXT NOT NULL DEFAULT '', `eTag` TEXT, `modified` INTEGER, `apiVersion` TEXT, `color` INTEGER NOT NULL DEFAULT -16743735, `textColor` INTEGER NOT NULL DEFAULT -16777216, `capabilitiesETag` TEXT, `displayName` TEXT, `directEditingAvailable` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "url", + "columnName": "url", + "affinity": "TEXT", + "notNull": true, + "defaultValue": "''" + }, + { + "fieldPath": "userName", + "columnName": "userName", + "affinity": "TEXT", + "notNull": true, + "defaultValue": "''" + }, + { + "fieldPath": "accountName", + "columnName": "accountName", + "affinity": "TEXT", + "notNull": true, + "defaultValue": "''" + }, + { + "fieldPath": "eTag", + "columnName": "eTag", + "affinity": "TEXT" + }, + { + "fieldPath": "modified", + "columnName": "modified", + "affinity": "INTEGER" + }, + { + "fieldPath": "apiVersion", + "columnName": "apiVersion", + "affinity": "TEXT" + }, + { + "fieldPath": "color", + "columnName": "color", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-16743735" + }, + { + "fieldPath": "textColor", + "columnName": "textColor", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-16777216" + }, + { + "fieldPath": "capabilitiesETag", + "columnName": "capabilitiesETag", + "affinity": "TEXT" + }, + { + "fieldPath": "displayName", + "columnName": "displayName", + "affinity": "TEXT" + }, + { + "fieldPath": "directEditingAvailable", + "columnName": "directEditingAvailable", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "IDX_ACCOUNT_MODIFIED", + "unique": false, + "columnNames": [ + "modified" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_ACCOUNT_MODIFIED` ON `${TABLE_NAME}` (`modified`)" + }, + { + "name": "IDX_ACCOUNT_URL", + "unique": false, + "columnNames": [ + "url" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_ACCOUNT_URL` ON `${TABLE_NAME}` (`url`)" + }, + { + "name": "IDX_ACCOUNT_USERNAME", + "unique": false, + "columnNames": [ + "userName" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_ACCOUNT_USERNAME` ON `${TABLE_NAME}` (`userName`)" + }, + { + "name": "IDX_ACCOUNT_ACCOUNTNAME", + "unique": false, + "columnNames": [ + "accountName" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_ACCOUNT_ACCOUNTNAME` ON `${TABLE_NAME}` (`accountName`)" + }, + { + "name": "IDX_ACCOUNT_ETAG", + "unique": false, + "columnNames": [ + "eTag" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_ACCOUNT_ETAG` ON `${TABLE_NAME}` (`eTag`)" + } + ] + }, + { + "tableName": "Note", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `remoteId` INTEGER, `accountId` INTEGER NOT NULL, `status` TEXT NOT NULL, `title` TEXT NOT NULL DEFAULT '', `category` TEXT NOT NULL DEFAULT '', `modified` INTEGER, `content` TEXT NOT NULL DEFAULT '', `favorite` INTEGER NOT NULL DEFAULT 0, `isShared` INTEGER NOT NULL DEFAULT 0, `readonly` INTEGER NOT NULL DEFAULT 0, `eTag` TEXT, `excerpt` TEXT NOT NULL DEFAULT '', `scrollY` INTEGER NOT NULL DEFAULT 0, `noteMode` TEXT DEFAULT NULL, FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "remoteId", + "columnName": "remoteId", + "affinity": "INTEGER" + }, + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "status", + "columnName": "status", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "title", + "columnName": "title", + "affinity": "TEXT", + "notNull": true, + "defaultValue": "''" + }, + { + "fieldPath": "category", + "columnName": "category", + "affinity": "TEXT", + "notNull": true, + "defaultValue": "''" + }, + { + "fieldPath": "modified", + "columnName": "modified", + "affinity": "INTEGER" + }, + { + "fieldPath": "content", + "columnName": "content", + "affinity": "TEXT", + "notNull": true, + "defaultValue": "''" + }, + { + "fieldPath": "favorite", + "columnName": "favorite", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "isShared", + "columnName": "isShared", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "readonly", + "columnName": "readonly", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "eTag", + "columnName": "eTag", + "affinity": "TEXT" + }, + { + "fieldPath": "excerpt", + "columnName": "excerpt", + "affinity": "TEXT", + "notNull": true, + "defaultValue": "''" + }, + { + "fieldPath": "scrollY", + "columnName": "scrollY", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "noteMode", + "columnName": "noteMode", + "affinity": "TEXT", + "defaultValue": "NULL" + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "IDX_NOTE_ACCOUNTID", + "unique": false, + "columnNames": [ + "accountId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTE_ACCOUNTID` ON `${TABLE_NAME}` (`accountId`)" + }, + { + "name": "IDX_NOTE_CATEGORY", + "unique": false, + "columnNames": [ + "category" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTE_CATEGORY` ON `${TABLE_NAME}` (`category`)" + }, + { + "name": "IDX_NOTE_FAVORITE", + "unique": false, + "columnNames": [ + "favorite" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTE_FAVORITE` ON `${TABLE_NAME}` (`favorite`)" + }, + { + "name": "IDX_NOTE_IS_SHARED", + "unique": false, + "columnNames": [ + "isShared" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTE_IS_SHARED` ON `${TABLE_NAME}` (`isShared`)" + }, + { + "name": "IDX_READONLY", + "unique": false, + "columnNames": [ + "readonly" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_READONLY` ON `${TABLE_NAME}` (`readonly`)" + }, + { + "name": "IDX_NOTE_MODIFIED", + "unique": false, + "columnNames": [ + "modified" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTE_MODIFIED` ON `${TABLE_NAME}` (`modified`)" + }, + { + "name": "IDX_NOTE_REMOTEID", + "unique": false, + "columnNames": [ + "remoteId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTE_REMOTEID` ON `${TABLE_NAME}` (`remoteId`)" + }, + { + "name": "IDX_NOTE_STATUS", + "unique": false, + "columnNames": [ + "status" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTE_STATUS` ON `${TABLE_NAME}` (`status`)" + } + ], + "foreignKeys": [ + { + "table": "Account", + "onDelete": "CASCADE", + "onUpdate": "NO ACTION", + "columns": [ + "accountId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "CategoryOptions", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`accountId` INTEGER NOT NULL, `category` TEXT NOT NULL, `sortingMethod` INTEGER, PRIMARY KEY(`accountId`, `category`), FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "category", + "columnName": "category", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "sortingMethod", + "columnName": "sortingMethod", + "affinity": "INTEGER" + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "accountId", + "category" + ] + }, + "indices": [ + { + "name": "IDX_CATEGORIYOPTIONS_ACCOUNTID", + "unique": false, + "columnNames": [ + "accountId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_CATEGORIYOPTIONS_ACCOUNTID` ON `${TABLE_NAME}` (`accountId`)" + }, + { + "name": "IDX_CATEGORIYOPTIONS_CATEGORY", + "unique": false, + "columnNames": [ + "category" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_CATEGORIYOPTIONS_CATEGORY` ON `${TABLE_NAME}` (`category`)" + }, + { + "name": "IDX_CATEGORIYOPTIONS_SORTING_METHOD", + "unique": false, + "columnNames": [ + "sortingMethod" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_CATEGORIYOPTIONS_SORTING_METHOD` ON `${TABLE_NAME}` (`sortingMethod`)" + }, + { + "name": "IDX_UNIQUE_CATEGORYOPTIONS_ACCOUNT_CATEGORY", + "unique": true, + "columnNames": [ + "accountId", + "category" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `IDX_UNIQUE_CATEGORYOPTIONS_ACCOUNT_CATEGORY` ON `${TABLE_NAME}` (`accountId`, `category`)" + } + ], + "foreignKeys": [ + { + "table": "Account", + "onDelete": "CASCADE", + "onUpdate": "NO ACTION", + "columns": [ + "accountId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "SingleNoteWidgetData", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`noteId` INTEGER NOT NULL, `id` INTEGER NOT NULL, `accountId` INTEGER NOT NULL, `themeMode` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`noteId`) REFERENCES `Note`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "noteId", + "columnName": "noteId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "themeMode", + "columnName": "themeMode", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "IDX_SINGLENOTEWIDGETDATA_ACCOUNTID", + "unique": false, + "columnNames": [ + "accountId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_SINGLENOTEWIDGETDATA_ACCOUNTID` ON `${TABLE_NAME}` (`accountId`)" + }, + { + "name": "IDX_SINGLENOTEWIDGETDATA_NOTEID", + "unique": false, + "columnNames": [ + "noteId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_SINGLENOTEWIDGETDATA_NOTEID` ON `${TABLE_NAME}` (`noteId`)" + } + ], + "foreignKeys": [ + { + "table": "Account", + "onDelete": "CASCADE", + "onUpdate": "NO ACTION", + "columns": [ + "accountId" + ], + "referencedColumns": [ + "id" + ] + }, + { + "table": "Note", + "onDelete": "CASCADE", + "onUpdate": "NO ACTION", + "columns": [ + "noteId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "NotesListWidgetData", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`mode` INTEGER NOT NULL, `category` TEXT, `id` INTEGER NOT NULL, `accountId` INTEGER NOT NULL, `themeMode` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "mode", + "columnName": "mode", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "category", + "columnName": "category", + "affinity": "TEXT" + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "themeMode", + "columnName": "themeMode", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "IDX_NOTESLISTWIDGETDATA_ACCOUNTID", + "unique": false, + "columnNames": [ + "accountId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTESLISTWIDGETDATA_ACCOUNTID` ON `${TABLE_NAME}` (`accountId`)" + }, + { + "name": "IDX_NOTESLISTWIDGETDATA_CATEGORY", + "unique": false, + "columnNames": [ + "category" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTESLISTWIDGETDATA_CATEGORY` ON `${TABLE_NAME}` (`category`)" + }, + { + "name": "IDX_NOTESLISTWIDGETDATA_ACCOUNT_CATEGORY", + "unique": false, + "columnNames": [ + "accountId", + "category" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `IDX_NOTESLISTWIDGETDATA_ACCOUNT_CATEGORY` ON `${TABLE_NAME}` (`accountId`, `category`)" + } + ], + "foreignKeys": [ + { + "table": "Account", + "onDelete": "CASCADE", + "onUpdate": "NO ACTION", + "columns": [ + "accountId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "share_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `note` TEXT, `path` TEXT, `file_target` TEXT, `share_with` TEXT, `share_with_displayname` TEXT, `uid_file_owner` TEXT, `displayname_file_owner` TEXT, `uid_owner` TEXT, `displayname_owner` TEXT, `url` TEXT, `expiration_date` INTEGER, `permissions` REAL, `attributes` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER" + }, + { + "fieldPath": "note", + "columnName": "note", + "affinity": "TEXT" + }, + { + "fieldPath": "path", + "columnName": "path", + "affinity": "TEXT" + }, + { + "fieldPath": "file_target", + "columnName": "file_target", + "affinity": "TEXT" + }, + { + "fieldPath": "share_with", + "columnName": "share_with", + "affinity": "TEXT" + }, + { + "fieldPath": "share_with_displayname", + "columnName": "share_with_displayname", + "affinity": "TEXT" + }, + { + "fieldPath": "uid_file_owner", + "columnName": "uid_file_owner", + "affinity": "TEXT" + }, + { + "fieldPath": "displayname_file_owner", + "columnName": "displayname_file_owner", + "affinity": "TEXT" + }, + { + "fieldPath": "uid_owner", + "columnName": "uid_owner", + "affinity": "TEXT" + }, + { + "fieldPath": "displayname_owner", + "columnName": "displayname_owner", + "affinity": "TEXT" + }, + { + "fieldPath": "url", + "columnName": "url", + "affinity": "TEXT" + }, + { + "fieldPath": "expiration_date", + "columnName": "expiration_date", + "affinity": "INTEGER" + }, + { + "fieldPath": "permissions", + "columnName": "permissions", + "affinity": "REAL" + }, + { + "fieldPath": "attributes", + "columnName": "attributes", + "affinity": "TEXT" + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + } + }, + { + "tableName": "capabilities", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `nextcloudMajorVersion` TEXT, `nextcloudMinorVersion` TEXT, `nextcloudMicroVersion` TEXT, `federationShare` INTEGER NOT NULL, `apiVersion` TEXT, `color` INTEGER NOT NULL, `textColor` INTEGER NOT NULL, `eTag` TEXT, `directEditingAvailable` INTEGER NOT NULL, `publicPasswordEnforced` INTEGER NOT NULL, `askForOptionalPassword` INTEGER NOT NULL, `isReSharingAllowed` INTEGER NOT NULL, `defaultPermission` INTEGER NOT NULL, `userStatusSupportsBusy` INTEGER, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "nextcloudMajorVersion", + "columnName": "nextcloudMajorVersion", + "affinity": "TEXT" + }, + { + "fieldPath": "nextcloudMinorVersion", + "columnName": "nextcloudMinorVersion", + "affinity": "TEXT" + }, + { + "fieldPath": "nextcloudMicroVersion", + "columnName": "nextcloudMicroVersion", + "affinity": "TEXT" + }, + { + "fieldPath": "federationShare", + "columnName": "federationShare", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "apiVersion", + "columnName": "apiVersion", + "affinity": "TEXT" + }, + { + "fieldPath": "color", + "columnName": "color", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "textColor", + "columnName": "textColor", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "eTag", + "columnName": "eTag", + "affinity": "TEXT" + }, + { + "fieldPath": "directEditingAvailable", + "columnName": "directEditingAvailable", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "publicPasswordEnforced", + "columnName": "publicPasswordEnforced", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "askForOptionalPassword", + "columnName": "askForOptionalPassword", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isReSharingAllowed", + "columnName": "isReSharingAllowed", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "defaultPermission", + "columnName": "defaultPermission", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "userStatusSupportsBusy", + "columnName": "userStatusSupportsBusy", + "affinity": "INTEGER" + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + } + } + ], + "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, '2860d8a8ebbede8e07299d74bc27018b')" + ] + } +} \ No newline at end of file diff --git a/app/src/main/java/it/niedermann/owncloud/notes/edit/EditNoteActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/EditNoteActivity.java index 1a669e615..ab6d2a0fc 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/edit/EditNoteActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/EditNoteActivity.java @@ -249,17 +249,31 @@ private void replaceFragment() { /** - * Returns the preferred mode for the account. If the mode is "remember last" the last mode is returned. - * If the mode is "direct edit" and the account does not support direct edit, the default mode is returned. + * Returns the preferred mode for the note. Checks the per-note stored mode first, then falls + * back to the global preference. If the mode is "remember last" the last mode is returned. + * If the mode is "direct edit" and the account does not support direct edit, edit mode is returned. */ - private String getPreferenceMode(long accountId) { + private String getPreferenceMode(long accountId, long noteId) { + final var defaultMode = getString(R.string.pref_value_mode_edit); + final var prefValueDirectEdit = getString(R.string.pref_value_mode_direct_edit); + + if (noteId > 0) { + final Note note = repo.getNoteById(noteId); + if (note != null && note.getNoteMode() != null) { + final String noteMode = note.getNoteMode(); + if (noteMode.equals(prefValueDirectEdit)) { + final Account accountById = repo.getAccountById(accountId); + if (accountById == null || !accountById.isDirectEditingAvailable()) { + return defaultMode; + } + } + return noteMode; + } + } final var prefKeyNoteMode = getString(R.string.pref_key_note_mode); final var prefKeyLastMode = getString(R.string.pref_key_last_note_mode); - final var defaultMode = getString(R.string.pref_value_mode_edit); final var prefValueLast = getString(R.string.pref_value_mode_last); - final var prefValueDirectEdit = getString(R.string.pref_value_mode_direct_edit); - final var preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); final String modePreference = preferences.getString(prefKeyNoteMode, defaultMode); @@ -282,7 +296,7 @@ private String getPreferenceMode(long accountId) { private BaseNoteFragment getNoteFragment(long accountId, long noteId, final @Nullable String modePref) { - final var effectiveMode = modePref == null ? getPreferenceMode(accountId) : modePref; + final var effectiveMode = modePref == null ? getPreferenceMode(accountId, noteId) : modePref; final var prefValueEdit = getString(R.string.pref_value_mode_edit); final var prefValueDirectEdit = getString(R.string.pref_value_mode_direct_edit); @@ -302,7 +316,7 @@ private BaseNoteFragment getNoteFragment(long accountId, long noteId, final @Nul @NonNull private BaseNoteFragment getNewNoteFragment(Note newNote) { - final var mode = getPreferenceMode(getAccountId()); + final var mode = getPreferenceMode(getAccountId(), 0); final var prefValueDirectEdit = getString(R.string.pref_value_mode_direct_edit); @@ -397,18 +411,6 @@ public boolean onOptionsItemSelected(MenuItem item) { * Send result and closes the Activity */ public void close() { - /* TODO enhancement: store last mode in note - * for cross device functionality per note mode should be stored on the server. - */ - final var preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); - final String prefKeyLastMode = getString(R.string.pref_key_last_note_mode); - if (fragment instanceof NoteEditFragment) { - preferences.edit().putString(prefKeyLastMode, getString(R.string.pref_value_mode_edit)).apply(); - } else if (fragment instanceof NotePreviewFragment) { - preferences.edit().putString(prefKeyLastMode, getString(R.string.pref_value_mode_preview)).apply(); - } else if (fragment instanceof NoteDirectEditFragment) { - preferences.edit().putString(prefKeyLastMode, getString(R.string.pref_value_mode_direct_edit)).apply(); - } fragment.onCloseNote(); if(isTaskRoot()) { @@ -435,12 +437,19 @@ public void onNoteUpdated(Note note) { @Override public void changeMode(@NonNull Mode mode, boolean reloadNote) { - switch (mode) { - case EDIT -> launchExistingNote(getAccountId(), getNoteId(), getString(R.string.pref_value_mode_edit), reloadNote); - case PREVIEW -> launchExistingNote(getAccountId(), getNoteId(), getString(R.string.pref_value_mode_preview), reloadNote); - case DIRECT_EDIT -> launchExistingNote(getAccountId(), getNoteId(), getString(R.string.pref_value_mode_direct_edit), reloadNote); + final String modeString = switch (mode) { + case EDIT -> getString(R.string.pref_value_mode_edit); + case PREVIEW -> getString(R.string.pref_value_mode_preview); + case DIRECT_EDIT -> getString(R.string.pref_value_mode_direct_edit); default -> throw new IllegalStateException("Unknown mode: " + mode); + }; + final long noteId = getNoteId(); + if (noteId > 0) { + repo.updateNoteMode(noteId, modeString); } + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()) + .edit().putString(getString(R.string.pref_key_last_note_mode), modeString).apply(); + launchExistingNote(getAccountId(), noteId, modeString, reloadNote); } diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java index 3bbfe0e20..0b6d30c4a 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java @@ -46,6 +46,7 @@ import it.niedermann.owncloud.notes.persistence.migration.Migration_22_23; import it.niedermann.owncloud.notes.persistence.migration.Migration_23_24; import it.niedermann.owncloud.notes.persistence.migration.Migration_24_25; +import it.niedermann.owncloud.notes.persistence.migration.Migration_29_30; import it.niedermann.owncloud.notes.persistence.migration.Migration_9_10; import it.niedermann.owncloud.notes.shared.model.Capabilities; @@ -58,7 +59,7 @@ NotesListWidgetData.class, ShareEntity.class, Capabilities.class - }, version = 29, + }, version = 30, autoMigrations = { @AutoMigration(from = 25, to = 26), @AutoMigration(from = 26, to = 27), @@ -101,7 +102,8 @@ private static NotesDatabase create(final Context context) { new Migration_21_22(context), new Migration_22_23(), new Migration_23_24(context), - new Migration_24_25() + new Migration_24_25(), + new Migration_29_30() ) .addCallback(new RoomDatabase.Callback() { @Override diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java index f25c91e00..f6a1d6e7c 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java @@ -372,6 +372,10 @@ public void updateScrollY(long id, int scrollY) { db.getNoteDao().updateScrollY(id, scrollY); } + public void updateNoteMode(long id, @Nullable String noteMode) { + db.getNoteDao().updateNoteMode(id, noteMode); + } + public LiveData> searchCategories$(Long accountId, String searchTerm) { return db.getNoteDao().searchCategories$(accountId, searchTerm); } diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/NoteDao.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/NoteDao.java index 29500f180..ad539dc1f 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/NoteDao.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/NoteDao.java @@ -6,6 +6,7 @@ */ package it.niedermann.owncloud.notes.persistence.dao; +import androidx.annotation.Nullable; import androidx.lifecycle.LiveData; import androidx.room.Dao; import androidx.room.Insert; @@ -125,6 +126,9 @@ public interface NoteDao { @Query("UPDATE NOTE SET scrollY = :scrollY WHERE id = :id") void updateScrollY(long id, int scrollY); + @Query("UPDATE NOTE SET noteMode = :noteMode WHERE id = :id") + void updateNoteMode(long id, @Nullable String noteMode); + @Query("UPDATE NOTE SET status = :status WHERE id = :id") void updateStatus(long id, DBStatus status); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/entity/Note.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/entity/Note.java index dabd3bd51..7cad7f5ae 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/entity/Note.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/entity/Note.java @@ -103,6 +103,10 @@ public class Note implements Serializable, Item { @ColumnInfo(defaultValue = "0") private int scrollY = 0; + @Nullable + @ColumnInfo(defaultValue = "NULL") + private String noteMode; + public Note() { super(); } @@ -272,6 +276,15 @@ public void setScrollY(int scrollY) { this.scrollY = scrollY; } + @Nullable + public String getNoteMode() { + return noteMode; + } + + public void setNoteMode(@Nullable String noteMode) { + this.noteMode = noteMode; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_29_30.kt b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_29_30.kt new file mode 100644 index 000000000..034f7db94 --- /dev/null +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_29_30.kt @@ -0,0 +1,17 @@ +/* + * Nextcloud Notes - Android Client + * + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ +package it.niedermann.owncloud.notes.persistence.migration + +import androidx.room.migration.Migration +import androidx.sqlite.db.SupportSQLiteDatabase + +@Suppress("ClassName", "Detekt.ClassNaming") +class Migration_29_30 : Migration(29, 30) { + override fun migrate(db: SupportSQLiteDatabase) { + db.execSQL("ALTER TABLE Note ADD COLUMN noteMode TEXT DEFAULT NULL") + } +}