mirror of https://github.com/tuskyapp/Tusky.git
67 changed files with 872 additions and 904 deletions
@ -0,0 +1,747 @@
|
||||
{ |
||||
"formatVersion": 1, |
||||
"database": { |
||||
"version": 26, |
||||
"identityHash": "14fb3d5743b7a89e8e62463e05f086ab", |
||||
"entities": [ |
||||
{ |
||||
"tableName": "DraftEntity", |
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `accountId` INTEGER NOT NULL, `inReplyToId` TEXT, `content` TEXT, `contentWarning` TEXT, `sensitive` INTEGER NOT NULL, `visibility` INTEGER NOT NULL, `attachments` TEXT NOT NULL, `poll` TEXT, `failedToSend` INTEGER NOT NULL)", |
||||
"fields": [ |
||||
{ |
||||
"fieldPath": "id", |
||||
"columnName": "id", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "accountId", |
||||
"columnName": "accountId", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "inReplyToId", |
||||
"columnName": "inReplyToId", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "content", |
||||
"columnName": "content", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "contentWarning", |
||||
"columnName": "contentWarning", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "sensitive", |
||||
"columnName": "sensitive", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "visibility", |
||||
"columnName": "visibility", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "attachments", |
||||
"columnName": "attachments", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "poll", |
||||
"columnName": "poll", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "failedToSend", |
||||
"columnName": "failedToSend", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
} |
||||
], |
||||
"primaryKey": { |
||||
"columnNames": [ |
||||
"id" |
||||
], |
||||
"autoGenerate": true |
||||
}, |
||||
"indices": [], |
||||
"foreignKeys": [] |
||||
}, |
||||
{ |
||||
"tableName": "AccountEntity", |
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `domain` TEXT NOT NULL, `accessToken` TEXT NOT NULL, `isActive` INTEGER NOT NULL, `accountId` TEXT NOT NULL, `username` TEXT NOT NULL, `displayName` TEXT NOT NULL, `profilePictureUrl` TEXT NOT NULL, `notificationsEnabled` INTEGER NOT NULL, `notificationsMentioned` INTEGER NOT NULL, `notificationsFollowed` INTEGER NOT NULL, `notificationsFollowRequested` INTEGER NOT NULL, `notificationsReblogged` INTEGER NOT NULL, `notificationsFavorited` INTEGER NOT NULL, `notificationsPolls` INTEGER NOT NULL, `notificationsSubscriptions` INTEGER NOT NULL, `notificationSound` INTEGER NOT NULL, `notificationVibration` INTEGER NOT NULL, `notificationLight` INTEGER NOT NULL, `defaultPostPrivacy` INTEGER NOT NULL, `defaultMediaSensitivity` INTEGER NOT NULL, `alwaysShowSensitiveMedia` INTEGER NOT NULL, `alwaysOpenSpoiler` INTEGER NOT NULL, `mediaPreviewEnabled` INTEGER NOT NULL, `lastNotificationId` TEXT NOT NULL, `activeNotifications` TEXT NOT NULL, `emojis` TEXT NOT NULL, `tabPreferences` TEXT NOT NULL, `notificationsFilter` TEXT NOT NULL)", |
||||
"fields": [ |
||||
{ |
||||
"fieldPath": "id", |
||||
"columnName": "id", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "domain", |
||||
"columnName": "domain", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "accessToken", |
||||
"columnName": "accessToken", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "isActive", |
||||
"columnName": "isActive", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "accountId", |
||||
"columnName": "accountId", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "username", |
||||
"columnName": "username", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "displayName", |
||||
"columnName": "displayName", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "profilePictureUrl", |
||||
"columnName": "profilePictureUrl", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "notificationsEnabled", |
||||
"columnName": "notificationsEnabled", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "notificationsMentioned", |
||||
"columnName": "notificationsMentioned", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "notificationsFollowed", |
||||
"columnName": "notificationsFollowed", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "notificationsFollowRequested", |
||||
"columnName": "notificationsFollowRequested", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "notificationsReblogged", |
||||
"columnName": "notificationsReblogged", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "notificationsFavorited", |
||||
"columnName": "notificationsFavorited", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "notificationsPolls", |
||||
"columnName": "notificationsPolls", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "notificationsSubscriptions", |
||||
"columnName": "notificationsSubscriptions", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "notificationSound", |
||||
"columnName": "notificationSound", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "notificationVibration", |
||||
"columnName": "notificationVibration", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "notificationLight", |
||||
"columnName": "notificationLight", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "defaultPostPrivacy", |
||||
"columnName": "defaultPostPrivacy", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "defaultMediaSensitivity", |
||||
"columnName": "defaultMediaSensitivity", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "alwaysShowSensitiveMedia", |
||||
"columnName": "alwaysShowSensitiveMedia", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "alwaysOpenSpoiler", |
||||
"columnName": "alwaysOpenSpoiler", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "mediaPreviewEnabled", |
||||
"columnName": "mediaPreviewEnabled", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "lastNotificationId", |
||||
"columnName": "lastNotificationId", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "activeNotifications", |
||||
"columnName": "activeNotifications", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "emojis", |
||||
"columnName": "emojis", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "tabPreferences", |
||||
"columnName": "tabPreferences", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "notificationsFilter", |
||||
"columnName": "notificationsFilter", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
} |
||||
], |
||||
"primaryKey": { |
||||
"columnNames": [ |
||||
"id" |
||||
], |
||||
"autoGenerate": true |
||||
}, |
||||
"indices": [ |
||||
{ |
||||
"name": "index_AccountEntity_domain_accountId", |
||||
"unique": true, |
||||
"columnNames": [ |
||||
"domain", |
||||
"accountId" |
||||
], |
||||
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_AccountEntity_domain_accountId` ON `${TABLE_NAME}` (`domain`, `accountId`)" |
||||
} |
||||
], |
||||
"foreignKeys": [] |
||||
}, |
||||
{ |
||||
"tableName": "InstanceEntity", |
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`instance` TEXT NOT NULL, `emojiList` TEXT, `maximumTootCharacters` INTEGER, `maxPollOptions` INTEGER, `maxPollOptionLength` INTEGER, `version` TEXT, PRIMARY KEY(`instance`))", |
||||
"fields": [ |
||||
{ |
||||
"fieldPath": "instance", |
||||
"columnName": "instance", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "emojiList", |
||||
"columnName": "emojiList", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "maximumTootCharacters", |
||||
"columnName": "maximumTootCharacters", |
||||
"affinity": "INTEGER", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "maxPollOptions", |
||||
"columnName": "maxPollOptions", |
||||
"affinity": "INTEGER", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "maxPollOptionLength", |
||||
"columnName": "maxPollOptionLength", |
||||
"affinity": "INTEGER", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "version", |
||||
"columnName": "version", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
} |
||||
], |
||||
"primaryKey": { |
||||
"columnNames": [ |
||||
"instance" |
||||
], |
||||
"autoGenerate": false |
||||
}, |
||||
"indices": [], |
||||
"foreignKeys": [] |
||||
}, |
||||
{ |
||||
"tableName": "TimelineStatusEntity", |
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serverId` TEXT NOT NULL, `url` TEXT, `timelineUserId` INTEGER NOT NULL, `authorServerId` TEXT, `inReplyToId` TEXT, `inReplyToAccountId` TEXT, `content` TEXT, `createdAt` INTEGER NOT NULL, `emojis` TEXT, `reblogsCount` INTEGER NOT NULL, `favouritesCount` INTEGER NOT NULL, `reblogged` INTEGER NOT NULL, `bookmarked` INTEGER NOT NULL, `favourited` INTEGER NOT NULL, `sensitive` INTEGER NOT NULL, `spoilerText` TEXT, `visibility` INTEGER, `attachments` TEXT, `mentions` TEXT, `application` TEXT, `reblogServerId` TEXT, `reblogAccountId` TEXT, `poll` TEXT, `muted` INTEGER, PRIMARY KEY(`serverId`, `timelineUserId`), FOREIGN KEY(`authorServerId`, `timelineUserId`) REFERENCES `TimelineAccountEntity`(`serverId`, `timelineUserId`) ON UPDATE NO ACTION ON DELETE NO ACTION )", |
||||
"fields": [ |
||||
{ |
||||
"fieldPath": "serverId", |
||||
"columnName": "serverId", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "url", |
||||
"columnName": "url", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "timelineUserId", |
||||
"columnName": "timelineUserId", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "authorServerId", |
||||
"columnName": "authorServerId", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "inReplyToId", |
||||
"columnName": "inReplyToId", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "inReplyToAccountId", |
||||
"columnName": "inReplyToAccountId", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "content", |
||||
"columnName": "content", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "createdAt", |
||||
"columnName": "createdAt", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "emojis", |
||||
"columnName": "emojis", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "reblogsCount", |
||||
"columnName": "reblogsCount", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "favouritesCount", |
||||
"columnName": "favouritesCount", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "reblogged", |
||||
"columnName": "reblogged", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "bookmarked", |
||||
"columnName": "bookmarked", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "favourited", |
||||
"columnName": "favourited", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "sensitive", |
||||
"columnName": "sensitive", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "spoilerText", |
||||
"columnName": "spoilerText", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "visibility", |
||||
"columnName": "visibility", |
||||
"affinity": "INTEGER", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "attachments", |
||||
"columnName": "attachments", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "mentions", |
||||
"columnName": "mentions", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "application", |
||||
"columnName": "application", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "reblogServerId", |
||||
"columnName": "reblogServerId", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "reblogAccountId", |
||||
"columnName": "reblogAccountId", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "poll", |
||||
"columnName": "poll", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "muted", |
||||
"columnName": "muted", |
||||
"affinity": "INTEGER", |
||||
"notNull": false |
||||
} |
||||
], |
||||
"primaryKey": { |
||||
"columnNames": [ |
||||
"serverId", |
||||
"timelineUserId" |
||||
], |
||||
"autoGenerate": false |
||||
}, |
||||
"indices": [ |
||||
{ |
||||
"name": "index_TimelineStatusEntity_authorServerId_timelineUserId", |
||||
"unique": false, |
||||
"columnNames": [ |
||||
"authorServerId", |
||||
"timelineUserId" |
||||
], |
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_TimelineStatusEntity_authorServerId_timelineUserId` ON `${TABLE_NAME}` (`authorServerId`, `timelineUserId`)" |
||||
} |
||||
], |
||||
"foreignKeys": [ |
||||
{ |
||||
"table": "TimelineAccountEntity", |
||||
"onDelete": "NO ACTION", |
||||
"onUpdate": "NO ACTION", |
||||
"columns": [ |
||||
"authorServerId", |
||||
"timelineUserId" |
||||
], |
||||
"referencedColumns": [ |
||||
"serverId", |
||||
"timelineUserId" |
||||
] |
||||
} |
||||
] |
||||
}, |
||||
{ |
||||
"tableName": "TimelineAccountEntity", |
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serverId` TEXT NOT NULL, `timelineUserId` INTEGER NOT NULL, `localUsername` TEXT NOT NULL, `username` TEXT NOT NULL, `displayName` TEXT NOT NULL, `url` TEXT NOT NULL, `avatar` TEXT NOT NULL, `emojis` TEXT NOT NULL, `bot` INTEGER NOT NULL, PRIMARY KEY(`serverId`, `timelineUserId`))", |
||||
"fields": [ |
||||
{ |
||||
"fieldPath": "serverId", |
||||
"columnName": "serverId", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "timelineUserId", |
||||
"columnName": "timelineUserId", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "localUsername", |
||||
"columnName": "localUsername", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "username", |
||||
"columnName": "username", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "displayName", |
||||
"columnName": "displayName", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "url", |
||||
"columnName": "url", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "avatar", |
||||
"columnName": "avatar", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "emojis", |
||||
"columnName": "emojis", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "bot", |
||||
"columnName": "bot", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
} |
||||
], |
||||
"primaryKey": { |
||||
"columnNames": [ |
||||
"serverId", |
||||
"timelineUserId" |
||||
], |
||||
"autoGenerate": false |
||||
}, |
||||
"indices": [], |
||||
"foreignKeys": [] |
||||
}, |
||||
{ |
||||
"tableName": "ConversationEntity", |
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`accountId` INTEGER NOT NULL, `id` TEXT NOT NULL, `accounts` TEXT NOT NULL, `unread` INTEGER NOT NULL, `s_id` TEXT NOT NULL, `s_url` TEXT, `s_inReplyToId` TEXT, `s_inReplyToAccountId` TEXT, `s_account` TEXT NOT NULL, `s_content` TEXT NOT NULL, `s_createdAt` INTEGER NOT NULL, `s_emojis` TEXT NOT NULL, `s_favouritesCount` INTEGER NOT NULL, `s_favourited` INTEGER NOT NULL, `s_bookmarked` INTEGER NOT NULL, `s_sensitive` INTEGER NOT NULL, `s_spoilerText` TEXT NOT NULL, `s_attachments` TEXT NOT NULL, `s_mentions` TEXT NOT NULL, `s_showingHiddenContent` INTEGER NOT NULL, `s_expanded` INTEGER NOT NULL, `s_collapsible` INTEGER NOT NULL, `s_collapsed` INTEGER NOT NULL, `s_poll` TEXT, PRIMARY KEY(`id`, `accountId`))", |
||||
"fields": [ |
||||
{ |
||||
"fieldPath": "accountId", |
||||
"columnName": "accountId", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "id", |
||||
"columnName": "id", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "accounts", |
||||
"columnName": "accounts", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "unread", |
||||
"columnName": "unread", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.id", |
||||
"columnName": "s_id", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.url", |
||||
"columnName": "s_url", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.inReplyToId", |
||||
"columnName": "s_inReplyToId", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.inReplyToAccountId", |
||||
"columnName": "s_inReplyToAccountId", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.account", |
||||
"columnName": "s_account", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.content", |
||||
"columnName": "s_content", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.createdAt", |
||||
"columnName": "s_createdAt", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.emojis", |
||||
"columnName": "s_emojis", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.favouritesCount", |
||||
"columnName": "s_favouritesCount", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.favourited", |
||||
"columnName": "s_favourited", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.bookmarked", |
||||
"columnName": "s_bookmarked", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.sensitive", |
||||
"columnName": "s_sensitive", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.spoilerText", |
||||
"columnName": "s_spoilerText", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.attachments", |
||||
"columnName": "s_attachments", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.mentions", |
||||
"columnName": "s_mentions", |
||||
"affinity": "TEXT", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.showingHiddenContent", |
||||
"columnName": "s_showingHiddenContent", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.expanded", |
||||
"columnName": "s_expanded", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.collapsible", |
||||
"columnName": "s_collapsible", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.collapsed", |
||||
"columnName": "s_collapsed", |
||||
"affinity": "INTEGER", |
||||
"notNull": true |
||||
}, |
||||
{ |
||||
"fieldPath": "lastStatus.poll", |
||||
"columnName": "s_poll", |
||||
"affinity": "TEXT", |
||||
"notNull": false |
||||
} |
||||
], |
||||
"primaryKey": { |
||||
"columnNames": [ |
||||
"id", |
||||
"accountId" |
||||
], |
||||
"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, '14fb3d5743b7a89e8e62463e05f086ab')" |
||||
] |
||||
} |
||||
} |
||||
@ -1,209 +0,0 @@
|
||||
/* Copyright 2017 Andrew Dawson |
||||
* |
||||
* This file is a part of Tusky. |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify it under the terms of the |
||||
* GNU General Public License as published by the Free Software Foundation; either version 3 of the |
||||
* License, or (at your option) any later version. |
||||
* |
||||
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
||||
* Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License along with Tusky; if not, |
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
package com.keylesspalace.tusky; |
||||
|
||||
import android.content.Intent; |
||||
import android.os.AsyncTask; |
||||
import android.os.Bundle; |
||||
import android.view.View; |
||||
|
||||
import androidx.annotation.Nullable; |
||||
import androidx.appcompat.app.ActionBar; |
||||
import androidx.appcompat.widget.Toolbar; |
||||
import androidx.lifecycle.Lifecycle; |
||||
import androidx.recyclerview.widget.DividerItemDecoration; |
||||
import androidx.recyclerview.widget.LinearLayoutManager; |
||||
import androidx.recyclerview.widget.RecyclerView; |
||||
|
||||
import com.google.gson.Gson; |
||||
import com.google.gson.reflect.TypeToken; |
||||
import com.keylesspalace.tusky.adapter.SavedTootAdapter; |
||||
import com.keylesspalace.tusky.appstore.EventHub; |
||||
import com.keylesspalace.tusky.appstore.StatusComposedEvent; |
||||
import com.keylesspalace.tusky.components.compose.ComposeActivity; |
||||
import com.keylesspalace.tusky.db.AppDatabase; |
||||
import com.keylesspalace.tusky.db.TootDao; |
||||
import com.keylesspalace.tusky.db.TootEntity; |
||||
import com.keylesspalace.tusky.di.Injectable; |
||||
import com.keylesspalace.tusky.util.SaveTootHelper; |
||||
import com.keylesspalace.tusky.view.BackgroundMessageView; |
||||
|
||||
import java.lang.ref.WeakReference; |
||||
import java.lang.reflect.Type; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import javax.inject.Inject; |
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers; |
||||
|
||||
import static com.keylesspalace.tusky.components.compose.ComposeActivity.ComposeOptions; |
||||
import static com.uber.autodispose.AutoDispose.autoDisposable; |
||||
import static com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider.from; |
||||
|
||||
public final class SavedTootActivity extends BaseActivity implements SavedTootAdapter.SavedTootAction, |
||||
Injectable { |
||||
|
||||
// ui
|
||||
private SavedTootAdapter adapter; |
||||
private BackgroundMessageView errorMessageView; |
||||
|
||||
private List<TootEntity> toots = new ArrayList<>(); |
||||
@Nullable |
||||
private AsyncTask<?, ?, ?> asyncTask; |
||||
|
||||
@Inject |
||||
EventHub eventHub; |
||||
@Inject |
||||
AppDatabase database; |
||||
@Inject |
||||
SaveTootHelper saveTootHelper; |
||||
|
||||
@Override |
||||
protected void onCreate(Bundle savedInstanceState) { |
||||
super.onCreate(savedInstanceState); |
||||
|
||||
eventHub.getEvents() |
||||
.observeOn(AndroidSchedulers.mainThread()) |
||||
.ofType(StatusComposedEvent.class) |
||||
.as(autoDisposable(from(this, Lifecycle.Event.ON_DESTROY))) |
||||
.subscribe((__) -> this.fetchToots()); |
||||
|
||||
setContentView(R.layout.activity_saved_toot); |
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar); |
||||
setSupportActionBar(toolbar); |
||||
ActionBar bar = getSupportActionBar(); |
||||
if (bar != null) { |
||||
bar.setTitle(getString(R.string.title_drafts)); |
||||
bar.setDisplayHomeAsUpEnabled(true); |
||||
bar.setDisplayShowHomeEnabled(true); |
||||
} |
||||
|
||||
RecyclerView recyclerView = findViewById(R.id.recyclerView); |
||||
errorMessageView = findViewById(R.id.errorMessageView); |
||||
recyclerView.setHasFixedSize(true); |
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(this); |
||||
recyclerView.setLayoutManager(layoutManager); |
||||
DividerItemDecoration divider = new DividerItemDecoration( |
||||
this, layoutManager.getOrientation()); |
||||
recyclerView.addItemDecoration(divider); |
||||
adapter = new SavedTootAdapter(this); |
||||
recyclerView.setAdapter(adapter); |
||||
} |
||||
|
||||
@Override |
||||
protected void onResume() { |
||||
super.onResume(); |
||||
fetchToots(); |
||||
} |
||||
|
||||
@Override |
||||
protected void onPause() { |
||||
super.onPause(); |
||||
if (asyncTask != null) asyncTask.cancel(true); |
||||
} |
||||
|
||||
private void fetchToots() { |
||||
asyncTask = new FetchPojosTask(this, database.tootDao()) |
||||
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); |
||||
} |
||||
|
||||
private void setNoContent(int size) { |
||||
if (size == 0) { |
||||
errorMessageView.setup(R.drawable.elephant_friend_empty, R.string.no_saved_status, null); |
||||
errorMessageView.setVisibility(View.VISIBLE); |
||||
} else { |
||||
errorMessageView.setVisibility(View.GONE); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void delete(int position, TootEntity item) { |
||||
|
||||
saveTootHelper.deleteDraft(item); |
||||
|
||||
toots.remove(position); |
||||
// update adapter
|
||||
if (adapter != null) { |
||||
adapter.removeItem(position); |
||||
setNoContent(toots.size()); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void click(int position, TootEntity item) { |
||||
Gson gson = new Gson(); |
||||
Type stringListType = new TypeToken<List<String>>() {}.getType(); |
||||
List<String> jsonUrls = gson.fromJson(item.getUrls(), stringListType); |
||||
List<String> descriptions = gson.fromJson(item.getDescriptions(), stringListType); |
||||
|
||||
ComposeOptions composeOptions = new ComposeOptions( |
||||
/*scheduledTootUid*/null, |
||||
item.getUid(), |
||||
/*drafId*/null, |
||||
item.getText(), |
||||
jsonUrls, |
||||
descriptions, |
||||
/*mentionedUsernames*/null, |
||||
item.getInReplyToId(), |
||||
/*replyVisibility*/null, |
||||
item.getVisibility(), |
||||
item.getContentWarning(), |
||||
item.getInReplyToUsername(), |
||||
item.getInReplyToText(), |
||||
/*mediaAttachments*/null, |
||||
/*draftAttachments*/null, |
||||
/*scheduledAt*/null, |
||||
/*sensitive*/null, |
||||
/*poll*/null, |
||||
/* modifiedInitialState */ true |
||||
); |
||||
Intent intent = ComposeActivity.startIntent(this, composeOptions); |
||||
startActivity(intent); |
||||
} |
||||
|
||||
static final class FetchPojosTask extends AsyncTask<Void, Void, List<TootEntity>> { |
||||
|
||||
private final WeakReference<SavedTootActivity> activityRef; |
||||
private final TootDao tootDao; |
||||
|
||||
FetchPojosTask(SavedTootActivity activity, TootDao tootDao) { |
||||
this.activityRef = new WeakReference<>(activity); |
||||
this.tootDao = tootDao; |
||||
} |
||||
|
||||
@Override |
||||
protected List<TootEntity> doInBackground(Void... voids) { |
||||
return tootDao.loadAll(); |
||||
} |
||||
|
||||
@Override |
||||
protected void onPostExecute(List<TootEntity> pojos) { |
||||
super.onPostExecute(pojos); |
||||
SavedTootActivity activity = activityRef.get(); |
||||
if (activity == null) return; |
||||
|
||||
activity.toots.clear(); |
||||
activity.toots.addAll(pojos); |
||||
|
||||
// set ui
|
||||
activity.setNoContent(pojos.size()); |
||||
activity.adapter.setItems(activity.toots); |
||||
activity.adapter.notifyDataSetChanged(); |
||||
} |
||||
} |
||||
} |
||||
@ -1,122 +0,0 @@
|
||||
/* Copyright 2017 Andrew Dawson |
||||
* |
||||
* This file is a part of Tusky. |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify it under the terms of the |
||||
* GNU General Public License as published by the Free Software Foundation; either version 3 of the |
||||
* License, or (at your option) any later version. |
||||
* |
||||
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
||||
* Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License along with Tusky; if not, |
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
package com.keylesspalace.tusky.adapter; |
||||
|
||||
import android.content.Context; |
||||
import androidx.annotation.Nullable; |
||||
import androidx.recyclerview.widget.RecyclerView; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.widget.ImageButton; |
||||
import android.widget.TextView; |
||||
|
||||
import com.keylesspalace.tusky.R; |
||||
import com.keylesspalace.tusky.db.TootEntity; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class SavedTootAdapter extends RecyclerView.Adapter { |
||||
private List<TootEntity> list; |
||||
private SavedTootAction handler; |
||||
|
||||
public SavedTootAdapter(Context context) { |
||||
super(); |
||||
list = new ArrayList<>(); |
||||
handler = (SavedTootAction) context; |
||||
} |
||||
|
||||
@Override |
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
||||
View view = LayoutInflater.from(parent.getContext()) |
||||
.inflate(R.layout.item_saved_toot, parent, false); |
||||
return new TootViewHolder(view); |
||||
} |
||||
|
||||
@Override |
||||
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { |
||||
TootViewHolder holder = (TootViewHolder) viewHolder; |
||||
holder.bind(getItem(position)); |
||||
} |
||||
|
||||
@Override |
||||
public int getItemCount() { |
||||
return list.size(); |
||||
} |
||||
|
||||
public void setItems(List<TootEntity> newToot) { |
||||
list = new ArrayList<>(); |
||||
list.addAll(newToot); |
||||
} |
||||
|
||||
public void addItems(List<TootEntity> newToot) { |
||||
int end = list.size(); |
||||
list.addAll(newToot); |
||||
notifyItemRangeInserted(end, newToot.size()); |
||||
} |
||||
|
||||
@Nullable |
||||
public TootEntity removeItem(int position) { |
||||
if (position < 0 || position >= list.size()) { |
||||
return null; |
||||
} |
||||
TootEntity toot = list.remove(position); |
||||
notifyItemRemoved(position); |
||||
return toot; |
||||
} |
||||
|
||||
private TootEntity getItem(int position) { |
||||
if (position >= 0 && position < list.size()) { |
||||
return list.get(position); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
// handler saved toot
|
||||
public interface SavedTootAction { |
||||
void delete(int position, TootEntity item); |
||||
|
||||
void click(int position, TootEntity item); |
||||
} |
||||
|
||||
private class TootViewHolder extends RecyclerView.ViewHolder { |
||||
View view; |
||||
TextView content; |
||||
ImageButton suppr; |
||||
|
||||
TootViewHolder(View view) { |
||||
super(view); |
||||
this.view = view; |
||||
this.content = view.findViewById(R.id.content); |
||||
this.suppr = view.findViewById(R.id.suppr); |
||||
} |
||||
|
||||
void bind(final TootEntity item) { |
||||
suppr.setEnabled(true); |
||||
|
||||
if (item != null) { |
||||
content.setText(item.getText()); |
||||
|
||||
suppr.setOnClickListener(v -> { |
||||
v.setEnabled(false); |
||||
handler.delete(getBindingAdapterPosition(), item); |
||||
}); |
||||
view.setOnClickListener(v -> handler.click(getBindingAdapterPosition(), item)); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -1,45 +0,0 @@
|
||||
/* Copyright 2017 Andrew Dawson |
||||
* |
||||
* This file is a part of Tusky. |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify it under the terms of the |
||||
* GNU General Public License as published by the Free Software Foundation; either version 3 of the |
||||
* License, or (at your option) any later version. |
||||
* |
||||
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
||||
* Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License along with Tusky; if not, |
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
package com.keylesspalace.tusky.db; |
||||
|
||||
import androidx.room.Dao; |
||||
import androidx.room.Query; |
||||
|
||||
import java.util.List; |
||||
|
||||
import io.reactivex.Observable; |
||||
|
||||
/** |
||||
* Created by cto3543 on 28/06/2017. |
||||
* |
||||
* DAO to fetch and update toots in the DB. |
||||
*/ |
||||
|
||||
@Dao |
||||
public interface TootDao { |
||||
|
||||
@Query("SELECT * FROM TootEntity ORDER BY uid DESC") |
||||
List<TootEntity> loadAll(); |
||||
|
||||
@Query("DELETE FROM TootEntity WHERE uid = :uid") |
||||
int delete(int uid); |
||||
|
||||
@Query("SELECT * FROM TootEntity WHERE uid = :uid") |
||||
TootEntity find(int uid); |
||||
|
||||
@Query("SELECT COUNT(*) FROM TootEntity") |
||||
Observable<Integer> savedTootCount(); |
||||
} |
||||
@ -1,151 +0,0 @@
|
||||
/* Copyright 2017 Andrew Dawson |
||||
* |
||||
* This file is a part of Tusky. |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify it under the terms of the |
||||
* GNU General Public License as published by the Free Software Foundation; either version 3 of the |
||||
* License, or (at your option) any later version. |
||||
* |
||||
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
||||
* Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License along with Tusky; if not, |
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
package com.keylesspalace.tusky.db; |
||||
|
||||
import com.google.gson.Gson; |
||||
import com.keylesspalace.tusky.entity.NewPoll; |
||||
import com.keylesspalace.tusky.entity.Status; |
||||
|
||||
import androidx.annotation.Nullable; |
||||
import androidx.room.ColumnInfo; |
||||
import androidx.room.Entity; |
||||
import androidx.room.PrimaryKey; |
||||
import androidx.room.TypeConverter; |
||||
import androidx.room.TypeConverters; |
||||
|
||||
/** |
||||
* Toot model. |
||||
*/ |
||||
|
||||
@Entity |
||||
@TypeConverters(TootEntity.Converters.class) |
||||
public class TootEntity { |
||||
@PrimaryKey(autoGenerate = true) |
||||
private final int uid; |
||||
|
||||
@ColumnInfo(name = "text") |
||||
private final String text; |
||||
|
||||
@ColumnInfo(name = "urls") |
||||
private final String urls; |
||||
|
||||
@ColumnInfo(name = "descriptions") |
||||
private final String descriptions; |
||||
|
||||
@ColumnInfo(name = "contentWarning") |
||||
private final String contentWarning; |
||||
|
||||
@ColumnInfo(name = "inReplyToId") |
||||
private final String inReplyToId; |
||||
|
||||
@Nullable |
||||
@ColumnInfo(name = "inReplyToText") |
||||
private final String inReplyToText; |
||||
|
||||
@Nullable |
||||
@ColumnInfo(name = "inReplyToUsername") |
||||
private final String inReplyToUsername; |
||||
|
||||
@ColumnInfo(name = "visibility") |
||||
private final Status.Visibility visibility; |
||||
|
||||
@Nullable |
||||
@ColumnInfo(name = "poll") |
||||
private final NewPoll poll; |
||||
|
||||
public TootEntity(int uid, String text, String urls, String descriptions, String contentWarning, String inReplyToId, |
||||
@Nullable String inReplyToText, @Nullable String inReplyToUsername, |
||||
Status.Visibility visibility, @Nullable NewPoll poll) { |
||||
this.uid = uid; |
||||
this.text = text; |
||||
this.urls = urls; |
||||
this.descriptions = descriptions; |
||||
this.contentWarning = contentWarning; |
||||
this.inReplyToId = inReplyToId; |
||||
this.inReplyToText = inReplyToText; |
||||
this.inReplyToUsername = inReplyToUsername; |
||||
this.visibility = visibility; |
||||
this.poll = poll; |
||||
} |
||||
|
||||
public String getText() { |
||||
return text; |
||||
} |
||||
|
||||
public String getContentWarning() { |
||||
return contentWarning; |
||||
} |
||||
|
||||
public int getUid() { |
||||
return uid; |
||||
} |
||||
|
||||
public String getUrls() { |
||||
return urls; |
||||
} |
||||
|
||||
public String getDescriptions() { |
||||
return descriptions; |
||||
} |
||||
|
||||
public String getInReplyToId() { |
||||
return inReplyToId; |
||||
} |
||||
|
||||
@Nullable |
||||
public String getInReplyToText() { |
||||
return inReplyToText; |
||||
} |
||||
|
||||
@Nullable |
||||
public String getInReplyToUsername() { |
||||
return inReplyToUsername; |
||||
} |
||||
|
||||
public Status.Visibility getVisibility() { |
||||
return visibility; |
||||
} |
||||
|
||||
@Nullable |
||||
public NewPoll getPoll() { |
||||
return poll; |
||||
} |
||||
|
||||
public static final class Converters { |
||||
|
||||
private static final Gson gson = new Gson(); |
||||
|
||||
@TypeConverter |
||||
public Status.Visibility visibilityFromInt(int number) { |
||||
return Status.Visibility.byNum(number); |
||||
} |
||||
|
||||
@TypeConverter |
||||
public int intFromVisibility(Status.Visibility visibility) { |
||||
return visibility == null ? Status.Visibility.UNKNOWN.getNum() : visibility.getNum(); |
||||
} |
||||
|
||||
@TypeConverter |
||||
public String pollToString(NewPoll poll) { |
||||
return gson.toJson(poll); |
||||
} |
||||
|
||||
@TypeConverter |
||||
public NewPoll stringToPoll(String poll) { |
||||
return gson.fromJson(poll, NewPoll.class); |
||||
} |
||||
} |
||||
} |
||||
@ -1,57 +0,0 @@
|
||||
package com.keylesspalace.tusky.util; |
||||
|
||||
import android.content.Context; |
||||
import android.net.Uri; |
||||
import android.util.Log; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
|
||||
import com.google.gson.Gson; |
||||
import com.google.gson.reflect.TypeToken; |
||||
import com.keylesspalace.tusky.db.AppDatabase; |
||||
import com.keylesspalace.tusky.db.TootDao; |
||||
import com.keylesspalace.tusky.db.TootEntity; |
||||
|
||||
import java.util.ArrayList; |
||||
|
||||
import javax.inject.Inject; |
||||
|
||||
public final class SaveTootHelper { |
||||
|
||||
private static final String TAG = "SaveTootHelper"; |
||||
|
||||
private TootDao tootDao; |
||||
private Context context; |
||||
private Gson gson = new Gson(); |
||||
|
||||
@Inject |
||||
public SaveTootHelper(@NonNull AppDatabase appDatabase, @NonNull Context context) { |
||||
this.tootDao = appDatabase.tootDao(); |
||||
this.context = context; |
||||
} |
||||
|
||||
public void deleteDraft(int tootId) { |
||||
TootEntity item = tootDao.find(tootId); |
||||
if (item != null) { |
||||
deleteDraft(item); |
||||
} |
||||
} |
||||
|
||||
public void deleteDraft(@NonNull TootEntity item) { |
||||
// Delete any media files associated with the status.
|
||||
ArrayList<String> uris = gson.fromJson(item.getUrls(), |
||||
new TypeToken<ArrayList<String>>() { |
||||
}.getType()); |
||||
if (uris != null) { |
||||
for (String uriString : uris) { |
||||
Uri uri = Uri.parse(uriString); |
||||
if (context.getContentResolver().delete(uri, null, null) == 0) { |
||||
Log.e(TAG, String.format("Did not delete file %s.", uriString)); |
||||
} |
||||
} |
||||
} |
||||
// update DB
|
||||
tootDao.delete(item.getUid()); |
||||
} |
||||
|
||||
} |
||||
@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
android:id="@+id/activity_view_thread" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
tools:context="com.keylesspalace.tusky.AccountListActivity"> |
||||
|
||||
<include layout="@layout/toolbar_basic" /> |
||||
|
||||
<RelativeLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"> |
||||
|
||||
<androidx.recyclerview.widget.RecyclerView |
||||
android:id="@+id/recyclerView" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" /> |
||||
|
||||
<com.keylesspalace.tusky.view.BackgroundMessageView |
||||
android:id="@+id/errorMessageView" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_centerInParent="true" |
||||
android:src="@android:color/transparent" |
||||
android:visibility="gone" |
||||
tools:src="@drawable/elephant_error" |
||||
tools:visibility="visible" /> |
||||
|
||||
</RelativeLayout> |
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout> |
||||
@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="horizontal"> |
||||
|
||||
<androidx.emoji.widget.EmojiTextView |
||||
android:id="@+id/content" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="0.91" |
||||
android:padding="8dp" |
||||
android:textSize="?attr/status_text_medium" /> |
||||
|
||||
<ImageButton |
||||
android:id="@+id/suppr" |
||||
style="@style/TuskyImageButton" |
||||
android:layout_width="32dp" |
||||
android:layout_height="32dp" |
||||
android:layout_gravity="center_vertical" |
||||
android:layout_margin="12dp" |
||||
android:background="?attr/selectableItemBackgroundBorderless" |
||||
android:contentDescription="@string/action_delete" |
||||
android:padding="4dp" |
||||
app:srcCompat="@drawable/ic_clear_24dp" /> |
||||
|
||||
</LinearLayout> |
||||
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto"> |
||||
<item |
||||
android:id="@+id/action_old_drafts" |
||||
android:icon="@drawable/ic_notebook" |
||||
android:title="@string/old_drafts" |
||||
android:visible="false" |
||||
app:showAsAction="ifRoom" /> |
||||
</menu> |
||||
Loading…
Reference in new issue