From c00579ae7f3d1bf8aef46b444816f72f64626e5c Mon Sep 17 00:00:00 2001 From: Artem Umerov Date: Mon, 22 May 2023 21:07:51 +0300 Subject: [PATCH] 28 28 --- .../kotlin/dev/ragnarok/fenrir/Constants.kt | 8 +- .../dev/ragnarok/fenrir/api/impl/AbsApi.kt | 14 + .../dev/ragnarok/fenrir/api/impl/StoreApi.kt | 21 +- .../fenrir/api/interfaces/IStoreApi.kt | 10 +- .../ragnarok/fenrir/api/model/Dictionary.kt | 13 + .../fenrir/api/model/VKApiStickerSetsData.kt | 13 - .../fenrir/api/model/VKApiStickersKeywords.kt | 8 +- .../fenrir/api/model/response/VKResponse.kt | 4 +- .../ragnarok/fenrir/api/rest/IServiceRest.kt | 5 + .../fenrir/api/services/IStoreService.kt | 37 +- .../kotlin/dev/ragnarok/fenrir/db/DBHelper.kt | 393 ++++----- .../fenrir/db/FenrirContentProvider.kt | 819 +++++++++--------- .../dev/ragnarok/fenrir/db/OwnerHelper.kt | 10 +- .../dev/ragnarok/fenrir/db/TempDataHelper.kt | 124 +-- .../{AudioColumns.kt => AudiosColumns.kt} | 2 +- .../column/{DocColumns.kt => DocsColumns.kt} | 2 +- ...kt => EncryptionKeysForMessagesColumns.kt} | 4 +- .../fenrir/db/column/FaveArticlesColumns.kt | 2 +- .../fenrir/db/column/FaveLinksColumns.kt | 2 +- ...FavePageColumns.kt => FavePagesColumns.kt} | 2 +- ...oductColumns.kt => FaveProductsColumns.kt} | 4 +- .../{GroupColumns.kt => GroupsColumns.kt} | 2 +- ...sDetColumns.kt => GroupsDetailsColumns.kt} | 4 +- .../column/{LogColumns.kt => LogsColumns.kt} | 2 +- .../{MessageColumns.kt => MessagesColumns.kt} | 2 +- ...tionColumns.kt => NotificationsColumns.kt} | 2 +- .../ragnarok/fenrir/db/column/PeersColumns.kt | 2 +- ...shipColumns.kt => RelationshipsColumns.kt} | 4 +- ...ShortcutColumns.kt => ShortcutsColumns.kt} | 2 +- ...kerSetColumns.kt => StickerSetsColumns.kt} | 4 +- .../db/column/StickerSetsCustomColumns.kt | 15 + .../{UserColumns.kt => UsersColumns.kt} | 2 +- ...psDetColumns.kt => UsersDetailsColumns.kt} | 4 +- .../{VideoColumns.kt => VideosColumns.kt} | 2 +- ...sColumns.kt => WallsAttachmentsColumns.kt} | 4 +- .../fenrir/db/impl/AttachmentsStorage.kt | 6 +- .../ragnarok/fenrir/db/impl/DialogsStorage.kt | 22 +- .../ragnarok/fenrir/db/impl/DocsStorage.kt | 64 +- .../ragnarok/fenrir/db/impl/FaveStorage.kt | 26 +- .../fenrir/db/impl/FeedbackStorage.kt | 22 +- .../fenrir/db/impl/KeysPersistStorage.kt | 40 +- .../fenrir/db/impl/MessagesStorage.kt | 301 +++---- .../ragnarok/fenrir/db/impl/OwnersStorage.kt | 188 ++-- .../fenrir/db/impl/RelativeshipStorage.kt | 110 +-- .../fenrir/db/impl/StickersStorage.kt | 218 ++++- .../fenrir/db/impl/TempDataStorage.kt | 228 ++--- .../ragnarok/fenrir/db/impl/TopicsStorage.kt | 6 +- .../ragnarok/fenrir/db/impl/VideoStorage.kt | 164 ++-- .../fenrir/db/interfaces/IDialogsStorage.kt | 6 +- .../fenrir/db/interfaces/IStickersStorage.kt | 3 +- .../dev/ragnarok/fenrir/db/model/PeerPatch.kt | 4 +- .../fenrir/db/model/entity/DialogDboEntity.kt | 4 +- ...pleDialogEntity.kt => PeerDialogEntity.kt} | 30 +- .../db/model/entity/StickersKeywordsEntity.kt | 2 +- .../fenrir/domain/IStickersInteractor.kt | 4 +- .../fenrir/domain/impl/MessagesRepository.kt | 16 +- .../fenrir/domain/impl/StickersInteractor.kt | 104 +-- .../fenrir/domain/mappers/Dto2Entity.kt | 8 +- .../messages/dialogs/DialogsPresenter.kt | 46 +- .../ragnarok/fenrir/model/StickersKeywords.kt | 12 +- .../dev/ragnarok/fenrir/settings/ISettings.kt | 12 +- .../ragnarok/fenrir/settings/OtherSettings.kt | 36 +- .../kotlin/dev/ragnarok/fenrir/util/Utils.kt | 31 +- .../db/impl/SearchRequestHelperStorage.kt | 10 +- .../main/java/com/github/luben/zstd/Zstd.java | 16 +- .../zxing/aztec/encoder/HighLevelEncoder.java | 1 - .../jni/animation/libyuv/include/libyuv/row.h | 142 ++- .../jni/animation/libyuv/source/convert.cc | 40 + .../animation/libyuv/source/convert_argb.cc | 19 + .../libyuv/source/convert_from_argb.cc | 97 +++ .../libyuv/source/planar_functions.cc | 78 ++ .../jni/animation/libyuv/source/row_any.cc | 41 + .../jni/animation/libyuv/source/row_lsx.cc | 570 ++++++++++++ .../jni/animation/libyuv/source/row_rvv.cc | 56 ++ .../src/main/jni/compress/zstd/jni_zdict.c | 10 +- libfenrir/src/main/jni/thorvg/inc/thorvg.h | 27 +- .../thorvg/src/lib/sw_engine/tvgSwCommon.h | 12 +- .../thorvg/src/lib/sw_engine/tvgSwRaster.cpp | 283 +++--- .../src/lib/sw_engine/tvgSwRasterTexmap.h | 40 +- .../lib/sw_engine/tvgSwRasterTexmapInternal.h | 4 +- .../src/lib/sw_engine/tvgSwRenderer.cpp | 31 +- .../src/main/jni/thorvg/src/lib/tvgCanvas.cpp | 2 +- .../main/jni/thorvg/src/lib/tvgLoadModule.h | 5 - .../main/jni/thorvg/src/lib/tvgPicture.cpp | 7 - .../main/jni/thorvg/src/lib/tvgPictureImpl.h | 15 +- .../src/main/jni/thorvg/src/lib/tvgRender.h | 1 + .../main/jni/thorvg/src/lib/tvgSceneImpl.h | 13 +- .../src/main/jni/thorvg/src/lib/tvgShape.cpp | 4 +- .../main/jni/thorvg/src/lib/tvgShapeImpl.h | 47 +- .../thorvg/src/loaders/svg/tvgSvgLoader.cpp | 2 +- .../jni/thorvg/src/loaders/svg/tvgSvgLoader.h | 4 + .../src/loaders/svg/tvgSvgSceneBuilder.cpp | 36 +- 92 files changed, 3072 insertions(+), 1802 deletions(-) create mode 100644 app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/model/Dictionary.kt delete mode 100644 app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/model/VKApiStickerSetsData.kt rename app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/{AudioColumns.kt => AudiosColumns.kt} (96%) rename app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/{DocColumns.kt => DocsColumns.kt} (96%) rename app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/{KeyColumns.kt => EncryptionKeysForMessagesColumns.kt} (88%) rename app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/{FavePageColumns.kt => FavePagesColumns.kt} (91%) rename app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/{FaveProductColumns.kt => FaveProductsColumns.kt} (72%) rename app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/{GroupColumns.kt => GroupsColumns.kt} (98%) rename app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/{UsersDetColumns.kt => GroupsDetailsColumns.kt} (70%) rename app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/{LogColumns.kt => LogsColumns.kt} (86%) rename app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/{MessageColumns.kt => MessagesColumns.kt} (98%) rename app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/{NotificationColumns.kt => NotificationsColumns.kt} (88%) rename app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/{RelationshipColumns.kt => RelationshipsColumns.kt} (97%) rename app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/{ShortcutColumns.kt => ShortcutsColumns.kt} (83%) rename app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/{StickerSetColumns.kt => StickerSetsColumns.kt} (80%) create mode 100644 app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/StickerSetsCustomColumns.kt rename app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/{UserColumns.kt => UsersColumns.kt} (98%) rename app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/{GroupsDetColumns.kt => UsersDetailsColumns.kt} (70%) rename app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/{VideoColumns.kt => VideosColumns.kt} (98%) rename app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/attachments/{WallAttachmentsColumns.kt => WallsAttachmentsColumns.kt} (76%) rename app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/model/entity/{SimpleDialogEntity.kt => PeerDialogEntity.kt} (63%) diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/Constants.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/Constants.kt index 60dd20956..32d5b6b69 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/Constants.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/Constants.kt @@ -6,8 +6,8 @@ object Constants { const val API_VERSION = "5.131" const val AUTH_VERSION = API_VERSION - const val DATABASE_FENRIR_VERSION = 27 - const val DATABASE_TEMPORARY_VERSION = 5 + const val DATABASE_FENRIR_VERSION = 28 + const val DATABASE_TEMPORARY_VERSION = 6 const val EXPORT_SETTINGS_FORMAT = 1 const val forceDeveloperMode = BuildConfig.FORCE_DEVELOPER_MODE @@ -17,8 +17,8 @@ object Constants { const val FILE_PROVIDER_AUTHORITY: String = BuildConfig.APPLICATION_ID + ".file_provider" const val VK_ANDROID_APP_VERSION_NAME = "8.15" const val VK_ANDROID_APP_VERSION_CODE = "15271" - const val KATE_APP_VERSION_NAME = "99 lite" - const val KATE_APP_VERSION_CODE = "535" + const val KATE_APP_VERSION_NAME = "100 lite" + const val KATE_APP_VERSION_CODE = "536" const val API_ID: Int = BuildConfig.VK_API_APP_ID const val SECRET: String = BuildConfig.VK_CLIENT_SECRET const val PHOTOS_PATH = "DCIM/Fenrir" diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/impl/AbsApi.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/impl/AbsApi.kt index 8487dcd87..04b9d7d56 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/impl/AbsApi.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/impl/AbsApi.kt @@ -233,6 +233,13 @@ internal open class AbsApi(val accountId: Long, private val restProvider: IServi .blockingGet() } } + /* + response.executeErrors.nonNullNoEmpty { + it[0].requireNonNull { sit -> + throw Exceptions.propagate(ApiException(sit)) + } + } + */ response.response ?: throw NullPointerException("VK return null response") } } @@ -254,6 +261,13 @@ internal open class AbsApi(val accountId: Long, private val restProvider: IServi .blockingGet() } } + /* + response.executeErrors.nonNullNoEmpty { + it[0].requireNonNull { sit -> + throw Exceptions.propagate(ApiException(sit)) + } + } + */ Completable.complete() } } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/impl/StoreApi.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/impl/StoreApi.kt index e25319171..770618bc4 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/impl/StoreApi.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/impl/StoreApi.kt @@ -1,28 +1,37 @@ package dev.ragnarok.fenrir.api.impl -import dev.ragnarok.fenrir.Constants import dev.ragnarok.fenrir.api.IServiceProvider import dev.ragnarok.fenrir.api.TokenType import dev.ragnarok.fenrir.api.interfaces.IStoreApi -import dev.ragnarok.fenrir.api.model.VKApiStickerSetsData +import dev.ragnarok.fenrir.api.model.Dictionary +import dev.ragnarok.fenrir.api.model.Items +import dev.ragnarok.fenrir.api.model.VKApiSticker +import dev.ragnarok.fenrir.api.model.VKApiStickerSet import dev.ragnarok.fenrir.api.model.VKApiStickersKeywords import dev.ragnarok.fenrir.api.services.IStoreService import io.reactivex.rxjava3.core.Single internal class StoreApi(accountId: Long, provider: IServiceProvider) : AbsApi(accountId, provider), IStoreApi { - override val stickerKeywords: Single + override val stickerKeywords: Single> get() = provideService(IStoreService(), TokenType.USER) .flatMap { service -> service - .getStickersKeywords("var dic=API.store.getStickersKeywords({'v':'" + Constants.API_VERSION + "','aliases':1,'all_products':1}).dictionary;return {'keywords': dic@.words, 'words_stickers': dic@.user_stickers};") + .getStickersKeywords() .map(extractResponseWithErrorHandling()) } - override val stickers: Single + override val stickersSets: Single> get() = provideService(IStoreService(), TokenType.USER) .flatMap { service -> service - .getStickers("var pack = API.store.getProducts({'v':'" + Constants.API_VERSION + "','extended':1,'filters':'active','type':'stickers'}); var recent = API.messages.getRecentStickers(); return {'sticker_pack': pack, 'recent': recent};") + .getStickersSets() + .map(extractResponseWithErrorHandling()) + } + override val recentStickers: Single> + get() = provideService(IStoreService(), TokenType.USER) + .flatMap { service -> + service + .getRecentStickers() .map(extractResponseWithErrorHandling()) } } \ No newline at end of file diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/interfaces/IStoreApi.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/interfaces/IStoreApi.kt index e0a294047..6ec140a95 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/interfaces/IStoreApi.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/interfaces/IStoreApi.kt @@ -1,10 +1,14 @@ package dev.ragnarok.fenrir.api.interfaces -import dev.ragnarok.fenrir.api.model.VKApiStickerSetsData +import dev.ragnarok.fenrir.api.model.Dictionary +import dev.ragnarok.fenrir.api.model.Items +import dev.ragnarok.fenrir.api.model.VKApiSticker +import dev.ragnarok.fenrir.api.model.VKApiStickerSet import dev.ragnarok.fenrir.api.model.VKApiStickersKeywords import io.reactivex.rxjava3.core.Single interface IStoreApi { - val stickerKeywords: Single - val stickers: Single + val stickerKeywords: Single> + val stickersSets: Single> + val recentStickers: Single> } \ No newline at end of file diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/model/Dictionary.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/model/Dictionary.kt new file mode 100644 index 000000000..239ebae23 --- /dev/null +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/model/Dictionary.kt @@ -0,0 +1,13 @@ +package dev.ragnarok.fenrir.api.model + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +class Dictionary { + @SerialName("count") + var count = 0 + + @SerialName("dictionary") + var dictionary: ArrayList? = null +} diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/model/VKApiStickerSetsData.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/model/VKApiStickerSetsData.kt deleted file mode 100644 index b09bd359f..000000000 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/model/VKApiStickerSetsData.kt +++ /dev/null @@ -1,13 +0,0 @@ -package dev.ragnarok.fenrir.api.model - -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -class VKApiStickerSetsData { - @SerialName("recent") - var recent: Items? = null - - @SerialName("sticker_pack") - var sticker_pack: Items? = null -} \ No newline at end of file diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/model/VKApiStickersKeywords.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/model/VKApiStickersKeywords.kt index 9c5dd950d..1e94eb050 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/model/VKApiStickersKeywords.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/model/VKApiStickersKeywords.kt @@ -5,9 +5,9 @@ import kotlinx.serialization.Serializable @Serializable class VKApiStickersKeywords { - @SerialName("words_stickers") - var words_stickers: List?>? = null + @SerialName("user_stickers") + var user_stickers: List? = null - @SerialName("keywords") - var keywords: List?>? = null + @SerialName("words") + var words: List? = null } \ No newline at end of file diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/model/response/VKResponse.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/model/response/VKResponse.kt index 759440ccd..71bcffdb6 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/model/response/VKResponse.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/model/response/VKResponse.kt @@ -11,6 +11,6 @@ open class VKResponse { /* @SerialName("execute_errors") - var executeErrors: List? = null - */ + var executeErrors: List? = null + */ } \ No newline at end of file diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/rest/IServiceRest.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/rest/IServiceRest.kt index fcd8424f2..3608eae9b 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/rest/IServiceRest.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/rest/IServiceRest.kt @@ -1,5 +1,6 @@ package dev.ragnarok.fenrir.api.rest +import dev.ragnarok.fenrir.api.model.Dictionary import dev.ragnarok.fenrir.api.model.Items import dev.ragnarok.fenrir.api.model.response.BaseResponse import dev.ragnarok.fenrir.kJson @@ -44,6 +45,10 @@ abstract class IServiceRest { return BaseResponse.serializer(Items.serializer(serial)) } + inline fun dictionary(serial: KSerializer): KSerializer>> { + return BaseResponse.serializer(Dictionary.serializer(serial)) + } + private fun toSerialStr(obj: Any?): String? { return when (obj) { is String -> { diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/services/IStoreService.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/services/IStoreService.kt index 4ec92e9ec..247de7be5 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/services/IStoreService.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/services/IStoreService.kt @@ -1,25 +1,44 @@ package dev.ragnarok.fenrir.api.services -import dev.ragnarok.fenrir.api.model.VKApiStickerSetsData +import dev.ragnarok.fenrir.api.model.Dictionary +import dev.ragnarok.fenrir.api.model.Items +import dev.ragnarok.fenrir.api.model.VKApiSticker +import dev.ragnarok.fenrir.api.model.VKApiStickerSet import dev.ragnarok.fenrir.api.model.VKApiStickersKeywords import dev.ragnarok.fenrir.api.model.response.BaseResponse import dev.ragnarok.fenrir.api.rest.IServiceRest import io.reactivex.rxjava3.core.Single class IStoreService : IServiceRest() { - fun getStickers(code: String?): Single> { + fun getRecentStickers(): Single>> { return rest.request( - "execute", - form("code" to code), - base(VKApiStickerSetsData.serializer()) + "messages.getRecentStickers", + null, + items(VKApiSticker.serializer()) ) } - fun getStickersKeywords(code: String?): Single> { + fun getStickersSets(): Single>> { return rest.request( - "execute", - form("code" to code), - base(VKApiStickersKeywords.serializer()) + "store.getProducts", + form( + "extended" to 1, + "filters" to "active", + "type" to "stickers" + ), + items(VKApiStickerSet.Product.serializer()) + ) + } + + fun getStickersKeywords(): Single>> { + return rest.request( + "store.getStickersKeywords", + form( + "aliases" to 1, + "all_products" to 0, + "need_stickers" to 1 + ), + dictionary(VKApiStickersKeywords.serializer()) ) } } \ No newline at end of file diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/DBHelper.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/DBHelper.kt index 4a4f5a2b5..f67e99799 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/DBHelper.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/DBHelper.kt @@ -8,36 +8,36 @@ import dev.ragnarok.fenrir.Constants import dev.ragnarok.fenrir.db.column.CommentsColumns import dev.ragnarok.fenrir.db.column.CountriesColumns import dev.ragnarok.fenrir.db.column.DialogsColumns -import dev.ragnarok.fenrir.db.column.DocColumns +import dev.ragnarok.fenrir.db.column.DocsColumns +import dev.ragnarok.fenrir.db.column.EncryptionKeysForMessagesColumns import dev.ragnarok.fenrir.db.column.FaveArticlesColumns import dev.ragnarok.fenrir.db.column.FaveLinksColumns -import dev.ragnarok.fenrir.db.column.FavePageColumns +import dev.ragnarok.fenrir.db.column.FavePagesColumns import dev.ragnarok.fenrir.db.column.FavePhotosColumns import dev.ragnarok.fenrir.db.column.FavePostsColumns -import dev.ragnarok.fenrir.db.column.FaveProductColumns +import dev.ragnarok.fenrir.db.column.FaveProductsColumns import dev.ragnarok.fenrir.db.column.FaveVideosColumns import dev.ragnarok.fenrir.db.column.FeedListsColumns import dev.ragnarok.fenrir.db.column.FriendListsColumns -import dev.ragnarok.fenrir.db.column.GroupColumns -import dev.ragnarok.fenrir.db.column.GroupsDetColumns -import dev.ragnarok.fenrir.db.column.KeyColumns -import dev.ragnarok.fenrir.db.column.MessageColumns +import dev.ragnarok.fenrir.db.column.GroupsColumns +import dev.ragnarok.fenrir.db.column.GroupsDetailsColumns +import dev.ragnarok.fenrir.db.column.MessagesColumns import dev.ragnarok.fenrir.db.column.NewsColumns -import dev.ragnarok.fenrir.db.column.NotificationColumns +import dev.ragnarok.fenrir.db.column.NotificationsColumns import dev.ragnarok.fenrir.db.column.PeersColumns import dev.ragnarok.fenrir.db.column.PhotoAlbumsColumns import dev.ragnarok.fenrir.db.column.PhotosColumns import dev.ragnarok.fenrir.db.column.PhotosExtendedColumns import dev.ragnarok.fenrir.db.column.PostsColumns -import dev.ragnarok.fenrir.db.column.RelationshipColumns +import dev.ragnarok.fenrir.db.column.RelationshipsColumns import dev.ragnarok.fenrir.db.column.TopicsColumns -import dev.ragnarok.fenrir.db.column.UserColumns -import dev.ragnarok.fenrir.db.column.UsersDetColumns +import dev.ragnarok.fenrir.db.column.UsersColumns +import dev.ragnarok.fenrir.db.column.UsersDetailsColumns import dev.ragnarok.fenrir.db.column.VideoAlbumsColumns -import dev.ragnarok.fenrir.db.column.VideoColumns +import dev.ragnarok.fenrir.db.column.VideosColumns import dev.ragnarok.fenrir.db.column.attachments.CommentsAttachmentsColumns import dev.ragnarok.fenrir.db.column.attachments.MessagesAttachmentsColumns -import dev.ragnarok.fenrir.db.column.attachments.WallAttachmentsColumns +import dev.ragnarok.fenrir.db.column.attachments.WallsAttachmentsColumns import dev.ragnarok.fenrir.module.FenrirNative import java.util.concurrent.ConcurrentHashMap @@ -138,29 +138,29 @@ class DBHelper private constructor(context: Context, aid: Long) : db.execSQL("DROP TABLE IF EXISTS " + CommentsColumns.TABLENAME) db.execSQL("DROP TABLE IF EXISTS " + DialogsColumns.TABLENAME) db.execSQL("DROP TABLE IF EXISTS " + PeersColumns.TABLENAME) - db.execSQL("DROP TABLE IF EXISTS " + DocColumns.TABLENAME) - db.execSQL("DROP TABLE IF EXISTS " + GroupColumns.TABLENAME) - db.execSQL("DROP TABLE IF EXISTS " + GroupsDetColumns.TABLENAME) - db.execSQL("DROP TABLE IF EXISTS " + MessageColumns.TABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + DocsColumns.TABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + GroupsColumns.TABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + GroupsDetailsColumns.TABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + MessagesColumns.TABLENAME) db.execSQL("DROP TABLE IF EXISTS " + NewsColumns.TABLENAME) db.execSQL("DROP TABLE IF EXISTS " + PhotoAlbumsColumns.TABLENAME) db.execSQL("DROP TABLE IF EXISTS " + PhotosColumns.TABLENAME) db.execSQL("DROP TABLE IF EXISTS " + PhotosExtendedColumns.TABLENAME) - db.execSQL("DROP TABLE IF EXISTS " + WallAttachmentsColumns.TABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + WallsAttachmentsColumns.TABLENAME) db.execSQL("DROP TABLE IF EXISTS " + PostsColumns.TABLENAME) - db.execSQL("DROP TABLE IF EXISTS " + RelationshipColumns.TABLENAME) - db.execSQL("DROP TABLE IF EXISTS " + UserColumns.TABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + RelationshipsColumns.TABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + UsersColumns.TABLENAME) db.execSQL("DROP TABLE IF EXISTS " + VideoAlbumsColumns.TABLENAME) - db.execSQL("DROP TABLE IF EXISTS " + VideoColumns.TABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + VideosColumns.TABLENAME) db.execSQL("DROP TABLE IF EXISTS " + TopicsColumns.TABLENAME) - db.execSQL("DROP TABLE IF EXISTS " + NotificationColumns.TABLENAME) - db.execSQL("DROP TABLE IF EXISTS " + UsersDetColumns.TABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + NotificationsColumns.TABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + UsersDetailsColumns.TABLENAME) db.execSQL("DROP TABLE IF EXISTS " + FavePhotosColumns.TABLENAME) db.execSQL("DROP TABLE IF EXISTS " + FaveArticlesColumns.TABLENAME) - db.execSQL("DROP TABLE IF EXISTS " + FaveProductColumns.TABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + FaveProductsColumns.TABLENAME) db.execSQL("DROP TABLE IF EXISTS " + FaveVideosColumns.TABLENAME) - db.execSQL("DROP TABLE IF EXISTS " + FavePageColumns.TABLENAME) - db.execSQL("DROP TABLE IF EXISTS " + FavePageColumns.GROUPSTABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + FavePagesColumns.TABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + FavePagesColumns.GROUPSTABLENAME) db.execSQL("DROP TABLE IF EXISTS " + FaveLinksColumns.TABLENAME) db.execSQL("DROP TABLE IF EXISTS " + FavePostsColumns.TABLENAME) db.execSQL("DROP TABLE IF EXISTS " + CountriesColumns.TABLENAME) @@ -171,29 +171,30 @@ class DBHelper private constructor(context: Context, aid: Long) : } private fun createKeysTableIfNotExist(db: SQLiteDatabase) { - val sql = "CREATE TABLE IF NOT EXISTS [" + KeyColumns.TABLENAME + "] (\n" + - " [" + BaseColumns._ID + "] INTEGER PRIMARY KEY AUTOINCREMENT, " + - " [" + KeyColumns.VERSION + "] INTEGER, " + - " [" + KeyColumns.PEER_ID + "] INTEGER, " + - " [" + KeyColumns.SESSION_ID + "] INTEGER, " + - " [" + KeyColumns.DATE + "] INTEGER, " + - " [" + KeyColumns.START_SESSION_MESSAGE_ID + "] INTEGER, " + - " [" + KeyColumns.END_SESSION_MESSAGE_ID + "] INTEGER, " + - " [" + KeyColumns.OUT_KEY + "] TEXT, " + - " [" + KeyColumns.IN_KEY + "] TEXT," + - " CONSTRAINT [] UNIQUE ([" + KeyColumns.SESSION_ID + "]) ON CONFLICT REPLACE);" + val sql = + "CREATE TABLE IF NOT EXISTS [" + EncryptionKeysForMessagesColumns.TABLENAME + "] (\n" + + " [" + BaseColumns._ID + "] INTEGER PRIMARY KEY AUTOINCREMENT, " + + " [" + EncryptionKeysForMessagesColumns.VERSION + "] INTEGER, " + + " [" + EncryptionKeysForMessagesColumns.PEER_ID + "] INTEGER, " + + " [" + EncryptionKeysForMessagesColumns.SESSION_ID + "] INTEGER, " + + " [" + EncryptionKeysForMessagesColumns.DATE + "] INTEGER, " + + " [" + EncryptionKeysForMessagesColumns.START_SESSION_MESSAGE_ID + "] INTEGER, " + + " [" + EncryptionKeysForMessagesColumns.END_SESSION_MESSAGE_ID + "] INTEGER, " + + " [" + EncryptionKeysForMessagesColumns.OUT_KEY + "] TEXT, " + + " [" + EncryptionKeysForMessagesColumns.IN_KEY + "] TEXT," + + " CONSTRAINT [] UNIQUE ([" + EncryptionKeysForMessagesColumns.SESSION_ID + "]) ON CONFLICT REPLACE);" db.execSQL(sql) } private fun createZeroMessageProtectionTriggers(db: SQLiteDatabase) { val sqlUpdate = - "CREATE TRIGGER zero_msg_upd BEFORE UPDATE ON " + MessageColumns.TABLENAME + " FOR EACH ROW " + - "WHEN OLD." + MessageColumns._ID + " = 0 BEGIN " + + "CREATE TRIGGER zero_msg_upd BEFORE UPDATE ON " + MessagesColumns.TABLENAME + " FOR EACH ROW " + + "WHEN OLD." + MessagesColumns._ID + " = 0 BEGIN " + " SELECT RAISE(ABORT, 'Cannot update record with _id=0');" + "END;" val sqlDelete = - "CREATE TRIGGER zero_msg_del BEFORE DELETE ON " + MessageColumns.TABLENAME + " FOR EACH ROW " + - "WHEN OLD." + MessageColumns._ID + " = 0 BEGIN " + + "CREATE TRIGGER zero_msg_del BEFORE DELETE ON " + MessagesColumns.TABLENAME + " FOR EACH ROW " + + "WHEN OLD." + MessagesColumns._ID + " = 0 BEGIN " + " SELECT RAISE(ABORT, 'Cannot delete record with _id=0');" + "END;" db.execSQL(sqlUpdate) @@ -265,7 +266,7 @@ class DBHelper private constructor(context: Context, aid: Long) : //" [" + MessagesAttachmentsColumns.ATTACHMENT_OWNER_ID + "] INTEGER, " + //" CONSTRAINT [] UNIQUE ([" + MessagesAttachmentsColumns.M_ID + "], [" + MessagesAttachmentsColumns.ATTACHMENT_ID + "], [" + MessagesAttachmentsColumns.ATTACHMENT_OWNER_ID + "], [" + MessagesAttachmentsColumns.TYPE + "]) ON CONFLICT REPLACE," + " FOREIGN KEY([" + MessagesAttachmentsColumns.M_ID + "]) " + - " REFERENCES " + MessageColumns.TABLENAME + "([" + MessageColumns._ID + "]) ON DELETE CASCADE ON UPDATE CASCADE);" + " REFERENCES " + MessagesColumns.TABLENAME + "([" + MessagesColumns._ID + "]) ON DELETE CASCADE ON UPDATE CASCADE);" db.execSQL(sql) } @@ -347,9 +348,9 @@ class DBHelper private constructor(context: Context, aid: Long) : * @param db БД */ private fun createFaveProductTable(db: SQLiteDatabase) { - val create = "CREATE TABLE [" + FaveProductColumns.TABLENAME + "] (" + + val create = "CREATE TABLE [" + FaveProductsColumns.TABLENAME + "] (" + " [" + BaseColumns._ID + "] INTEGER PRIMARY KEY AUTOINCREMENT, " + - " [" + FaveProductColumns.PRODUCT + "] BLOB);" + " [" + FaveProductsColumns.PRODUCT + "] BLOB);" db.execSQL(create) } @@ -371,21 +372,21 @@ class DBHelper private constructor(context: Context, aid: Long) : * @param db БД */ private fun createFavePageTable(db: SQLiteDatabase) { - val create = "CREATE TABLE [" + FavePageColumns.TABLENAME + "] (" + + val create = "CREATE TABLE [" + FavePagesColumns.TABLENAME + "] (" + " [" + BaseColumns._ID + "] INTEGER NOT NULL UNIQUE, " + - " [" + FavePageColumns.DESCRIPTION + "] TEXT, " + - " [" + FavePageColumns.UPDATED_TIME + "] INTEGER, " + - " [" + FavePageColumns.FAVE_TYPE + "] TEXT, " + + " [" + FavePagesColumns.DESCRIPTION + "] TEXT, " + + " [" + FavePagesColumns.UPDATED_TIME + "] INTEGER, " + + " [" + FavePagesColumns.FAVE_TYPE + "] TEXT, " + " CONSTRAINT [] PRIMARY KEY([" + BaseColumns._ID + "]) ON CONFLICT REPLACE);" db.execSQL(create) } private fun createFaveGroupsTable(db: SQLiteDatabase) { - val create = "CREATE TABLE [" + FavePageColumns.GROUPSTABLENAME + "] (" + + val create = "CREATE TABLE [" + FavePagesColumns.GROUPSTABLENAME + "] (" + " [" + BaseColumns._ID + "] INTEGER NOT NULL UNIQUE, " + - " [" + FavePageColumns.DESCRIPTION + "] TEXT, " + - " [" + FavePageColumns.UPDATED_TIME + "] INTEGER, " + - " [" + FavePageColumns.FAVE_TYPE + "] TEXT, " + + " [" + FavePagesColumns.DESCRIPTION + "] TEXT, " + + " [" + FavePagesColumns.UPDATED_TIME + "] INTEGER, " + + " [" + FavePagesColumns.FAVE_TYPE + "] TEXT, " + " CONSTRAINT [] PRIMARY KEY([" + BaseColumns._ID + "]) ON CONFLICT REPLACE);" db.execSQL(create) } @@ -431,50 +432,50 @@ class DBHelper private constructor(context: Context, aid: Long) : * @param db БД */ private fun createPostAttachmentsTable(db: SQLiteDatabase) { - val sql = "CREATE TABLE [" + WallAttachmentsColumns.TABLENAME + "] (\n" + + val sql = "CREATE TABLE [" + WallsAttachmentsColumns.TABLENAME + "] (\n" + " [" + BaseColumns._ID + "] INTEGER PRIMARY KEY AUTOINCREMENT, " + - " [" + WallAttachmentsColumns.P_ID + "] INTEGER, " + - " [" + WallAttachmentsColumns.DATA + "] BLOB, " + - " FOREIGN KEY([" + WallAttachmentsColumns.P_ID + "]) " + + " [" + WallsAttachmentsColumns.P_ID + "] INTEGER, " + + " [" + WallsAttachmentsColumns.DATA + "] BLOB, " + + " FOREIGN KEY([" + WallsAttachmentsColumns.P_ID + "]) " + " REFERENCES " + PostsColumns.TABLENAME + "([" + BaseColumns._ID + "]) ON DELETE CASCADE ON UPDATE CASCADE);" db.execSQL(sql) } private fun createMessagesTable(db: SQLiteDatabase) { - val create = "CREATE TABLE [" + MessageColumns.TABLENAME + "] (\n" + - " [" + MessageColumns._ID + "] INTEGER PRIMARY KEY ON CONFLICT REPLACE AUTOINCREMENT NOT NULL UNIQUE, " + - " [" + MessageColumns.PEER_ID + "] INTEGER, " + - " [" + MessageColumns.FROM_ID + "] INTEGER, " + - " [" + MessageColumns.DATE + "] INTEGER, " + - " [" + MessageColumns.OUT + "] BOOLEAN, " + - " [" + MessageColumns.BODY + "] TEXT, " + - " [" + MessageColumns.ENCRYPTED + "] BOOLEAN, " + - " [" + MessageColumns.DELETED + "] BOOLEAN, " + - " [" + MessageColumns.DELETED_FOR_ALL + "] BOOLEAN, " + - " [" + MessageColumns.IMPORTANT + "] BOOLEAN, " + - " [" + MessageColumns.FORWARD_COUNT + "] INTEGER, " + - " [" + MessageColumns.HAS_ATTACHMENTS + "] BOOLEAN, " + - " [" + MessageColumns.ATTACH_TO + "] INTEGER REFERENCES " + MessageColumns.TABLENAME + "([" + MessageColumns._ID + "]) ON DELETE CASCADE ON UPDATE CASCADE, " + - " [" + MessageColumns.STATUS + "] INTEGER, " + - " [" + MessageColumns.UPDATE_TIME + "] INTEGER, " + - " [" + MessageColumns.ACTION + "] INTEGER, " + - " [" + MessageColumns.ACTION_MID + "] INTEGER, " + - " [" + MessageColumns.ACTION_EMAIL + "] TEXT, " + - " [" + MessageColumns.ACTION_TEXT + "] TEXT, " + - " [" + MessageColumns.PHOTO_50 + "] TEXT, " + - " [" + MessageColumns.PHOTO_100 + "] TEXT, " + - " [" + MessageColumns.PHOTO_200 + "] TEXT, " + - " [" + MessageColumns.RANDOM_ID + "] INTEGER, " + - " [" + MessageColumns.EXTRAS + "] BLOB, " + - " [" + MessageColumns.ORIGINAL_ID + "] INTEGER, " + - " [" + MessageColumns.KEYBOARD + "] BLOB, " + - " [" + MessageColumns.PAYLOAD + "] TEXT);" + val create = "CREATE TABLE [" + MessagesColumns.TABLENAME + "] (\n" + + " [" + MessagesColumns._ID + "] INTEGER PRIMARY KEY ON CONFLICT REPLACE AUTOINCREMENT NOT NULL UNIQUE, " + + " [" + MessagesColumns.PEER_ID + "] INTEGER, " + + " [" + MessagesColumns.FROM_ID + "] INTEGER, " + + " [" + MessagesColumns.DATE + "] INTEGER, " + + " [" + MessagesColumns.OUT + "] BOOLEAN, " + + " [" + MessagesColumns.BODY + "] TEXT, " + + " [" + MessagesColumns.ENCRYPTED + "] BOOLEAN, " + + " [" + MessagesColumns.DELETED + "] BOOLEAN, " + + " [" + MessagesColumns.DELETED_FOR_ALL + "] BOOLEAN, " + + " [" + MessagesColumns.IMPORTANT + "] BOOLEAN, " + + " [" + MessagesColumns.FORWARD_COUNT + "] INTEGER, " + + " [" + MessagesColumns.HAS_ATTACHMENTS + "] BOOLEAN, " + + " [" + MessagesColumns.ATTACH_TO + "] INTEGER REFERENCES " + MessagesColumns.TABLENAME + "([" + MessagesColumns._ID + "]) ON DELETE CASCADE ON UPDATE CASCADE, " + + " [" + MessagesColumns.STATUS + "] INTEGER, " + + " [" + MessagesColumns.UPDATE_TIME + "] INTEGER, " + + " [" + MessagesColumns.ACTION + "] INTEGER, " + + " [" + MessagesColumns.ACTION_MID + "] INTEGER, " + + " [" + MessagesColumns.ACTION_EMAIL + "] TEXT, " + + " [" + MessagesColumns.ACTION_TEXT + "] TEXT, " + + " [" + MessagesColumns.PHOTO_50 + "] TEXT, " + + " [" + MessagesColumns.PHOTO_100 + "] TEXT, " + + " [" + MessagesColumns.PHOTO_200 + "] TEXT, " + + " [" + MessagesColumns.RANDOM_ID + "] INTEGER, " + + " [" + MessagesColumns.EXTRAS + "] BLOB, " + + " [" + MessagesColumns.ORIGINAL_ID + "] INTEGER, " + + " [" + MessagesColumns.KEYBOARD + "] BLOB, " + + " [" + MessagesColumns.PAYLOAD + "] TEXT);" val insertZeroRow = - "INSERT INTO " + MessageColumns.TABLENAME + " (" + MessageColumns._ID + ") VALUES (0)" + "INSERT INTO " + MessagesColumns.TABLENAME + " (" + MessagesColumns._ID + ") VALUES (0)" val insert = - "INSERT INTO " + MessageColumns.TABLENAME + " (" + MessageColumns._ID + ") VALUES (1000000000)" + "INSERT INTO " + MessagesColumns.TABLENAME + " (" + MessagesColumns._ID + ") VALUES (1000000000)" val delete = - "DELETE FROM " + MessageColumns.TABLENAME + " WHERE " + MessageColumns._ID + " = 1000000000" + "DELETE FROM " + MessagesColumns.TABLENAME + " WHERE " + MessagesColumns._ID + " = 1000000000" db.execSQL(create) db.execSQL(insertZeroRow) db.execSQL(insert) @@ -492,65 +493,65 @@ class DBHelper private constructor(context: Context, aid: Long) : } private fun createVideosTable(db: SQLiteDatabase) { - val sql = "CREATE TABLE [" + VideoColumns.TABLENAME + "] (\n" + + val sql = "CREATE TABLE [" + VideosColumns.TABLENAME + "] (\n" + " [" + BaseColumns._ID + "] INTEGER PRIMARY KEY AUTOINCREMENT, " + - " [" + VideoColumns.VIDEO_ID + "] INTEGER, " + - " [" + VideoColumns.OWNER_ID + "] INTEGER, " + - " [" + VideoColumns.ORIGINAL_OWNER_ID + "] INTEGER, " + - " [" + VideoColumns.ALBUM_ID + "] INTEGER, " + - " [" + VideoColumns.TITLE + "] TEXT, " + - " [" + VideoColumns.DESCRIPTION + "] TEXT, " + - " [" + VideoColumns.DURATION + "] INTEGER, " + - " [" + VideoColumns.LINK + "] TEXT, " + - " [" + VideoColumns.DATE + "] INTEGER, " + - " [" + VideoColumns.ADDING_DATE + "] INTEGER, " + - " [" + VideoColumns.VIEWS + "] INTEGER, " + - " [" + VideoColumns.PLAYER + "] TEXT, " + - " [" + VideoColumns.IMAGE + "] TEXT, " + - " [" + VideoColumns.ACCESS_KEY + "] TEXT, " + - " [" + VideoColumns.COMMENTS + "] INTEGER, " + - " [" + VideoColumns.CAN_COMMENT + "] BOOLEAN, " + - " [" + VideoColumns.IS_PRIVATE + "] BOOLEAN, " + - " [" + VideoColumns.IS_FAVORITE + "] BOOLEAN, " + - " [" + VideoColumns.CAN_REPOST + "] INTEGER, " + - " [" + VideoColumns.USER_LIKES + "] INTEGER, " + - " [" + VideoColumns.REPEAT + "] INTEGER, " + - " [" + VideoColumns.LIKES + "] INTEGER, " + - " [" + VideoColumns.PRIVACY_VIEW + "] BLOB, " + - " [" + VideoColumns.PRIVACY_COMMENT + "] BLOB, " + - " [" + VideoColumns.MP4_240 + "] TEXT, " + - " [" + VideoColumns.MP4_360 + "] TEXT, " + - " [" + VideoColumns.MP4_480 + "] TEXT, " + - " [" + VideoColumns.MP4_720 + "] TEXT, " + - " [" + VideoColumns.MP4_1080 + "] TEXT, " + - " [" + VideoColumns.MP4_1440 + "] TEXT, " + - " [" + VideoColumns.MP4_2160 + "] TEXT, " + - " [" + VideoColumns.EXTERNAL + "] TEXT, " + - " [" + VideoColumns.HLS + "] TEXT, " + - " [" + VideoColumns.LIVE + "] TEXT, " + - " [" + VideoColumns.PLATFORM + "] TEXT, " + - " [" + VideoColumns.CAN_EDIT + "] BOOLEAN, " + - " [" + VideoColumns.CAN_ADD + "] BOOLEAN, " + - " CONSTRAINT [] UNIQUE ([" + VideoColumns.VIDEO_ID + "], [" + VideoColumns.OWNER_ID + "]) ON CONFLICT REPLACE);" + " [" + VideosColumns.VIDEO_ID + "] INTEGER, " + + " [" + VideosColumns.OWNER_ID + "] INTEGER, " + + " [" + VideosColumns.ORIGINAL_OWNER_ID + "] INTEGER, " + + " [" + VideosColumns.ALBUM_ID + "] INTEGER, " + + " [" + VideosColumns.TITLE + "] TEXT, " + + " [" + VideosColumns.DESCRIPTION + "] TEXT, " + + " [" + VideosColumns.DURATION + "] INTEGER, " + + " [" + VideosColumns.LINK + "] TEXT, " + + " [" + VideosColumns.DATE + "] INTEGER, " + + " [" + VideosColumns.ADDING_DATE + "] INTEGER, " + + " [" + VideosColumns.VIEWS + "] INTEGER, " + + " [" + VideosColumns.PLAYER + "] TEXT, " + + " [" + VideosColumns.IMAGE + "] TEXT, " + + " [" + VideosColumns.ACCESS_KEY + "] TEXT, " + + " [" + VideosColumns.COMMENTS + "] INTEGER, " + + " [" + VideosColumns.CAN_COMMENT + "] BOOLEAN, " + + " [" + VideosColumns.IS_PRIVATE + "] BOOLEAN, " + + " [" + VideosColumns.IS_FAVORITE + "] BOOLEAN, " + + " [" + VideosColumns.CAN_REPOST + "] INTEGER, " + + " [" + VideosColumns.USER_LIKES + "] INTEGER, " + + " [" + VideosColumns.REPEAT + "] INTEGER, " + + " [" + VideosColumns.LIKES + "] INTEGER, " + + " [" + VideosColumns.PRIVACY_VIEW + "] BLOB, " + + " [" + VideosColumns.PRIVACY_COMMENT + "] BLOB, " + + " [" + VideosColumns.MP4_240 + "] TEXT, " + + " [" + VideosColumns.MP4_360 + "] TEXT, " + + " [" + VideosColumns.MP4_480 + "] TEXT, " + + " [" + VideosColumns.MP4_720 + "] TEXT, " + + " [" + VideosColumns.MP4_1080 + "] TEXT, " + + " [" + VideosColumns.MP4_1440 + "] TEXT, " + + " [" + VideosColumns.MP4_2160 + "] TEXT, " + + " [" + VideosColumns.EXTERNAL + "] TEXT, " + + " [" + VideosColumns.HLS + "] TEXT, " + + " [" + VideosColumns.LIVE + "] TEXT, " + + " [" + VideosColumns.PLATFORM + "] TEXT, " + + " [" + VideosColumns.CAN_EDIT + "] BOOLEAN, " + + " [" + VideosColumns.CAN_ADD + "] BOOLEAN, " + + " CONSTRAINT [] UNIQUE ([" + VideosColumns.VIDEO_ID + "], [" + VideosColumns.OWNER_ID + "]) ON CONFLICT REPLACE);" db.execSQL(sql) } private fun createDocsTable(db: SQLiteDatabase) { - val sql = "CREATE TABLE [" + DocColumns.TABLENAME + "] (\n" + + val sql = "CREATE TABLE [" + DocsColumns.TABLENAME + "] (\n" + " [" + BaseColumns._ID + "] INTEGER PRIMARY KEY AUTOINCREMENT, " + - " [" + DocColumns.DOC_ID + "] INTEGER, " + - " [" + DocColumns.OWNER_ID + "] INTEGER, " + - " [" + DocColumns.TITLE + "] TEXT, " + - " [" + DocColumns.SIZE + "] INTEGER, " + - " [" + DocColumns.EXT + "] TEXT, " + - " [" + DocColumns.URL + "] TEXT, " + - " [" + DocColumns.DATE + "] INTEGER, " + - " [" + DocColumns.TYPE + "] INTEGER, " + - " [" + DocColumns.PHOTO + "] BLOB, " + - " [" + DocColumns.GRAFFITI + "] BLOB, " + - " [" + DocColumns.VIDEO + "] BLOB, " + - " [" + DocColumns.ACCESS_KEY + "] TEXT, " + - " CONSTRAINT [] UNIQUE ([" + DocColumns.DOC_ID + "], [" + DocColumns.OWNER_ID + "]) ON CONFLICT REPLACE);" + " [" + DocsColumns.DOC_ID + "] INTEGER, " + + " [" + DocsColumns.OWNER_ID + "] INTEGER, " + + " [" + DocsColumns.TITLE + "] TEXT, " + + " [" + DocsColumns.SIZE + "] INTEGER, " + + " [" + DocsColumns.EXT + "] TEXT, " + + " [" + DocsColumns.URL + "] TEXT, " + + " [" + DocsColumns.DATE + "] INTEGER, " + + " [" + DocsColumns.TYPE + "] INTEGER, " + + " [" + DocsColumns.PHOTO + "] BLOB, " + + " [" + DocsColumns.GRAFFITI + "] BLOB, " + + " [" + DocsColumns.VIDEO + "] BLOB, " + + " [" + DocsColumns.ACCESS_KEY + "] TEXT, " + + " CONSTRAINT [] UNIQUE ([" + DocsColumns.DOC_ID + "], [" + DocsColumns.OWNER_ID + "]) ON CONFLICT REPLACE);" db.execSQL(sql) } @@ -593,42 +594,42 @@ class DBHelper private constructor(context: Context, aid: Long) : } private fun createRelativeshipTable(db: SQLiteDatabase) { - val sql = "CREATE TABLE [" + RelationshipColumns.TABLENAME + "] (" + + val sql = "CREATE TABLE [" + RelationshipsColumns.TABLENAME + "] (" + " [" + BaseColumns._ID + "] INTEGER PRIMARY KEY AUTOINCREMENT, " + - " [" + RelationshipColumns.OBJECT_ID + "] INTEGER NOT NULL, " + - " [" + RelationshipColumns.SUBJECT_ID + "] INTEGER NOT NULL, " + - " [" + RelationshipColumns.TYPE + "] INTEGER, " + - " CONSTRAINT [] UNIQUE ([" + RelationshipColumns.OBJECT_ID + "], [" + RelationshipColumns.SUBJECT_ID + "], [" + RelationshipColumns.TYPE + "]) ON CONFLICT REPLACE);" + " [" + RelationshipsColumns.OBJECT_ID + "] INTEGER NOT NULL, " + + " [" + RelationshipsColumns.SUBJECT_ID + "] INTEGER NOT NULL, " + + " [" + RelationshipsColumns.TYPE + "] INTEGER, " + + " CONSTRAINT [] UNIQUE ([" + RelationshipsColumns.OBJECT_ID + "], [" + RelationshipsColumns.SUBJECT_ID + "], [" + RelationshipsColumns.TYPE + "]) ON CONFLICT REPLACE);" db.execSQL(sql) } private fun createUsersTable(db: SQLiteDatabase) { - val sql = "CREATE TABLE [" + UserColumns.TABLENAME + "](" + + val sql = "CREATE TABLE [" + UsersColumns.TABLENAME + "](" + " [" + BaseColumns._ID + "] INTEGER NOT NULL UNIQUE, " + - " [" + UserColumns.FIRST_NAME + "] TEXT, " + - " [" + UserColumns.LAST_NAME + "] TEXT, " + - " [" + UserColumns.ONLINE + "] BOOLEAN, " + - " [" + UserColumns.ONLINE_MOBILE + "] BOOLEAN, " + - " [" + UserColumns.ONLINE_APP + "] INTEGER, " + - " [" + UserColumns.PHOTO_50 + "] TEXT, " + - " [" + UserColumns.PHOTO_100 + "] TEXT, " + - " [" + UserColumns.PHOTO_200 + "] TEXT, " + - " [" + UserColumns.PHOTO_MAX + "] TEXT, " + - " [" + UserColumns.LAST_SEEN + "] INTEGER, " + - " [" + UserColumns.PLATFORM + "] INTEGER, " + - " [" + UserColumns.USER_STATUS + "] TEXT, " + - " [" + UserColumns.SEX + "] INTEGER, " + - " [" + UserColumns.DOMAIN + "] TEXT, " + - " [" + UserColumns.MAIDEN_NAME + "] TEXT, " + - " [" + UserColumns.BDATE + "] TEXT, " + - " [" + UserColumns.IS_FRIEND + "] BOOLEAN, " + - " [" + UserColumns.FRIEND_STATUS + "] INTEGER, " + - " [" + UserColumns.WRITE_MESSAGE_STATUS + "] BOOLEAN, " + - " [" + UserColumns.IS_USER_BLACK_LIST + "] BOOLEAN, " + - " [" + UserColumns.IS_BLACK_LISTED + "] BOOLEAN, " + - " [" + UserColumns.IS_CAN_ACCESS_CLOSED + "] BOOLEAN, " + - " [" + UserColumns.IS_VERIFIED + "] BOOLEAN, " + - " [" + UserColumns.HAS_UNSEEN_STORIES + "] BOOLEAN, " + + " [" + UsersColumns.FIRST_NAME + "] TEXT, " + + " [" + UsersColumns.LAST_NAME + "] TEXT, " + + " [" + UsersColumns.ONLINE + "] BOOLEAN, " + + " [" + UsersColumns.ONLINE_MOBILE + "] BOOLEAN, " + + " [" + UsersColumns.ONLINE_APP + "] INTEGER, " + + " [" + UsersColumns.PHOTO_50 + "] TEXT, " + + " [" + UsersColumns.PHOTO_100 + "] TEXT, " + + " [" + UsersColumns.PHOTO_200 + "] TEXT, " + + " [" + UsersColumns.PHOTO_MAX + "] TEXT, " + + " [" + UsersColumns.LAST_SEEN + "] INTEGER, " + + " [" + UsersColumns.PLATFORM + "] INTEGER, " + + " [" + UsersColumns.USER_STATUS + "] TEXT, " + + " [" + UsersColumns.SEX + "] INTEGER, " + + " [" + UsersColumns.DOMAIN + "] TEXT, " + + " [" + UsersColumns.MAIDEN_NAME + "] TEXT, " + + " [" + UsersColumns.BDATE + "] TEXT, " + + " [" + UsersColumns.IS_FRIEND + "] BOOLEAN, " + + " [" + UsersColumns.FRIEND_STATUS + "] INTEGER, " + + " [" + UsersColumns.WRITE_MESSAGE_STATUS + "] BOOLEAN, " + + " [" + UsersColumns.IS_USER_BLACK_LIST + "] BOOLEAN, " + + " [" + UsersColumns.IS_BLACK_LISTED + "] BOOLEAN, " + + " [" + UsersColumns.IS_CAN_ACCESS_CLOSED + "] BOOLEAN, " + + " [" + UsersColumns.IS_VERIFIED + "] BOOLEAN, " + + " [" + UsersColumns.HAS_UNSEEN_STORIES + "] BOOLEAN, " + " CONSTRAINT [] PRIMARY KEY([" + BaseColumns._ID + "]) ON CONFLICT REPLACE);" db.execSQL(sql) } @@ -732,41 +733,41 @@ class DBHelper private constructor(context: Context, aid: Long) : } private fun createGroupsTable(db: SQLiteDatabase) { - val sql = "CREATE TABLE [" + GroupColumns.TABLENAME + "](" + + val sql = "CREATE TABLE [" + GroupsColumns.TABLENAME + "](" + " [" + BaseColumns._ID + "] INTEGER NOT NULL UNIQUE, " + - " [" + GroupColumns.NAME + "] TEXT, " + - " [" + GroupColumns.SCREEN_NAME + "] TEXT, " + - " [" + GroupColumns.IS_CLOSED + "] INTEGER, " + - " [" + GroupColumns.IS_VERIFIED + "] BOOLEAN, " + - " [" + GroupColumns.IS_ADMIN + "] BOOLEAN, " + - " [" + GroupColumns.ADMIN_LEVEL + "] INTEGER, " + - " [" + GroupColumns.IS_MEMBER + "] BOOLEAN, " + - " [" + GroupColumns.MEMBER_STATUS + "] INTEGER, " + - " [" + GroupColumns.MEMBERS_COUNT + "] INTEGER, " + - " [" + GroupColumns.TYPE + "] INTEGER, " + - " [" + GroupColumns.PHOTO_50 + "] TEXT, " + - " [" + GroupColumns.PHOTO_100 + "] TEXT, " + - " [" + GroupColumns.PHOTO_200 + "] TEXT, " + - " [" + GroupColumns.CAN_ADD_TOPICS + "] BOOLEAN, " + - " [" + GroupColumns.TOPICS_ORDER + "] BOOLEAN, " + - " [" + GroupColumns.IS_BLACK_LISTED + "] BOOLEAN, " + - " [" + GroupColumns.HAS_UNSEEN_STORIES + "] BOOLEAN, " + + " [" + GroupsColumns.NAME + "] TEXT, " + + " [" + GroupsColumns.SCREEN_NAME + "] TEXT, " + + " [" + GroupsColumns.IS_CLOSED + "] INTEGER, " + + " [" + GroupsColumns.IS_VERIFIED + "] BOOLEAN, " + + " [" + GroupsColumns.IS_ADMIN + "] BOOLEAN, " + + " [" + GroupsColumns.ADMIN_LEVEL + "] INTEGER, " + + " [" + GroupsColumns.IS_MEMBER + "] BOOLEAN, " + + " [" + GroupsColumns.MEMBER_STATUS + "] INTEGER, " + + " [" + GroupsColumns.MEMBERS_COUNT + "] INTEGER, " + + " [" + GroupsColumns.TYPE + "] INTEGER, " + + " [" + GroupsColumns.PHOTO_50 + "] TEXT, " + + " [" + GroupsColumns.PHOTO_100 + "] TEXT, " + + " [" + GroupsColumns.PHOTO_200 + "] TEXT, " + + " [" + GroupsColumns.CAN_ADD_TOPICS + "] BOOLEAN, " + + " [" + GroupsColumns.TOPICS_ORDER + "] BOOLEAN, " + + " [" + GroupsColumns.IS_BLACK_LISTED + "] BOOLEAN, " + + " [" + GroupsColumns.HAS_UNSEEN_STORIES + "] BOOLEAN, " + " CONSTRAINT [] PRIMARY KEY([" + BaseColumns._ID + "]) ON CONFLICT REPLACE);" db.execSQL(sql) } private fun createGroupsDetTable(db: SQLiteDatabase) { - val sql = "CREATE TABLE [" + GroupsDetColumns.TABLENAME + "] (\n" + + val sql = "CREATE TABLE [" + GroupsDetailsColumns.TABLENAME + "] (\n" + " [" + BaseColumns._ID + "] INTEGER NOT NULL UNIQUE, " + - " [" + GroupsDetColumns.DATA + "] BLOB, " + + " [" + GroupsDetailsColumns.DATA + "] BLOB, " + " CONSTRAINT [] PRIMARY KEY([" + BaseColumns._ID + "]) ON CONFLICT REPLACE);" db.execSQL(sql) } private fun createUserDetTable(db: SQLiteDatabase) { - val sql = "CREATE TABLE [" + UsersDetColumns.TABLENAME + "] (\n" + + val sql = "CREATE TABLE [" + UsersDetailsColumns.TABLENAME + "] (\n" + " [" + BaseColumns._ID + "] INTEGER NOT NULL UNIQUE, " + - " [" + UsersDetColumns.DATA + "] BLOB, " + + " [" + UsersDetailsColumns.DATA + "] BLOB, " + " CONSTRAINT [] PRIMARY KEY([" + BaseColumns._ID + "]) ON CONFLICT REPLACE);" db.execSQL(sql) } @@ -826,10 +827,10 @@ class DBHelper private constructor(context: Context, aid: Long) : } private fun createNotoficationsTable(db: SQLiteDatabase) { - val sql = "CREATE TABLE [" + NotificationColumns.TABLENAME + "] (\n" + + val sql = "CREATE TABLE [" + NotificationsColumns.TABLENAME + "] (\n" + " [" + BaseColumns._ID + "] INTEGER PRIMARY KEY AUTOINCREMENT, " + - " [" + NotificationColumns.DATE + "] INTEGER, " + - " [" + NotificationColumns.CONTENT_PACK + "] BLOB);" + " [" + NotificationsColumns.DATE + "] INTEGER, " + + " [" + NotificationsColumns.CONTENT_PACK + "] BLOB);" db.execSQL(sql) } @@ -863,7 +864,7 @@ class DBHelper private constructor(context: Context, aid: Long) : } internal fun getDatabaseFileName(aid: Long): String { - return if (!FenrirNative.isNativeLoaded) "fenrir_uncompressed_$aid.sqlite" else "fenrir_$aid.sqlite" + return if (!FenrirNative.isNativeLoaded) "fenrir_$aid.sqlite" else "fenrir_lz4_$aid.sqlite" } } } \ No newline at end of file diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/FenrirContentProvider.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/FenrirContentProvider.kt index 5ab44bf5f..c84aacc97 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/FenrirContentProvider.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/FenrirContentProvider.kt @@ -11,7 +11,7 @@ import dev.ragnarok.fenrir.BuildConfig import dev.ragnarok.fenrir.db.column.* import dev.ragnarok.fenrir.db.column.attachments.CommentsAttachmentsColumns import dev.ragnarok.fenrir.db.column.attachments.MessagesAttachmentsColumns -import dev.ragnarok.fenrir.db.column.attachments.WallAttachmentsColumns +import dev.ragnarok.fenrir.db.column.attachments.WallsAttachmentsColumns import dev.ragnarok.fenrir.nonNullNoEmpty import dev.ragnarok.fenrir.util.Logger @@ -569,167 +569,167 @@ class FenrirContentProvider : ContentProvider() { init { //Setup projection maps sUsersProjectionMap = HashMap() - sUsersProjectionMap[BaseColumns._ID] = UserColumns.FULL_ID - sUsersProjectionMap[UserColumns.FIRST_NAME] = UserColumns.FULL_FIRST_NAME - sUsersProjectionMap[UserColumns.LAST_NAME] = - UserColumns.FULL_LAST_NAME - sUsersProjectionMap[UserColumns.ONLINE] = UserColumns.FULL_ONLINE - sUsersProjectionMap[UserColumns.ONLINE_MOBILE] = UserColumns.FULL_ONLINE_MOBILE - sUsersProjectionMap[UserColumns.ONLINE_APP] = UserColumns.FULL_ONLINE_APP - sUsersProjectionMap[UserColumns.PHOTO_50] = UserColumns.FULL_PHOTO_50 - sUsersProjectionMap[UserColumns.PHOTO_100] = - UserColumns.FULL_PHOTO_100 - sUsersProjectionMap[UserColumns.PHOTO_200] = UserColumns.FULL_PHOTO_200 - sUsersProjectionMap[UserColumns.PHOTO_MAX] = UserColumns.FULL_PHOTO_MAX - sUsersProjectionMap[UserColumns.LAST_SEEN] = UserColumns.FULL_LAST_SEEN - sUsersProjectionMap[UserColumns.HAS_UNSEEN_STORIES] = - UserColumns.FULL_HAS_UNSEEN_STORIES - sUsersProjectionMap[UserColumns.PLATFORM] = - UserColumns.FULL_PLATFORM - sUsersProjectionMap[UserColumns.USER_STATUS] = UserColumns.FULL_USER_STATUS - sUsersProjectionMap[UserColumns.SEX] = UserColumns.FULL_SEX - sUsersProjectionMap[UserColumns.DOMAIN] = - UserColumns.FULL_DOMAIN - sUsersProjectionMap[UserColumns.IS_FRIEND] = UserColumns.FULL_IS_FRIEND - sUsersProjectionMap[UserColumns.FRIEND_STATUS] = UserColumns.FULL_FRIEND_STATUS - sUsersProjectionMap[UserColumns.WRITE_MESSAGE_STATUS] = - UserColumns.FULL_WRITE_MESSAGE_STATUS - sUsersProjectionMap[UserColumns.IS_USER_BLACK_LIST] = - UserColumns.FULL_IS_USER_BLACK_LIST - sUsersProjectionMap[UserColumns.IS_BLACK_LISTED] = UserColumns.FULL_IS_BLACK_LISTED - sUsersProjectionMap[UserColumns.IS_CAN_ACCESS_CLOSED] = - UserColumns.FULL_IS_CAN_ACCESS_CLOSED - sUsersProjectionMap[UserColumns.IS_VERIFIED] = UserColumns.FULL_IS_VERIFIED - sUsersProjectionMap[UserColumns.MAIDEN_NAME] = UserColumns.FULL_MAIDEN_NAME - sUsersProjectionMap[UserColumns.BDATE] = UserColumns.FULL_BDATE + sUsersProjectionMap[BaseColumns._ID] = UsersColumns.FULL_ID + sUsersProjectionMap[UsersColumns.FIRST_NAME] = UsersColumns.FULL_FIRST_NAME + sUsersProjectionMap[UsersColumns.LAST_NAME] = + UsersColumns.FULL_LAST_NAME + sUsersProjectionMap[UsersColumns.ONLINE] = UsersColumns.FULL_ONLINE + sUsersProjectionMap[UsersColumns.ONLINE_MOBILE] = UsersColumns.FULL_ONLINE_MOBILE + sUsersProjectionMap[UsersColumns.ONLINE_APP] = UsersColumns.FULL_ONLINE_APP + sUsersProjectionMap[UsersColumns.PHOTO_50] = UsersColumns.FULL_PHOTO_50 + sUsersProjectionMap[UsersColumns.PHOTO_100] = + UsersColumns.FULL_PHOTO_100 + sUsersProjectionMap[UsersColumns.PHOTO_200] = UsersColumns.FULL_PHOTO_200 + sUsersProjectionMap[UsersColumns.PHOTO_MAX] = UsersColumns.FULL_PHOTO_MAX + sUsersProjectionMap[UsersColumns.LAST_SEEN] = UsersColumns.FULL_LAST_SEEN + sUsersProjectionMap[UsersColumns.HAS_UNSEEN_STORIES] = + UsersColumns.FULL_HAS_UNSEEN_STORIES + sUsersProjectionMap[UsersColumns.PLATFORM] = + UsersColumns.FULL_PLATFORM + sUsersProjectionMap[UsersColumns.USER_STATUS] = UsersColumns.FULL_USER_STATUS + sUsersProjectionMap[UsersColumns.SEX] = UsersColumns.FULL_SEX + sUsersProjectionMap[UsersColumns.DOMAIN] = + UsersColumns.FULL_DOMAIN + sUsersProjectionMap[UsersColumns.IS_FRIEND] = UsersColumns.FULL_IS_FRIEND + sUsersProjectionMap[UsersColumns.FRIEND_STATUS] = UsersColumns.FULL_FRIEND_STATUS + sUsersProjectionMap[UsersColumns.WRITE_MESSAGE_STATUS] = + UsersColumns.FULL_WRITE_MESSAGE_STATUS + sUsersProjectionMap[UsersColumns.IS_USER_BLACK_LIST] = + UsersColumns.FULL_IS_USER_BLACK_LIST + sUsersProjectionMap[UsersColumns.IS_BLACK_LISTED] = UsersColumns.FULL_IS_BLACK_LISTED + sUsersProjectionMap[UsersColumns.IS_CAN_ACCESS_CLOSED] = + UsersColumns.FULL_IS_CAN_ACCESS_CLOSED + sUsersProjectionMap[UsersColumns.IS_VERIFIED] = UsersColumns.FULL_IS_VERIFIED + sUsersProjectionMap[UsersColumns.MAIDEN_NAME] = UsersColumns.FULL_MAIDEN_NAME + sUsersProjectionMap[UsersColumns.BDATE] = UsersColumns.FULL_BDATE sRelativeshipProjectionMap = HashMap() - sRelativeshipProjectionMap[BaseColumns._ID] = RelationshipColumns.FULL_ID - sRelativeshipProjectionMap[RelationshipColumns.OBJECT_ID] = - RelationshipColumns.FULL_OBJECT_ID - sRelativeshipProjectionMap[RelationshipColumns.SUBJECT_ID] = - RelationshipColumns.FULL_SUBJECT_ID - sRelativeshipProjectionMap[RelationshipColumns.TYPE] = RelationshipColumns.FULL_TYPE - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_FIRST_NAME] = - UserColumns.FULL_FIRST_NAME + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_FIRST_NAME - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_LAST_NAME] = - UserColumns.FULL_LAST_NAME + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_LAST_NAME - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_ONLINE] = - UserColumns.FULL_ONLINE + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_ONLINE - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_ONLINE_MOBILE] = - UserColumns.FULL_ONLINE_MOBILE + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_ONLINE_MOBILE - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_ONLINE_APP] = - UserColumns.FULL_ONLINE_APP + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_ONLINE_APP - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_PHOTO_50] = - UserColumns.FULL_PHOTO_50 + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_PHOTO_50 - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_PHOTO_100] = - UserColumns.FULL_PHOTO_100 + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_PHOTO_100 - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_PHOTO_200] = - UserColumns.FULL_PHOTO_200 + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_PHOTO_200 - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_PHOTO_MAX] = - UserColumns.FULL_PHOTO_MAX + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_PHOTO_MAX - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_HAS_UNSEEN_STORIES] = - UserColumns.FULL_HAS_UNSEEN_STORIES + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_HAS_UNSEEN_STORIES - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_LAST_SEEN] = - UserColumns.FULL_LAST_SEEN + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_LAST_SEEN - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_PLATFORM] = - UserColumns.FULL_PLATFORM + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_PLATFORM - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_STATUS] = - UserColumns.FULL_USER_STATUS + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_STATUS - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_SEX] = - UserColumns.FULL_SEX + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_SEX - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_IS_FRIEND] = - UserColumns.FULL_IS_FRIEND + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_IS_FRIEND - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_FRIEND_STATUS] = - UserColumns.FULL_FRIEND_STATUS + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_FRIEND_STATUS - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_WRITE_MESSAGE_STATUS] = - UserColumns.FULL_WRITE_MESSAGE_STATUS + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_WRITE_MESSAGE_STATUS - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_IS_USER_BLACK_LIST] = - UserColumns.FULL_IS_USER_BLACK_LIST + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_IS_USER_BLACK_LIST - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_IS_BLACK_LISTED] = - UserColumns.FULL_IS_BLACK_LISTED + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_IS_BLACK_LISTED - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_IS_CAN_ACCESS_CLOSED] = - UserColumns.FULL_IS_CAN_ACCESS_CLOSED + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_IS_CAN_ACCESS_CLOSED - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_IS_VERIFIED] = - UserColumns.FULL_IS_VERIFIED + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_IS_VERIFIED - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_MAIDEN_NAME] = - UserColumns.FULL_MAIDEN_NAME + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_MAIDEN_NAME - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_USER_BDATE] = - UserColumns.FULL_BDATE + " AS " + RelationshipColumns.FOREIGN_SUBJECT_USER_BDATE - - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_GROUP_NAME] = - GroupColumns.FULL_NAME + " AS " + RelationshipColumns.FOREIGN_SUBJECT_GROUP_NAME - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_GROUP_SCREEN_NAME] = - GroupColumns.FULL_SCREEN_NAME + " AS " + RelationshipColumns.FOREIGN_SUBJECT_GROUP_SCREEN_NAME - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_GROUP_PHOTO_50] = - GroupColumns.FULL_PHOTO_50 + " AS " + RelationshipColumns.FOREIGN_SUBJECT_GROUP_PHOTO_50 - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_GROUP_PHOTO_100] = - GroupColumns.FULL_PHOTO_100 + " AS " + RelationshipColumns.FOREIGN_SUBJECT_GROUP_PHOTO_100 - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_GROUP_PHOTO_200] = - GroupColumns.FULL_PHOTO_200 + " AS " + RelationshipColumns.FOREIGN_SUBJECT_GROUP_PHOTO_200 - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_GROUP_IS_CLOSED] = - GroupColumns.FULL_IS_CLOSED + " AS " + RelationshipColumns.FOREIGN_SUBJECT_GROUP_IS_CLOSED - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_GROUP_IS_BLACK_LISTED] = - GroupColumns.FULL_IS_BLACK_LISTED + " AS " + RelationshipColumns.FOREIGN_SUBJECT_GROUP_IS_BLACK_LISTED - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_GROUP_IS_VERIFIED] = - GroupColumns.FULL_IS_VERIFIED + " AS " + RelationshipColumns.FOREIGN_SUBJECT_GROUP_IS_VERIFIED - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_GROUP_HAS_UNSEEN_STORIES] = - GroupColumns.FULL_HAS_UNSEEN_STORIES + " AS " + RelationshipColumns.FOREIGN_SUBJECT_GROUP_HAS_UNSEEN_STORIES - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_GROUP_IS_ADMIN] = - GroupColumns.FULL_IS_ADMIN + " AS " + RelationshipColumns.FOREIGN_SUBJECT_GROUP_IS_ADMIN - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_GROUP_ADMIN_LEVEL] = - GroupColumns.FULL_ADMIN_LEVEL + " AS " + RelationshipColumns.FOREIGN_SUBJECT_GROUP_ADMIN_LEVEL - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_GROUP_IS_MEMBER] = - GroupColumns.FULL_IS_MEMBER + " AS " + RelationshipColumns.FOREIGN_SUBJECT_GROUP_IS_MEMBER - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_GROUP_MEMBERS_COUNT] = - GroupColumns.FULL_MEMBERS_COUNT + " AS " + RelationshipColumns.FOREIGN_SUBJECT_GROUP_MEMBERS_COUNT - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_GROUP_MEMBER_STATUS] = - GroupColumns.FULL_MEMBER_STATUS + " AS " + RelationshipColumns.FOREIGN_SUBJECT_GROUP_MEMBER_STATUS - sRelativeshipProjectionMap[RelationshipColumns.FOREIGN_SUBJECT_GROUP_TYPE] = - GroupColumns.FULL_TYPE + " AS " + RelationshipColumns.FOREIGN_SUBJECT_GROUP_TYPE + sRelativeshipProjectionMap[BaseColumns._ID] = RelationshipsColumns.FULL_ID + sRelativeshipProjectionMap[RelationshipsColumns.OBJECT_ID] = + RelationshipsColumns.FULL_OBJECT_ID + sRelativeshipProjectionMap[RelationshipsColumns.SUBJECT_ID] = + RelationshipsColumns.FULL_SUBJECT_ID + sRelativeshipProjectionMap[RelationshipsColumns.TYPE] = RelationshipsColumns.FULL_TYPE + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_FIRST_NAME] = + UsersColumns.FULL_FIRST_NAME + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_FIRST_NAME + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_LAST_NAME] = + UsersColumns.FULL_LAST_NAME + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_LAST_NAME + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_ONLINE] = + UsersColumns.FULL_ONLINE + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_ONLINE + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_ONLINE_MOBILE] = + UsersColumns.FULL_ONLINE_MOBILE + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_ONLINE_MOBILE + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_ONLINE_APP] = + UsersColumns.FULL_ONLINE_APP + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_ONLINE_APP + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_PHOTO_50] = + UsersColumns.FULL_PHOTO_50 + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_PHOTO_50 + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_PHOTO_100] = + UsersColumns.FULL_PHOTO_100 + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_PHOTO_100 + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_PHOTO_200] = + UsersColumns.FULL_PHOTO_200 + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_PHOTO_200 + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_PHOTO_MAX] = + UsersColumns.FULL_PHOTO_MAX + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_PHOTO_MAX + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_HAS_UNSEEN_STORIES] = + UsersColumns.FULL_HAS_UNSEEN_STORIES + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_HAS_UNSEEN_STORIES + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_LAST_SEEN] = + UsersColumns.FULL_LAST_SEEN + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_LAST_SEEN + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_PLATFORM] = + UsersColumns.FULL_PLATFORM + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_PLATFORM + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_STATUS] = + UsersColumns.FULL_USER_STATUS + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_STATUS + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_SEX] = + UsersColumns.FULL_SEX + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_SEX + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_IS_FRIEND] = + UsersColumns.FULL_IS_FRIEND + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_IS_FRIEND + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_FRIEND_STATUS] = + UsersColumns.FULL_FRIEND_STATUS + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_FRIEND_STATUS + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_WRITE_MESSAGE_STATUS] = + UsersColumns.FULL_WRITE_MESSAGE_STATUS + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_WRITE_MESSAGE_STATUS + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_IS_USER_BLACK_LIST] = + UsersColumns.FULL_IS_USER_BLACK_LIST + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_IS_USER_BLACK_LIST + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_IS_BLACK_LISTED] = + UsersColumns.FULL_IS_BLACK_LISTED + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_IS_BLACK_LISTED + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_IS_CAN_ACCESS_CLOSED] = + UsersColumns.FULL_IS_CAN_ACCESS_CLOSED + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_IS_CAN_ACCESS_CLOSED + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_IS_VERIFIED] = + UsersColumns.FULL_IS_VERIFIED + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_IS_VERIFIED + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_MAIDEN_NAME] = + UsersColumns.FULL_MAIDEN_NAME + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_MAIDEN_NAME + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_USER_BDATE] = + UsersColumns.FULL_BDATE + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_USER_BDATE + + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_GROUP_NAME] = + GroupsColumns.FULL_NAME + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_GROUP_NAME + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_GROUP_SCREEN_NAME] = + GroupsColumns.FULL_SCREEN_NAME + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_GROUP_SCREEN_NAME + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_GROUP_PHOTO_50] = + GroupsColumns.FULL_PHOTO_50 + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_GROUP_PHOTO_50 + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_GROUP_PHOTO_100] = + GroupsColumns.FULL_PHOTO_100 + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_GROUP_PHOTO_100 + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_GROUP_PHOTO_200] = + GroupsColumns.FULL_PHOTO_200 + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_GROUP_PHOTO_200 + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_GROUP_IS_CLOSED] = + GroupsColumns.FULL_IS_CLOSED + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_GROUP_IS_CLOSED + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_GROUP_IS_BLACK_LISTED] = + GroupsColumns.FULL_IS_BLACK_LISTED + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_GROUP_IS_BLACK_LISTED + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_GROUP_IS_VERIFIED] = + GroupsColumns.FULL_IS_VERIFIED + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_GROUP_IS_VERIFIED + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_GROUP_HAS_UNSEEN_STORIES] = + GroupsColumns.FULL_HAS_UNSEEN_STORIES + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_GROUP_HAS_UNSEEN_STORIES + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_GROUP_IS_ADMIN] = + GroupsColumns.FULL_IS_ADMIN + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_GROUP_IS_ADMIN + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_GROUP_ADMIN_LEVEL] = + GroupsColumns.FULL_ADMIN_LEVEL + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_GROUP_ADMIN_LEVEL + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_GROUP_IS_MEMBER] = + GroupsColumns.FULL_IS_MEMBER + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_GROUP_IS_MEMBER + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_GROUP_MEMBERS_COUNT] = + GroupsColumns.FULL_MEMBERS_COUNT + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_GROUP_MEMBERS_COUNT + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_GROUP_MEMBER_STATUS] = + GroupsColumns.FULL_MEMBER_STATUS + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_GROUP_MEMBER_STATUS + sRelativeshipProjectionMap[RelationshipsColumns.FOREIGN_SUBJECT_GROUP_TYPE] = + GroupsColumns.FULL_TYPE + " AS " + RelationshipsColumns.FOREIGN_SUBJECT_GROUP_TYPE sMessagesProjectionMap = HashMap() - sMessagesProjectionMap[MessageColumns._ID] = MessageColumns.FULL_ID - sMessagesProjectionMap[MessageColumns.PEER_ID] = MessageColumns.FULL_PEER_ID - sMessagesProjectionMap[MessageColumns.FROM_ID] = MessageColumns.FULL_FROM_ID - sMessagesProjectionMap[MessageColumns.DATE] = MessageColumns.FULL_DATE + sMessagesProjectionMap[MessagesColumns._ID] = MessagesColumns.FULL_ID + sMessagesProjectionMap[MessagesColumns.PEER_ID] = MessagesColumns.FULL_PEER_ID + sMessagesProjectionMap[MessagesColumns.FROM_ID] = MessagesColumns.FULL_FROM_ID + sMessagesProjectionMap[MessagesColumns.DATE] = MessagesColumns.FULL_DATE //sMessagesProjectionMap.put(MessageColumns.READ_STATE, MessageColumns.FULL_READ_STATE); - sMessagesProjectionMap[MessageColumns.OUT] = MessageColumns.FULL_OUT + sMessagesProjectionMap[MessagesColumns.OUT] = MessagesColumns.FULL_OUT //sMessagesProjectionMap.put(MessageColumns.TITLE, MessageColumns.FULL_TITLE); - sMessagesProjectionMap[MessageColumns.BODY] = - MessageColumns.FULL_BODY - sMessagesProjectionMap[MessageColumns.ENCRYPTED] = - MessageColumns.FULL_ENCRYPTED - sMessagesProjectionMap[MessageColumns.DELETED] = MessageColumns.FULL_DELETED - sMessagesProjectionMap[MessageColumns.DELETED_FOR_ALL] = - MessageColumns.FULL_DELETED_FOR_ALL - sMessagesProjectionMap[MessageColumns.IMPORTANT] = MessageColumns.FULL_IMPORTANT - sMessagesProjectionMap[MessageColumns.FORWARD_COUNT] = - MessageColumns.FULL_FORWARD_COUNT - sMessagesProjectionMap[MessageColumns.HAS_ATTACHMENTS] = - MessageColumns.FULL_HAS_ATTACHMENTS - sMessagesProjectionMap[MessageColumns.STATUS] = - MessageColumns.FULL_STATUS - sMessagesProjectionMap[MessageColumns.ATTACH_TO] = MessageColumns.FULL_ATTACH_TO - sMessagesProjectionMap[MessageColumns.ORIGINAL_ID] = - MessageColumns.FULL_ORIGINAL_ID - sMessagesProjectionMap[MessageColumns.UPDATE_TIME] = MessageColumns.FULL_UPDATE_TIME - sMessagesProjectionMap[MessageColumns.ACTION] = - MessageColumns.FULL_ACTION - sMessagesProjectionMap[MessageColumns.ACTION_MID] = - MessageColumns.FULL_ACTION_MID - sMessagesProjectionMap[MessageColumns.ACTION_EMAIL] = MessageColumns.FULL_ACTION_EMAIL - sMessagesProjectionMap[MessageColumns.ACTION_TEXT] = MessageColumns.FULL_ACTION_TEXT - sMessagesProjectionMap[MessageColumns.PHOTO_50] = - MessageColumns.FULL_PHOTO_50 - sMessagesProjectionMap[MessageColumns.PHOTO_100] = MessageColumns.FULL_PHOTO_100 - sMessagesProjectionMap[MessageColumns.PHOTO_200] = MessageColumns.FULL_PHOTO_200 - sMessagesProjectionMap[MessageColumns.RANDOM_ID] = - MessageColumns.FULL_RANDOM_ID - sMessagesProjectionMap[MessageColumns.EXTRAS] = MessageColumns.FULL_EXTRAS - sMessagesProjectionMap[MessageColumns.PAYLOAD] = - MessageColumns.FULL_PAYLOAD - sMessagesProjectionMap[MessageColumns.KEYBOARD] = MessageColumns.FULL_KEYBOARD + sMessagesProjectionMap[MessagesColumns.BODY] = + MessagesColumns.FULL_BODY + sMessagesProjectionMap[MessagesColumns.ENCRYPTED] = + MessagesColumns.FULL_ENCRYPTED + sMessagesProjectionMap[MessagesColumns.DELETED] = MessagesColumns.FULL_DELETED + sMessagesProjectionMap[MessagesColumns.DELETED_FOR_ALL] = + MessagesColumns.FULL_DELETED_FOR_ALL + sMessagesProjectionMap[MessagesColumns.IMPORTANT] = MessagesColumns.FULL_IMPORTANT + sMessagesProjectionMap[MessagesColumns.FORWARD_COUNT] = + MessagesColumns.FULL_FORWARD_COUNT + sMessagesProjectionMap[MessagesColumns.HAS_ATTACHMENTS] = + MessagesColumns.FULL_HAS_ATTACHMENTS + sMessagesProjectionMap[MessagesColumns.STATUS] = + MessagesColumns.FULL_STATUS + sMessagesProjectionMap[MessagesColumns.ATTACH_TO] = MessagesColumns.FULL_ATTACH_TO + sMessagesProjectionMap[MessagesColumns.ORIGINAL_ID] = + MessagesColumns.FULL_ORIGINAL_ID + sMessagesProjectionMap[MessagesColumns.UPDATE_TIME] = MessagesColumns.FULL_UPDATE_TIME + sMessagesProjectionMap[MessagesColumns.ACTION] = + MessagesColumns.FULL_ACTION + sMessagesProjectionMap[MessagesColumns.ACTION_MID] = + MessagesColumns.FULL_ACTION_MID + sMessagesProjectionMap[MessagesColumns.ACTION_EMAIL] = MessagesColumns.FULL_ACTION_EMAIL + sMessagesProjectionMap[MessagesColumns.ACTION_TEXT] = MessagesColumns.FULL_ACTION_TEXT + sMessagesProjectionMap[MessagesColumns.PHOTO_50] = + MessagesColumns.FULL_PHOTO_50 + sMessagesProjectionMap[MessagesColumns.PHOTO_100] = MessagesColumns.FULL_PHOTO_100 + sMessagesProjectionMap[MessagesColumns.PHOTO_200] = MessagesColumns.FULL_PHOTO_200 + sMessagesProjectionMap[MessagesColumns.RANDOM_ID] = + MessagesColumns.FULL_RANDOM_ID + sMessagesProjectionMap[MessagesColumns.EXTRAS] = MessagesColumns.FULL_EXTRAS + sMessagesProjectionMap[MessagesColumns.PAYLOAD] = + MessagesColumns.FULL_PAYLOAD + sMessagesProjectionMap[MessagesColumns.KEYBOARD] = MessagesColumns.FULL_KEYBOARD sMessagesAttachmentsProjectionMap = HashMap() sMessagesAttachmentsProjectionMap[BaseColumns._ID] = MessagesAttachmentsColumns.FULL_ID @@ -831,22 +831,22 @@ class FenrirContentProvider : ContentProvider() { sDialogsProjectionMap[DialogsColumns.MINOR_ID] = DialogsColumns.FULL_MINOR_ID sDialogsProjectionMap[DialogsColumns.FOREIGN_MESSAGE_FROM_ID] = - MessageColumns.FULL_FROM_ID + " AS " + DialogsColumns.FOREIGN_MESSAGE_FROM_ID + MessagesColumns.FULL_FROM_ID + " AS " + DialogsColumns.FOREIGN_MESSAGE_FROM_ID sDialogsProjectionMap[DialogsColumns.FOREIGN_MESSAGE_BODY] = - MessageColumns.FULL_BODY + " AS " + DialogsColumns.FOREIGN_MESSAGE_BODY + MessagesColumns.FULL_BODY + " AS " + DialogsColumns.FOREIGN_MESSAGE_BODY sDialogsProjectionMap[DialogsColumns.FOREIGN_MESSAGE_DATE] = - MessageColumns.FULL_DATE + " AS " + DialogsColumns.FOREIGN_MESSAGE_DATE + MessagesColumns.FULL_DATE + " AS " + DialogsColumns.FOREIGN_MESSAGE_DATE sDialogsProjectionMap[DialogsColumns.FOREIGN_MESSAGE_OUT] = - MessageColumns.FULL_OUT + " AS " + DialogsColumns.FOREIGN_MESSAGE_OUT + MessagesColumns.FULL_OUT + " AS " + DialogsColumns.FOREIGN_MESSAGE_OUT //sDialogsProjectionMap.put(DialogsColumns.FOREIGN_MESSAGE_READ_STATE, MessageColumns.FULL_READ_STATE + " AS " + DialogsColumns.FOREIGN_MESSAGE_READ_STATE); sDialogsProjectionMap[DialogsColumns.FOREIGN_MESSAGE_HAS_ATTACHMENTS] = - MessageColumns.FULL_HAS_ATTACHMENTS + " AS " + DialogsColumns.FOREIGN_MESSAGE_HAS_ATTACHMENTS + MessagesColumns.FULL_HAS_ATTACHMENTS + " AS " + DialogsColumns.FOREIGN_MESSAGE_HAS_ATTACHMENTS sDialogsProjectionMap[DialogsColumns.FOREIGN_MESSAGE_FWD_COUNT] = - MessageColumns.FULL_FORWARD_COUNT + " AS " + DialogsColumns.FOREIGN_MESSAGE_FWD_COUNT + MessagesColumns.FULL_FORWARD_COUNT + " AS " + DialogsColumns.FOREIGN_MESSAGE_FWD_COUNT sDialogsProjectionMap[DialogsColumns.FOREIGN_MESSAGE_ACTION] = - MessageColumns.FULL_ACTION + " AS " + DialogsColumns.FOREIGN_MESSAGE_ACTION + MessagesColumns.FULL_ACTION + " AS " + DialogsColumns.FOREIGN_MESSAGE_ACTION sDialogsProjectionMap[DialogsColumns.FOREIGN_MESSAGE_ENCRYPTED] = - MessageColumns.FULL_ENCRYPTED + " AS " + DialogsColumns.FOREIGN_MESSAGE_ENCRYPTED + MessagesColumns.FULL_ENCRYPTED + " AS " + DialogsColumns.FOREIGN_MESSAGE_ENCRYPTED sPeersProjectionMap = HashMap() sPeersProjectionMap[BaseColumns._ID] = PeersColumns.FULL_ID @@ -871,83 +871,83 @@ class FenrirContentProvider : ContentProvider() { sPeersProjectionMap[PeersColumns.MINOR_ID] = PeersColumns.FULL_MINOR_ID sDocsProjectionMap = HashMap() - sDocsProjectionMap[BaseColumns._ID] = DocColumns.FULL_ID - sDocsProjectionMap[DocColumns.DOC_ID] = DocColumns.FULL_DOC_ID - sDocsProjectionMap[DocColumns.OWNER_ID] = DocColumns.FULL_OWNER_ID - sDocsProjectionMap[DocColumns.TITLE] = DocColumns.FULL_TITLE - sDocsProjectionMap[DocColumns.SIZE] = DocColumns.FULL_SIZE - sDocsProjectionMap[DocColumns.EXT] = DocColumns.FULL_EXT - sDocsProjectionMap[DocColumns.URL] = DocColumns.FULL_URL - sDocsProjectionMap[DocColumns.PHOTO] = DocColumns.FULL_PHOTO - sDocsProjectionMap[DocColumns.GRAFFITI] = - DocColumns.FULL_GRAFFITI - sDocsProjectionMap[DocColumns.VIDEO] = DocColumns.FULL_VIDEO - sDocsProjectionMap[DocColumns.DATE] = DocColumns.FULL_DATE - sDocsProjectionMap[DocColumns.TYPE] = DocColumns.FULL_TYPE - sDocsProjectionMap[DocColumns.ACCESS_KEY] = DocColumns.FULL_ACCESS_KEY + sDocsProjectionMap[BaseColumns._ID] = DocsColumns.FULL_ID + sDocsProjectionMap[DocsColumns.DOC_ID] = DocsColumns.FULL_DOC_ID + sDocsProjectionMap[DocsColumns.OWNER_ID] = DocsColumns.FULL_OWNER_ID + sDocsProjectionMap[DocsColumns.TITLE] = DocsColumns.FULL_TITLE + sDocsProjectionMap[DocsColumns.SIZE] = DocsColumns.FULL_SIZE + sDocsProjectionMap[DocsColumns.EXT] = DocsColumns.FULL_EXT + sDocsProjectionMap[DocsColumns.URL] = DocsColumns.FULL_URL + sDocsProjectionMap[DocsColumns.PHOTO] = DocsColumns.FULL_PHOTO + sDocsProjectionMap[DocsColumns.GRAFFITI] = + DocsColumns.FULL_GRAFFITI + sDocsProjectionMap[DocsColumns.VIDEO] = DocsColumns.FULL_VIDEO + sDocsProjectionMap[DocsColumns.DATE] = DocsColumns.FULL_DATE + sDocsProjectionMap[DocsColumns.TYPE] = DocsColumns.FULL_TYPE + sDocsProjectionMap[DocsColumns.ACCESS_KEY] = DocsColumns.FULL_ACCESS_KEY sVideosProjectionMap = HashMap() sVideosProjectionMap[BaseColumns._ID] = - VideoColumns.FULL_ID - sVideosProjectionMap[VideoColumns.VIDEO_ID] = - VideoColumns.FULL_VIDEO_ID - sVideosProjectionMap[VideoColumns.OWNER_ID] = - VideoColumns.FULL_OWNER_ID - sVideosProjectionMap[VideoColumns.ORIGINAL_OWNER_ID] = - VideoColumns.FULL_ORIGINAL_OWNER_ID - sVideosProjectionMap[VideoColumns.ALBUM_ID] = VideoColumns.FULL_ALBUM_ID - sVideosProjectionMap[VideoColumns.TITLE] = VideoColumns.FULL_TITLE - sVideosProjectionMap[VideoColumns.DESCRIPTION] = - VideoColumns.FULL_DESCRIPTION - sVideosProjectionMap[VideoColumns.DURATION] = - VideoColumns.FULL_DURATION - sVideosProjectionMap[VideoColumns.LINK] = VideoColumns.FULL_LINK - sVideosProjectionMap[VideoColumns.DATE] = - VideoColumns.FULL_DATE - sVideosProjectionMap[VideoColumns.ADDING_DATE] = VideoColumns.FULL_ADDING_DATE - sVideosProjectionMap[VideoColumns.VIEWS] = VideoColumns.FULL_VIEWS - sVideosProjectionMap[VideoColumns.PLAYER] = VideoColumns.FULL_PLAYER - sVideosProjectionMap[VideoColumns.IMAGE] = VideoColumns.FULL_IMAGE - sVideosProjectionMap[VideoColumns.ACCESS_KEY] = - VideoColumns.FULL_ACCESS_KEY - sVideosProjectionMap[VideoColumns.COMMENTS] = - VideoColumns.FULL_COMMENTS - sVideosProjectionMap[VideoColumns.CAN_COMMENT] = VideoColumns.FULL_CAN_COMMENT - sVideosProjectionMap[VideoColumns.IS_PRIVATE] = VideoColumns.FULL_IS_PRIVATE - sVideosProjectionMap[VideoColumns.IS_FAVORITE] = VideoColumns.FULL_IS_FAVORITE - sVideosProjectionMap[VideoColumns.CAN_REPOST] = - VideoColumns.FULL_CAN_REPOST - sVideosProjectionMap[VideoColumns.USER_LIKES] = - VideoColumns.FULL_USER_LIKES - sVideosProjectionMap[VideoColumns.REPEAT] = - VideoColumns.FULL_REPEAT - sVideosProjectionMap[VideoColumns.LIKES] = VideoColumns.FULL_LIKES - sVideosProjectionMap[VideoColumns.PRIVACY_VIEW] = VideoColumns.FULL_PRIVACY_VIEW - sVideosProjectionMap[VideoColumns.PRIVACY_COMMENT] = - VideoColumns.FULL_PRIVACY_COMMENT - sVideosProjectionMap[VideoColumns.MP4_240] = - VideoColumns.FULL_MP4_240 - sVideosProjectionMap[VideoColumns.MP4_360] = - VideoColumns.FULL_MP4_360 - sVideosProjectionMap[VideoColumns.MP4_480] = - VideoColumns.FULL_MP4_480 - sVideosProjectionMap[VideoColumns.MP4_720] = - VideoColumns.FULL_MP4_720 - sVideosProjectionMap[VideoColumns.MP4_1080] = - VideoColumns.FULL_MP4_1080 - sVideosProjectionMap[VideoColumns.MP4_1440] = - VideoColumns.FULL_MP4_1440 - sVideosProjectionMap[VideoColumns.MP4_2160] = - VideoColumns.FULL_MP4_2160 - sVideosProjectionMap[VideoColumns.EXTERNAL] = VideoColumns.FULL_EXTERNAL - sVideosProjectionMap[VideoColumns.HLS] = VideoColumns.FULL_HLS - sVideosProjectionMap[VideoColumns.LIVE] = - VideoColumns.FULL_LIVE - sVideosProjectionMap[VideoColumns.PLATFORM] = - VideoColumns.FULL_PLATFORM - sVideosProjectionMap[VideoColumns.CAN_EDIT] = - VideoColumns.FULL_CAN_EDIT - sVideosProjectionMap[VideoColumns.CAN_ADD] = VideoColumns.FULL_CAN_ADD + VideosColumns.FULL_ID + sVideosProjectionMap[VideosColumns.VIDEO_ID] = + VideosColumns.FULL_VIDEO_ID + sVideosProjectionMap[VideosColumns.OWNER_ID] = + VideosColumns.FULL_OWNER_ID + sVideosProjectionMap[VideosColumns.ORIGINAL_OWNER_ID] = + VideosColumns.FULL_ORIGINAL_OWNER_ID + sVideosProjectionMap[VideosColumns.ALBUM_ID] = VideosColumns.FULL_ALBUM_ID + sVideosProjectionMap[VideosColumns.TITLE] = VideosColumns.FULL_TITLE + sVideosProjectionMap[VideosColumns.DESCRIPTION] = + VideosColumns.FULL_DESCRIPTION + sVideosProjectionMap[VideosColumns.DURATION] = + VideosColumns.FULL_DURATION + sVideosProjectionMap[VideosColumns.LINK] = VideosColumns.FULL_LINK + sVideosProjectionMap[VideosColumns.DATE] = + VideosColumns.FULL_DATE + sVideosProjectionMap[VideosColumns.ADDING_DATE] = VideosColumns.FULL_ADDING_DATE + sVideosProjectionMap[VideosColumns.VIEWS] = VideosColumns.FULL_VIEWS + sVideosProjectionMap[VideosColumns.PLAYER] = VideosColumns.FULL_PLAYER + sVideosProjectionMap[VideosColumns.IMAGE] = VideosColumns.FULL_IMAGE + sVideosProjectionMap[VideosColumns.ACCESS_KEY] = + VideosColumns.FULL_ACCESS_KEY + sVideosProjectionMap[VideosColumns.COMMENTS] = + VideosColumns.FULL_COMMENTS + sVideosProjectionMap[VideosColumns.CAN_COMMENT] = VideosColumns.FULL_CAN_COMMENT + sVideosProjectionMap[VideosColumns.IS_PRIVATE] = VideosColumns.FULL_IS_PRIVATE + sVideosProjectionMap[VideosColumns.IS_FAVORITE] = VideosColumns.FULL_IS_FAVORITE + sVideosProjectionMap[VideosColumns.CAN_REPOST] = + VideosColumns.FULL_CAN_REPOST + sVideosProjectionMap[VideosColumns.USER_LIKES] = + VideosColumns.FULL_USER_LIKES + sVideosProjectionMap[VideosColumns.REPEAT] = + VideosColumns.FULL_REPEAT + sVideosProjectionMap[VideosColumns.LIKES] = VideosColumns.FULL_LIKES + sVideosProjectionMap[VideosColumns.PRIVACY_VIEW] = VideosColumns.FULL_PRIVACY_VIEW + sVideosProjectionMap[VideosColumns.PRIVACY_COMMENT] = + VideosColumns.FULL_PRIVACY_COMMENT + sVideosProjectionMap[VideosColumns.MP4_240] = + VideosColumns.FULL_MP4_240 + sVideosProjectionMap[VideosColumns.MP4_360] = + VideosColumns.FULL_MP4_360 + sVideosProjectionMap[VideosColumns.MP4_480] = + VideosColumns.FULL_MP4_480 + sVideosProjectionMap[VideosColumns.MP4_720] = + VideosColumns.FULL_MP4_720 + sVideosProjectionMap[VideosColumns.MP4_1080] = + VideosColumns.FULL_MP4_1080 + sVideosProjectionMap[VideosColumns.MP4_1440] = + VideosColumns.FULL_MP4_1440 + sVideosProjectionMap[VideosColumns.MP4_2160] = + VideosColumns.FULL_MP4_2160 + sVideosProjectionMap[VideosColumns.EXTERNAL] = VideosColumns.FULL_EXTERNAL + sVideosProjectionMap[VideosColumns.HLS] = VideosColumns.FULL_HLS + sVideosProjectionMap[VideosColumns.LIVE] = + VideosColumns.FULL_LIVE + sVideosProjectionMap[VideosColumns.PLATFORM] = + VideosColumns.FULL_PLATFORM + sVideosProjectionMap[VideosColumns.CAN_EDIT] = + VideosColumns.FULL_CAN_EDIT + sVideosProjectionMap[VideosColumns.CAN_ADD] = VideosColumns.FULL_CAN_ADD sPostsProjectionMap = HashMap() sPostsProjectionMap[BaseColumns._ID] = PostsColumns.FULL_ID @@ -994,37 +994,37 @@ class FenrirContentProvider : ContentProvider() { sPostsMessagesAttachmentsProjectionMap = HashMap() sPostsMessagesAttachmentsProjectionMap[BaseColumns._ID] = - WallAttachmentsColumns.FULL_ID - sPostsMessagesAttachmentsProjectionMap[WallAttachmentsColumns.P_ID] = - WallAttachmentsColumns.FULL_P_ID - sPostsMessagesAttachmentsProjectionMap[WallAttachmentsColumns.DATA] = - WallAttachmentsColumns.FULL_DATA + WallsAttachmentsColumns.FULL_ID + sPostsMessagesAttachmentsProjectionMap[WallsAttachmentsColumns.P_ID] = + WallsAttachmentsColumns.FULL_P_ID + sPostsMessagesAttachmentsProjectionMap[WallsAttachmentsColumns.DATA] = + WallsAttachmentsColumns.FULL_DATA sGroupsProjectionMap = HashMap() - sGroupsProjectionMap[BaseColumns._ID] = GroupColumns.FULL_ID - sGroupsProjectionMap[GroupColumns.NAME] = GroupColumns.FULL_NAME - sGroupsProjectionMap[GroupColumns.SCREEN_NAME] = GroupColumns.FULL_SCREEN_NAME - sGroupsProjectionMap[GroupColumns.HAS_UNSEEN_STORIES] = - GroupColumns.FULL_HAS_UNSEEN_STORIES - sGroupsProjectionMap[GroupColumns.IS_CLOSED] = - GroupColumns.FULL_IS_CLOSED - sGroupsProjectionMap[GroupColumns.IS_VERIFIED] = GroupColumns.FULL_IS_VERIFIED - sGroupsProjectionMap[GroupColumns.IS_ADMIN] = GroupColumns.FULL_IS_ADMIN - sGroupsProjectionMap[GroupColumns.ADMIN_LEVEL] = GroupColumns.FULL_ADMIN_LEVEL - sGroupsProjectionMap[GroupColumns.IS_MEMBER] = GroupColumns.FULL_IS_MEMBER - sGroupsProjectionMap[GroupColumns.MEMBERS_COUNT] = GroupColumns.FULL_MEMBERS_COUNT - sGroupsProjectionMap[GroupColumns.MEMBER_STATUS] = GroupColumns.FULL_MEMBER_STATUS - sGroupsProjectionMap[GroupColumns.TYPE] = - GroupColumns.FULL_TYPE - sGroupsProjectionMap[GroupColumns.PHOTO_50] = - GroupColumns.FULL_PHOTO_50 - sGroupsProjectionMap[GroupColumns.PHOTO_100] = GroupColumns.FULL_PHOTO_100 - sGroupsProjectionMap[GroupColumns.PHOTO_200] = - GroupColumns.FULL_PHOTO_200 - sGroupsProjectionMap[GroupColumns.CAN_ADD_TOPICS] = - GroupColumns.FULL_CAN_ADD_TOPICS - sGroupsProjectionMap[GroupColumns.TOPICS_ORDER] = GroupColumns.FULL_TOPICS_ORDER - sGroupsProjectionMap[GroupColumns.IS_BLACK_LISTED] = GroupColumns.FULL_IS_BLACK_LISTED + sGroupsProjectionMap[BaseColumns._ID] = GroupsColumns.FULL_ID + sGroupsProjectionMap[GroupsColumns.NAME] = GroupsColumns.FULL_NAME + sGroupsProjectionMap[GroupsColumns.SCREEN_NAME] = GroupsColumns.FULL_SCREEN_NAME + sGroupsProjectionMap[GroupsColumns.HAS_UNSEEN_STORIES] = + GroupsColumns.FULL_HAS_UNSEEN_STORIES + sGroupsProjectionMap[GroupsColumns.IS_CLOSED] = + GroupsColumns.FULL_IS_CLOSED + sGroupsProjectionMap[GroupsColumns.IS_VERIFIED] = GroupsColumns.FULL_IS_VERIFIED + sGroupsProjectionMap[GroupsColumns.IS_ADMIN] = GroupsColumns.FULL_IS_ADMIN + sGroupsProjectionMap[GroupsColumns.ADMIN_LEVEL] = GroupsColumns.FULL_ADMIN_LEVEL + sGroupsProjectionMap[GroupsColumns.IS_MEMBER] = GroupsColumns.FULL_IS_MEMBER + sGroupsProjectionMap[GroupsColumns.MEMBERS_COUNT] = GroupsColumns.FULL_MEMBERS_COUNT + sGroupsProjectionMap[GroupsColumns.MEMBER_STATUS] = GroupsColumns.FULL_MEMBER_STATUS + sGroupsProjectionMap[GroupsColumns.TYPE] = + GroupsColumns.FULL_TYPE + sGroupsProjectionMap[GroupsColumns.PHOTO_50] = + GroupsColumns.FULL_PHOTO_50 + sGroupsProjectionMap[GroupsColumns.PHOTO_100] = GroupsColumns.FULL_PHOTO_100 + sGroupsProjectionMap[GroupsColumns.PHOTO_200] = + GroupsColumns.FULL_PHOTO_200 + sGroupsProjectionMap[GroupsColumns.CAN_ADD_TOPICS] = + GroupsColumns.FULL_CAN_ADD_TOPICS + sGroupsProjectionMap[GroupsColumns.TOPICS_ORDER] = GroupsColumns.FULL_TOPICS_ORDER + sGroupsProjectionMap[GroupsColumns.IS_BLACK_LISTED] = GroupsColumns.FULL_IS_BLACK_LISTED sCommentsProjectionMap = HashMap() sCommentsProjectionMap[BaseColumns._ID] = CommentsColumns.FULL_ID @@ -1146,9 +1146,9 @@ class FenrirContentProvider : ContentProvider() { sGroupsDetProjectionMap = HashMap() sGroupsDetProjectionMap[BaseColumns._ID] = - GroupsDetColumns.FULL_ID - sGroupsDetProjectionMap[GroupsDetColumns.DATA] = - GroupsDetColumns.FULL_DATA + GroupsDetailsColumns.FULL_ID + sGroupsDetProjectionMap[GroupsDetailsColumns.DATA] = + GroupsDetailsColumns.FULL_DATA sVideoAlbumsProjectionMap = HashMap() sVideoAlbumsProjectionMap[BaseColumns._ID] = @@ -1189,15 +1189,15 @@ class FenrirContentProvider : ContentProvider() { //sTopicsProjectionMap.put(TopicsColumns.POLL_ID, TopicsColumns.FULL_POLL_ID); sNoticationsProjectionMap = HashMap() - sNoticationsProjectionMap[BaseColumns._ID] = NotificationColumns.FULL_ID - sNoticationsProjectionMap[NotificationColumns.DATE] = - NotificationColumns.FULL_DATE - sNoticationsProjectionMap[NotificationColumns.CONTENT_PACK] = - NotificationColumns.FULL_CONTENT_PACK + sNoticationsProjectionMap[BaseColumns._ID] = NotificationsColumns.FULL_ID + sNoticationsProjectionMap[NotificationsColumns.DATE] = + NotificationsColumns.FULL_DATE + sNoticationsProjectionMap[NotificationsColumns.CONTENT_PACK] = + NotificationsColumns.FULL_CONTENT_PACK sUserDetProjectionMap = HashMap() - sUserDetProjectionMap[BaseColumns._ID] = UsersDetColumns.FULL_ID - sUserDetProjectionMap[UsersDetColumns.DATA] = UsersDetColumns.FULL_DATA + sUserDetProjectionMap[BaseColumns._ID] = UsersDetailsColumns.FULL_ID + sUserDetProjectionMap[UsersDetailsColumns.DATA] = UsersDetailsColumns.FULL_DATA sFavePhotosProjectionMap = HashMap() sFavePhotosProjectionMap[BaseColumns._ID] = @@ -1221,25 +1221,25 @@ class FenrirContentProvider : ContentProvider() { FaveArticlesColumns.FULL_ARTICLE sFaveProductsProjectionMap = HashMap() - sFaveProductsProjectionMap[BaseColumns._ID] = FaveProductColumns.FULL_ID - sFaveProductsProjectionMap[FaveProductColumns.PRODUCT] = - FaveProductColumns.FULL_PRODUCT + sFaveProductsProjectionMap[BaseColumns._ID] = FaveProductsColumns.FULL_ID + sFaveProductsProjectionMap[FaveProductsColumns.PRODUCT] = + FaveProductsColumns.FULL_PRODUCT sFaveUsersProjectionMap = HashMap() sFaveUsersProjectionMap[BaseColumns._ID] = - FavePageColumns.FULL_ID - sFaveUsersProjectionMap[FavePageColumns.UPDATED_TIME] = FavePageColumns.UPDATED_TIME - sFaveUsersProjectionMap[FavePageColumns.DESCRIPTION] = - FavePageColumns.DESCRIPTION - sFaveUsersProjectionMap[FavePageColumns.FAVE_TYPE] = FavePageColumns.FAVE_TYPE + FavePagesColumns.FULL_ID + sFaveUsersProjectionMap[FavePagesColumns.UPDATED_TIME] = FavePagesColumns.UPDATED_TIME + sFaveUsersProjectionMap[FavePagesColumns.DESCRIPTION] = + FavePagesColumns.DESCRIPTION + sFaveUsersProjectionMap[FavePagesColumns.FAVE_TYPE] = FavePagesColumns.FAVE_TYPE sFaveGroupsProjectionMap = HashMap() sFaveGroupsProjectionMap[BaseColumns._ID] = - FavePageColumns.FULL_GROUPS_ID - sFaveGroupsProjectionMap[FavePageColumns.UPDATED_TIME] = - FavePageColumns.UPDATED_TIME - sFaveGroupsProjectionMap[FavePageColumns.DESCRIPTION] = FavePageColumns.DESCRIPTION - sFaveGroupsProjectionMap[FavePageColumns.FAVE_TYPE] = FavePageColumns.FAVE_TYPE + FavePagesColumns.FULL_GROUPS_ID + sFaveGroupsProjectionMap[FavePagesColumns.UPDATED_TIME] = + FavePagesColumns.UPDATED_TIME + sFaveGroupsProjectionMap[FavePagesColumns.DESCRIPTION] = FavePagesColumns.DESCRIPTION + sFaveGroupsProjectionMap[FavePagesColumns.FAVE_TYPE] = FavePagesColumns.FAVE_TYPE sFaveLinksProjectionMap = HashMap() sFaveLinksProjectionMap[BaseColumns._ID] = @@ -1280,20 +1280,23 @@ class FenrirContentProvider : ContentProvider() { FriendListsColumns.FULL_NAME sKeysProjectionMap = HashMap() - sKeysProjectionMap[BaseColumns._ID] = KeyColumns.FULL_ID - sKeysProjectionMap[KeyColumns.VERSION] = KeyColumns.FULL_VERSION - sKeysProjectionMap[KeyColumns.PEER_ID] = - KeyColumns.FULL_PEER_ID - sKeysProjectionMap[KeyColumns.SESSION_ID] = - KeyColumns.FULL_SESSION_ID - sKeysProjectionMap[KeyColumns.DATE] = KeyColumns.FULL_DATE - sKeysProjectionMap[KeyColumns.START_SESSION_MESSAGE_ID] = - KeyColumns.FULL_START_SESSION_MESSAGE_ID - sKeysProjectionMap[KeyColumns.END_SESSION_MESSAGE_ID] = - KeyColumns.FULL_END_SESSION_MESSAGE_ID - sKeysProjectionMap[KeyColumns.OUT_KEY] = KeyColumns.FULL_OUT_KEY - sKeysProjectionMap[KeyColumns.IN_KEY] = - KeyColumns.FULL_IN_KEY + sKeysProjectionMap[BaseColumns._ID] = EncryptionKeysForMessagesColumns.FULL_ID + sKeysProjectionMap[EncryptionKeysForMessagesColumns.VERSION] = + EncryptionKeysForMessagesColumns.FULL_VERSION + sKeysProjectionMap[EncryptionKeysForMessagesColumns.PEER_ID] = + EncryptionKeysForMessagesColumns.FULL_PEER_ID + sKeysProjectionMap[EncryptionKeysForMessagesColumns.SESSION_ID] = + EncryptionKeysForMessagesColumns.FULL_SESSION_ID + sKeysProjectionMap[EncryptionKeysForMessagesColumns.DATE] = + EncryptionKeysForMessagesColumns.FULL_DATE + sKeysProjectionMap[EncryptionKeysForMessagesColumns.START_SESSION_MESSAGE_ID] = + EncryptionKeysForMessagesColumns.FULL_START_SESSION_MESSAGE_ID + sKeysProjectionMap[EncryptionKeysForMessagesColumns.END_SESSION_MESSAGE_ID] = + EncryptionKeysForMessagesColumns.FULL_END_SESSION_MESSAGE_ID + sKeysProjectionMap[EncryptionKeysForMessagesColumns.OUT_KEY] = + EncryptionKeysForMessagesColumns.FULL_OUT_KEY + sKeysProjectionMap[EncryptionKeysForMessagesColumns.IN_KEY] = + EncryptionKeysForMessagesColumns.FULL_IN_KEY //testProjectionMaps() } @@ -1365,12 +1368,12 @@ class FenrirContentProvider : ContentProvider() { val matchUri: Int = sUriMatcher.match(uri) when (matchUri) { URI_USERS -> { - rowId = db.replace(UserColumns.TABLENAME, null, values) + rowId = db.replace(UsersColumns.TABLENAME, null, values) resultUri = ContentUris.withAppendedId(USER_CONTENT_URI, rowId) } URI_MESSAGES -> { - rowId = db.replace(MessageColumns.TABLENAME, null, values) + rowId = db.replace(MessagesColumns.TABLENAME, null, values) resultUri = ContentUris.withAppendedId(MESSAGE_CONTENT_URI, rowId) } @@ -1400,12 +1403,12 @@ class FenrirContentProvider : ContentProvider() { } URI_DOCS -> { - rowId = db.replace(DocColumns.TABLENAME, null, values) + rowId = db.replace(DocsColumns.TABLENAME, null, values) resultUri = ContentUris.withAppendedId(DOCS_CONTENT_URI, rowId) } URI_VIDEOS -> { - rowId = db.replace(VideoColumns.TABLENAME, null, values) + rowId = db.replace(VideosColumns.TABLENAME, null, values) resultUri = ContentUris.withAppendedId(VIDEOS_CONTENT_URI, rowId) } @@ -1415,17 +1418,17 @@ class FenrirContentProvider : ContentProvider() { } URI_POST_ATTACHMENTS -> { - rowId = db.replace(WallAttachmentsColumns.TABLENAME, null, values) + rowId = db.replace(WallsAttachmentsColumns.TABLENAME, null, values) resultUri = ContentUris.withAppendedId(POSTS_ATTACHMENTS_CONTENT_URI, rowId) } URI_GROUPS -> { - rowId = db.replace(GroupColumns.TABLENAME, null, values) + rowId = db.replace(GroupsColumns.TABLENAME, null, values) resultUri = ContentUris.withAppendedId(GROUPS_CONTENT_URI, rowId) } URI_RELATIVESHIP -> { - rowId = db.replace(RelationshipColumns.TABLENAME, null, values) + rowId = db.replace(RelationshipsColumns.TABLENAME, null, values) resultUri = ContentUris.withAppendedId(RELATIVESHIP_CONTENT_URI, rowId) } @@ -1450,7 +1453,7 @@ class FenrirContentProvider : ContentProvider() { } URI_GROUPS_DET -> { - rowId = db.replace(GroupsDetColumns.TABLENAME, null, values) + rowId = db.replace(GroupsDetailsColumns.TABLENAME, null, values) resultUri = ContentUris.withAppendedId(GROUPS_DET_CONTENT_URI, rowId) } @@ -1465,12 +1468,12 @@ class FenrirContentProvider : ContentProvider() { } URI_NOTIFICATIONS -> { - rowId = db.replace(NotificationColumns.TABLENAME, null, values) + rowId = db.replace(NotificationsColumns.TABLENAME, null, values) resultUri = ContentUris.withAppendedId(NOTIFICATIONS_CONTENT_URI, rowId) } URI_USER_DET -> { - rowId = db.replace(UsersDetColumns.TABLENAME, null, values) + rowId = db.replace(UsersDetailsColumns.TABLENAME, null, values) resultUri = ContentUris.withAppendedId(USER_DET_CONTENT_URI, rowId) } @@ -1485,12 +1488,12 @@ class FenrirContentProvider : ContentProvider() { } URI_FAVE_PAGES -> { - rowId = db.replace(FavePageColumns.TABLENAME, null, values) + rowId = db.replace(FavePagesColumns.TABLENAME, null, values) resultUri = ContentUris.withAppendedId(FAVE_PAGES_CONTENT_URI, rowId) } URI_FAVE_GROUPS -> { - rowId = db.replace(FavePageColumns.GROUPSTABLENAME, null, values) + rowId = db.replace(FavePagesColumns.GROUPSTABLENAME, null, values) resultUri = ContentUris.withAppendedId(FAVE_GROUPS_CONTENT_URI, rowId) } @@ -1505,7 +1508,7 @@ class FenrirContentProvider : ContentProvider() { } URI_FAVE_PRODUCTS -> { - rowId = db.replace(FaveProductColumns.TABLENAME, null, values) + rowId = db.replace(FaveProductsColumns.TABLENAME, null, values) resultUri = ContentUris.withAppendedId(FAVE_PRODUCTS_CONTENT_URI, rowId) } @@ -1530,7 +1533,7 @@ class FenrirContentProvider : ContentProvider() { } URI_KEYS -> { - rowId = db.replace(KeyColumns.TABLENAME, null, values) + rowId = db.replace(EncryptionKeysForMessagesColumns.TABLENAME, null, values) resultUri = ContentUris.withAppendedId(KEYS_CONTENT_URI, rowId) } @@ -1538,7 +1541,7 @@ class FenrirContentProvider : ContentProvider() { } safeNotifyChange(resultUri) if (matchUri == URI_MESSAGES && values != null) { - val peerId: Long = values.getAsLong(MessageColumns.PEER_ID) + val peerId: Long = values.getAsLong(MessagesColumns.PEER_ID) val dUri: Uri = ContentUris.withAppendedId(DIALOGS_CONTENT_URI, peerId) safeNotifyChange(dUri) } @@ -1559,33 +1562,33 @@ class FenrirContentProvider : ContentProvider() { val _QB = SQLiteQueryBuilder() val _TableType: Int = when (sUriMatcher.match(uri)) { URI_USERS -> { - _QB.tables = UserColumns.TABLENAME + _QB.tables = UsersColumns.TABLENAME _QB.projectionMap = sUsersProjectionMap URI_USERS } URI_USERS_ID -> { - _QB.tables = UserColumns.TABLENAME + _QB.tables = UsersColumns.TABLENAME _QB.projectionMap = sUsersProjectionMap - _QB.appendWhere(UserColumns.FULL_ID + "=" + uri.pathSegments[1]) + _QB.appendWhere(UsersColumns.FULL_ID + "=" + uri.pathSegments[1]) URI_USERS } URI_GROUPS -> { - _QB.tables = GroupColumns.TABLENAME + _QB.tables = GroupsColumns.TABLENAME _QB.projectionMap = sGroupsProjectionMap URI_GROUPS } URI_GROUPS_ID -> { - _QB.tables = GroupColumns.TABLENAME + _QB.tables = GroupsColumns.TABLENAME _QB.projectionMap = sGroupsProjectionMap - _QB.appendWhere(GroupColumns.FULL_ID + "=" + uri.pathSegments[1]) + _QB.appendWhere(GroupsColumns.FULL_ID + "=" + uri.pathSegments[1]) URI_GROUPS } URI_MESSAGES -> { - _QB.tables = MessageColumns.TABLENAME + _QB.tables = MessagesColumns.TABLENAME //" LEFT OUTER JOIN " + PeerColumns.TABLENAME + " ON " + MessageColumns.FULL_FROM_ID + " = " + PeerColumns.FULL_ID + //" LEFT OUTER JOIN " + UserColumns.TABLENAME + " ON " + MessageColumns.FULL_ACTION_MID + " = " + UserColumns.FULL_ID); _QB.projectionMap = sMessagesProjectionMap @@ -1593,11 +1596,11 @@ class FenrirContentProvider : ContentProvider() { } URI_MESSAGES_ID -> { - _QB.tables = MessageColumns.TABLENAME + _QB.tables = MessagesColumns.TABLENAME //" LEFT OUTER JOIN " + PeerColumns.TABLENAME + " ON " + MessageColumns.FULL_FROM_ID + " = " + PeerColumns.FULL_ID + //" LEFT OUTER JOIN " + UserColumns.TABLENAME + " ON " + MessageColumns.FULL_ACTION_MID + " = " + UserColumns.FULL_ID); _QB.projectionMap = sMessagesProjectionMap - _QB.appendWhere(MessageColumns.FULL_ID + "=" + uri.pathSegments[1]) + _QB.appendWhere(MessagesColumns.FULL_ID + "=" + uri.pathSegments[1]) URI_MESSAGES } @@ -1647,7 +1650,7 @@ class FenrirContentProvider : ContentProvider() { URI_DIALOGS -> { _QB.tables = - DialogsColumns.TABLENAME + " LEFT OUTER JOIN " + MessageColumns.TABLENAME + " ON " + DialogsColumns.FULL_LAST_MESSAGE_ID + " = " + MessageColumns.FULL_ID + DialogsColumns.TABLENAME + " LEFT OUTER JOIN " + MessagesColumns.TABLENAME + " ON " + DialogsColumns.FULL_LAST_MESSAGE_ID + " = " + MessagesColumns.FULL_ID _QB.projectionMap = sDialogsProjectionMap URI_DIALOGS } @@ -1659,28 +1662,28 @@ class FenrirContentProvider : ContentProvider() { } URI_DOCS -> { - _QB.tables = DocColumns.TABLENAME + _QB.tables = DocsColumns.TABLENAME _QB.projectionMap = sDocsProjectionMap URI_DOCS } URI_DOCS_ID -> { - _QB.tables = DocColumns.TABLENAME + _QB.tables = DocsColumns.TABLENAME _QB.projectionMap = sDocsProjectionMap - _QB.appendWhere(DocColumns.FULL_ID + "=" + uri.pathSegments[1]) + _QB.appendWhere(DocsColumns.FULL_ID + "=" + uri.pathSegments[1]) URI_DOCS } URI_VIDEOS -> { - _QB.tables = VideoColumns.TABLENAME + _QB.tables = VideosColumns.TABLENAME _QB.projectionMap = sVideosProjectionMap URI_VIDEOS } URI_VIDEOS_ID -> { - _QB.tables = VideoColumns.TABLENAME + _QB.tables = VideosColumns.TABLENAME _QB.projectionMap = sVideosProjectionMap - _QB.appendWhere(VideoColumns.FULL_ID + "=" + uri.pathSegments[1]) + _QB.appendWhere(VideosColumns.FULL_ID + "=" + uri.pathSegments[1]) URI_DOCS } @@ -1698,22 +1701,22 @@ class FenrirContentProvider : ContentProvider() { } URI_POST_ATTACHMENTS -> { - _QB.tables = WallAttachmentsColumns.TABLENAME + _QB.tables = WallsAttachmentsColumns.TABLENAME _QB.projectionMap = sPostsMessagesAttachmentsProjectionMap URI_POST_ATTACHMENTS } URI_POST_ATTACHMENTS_ID -> { - _QB.tables = WallAttachmentsColumns.TABLENAME + _QB.tables = WallsAttachmentsColumns.TABLENAME _QB.projectionMap = sPostsMessagesAttachmentsProjectionMap - _QB.appendWhere(WallAttachmentsColumns.FULL_ID + "=" + uri.pathSegments[1]) + _QB.appendWhere(WallsAttachmentsColumns.FULL_ID + "=" + uri.pathSegments[1]) URI_POST_ATTACHMENTS } URI_RELATIVESHIP -> { - _QB.tables = RelationshipColumns.TABLENAME + - " LEFT OUTER JOIN " + UserColumns.TABLENAME + " ON " + RelationshipColumns.FULL_SUBJECT_ID + " = " + UserColumns.FULL_ID + - " LEFT OUTER JOIN " + GroupColumns.TABLENAME + " ON -" + RelationshipColumns.FULL_SUBJECT_ID + " = " + GroupColumns.FULL_ID + _QB.tables = RelationshipsColumns.TABLENAME + + " LEFT OUTER JOIN " + UsersColumns.TABLENAME + " ON " + RelationshipsColumns.FULL_SUBJECT_ID + " = " + UsersColumns.FULL_ID + + " LEFT OUTER JOIN " + GroupsColumns.TABLENAME + " ON -" + RelationshipsColumns.FULL_SUBJECT_ID + " = " + GroupsColumns.FULL_ID _QB.projectionMap = sRelativeshipProjectionMap URI_RELATIVESHIP } @@ -1769,15 +1772,15 @@ class FenrirContentProvider : ContentProvider() { } URI_GROUPS_DET -> { - _QB.tables = GroupsDetColumns.TABLENAME + _QB.tables = GroupsDetailsColumns.TABLENAME _QB.projectionMap = sGroupsDetProjectionMap URI_GROUPS_DET } URI_GROUPS_DET_ID -> { - _QB.tables = GroupsDetColumns.TABLENAME + _QB.tables = GroupsDetailsColumns.TABLENAME _QB.projectionMap = sGroupsDetProjectionMap - _QB.appendWhere(GroupsDetColumns.FULL_ID + " = " + uri.pathSegments[1]) + _QB.appendWhere(GroupsDetailsColumns.FULL_ID + " = " + uri.pathSegments[1]) URI_GROUPS_DET } @@ -1794,21 +1797,21 @@ class FenrirContentProvider : ContentProvider() { } URI_NOTIFICATIONS -> { - _QB.tables = NotificationColumns.TABLENAME + _QB.tables = NotificationsColumns.TABLENAME _QB.projectionMap = sNoticationsProjectionMap URI_NOTIFICATIONS } URI_USER_DET -> { - _QB.tables = UsersDetColumns.TABLENAME + _QB.tables = UsersDetailsColumns.TABLENAME _QB.projectionMap = sUserDetProjectionMap URI_USER_DET } URI_USER_DET_ID -> { - _QB.tables = UsersDetColumns.TABLENAME + _QB.tables = UsersDetailsColumns.TABLENAME _QB.projectionMap = sUserDetProjectionMap - _QB.appendWhere(UsersDetColumns.FULL_ID + " = " + uri.pathSegments[1]) + _QB.appendWhere(UsersDetailsColumns.FULL_ID + " = " + uri.pathSegments[1]) URI_USER_DET } @@ -1831,23 +1834,23 @@ class FenrirContentProvider : ContentProvider() { } URI_FAVE_PRODUCTS -> { - _QB.tables = FaveProductColumns.TABLENAME + _QB.tables = FaveProductsColumns.TABLENAME _QB.projectionMap = sFaveProductsProjectionMap URI_FAVE_PRODUCTS } URI_FAVE_PAGES -> { - _QB.tables = FavePageColumns.TABLENAME + - " LEFT OUTER JOIN " + UserColumns.TABLENAME + - " users ON " + FavePageColumns.FULL_ID + " = users." + BaseColumns._ID + _QB.tables = FavePagesColumns.TABLENAME + + " LEFT OUTER JOIN " + UsersColumns.TABLENAME + + " users ON " + FavePagesColumns.FULL_ID + " = users." + BaseColumns._ID _QB.projectionMap = sFaveUsersProjectionMap URI_FAVE_PAGES } URI_FAVE_GROUPS -> { - _QB.tables = FavePageColumns.GROUPSTABLENAME + - " LEFT OUTER JOIN " + GroupColumns.TABLENAME + - " groups ON " + FavePageColumns.FULL_GROUPS_ID + " = groups." + BaseColumns._ID + _QB.tables = FavePagesColumns.GROUPSTABLENAME + + " LEFT OUTER JOIN " + GroupsColumns.TABLENAME + + " groups ON " + FavePagesColumns.FULL_GROUPS_ID + " = groups." + BaseColumns._ID _QB.projectionMap = sFaveGroupsProjectionMap URI_FAVE_GROUPS } @@ -1883,7 +1886,7 @@ class FenrirContentProvider : ContentProvider() { } URI_KEYS -> { - _QB.tables = KeyColumns.TABLENAME + _QB.tables = EncryptionKeysForMessagesColumns.TABLENAME _QB.projectionMap = sKeysProjectionMap URI_KEYS } @@ -1895,40 +1898,40 @@ class FenrirContentProvider : ContentProvider() { val _OrderBy: String = if (sortOrder.isNullOrEmpty()) { // If no sort order is specified use the default when (_TableType) { - URI_USERS -> UserColumns.FULL_LAST_NAME + " ASC" - URI_GROUPS -> GroupColumns.FULL_NAME + " ASC" - URI_MESSAGES -> MessageColumns.FULL_STATUS + ", " + MessageColumns.FULL_ID + " ASC" + URI_USERS -> UsersColumns.FULL_LAST_NAME + " ASC" + URI_GROUPS -> GroupsColumns.FULL_NAME + " ASC" + URI_MESSAGES -> MessagesColumns.FULL_STATUS + ", " + MessagesColumns.FULL_ID + " ASC" URI_MESSAGES_ATTACHMENTS -> MessagesAttachmentsColumns.FULL_ID + " ASC" URI_PHOTOS -> PhotosColumns.FULL_ID + " ASC" URI_PHOTOS_EXTENDED -> PhotosExtendedColumns.FULL_ID + " ASC" - URI_DIALOGS -> MessageColumns.FULL_DATE + " DESC" + URI_DIALOGS -> MessagesColumns.FULL_DATE + " DESC" URI_PEERS -> PeersColumns.FULL_ID + " DESC" - URI_DOCS -> DocColumns.FULL_ID + " ASC" - URI_VIDEOS -> VideoColumns.FULL_ID + " ASC" + URI_DOCS -> DocsColumns.FULL_ID + " ASC" + URI_VIDEOS -> VideosColumns.FULL_ID + " ASC" URI_POSTS -> PostsColumns.FULL_ID + " ASC" - URI_POST_ATTACHMENTS -> WallAttachmentsColumns.FULL_ID + " ASC" - URI_RELATIVESHIP -> RelationshipColumns.FULL_ID + " ASC" + URI_POST_ATTACHMENTS -> WallsAttachmentsColumns.FULL_ID + " ASC" + URI_RELATIVESHIP -> RelationshipsColumns.FULL_ID + " ASC" URI_COMMENTS -> CommentsColumns.FULL_COMMENT_ID + " ASC" URI_COMMENTS_ATTACHMENTS -> CommentsAttachmentsColumns.FULL_ID + " ASC" URI_PHOTO_ALBUMS -> PhotoAlbumsColumns.FULL_ID + " ASC" URI_NEWS -> NewsColumns.FULL_ID + " ASC" - URI_GROUPS_DET -> GroupsDetColumns.FULL_ID + " ASC" + URI_GROUPS_DET -> GroupsDetailsColumns.FULL_ID + " ASC" URI_VIDEO_ALBUMS -> VideoAlbumsColumns.FULL_ID + " ASC" URI_TOPICS -> TopicsColumns.FULL_ID + " ASC" - URI_NOTIFICATIONS -> NotificationColumns.FULL_ID + " ASC" - URI_USER_DET -> UsersDetColumns.FULL_ID + " ASC" + URI_NOTIFICATIONS -> NotificationsColumns.FULL_ID + " ASC" + URI_USER_DET -> UsersDetailsColumns.FULL_ID + " ASC" URI_FAVE_PHOTOS -> FavePhotosColumns.FULL_ID + " ASC" URI_FAVE_VIDEOS -> FaveVideosColumns.FULL_ID + " ASC" URI_FAVE_ARTICLES -> FaveArticlesColumns.FULL_ID + " ASC" - URI_FAVE_PRODUCTS -> FaveProductColumns.FULL_ID + " ASC" - URI_FAVE_PAGES -> FavePageColumns.UPDATED_TIME + " DESC" - URI_FAVE_GROUPS -> FavePageColumns.UPDATED_TIME + " DESC" + URI_FAVE_PRODUCTS -> FaveProductsColumns.FULL_ID + " ASC" + URI_FAVE_PAGES -> FavePagesColumns.UPDATED_TIME + " DESC" + URI_FAVE_GROUPS -> FavePagesColumns.UPDATED_TIME + " DESC" URI_FAVE_LINKS -> FaveLinksColumns.FULL_ID + " ASC" URI_FAVE_POSTS -> FavePostsColumns.FULL_ID + " ASC" URI_COUNTRIES -> CountriesColumns.FULL_ID + " ASC" URI_FEED_LISTS -> FeedListsColumns.FULL_ID + " ASC" URI_FRIEND_LISTS -> FriendListsColumns.FULL_ID + " ASC" - URI_KEYS -> KeyColumns.FULL_ID + " ASC" + URI_KEYS -> EncryptionKeysForMessagesColumns.FULL_ID + " ASC" else -> throw UnknownError("Unknown table type for sort order") } } else { @@ -2009,19 +2012,19 @@ class FenrirContentProvider : ContentProvider() { var selection = pSelection val tbName: String when (sUriMatcher.match(uri)) { - URI_MESSAGES -> tbName = MessageColumns.TABLENAME + URI_MESSAGES -> tbName = MessagesColumns.TABLENAME URI_MESSAGES_ID -> { val id = uri.lastPathSegment selection = if (selection.isNullOrEmpty()) { - MessageColumns._ID + " = " + id + MessagesColumns._ID + " = " + id } else { - selection + " AND " + MessageColumns._ID + " = " + id + selection + " AND " + MessagesColumns._ID + " = " + id } - tbName = MessageColumns.TABLENAME + tbName = MessagesColumns.TABLENAME } URI_DIALOGS -> tbName = DialogsColumns.TABLENAME - URI_RELATIVESHIP -> tbName = RelationshipColumns.TABLENAME + URI_RELATIVESHIP -> tbName = RelationshipsColumns.TABLENAME URI_POSTS -> tbName = PostsColumns.TABLENAME URI_POSTS_ID -> { val postId = uri.lastPathSegment @@ -2038,11 +2041,11 @@ class FenrirContentProvider : ContentProvider() { URI_MESSAGES_ATTACHMENTS -> tbName = MessagesAttachmentsColumns.TABLENAME URI_COMMENTS -> tbName = CommentsColumns.TABLENAME URI_PHOTO_ALBUMS -> tbName = PhotoAlbumsColumns.TABLENAME - URI_POST_ATTACHMENTS -> tbName = WallAttachmentsColumns.TABLENAME + URI_POST_ATTACHMENTS -> tbName = WallsAttachmentsColumns.TABLENAME URI_COMMENTS_ATTACHMENTS -> tbName = CommentsAttachmentsColumns.TABLENAME - URI_DOCS -> tbName = DocColumns.TABLENAME + URI_DOCS -> tbName = DocsColumns.TABLENAME URI_NEWS -> tbName = NewsColumns.TABLENAME - URI_GROUPS_DET -> tbName = GroupsDetColumns.TABLENAME + URI_GROUPS_DET -> tbName = GroupsDetailsColumns.TABLENAME URI_GROUPS_DET_ID -> { val groupDetId = uri.lastPathSegment selection = if (selection.isNullOrEmpty()) { @@ -2050,14 +2053,14 @@ class FenrirContentProvider : ContentProvider() { } else { selection + " AND " + BaseColumns._ID + " = " + groupDetId } - tbName = GroupsDetColumns.TABLENAME + tbName = GroupsDetailsColumns.TABLENAME } URI_VIDEO_ALBUMS -> tbName = VideoAlbumsColumns.TABLENAME - URI_VIDEOS -> tbName = VideoColumns.TABLENAME + URI_VIDEOS -> tbName = VideosColumns.TABLENAME URI_TOPICS -> tbName = TopicsColumns.TABLENAME - URI_NOTIFICATIONS -> tbName = NotificationColumns.TABLENAME - URI_USER_DET -> tbName = UsersDetColumns.TABLENAME + URI_NOTIFICATIONS -> tbName = NotificationsColumns.TABLENAME + URI_USER_DET -> tbName = UsersDetailsColumns.TABLENAME URI_USER_DET_ID -> { val userDetId = uri.lastPathSegment selection = if (selection.isNullOrEmpty()) { @@ -2065,21 +2068,21 @@ class FenrirContentProvider : ContentProvider() { } else { selection + " AND " + BaseColumns._ID + " = " + userDetId } - tbName = UsersDetColumns.TABLENAME + tbName = UsersDetailsColumns.TABLENAME } URI_FAVE_PHOTOS -> tbName = FavePhotosColumns.TABLENAME URI_FAVE_VIDEOS -> tbName = FaveVideosColumns.TABLENAME URI_FAVE_ARTICLES -> tbName = FaveArticlesColumns.TABLENAME - URI_FAVE_PRODUCTS -> tbName = FaveProductColumns.TABLENAME - URI_FAVE_PAGES -> tbName = FavePageColumns.TABLENAME - URI_FAVE_GROUPS -> tbName = FavePageColumns.GROUPSTABLENAME + URI_FAVE_PRODUCTS -> tbName = FaveProductsColumns.TABLENAME + URI_FAVE_PAGES -> tbName = FavePagesColumns.TABLENAME + URI_FAVE_GROUPS -> tbName = FavePagesColumns.GROUPSTABLENAME URI_FAVE_LINKS -> tbName = FaveLinksColumns.TABLENAME URI_FAVE_POSTS -> tbName = FavePostsColumns.TABLENAME URI_COUNTRIES -> tbName = CountriesColumns.TABLENAME URI_FEED_LISTS -> tbName = FeedListsColumns.TABLENAME URI_FRIEND_LISTS -> tbName = FriendListsColumns.TABLENAME - URI_KEYS -> tbName = KeyColumns.TABLENAME + URI_KEYS -> tbName = EncryptionKeysForMessagesColumns.TABLENAME else -> throw IllegalArgumentException("Wrong URI: $uri") } val db: SQLiteDatabase = getDbHelper(uri).writableDatabase @@ -2097,18 +2100,18 @@ class FenrirContentProvider : ContentProvider() { var selection = pSelection val tbName: String when (sUriMatcher.match(uri)) { - URI_MESSAGES -> tbName = MessageColumns.TABLENAME + URI_MESSAGES -> tbName = MessagesColumns.TABLENAME URI_MESSAGES_ID -> { val id = uri.lastPathSegment selection = if (selection.isNullOrEmpty()) { - MessageColumns._ID + " = " + id + MessagesColumns._ID + " = " + id } else { - selection + " AND " + MessageColumns._ID + " = " + id + selection + " AND " + MessagesColumns._ID + " = " + id } - tbName = MessageColumns.TABLENAME + tbName = MessagesColumns.TABLENAME } - URI_USERS -> tbName = UserColumns.TABLENAME + URI_USERS -> tbName = UsersColumns.TABLENAME URI_USERS_ID -> { val userID = uri.lastPathSegment selection = if (selection.isNullOrEmpty()) { @@ -2116,10 +2119,10 @@ class FenrirContentProvider : ContentProvider() { } else { selection + " AND " + BaseColumns._ID + " = " + userID } - tbName = UserColumns.TABLENAME + tbName = UsersColumns.TABLENAME } - URI_GROUPS -> tbName = GroupColumns.TABLENAME + URI_GROUPS -> tbName = GroupsColumns.TABLENAME URI_GROUPS_ID -> { val groupID = uri.lastPathSegment selection = if (selection.isNullOrEmpty()) { @@ -2127,7 +2130,7 @@ class FenrirContentProvider : ContentProvider() { } else { selection + " AND " + BaseColumns._ID + " = " + groupID } - tbName = GroupColumns.TABLENAME + tbName = GroupsColumns.TABLENAME } URI_DIALOGS -> tbName = DialogsColumns.TABLENAME @@ -2155,7 +2158,7 @@ class FenrirContentProvider : ContentProvider() { tbName = PhotosColumns.TABLENAME } - URI_VIDEOS -> tbName = VideoColumns.TABLENAME + URI_VIDEOS -> tbName = VideosColumns.TABLENAME URI_COMMENTS -> tbName = CommentsColumns.TABLENAME URI_COMMENTS_ID -> { val commentId = uri.lastPathSegment @@ -2167,10 +2170,10 @@ class FenrirContentProvider : ContentProvider() { tbName = CommentsColumns.TABLENAME } - URI_RELATIVESHIP -> tbName = RelationshipColumns.TABLENAME + URI_RELATIVESHIP -> tbName = RelationshipsColumns.TABLENAME URI_PHOTO_ALBUMS -> tbName = PhotoAlbumsColumns.TABLENAME URI_NEWS -> tbName = NewsColumns.TABLENAME - URI_GROUPS_DET -> tbName = GroupsDetColumns.TABLENAME + URI_GROUPS_DET -> tbName = GroupsDetailsColumns.TABLENAME URI_GROUPS_DET_ID -> { val groupDetId = uri.lastPathSegment selection = if (selection.isNullOrEmpty()) { @@ -2178,13 +2181,13 @@ class FenrirContentProvider : ContentProvider() { } else { selection + " AND " + BaseColumns._ID + " = " + groupDetId } - tbName = GroupsDetColumns.TABLENAME + tbName = GroupsDetailsColumns.TABLENAME } URI_VIDEO_ALBUMS -> tbName = VideoAlbumsColumns.TABLENAME URI_TOPICS -> tbName = TopicsColumns.TABLENAME - URI_NOTIFICATIONS -> tbName = NotificationColumns.TABLENAME - URI_USER_DET -> tbName = UsersDetColumns.TABLENAME + URI_NOTIFICATIONS -> tbName = NotificationsColumns.TABLENAME + URI_USER_DET -> tbName = UsersDetailsColumns.TABLENAME URI_USER_DET_ID -> { val userDetId = uri.lastPathSegment selection = if (selection.isNullOrEmpty()) { @@ -2192,28 +2195,28 @@ class FenrirContentProvider : ContentProvider() { } else { selection + " AND " + BaseColumns._ID + " = " + userDetId } - tbName = UsersDetColumns.TABLENAME + tbName = UsersDetailsColumns.TABLENAME } URI_FAVE_PHOTOS -> tbName = FavePhotosColumns.TABLENAME URI_FAVE_VIDEOS -> tbName = FaveVideosColumns.TABLENAME URI_FAVE_ARTICLES -> tbName = FaveArticlesColumns.TABLENAME - URI_FAVE_PRODUCTS -> tbName = FaveProductColumns.TABLENAME - URI_FAVE_PAGES -> tbName = FavePageColumns.TABLENAME - URI_FAVE_GROUPS -> tbName = FavePageColumns.GROUPSTABLENAME + URI_FAVE_PRODUCTS -> tbName = FaveProductsColumns.TABLENAME + URI_FAVE_PAGES -> tbName = FavePagesColumns.TABLENAME + URI_FAVE_GROUPS -> tbName = FavePagesColumns.GROUPSTABLENAME URI_FAVE_LINKS -> tbName = FaveLinksColumns.TABLENAME URI_FAVE_POSTS -> tbName = FavePostsColumns.TABLENAME URI_COUNTRIES -> tbName = CountriesColumns.TABLENAME URI_FEED_LISTS -> tbName = FeedListsColumns.TABLENAME URI_FRIEND_LISTS -> tbName = FriendListsColumns.TABLENAME - URI_KEYS -> tbName = KeyColumns.TABLENAME + URI_KEYS -> tbName = EncryptionKeysForMessagesColumns.TABLENAME else -> throw IllegalArgumentException("Wrong URI: $uri") } val db: SQLiteDatabase = getDbHelper(uri).writableDatabase val cnt: Int = db.updateWithOnConflict(tbName, values, selection, selectionArgs, CONFLICT_REPLACE) safeNotifyChange(uri) - if (tbName == MessageColumns.TABLENAME) { + if (tbName == MessagesColumns.TABLENAME) { safeNotifyChange(DIALOGS_CONTENT_URI) } return cnt diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/OwnerHelper.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/OwnerHelper.kt index 52981063c..a1b7008fe 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/OwnerHelper.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/OwnerHelper.kt @@ -4,8 +4,8 @@ import android.content.Context import android.provider.BaseColumns import dev.ragnarok.fenrir.db.FenrirContentProvider.Companion.getGroupsContentUriFor import dev.ragnarok.fenrir.db.FenrirContentProvider.Companion.getUserContentUriFor -import dev.ragnarok.fenrir.db.column.GroupColumns -import dev.ragnarok.fenrir.db.column.UserColumns +import dev.ragnarok.fenrir.db.column.GroupsColumns +import dev.ragnarok.fenrir.db.column.UsersColumns import dev.ragnarok.fenrir.getString object OwnerHelper { @@ -20,8 +20,8 @@ object OwnerHelper { if (uCursor != null) { if (uCursor.moveToNext()) { result = - uCursor.getString(UserColumns.FIRST_NAME) + - " " + uCursor.getString(UserColumns.LAST_NAME) + uCursor.getString(UsersColumns.FIRST_NAME) + + " " + uCursor.getString(UsersColumns.LAST_NAME) } uCursor.close() } @@ -32,7 +32,7 @@ object OwnerHelper { ) if (gCursor != null) { if (gCursor.moveToNext()) { - result = gCursor.getString(GroupColumns.NAME) + result = gCursor.getString(GroupsColumns.NAME) } gCursor.close() } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/TempDataHelper.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/TempDataHelper.kt index 2363cb31e..0e59a5569 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/TempDataHelper.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/TempDataHelper.kt @@ -6,11 +6,12 @@ import android.database.sqlite.SQLiteOpenHelper import android.provider.BaseColumns import dev.ragnarok.fenrir.Constants import dev.ragnarok.fenrir.Includes -import dev.ragnarok.fenrir.db.column.AudioColumns -import dev.ragnarok.fenrir.db.column.LogColumns +import dev.ragnarok.fenrir.db.column.AudiosColumns +import dev.ragnarok.fenrir.db.column.LogsColumns import dev.ragnarok.fenrir.db.column.SearchRequestColumns -import dev.ragnarok.fenrir.db.column.ShortcutColumns -import dev.ragnarok.fenrir.db.column.StickerSetColumns +import dev.ragnarok.fenrir.db.column.ShortcutsColumns +import dev.ragnarok.fenrir.db.column.StickerSetsColumns +import dev.ragnarok.fenrir.db.column.StickerSetsCustomColumns import dev.ragnarok.fenrir.db.column.StickersKeywordsColumns import dev.ragnarok.fenrir.db.column.TempDataColumns import dev.ragnarok.fenrir.module.FenrirNative @@ -18,7 +19,7 @@ import dev.ragnarok.fenrir.module.FenrirNative class TempDataHelper(context: Context) : SQLiteOpenHelper( context, - if (!FenrirNative.isNativeLoaded) "temp_app_data_uncompressed.sqlite" else "temp_app_data.sqlite", + if (!FenrirNative.isNativeLoaded) "temp_app_data.sqlite" else "temp_app_data_lz4.sqlite", null, Constants.DATABASE_TEMPORARY_VERSION ) { @@ -28,21 +29,37 @@ class TempDataHelper(context: Context) : createLogsTable(db) createShortcutsColumn(db) createAudiosTable(db) - createStickerSetTable(db) + createStickerSetsTable(db) + createStickerSetsCustomTable(db) createStickersKeywordsTable(db) } - private fun createStickerSetTable(db: SQLiteDatabase) { - val sql = "CREATE TABLE IF NOT EXISTS [" + StickerSetColumns.TABLENAME + "] (\n" + + private fun createStickerSetsTable(db: SQLiteDatabase) { + val sql = "CREATE TABLE IF NOT EXISTS [" + StickerSetsColumns.TABLENAME + "] (\n" + " [" + BaseColumns._ID + "] INTEGER NOT NULL UNIQUE ON CONFLICT REPLACE, " + - " [" + StickerSetColumns.ACCOUNT_ID + "] INTEGER, " + - " [" + StickerSetColumns.POSITION + "] INTEGER, " + - " [" + StickerSetColumns.TITLE + "] TEXT, " + - " [" + StickerSetColumns.ICON + "] BLOB, " + - " [" + StickerSetColumns.PURCHASED + "] BOOLEAN, " + - " [" + StickerSetColumns.PROMOTED + "] BOOLEAN, " + - " [" + StickerSetColumns.ACTIVE + "] BOOLEAN, " + - " [" + StickerSetColumns.STICKERS + "] BLOB, " + + " [" + StickerSetsColumns.ACCOUNT_ID + "] INTEGER, " + + " [" + StickerSetsColumns.POSITION + "] INTEGER, " + + " [" + StickerSetsColumns.TITLE + "] TEXT, " + + " [" + StickerSetsColumns.ICON + "] BLOB, " + + " [" + StickerSetsColumns.PURCHASED + "] BOOLEAN, " + + " [" + StickerSetsColumns.PROMOTED + "] BOOLEAN, " + + " [" + StickerSetsColumns.ACTIVE + "] BOOLEAN, " + + " [" + StickerSetsColumns.STICKERS + "] BLOB, " + + " CONSTRAINT [] PRIMARY KEY([" + BaseColumns._ID + "]) ON CONFLICT REPLACE);" + db.execSQL(sql) + } + + private fun createStickerSetsCustomTable(db: SQLiteDatabase) { + val sql = "CREATE TABLE IF NOT EXISTS [" + StickerSetsCustomColumns.TABLENAME + "] (\n" + + " [" + BaseColumns._ID + "] INTEGER NOT NULL UNIQUE ON CONFLICT REPLACE, " + + " [" + StickerSetsCustomColumns.ACCOUNT_ID + "] INTEGER, " + + " [" + StickerSetsCustomColumns.POSITION + "] INTEGER, " + + " [" + StickerSetsCustomColumns.TITLE + "] TEXT, " + + " [" + StickerSetsCustomColumns.ICON + "] BLOB, " + + " [" + StickerSetsCustomColumns.PURCHASED + "] BOOLEAN, " + + " [" + StickerSetsCustomColumns.PROMOTED + "] BOOLEAN, " + + " [" + StickerSetsCustomColumns.ACTIVE + "] BOOLEAN, " + + " [" + StickerSetsCustomColumns.STICKERS + "] BLOB, " + " CONSTRAINT [] PRIMARY KEY([" + BaseColumns._ID + "]) ON CONFLICT REPLACE);" db.execSQL(sql) } @@ -77,50 +94,50 @@ class TempDataHelper(context: Context) : } private fun createShortcutsColumn(db: SQLiteDatabase) { - val sql = "CREATE TABLE IF NOT EXISTS [" + ShortcutColumns.TABLENAME + "] (\n" + + val sql = "CREATE TABLE IF NOT EXISTS [" + ShortcutsColumns.TABLENAME + "] (\n" + " [" + BaseColumns._ID + "] INTEGER PRIMARY KEY AUTOINCREMENT, " + - " [" + ShortcutColumns.ACTION + "] TEXT, " + - " [" + ShortcutColumns.COVER + "] TEXT, " + - " [" + ShortcutColumns.NAME + "] TEXT, " + + " [" + ShortcutsColumns.ACTION + "] TEXT, " + + " [" + ShortcutsColumns.COVER + "] TEXT, " + + " [" + ShortcutsColumns.NAME + "] TEXT, " + " CONSTRAINT [] UNIQUE ([" + BaseColumns._ID + "]) ON CONFLICT REPLACE);" db.execSQL(sql) } private fun createLogsTable(db: SQLiteDatabase) { - val sql = "CREATE TABLE IF NOT EXISTS [" + LogColumns.TABLENAME + "] (\n" + + val sql = "CREATE TABLE IF NOT EXISTS [" + LogsColumns.TABLENAME + "] (\n" + " [" + BaseColumns._ID + "] INTEGER PRIMARY KEY AUTOINCREMENT, " + - " [" + LogColumns.TYPE + "] INTEGER, " + - " [" + LogColumns.DATE + "] INTEGER, " + - " [" + LogColumns.TAG + "] TEXT, " + - " [" + LogColumns.BODY + "] TEXT, " + + " [" + LogsColumns.TYPE + "] INTEGER, " + + " [" + LogsColumns.DATE + "] INTEGER, " + + " [" + LogsColumns.TAG + "] TEXT, " + + " [" + LogsColumns.BODY + "] TEXT, " + " CONSTRAINT [] UNIQUE ([" + BaseColumns._ID + "]) ON CONFLICT REPLACE);" db.execSQL(sql) } private fun createAudiosTable(db: SQLiteDatabase) { - val sql = "CREATE TABLE IF NOT EXISTS [" + AudioColumns.TABLENAME + "] (\n" + + val sql = "CREATE TABLE IF NOT EXISTS [" + AudiosColumns.TABLENAME + "] (\n" + " [" + BaseColumns._ID + "] INTEGER PRIMARY KEY AUTOINCREMENT, " + - " [" + AudioColumns.SOURCE_OWNER_ID + "] INTEGER, " + - " [" + AudioColumns.AUDIO_ID + "] INTEGER, " + - " [" + AudioColumns.AUDIO_OWNER_ID + "] INTEGER, " + - " [" + AudioColumns.ARTIST + "] TEXT, " + - " [" + AudioColumns.TITLE + "] TEXT, " + - " [" + AudioColumns.DURATION + "] INTEGER, " + - " [" + AudioColumns.URL + "] TEXT, " + - " [" + AudioColumns.LYRICS_ID + "] INTEGER, " + - " [" + AudioColumns.DATE + "] INTEGER, " + - " [" + AudioColumns.ALBUM_ID + "] INTEGER, " + - " [" + AudioColumns.ALBUM_OWNER_ID + "] INTEGER, " + - " [" + AudioColumns.ALBUM_ACCESS_KEY + "] TEXT, " + - " [" + AudioColumns.GENRE + "] INTEGER, " + - " [" + AudioColumns.DELETED + "] BOOLEAN, " + - " [" + AudioColumns.ACCESS_KEY + "] TEXT, " + - " [" + AudioColumns.THUMB_IMAGE_BIG + "] TEXT, " + - " [" + AudioColumns.THUMB_IMAGE_VERY_BIG + "] TEXT, " + - " [" + AudioColumns.THUMB_IMAGE_LITTLE + "] TEXT, " + - " [" + AudioColumns.ALBUM_TITLE + "] TEXT, " + - " [" + AudioColumns.MAIN_ARTISTS + "] BLOB, " + - " [" + AudioColumns.IS_HQ + "] BOOLEAN, " + + " [" + AudiosColumns.SOURCE_OWNER_ID + "] INTEGER, " + + " [" + AudiosColumns.AUDIO_ID + "] INTEGER, " + + " [" + AudiosColumns.AUDIO_OWNER_ID + "] INTEGER, " + + " [" + AudiosColumns.ARTIST + "] TEXT, " + + " [" + AudiosColumns.TITLE + "] TEXT, " + + " [" + AudiosColumns.DURATION + "] INTEGER, " + + " [" + AudiosColumns.URL + "] TEXT, " + + " [" + AudiosColumns.LYRICS_ID + "] INTEGER, " + + " [" + AudiosColumns.DATE + "] INTEGER, " + + " [" + AudiosColumns.ALBUM_ID + "] INTEGER, " + + " [" + AudiosColumns.ALBUM_OWNER_ID + "] INTEGER, " + + " [" + AudiosColumns.ALBUM_ACCESS_KEY + "] TEXT, " + + " [" + AudiosColumns.GENRE + "] INTEGER, " + + " [" + AudiosColumns.DELETED + "] BOOLEAN, " + + " [" + AudiosColumns.ACCESS_KEY + "] TEXT, " + + " [" + AudiosColumns.THUMB_IMAGE_BIG + "] TEXT, " + + " [" + AudiosColumns.THUMB_IMAGE_VERY_BIG + "] TEXT, " + + " [" + AudiosColumns.THUMB_IMAGE_LITTLE + "] TEXT, " + + " [" + AudiosColumns.ALBUM_TITLE + "] TEXT, " + + " [" + AudiosColumns.MAIN_ARTISTS + "] BLOB, " + + " [" + AudiosColumns.IS_HQ + "] BOOLEAN, " + " CONSTRAINT [] UNIQUE ([" + BaseColumns._ID + "]) ON CONFLICT REPLACE);" db.execSQL(sql) } @@ -129,23 +146,24 @@ class TempDataHelper(context: Context) : val db = writableDatabase db.execSQL("DROP TABLE IF EXISTS " + TempDataColumns.TABLENAME) db.execSQL("DROP TABLE IF EXISTS " + SearchRequestColumns.TABLENAME) - db.execSQL("DROP TABLE IF EXISTS " + AudioColumns.TABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + AudiosColumns.TABLENAME) onCreate(db) } fun clearLogs() { val db = writableDatabase - db.execSQL("DROP TABLE IF EXISTS " + LogColumns.TABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + LogsColumns.TABLENAME) onCreate(db) } private fun purge(db: SQLiteDatabase) { db.execSQL("DROP TABLE IF EXISTS " + TempDataColumns.TABLENAME) db.execSQL("DROP TABLE IF EXISTS " + SearchRequestColumns.TABLENAME) - db.execSQL("DROP TABLE IF EXISTS " + LogColumns.TABLENAME) - db.execSQL("DROP TABLE IF EXISTS " + ShortcutColumns.TABLENAME) - db.execSQL("DROP TABLE IF EXISTS " + AudioColumns.TABLENAME) - db.execSQL("DROP TABLE IF EXISTS " + StickerSetColumns.TABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + LogsColumns.TABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + ShortcutsColumns.TABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + AudiosColumns.TABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + StickerSetsColumns.TABLENAME) + db.execSQL("DROP TABLE IF EXISTS " + StickerSetsCustomColumns.TABLENAME) db.execSQL("DROP TABLE IF EXISTS " + StickersKeywordsColumns.TABLENAME) onCreate(db) } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/AudioColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/AudiosColumns.kt similarity index 96% rename from app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/AudioColumns.kt rename to app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/AudiosColumns.kt index e092c672e..a17e14002 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/AudioColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/AudiosColumns.kt @@ -2,7 +2,7 @@ package dev.ragnarok.fenrir.db.column import android.provider.BaseColumns -object AudioColumns : BaseColumns { +object AudiosColumns : BaseColumns { const val TABLENAME = "audio_cache_data" const val SOURCE_OWNER_ID = "source_owner_id" diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/DocColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/DocsColumns.kt similarity index 96% rename from app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/DocColumns.kt rename to app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/DocsColumns.kt index 69486e0f6..0c1bb3f75 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/DocColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/DocsColumns.kt @@ -2,7 +2,7 @@ package dev.ragnarok.fenrir.db.column import android.provider.BaseColumns -object DocColumns : BaseColumns { +object DocsColumns : BaseColumns { const val TABLENAME = "docs" const val DOC_ID = "doc_id" const val OWNER_ID = "owner_id" diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/KeyColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/EncryptionKeysForMessagesColumns.kt similarity index 88% rename from app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/KeyColumns.kt rename to app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/EncryptionKeysForMessagesColumns.kt index fffa00701..4db737acd 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/KeyColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/EncryptionKeysForMessagesColumns.kt @@ -2,8 +2,8 @@ package dev.ragnarok.fenrir.db.column import android.provider.BaseColumns -object KeyColumns : BaseColumns { - const val TABLENAME = "keys" +object EncryptionKeysForMessagesColumns : BaseColumns { + const val TABLENAME = "encryption_keys_for_messages" const val VERSION = "version" const val PEER_ID = "peer_id" const val SESSION_ID = "session_id" diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FaveArticlesColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FaveArticlesColumns.kt index 3e428a186..9afe13ba4 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FaveArticlesColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FaveArticlesColumns.kt @@ -3,7 +3,7 @@ package dev.ragnarok.fenrir.db.column import android.provider.BaseColumns object FaveArticlesColumns : BaseColumns { - const val TABLENAME = "fave_article" + const val TABLENAME = "fave_articles" const val ARTICLE = "article" const val FULL_ID = TABLENAME + "." + BaseColumns._ID const val FULL_ARTICLE = "$TABLENAME.$ARTICLE" diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FaveLinksColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FaveLinksColumns.kt index 4124eeedb..26751749d 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FaveLinksColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FaveLinksColumns.kt @@ -3,7 +3,7 @@ package dev.ragnarok.fenrir.db.column import android.provider.BaseColumns object FaveLinksColumns : BaseColumns { - const val TABLENAME = "fave_link" + const val TABLENAME = "fave_links" const val LINK_ID = "link_id" const val URL = "url" const val TITLE = "title" diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FavePageColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FavePagesColumns.kt similarity index 91% rename from app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FavePageColumns.kt rename to app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FavePagesColumns.kt index 6a2edbabd..1d1dc0404 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FavePageColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FavePagesColumns.kt @@ -2,7 +2,7 @@ package dev.ragnarok.fenrir.db.column import android.provider.BaseColumns -object FavePageColumns : BaseColumns { +object FavePagesColumns : BaseColumns { const val TABLENAME = "fave_pages" const val GROUPSTABLENAME = "fave_groups" const val FULL_ID = TABLENAME + "." + BaseColumns._ID diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FaveProductColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FaveProductsColumns.kt similarity index 72% rename from app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FaveProductColumns.kt rename to app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FaveProductsColumns.kt index 876e9efa0..0ded22813 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FaveProductColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/FaveProductsColumns.kt @@ -2,8 +2,8 @@ package dev.ragnarok.fenrir.db.column import android.provider.BaseColumns -object FaveProductColumns : BaseColumns { - const val TABLENAME = "fave_product" +object FaveProductsColumns : BaseColumns { + const val TABLENAME = "fave_products" const val PRODUCT = "product" const val FULL_ID = TABLENAME + "." + BaseColumns._ID const val FULL_PRODUCT = "$TABLENAME.$PRODUCT" diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/GroupColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/GroupsColumns.kt similarity index 98% rename from app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/GroupColumns.kt rename to app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/GroupsColumns.kt index 2d87b2636..ca163b60f 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/GroupColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/GroupsColumns.kt @@ -2,7 +2,7 @@ package dev.ragnarok.fenrir.db.column import android.provider.BaseColumns -object GroupColumns : BaseColumns { +object GroupsColumns : BaseColumns { const val TABLENAME = "groups" const val NAME = "name" const val SCREEN_NAME = "screen_name" diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/UsersDetColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/GroupsDetailsColumns.kt similarity index 70% rename from app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/UsersDetColumns.kt rename to app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/GroupsDetailsColumns.kt index 0947af430..4fa1dfd24 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/UsersDetColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/GroupsDetailsColumns.kt @@ -2,8 +2,8 @@ package dev.ragnarok.fenrir.db.column import android.provider.BaseColumns -object UsersDetColumns : BaseColumns { - const val TABLENAME = "users_det" +object GroupsDetailsColumns : BaseColumns { + const val TABLENAME = "groups_details" const val DATA = "data" const val FULL_ID = TABLENAME + "." + BaseColumns._ID const val FULL_DATA = "$TABLENAME.$DATA" diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/LogColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/LogsColumns.kt similarity index 86% rename from app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/LogColumns.kt rename to app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/LogsColumns.kt index cd5ce5e35..afd3886f2 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/LogColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/LogsColumns.kt @@ -2,7 +2,7 @@ package dev.ragnarok.fenrir.db.column import android.provider.BaseColumns -object LogColumns : BaseColumns { +object LogsColumns : BaseColumns { const val TABLENAME = "logs" const val TYPE = "eventtype" const val DATE = "eventdate" diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/MessageColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/MessagesColumns.kt similarity index 98% rename from app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/MessageColumns.kt rename to app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/MessagesColumns.kt index 90e05e307..3cd62b38f 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/MessageColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/MessagesColumns.kt @@ -2,7 +2,7 @@ package dev.ragnarok.fenrir.db.column import android.provider.BaseColumns -object MessageColumns : BaseColumns { +object MessagesColumns : BaseColumns { const val TABLENAME = "messages" const val _ID = "_id" const val PEER_ID = "peer_id" diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/NotificationColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/NotificationsColumns.kt similarity index 88% rename from app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/NotificationColumns.kt rename to app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/NotificationsColumns.kt index bfd8ebfd7..a843a9f23 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/NotificationColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/NotificationsColumns.kt @@ -2,7 +2,7 @@ package dev.ragnarok.fenrir.db.column import android.provider.BaseColumns -object NotificationColumns : BaseColumns { +object NotificationsColumns : BaseColumns { const val TABLENAME = "notifications" const val DATE = "date" const val CONTENT_PACK = "content_pack" diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/PeersColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/PeersColumns.kt index 959ef6c0a..be5abc820 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/PeersColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/PeersColumns.kt @@ -3,7 +3,7 @@ package dev.ragnarok.fenrir.db.column import android.provider.BaseColumns object PeersColumns : BaseColumns { - const val TABLENAME = "peersnew" + const val TABLENAME = "peers_of_dialogs" const val UNREAD = "unread" const val TITLE = "title" const val IN_READ = "in_read" diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/RelationshipColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/RelationshipsColumns.kt similarity index 97% rename from app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/RelationshipColumns.kt rename to app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/RelationshipsColumns.kt index 93e32956b..5f7a9a600 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/RelationshipColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/RelationshipsColumns.kt @@ -3,13 +3,13 @@ package dev.ragnarok.fenrir.db.column import android.content.ContentValues import android.provider.BaseColumns -object RelationshipColumns : BaseColumns { +object RelationshipsColumns : BaseColumns { const val TYPE_FRIEND = 1 const val TYPE_FOLLOWER = 2 const val TYPE_GROUP_MEMBER = 3 const val TYPE_MEMBER = 4 const val TYPE_REQUESTS = 5 - const val TABLENAME = "relationship" + const val TABLENAME = "relationships" const val OBJECT_ID = "object_id" const val SUBJECT_ID = "subject_id" const val TYPE = "type" diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/ShortcutColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/ShortcutsColumns.kt similarity index 83% rename from app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/ShortcutColumns.kt rename to app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/ShortcutsColumns.kt index c89057b9f..f93081522 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/ShortcutColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/ShortcutsColumns.kt @@ -2,7 +2,7 @@ package dev.ragnarok.fenrir.db.column import android.provider.BaseColumns -object ShortcutColumns : BaseColumns { +object ShortcutsColumns : BaseColumns { const val TABLENAME = "shortcuts" const val ACTION = "action" const val NAME = "name" diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/StickerSetColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/StickerSetsColumns.kt similarity index 80% rename from app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/StickerSetColumns.kt rename to app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/StickerSetsColumns.kt index 14a930bf9..40034f2fd 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/StickerSetColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/StickerSetsColumns.kt @@ -2,8 +2,8 @@ package dev.ragnarok.fenrir.db.column import android.provider.BaseColumns -object StickerSetColumns : BaseColumns { - const val TABLENAME = "sticker_set" +object StickerSetsColumns : BaseColumns { + const val TABLENAME = "sticker_sets" const val ACCOUNT_ID = "account_id" const val POSITION = "position" const val TITLE = "title" diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/StickerSetsCustomColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/StickerSetsCustomColumns.kt new file mode 100644 index 000000000..40a1e2abd --- /dev/null +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/StickerSetsCustomColumns.kt @@ -0,0 +1,15 @@ +package dev.ragnarok.fenrir.db.column + +import android.provider.BaseColumns + +object StickerSetsCustomColumns : BaseColumns { + const val TABLENAME = "sticker_sets_custom" + const val ACCOUNT_ID = "account_id" + const val POSITION = "position" + const val TITLE = "title" + const val ICON = "icon" + const val PURCHASED = "purchased" + const val PROMOTED = "promoted" + const val ACTIVE = "active" + const val STICKERS = "stickers" +} diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/UserColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/UsersColumns.kt similarity index 98% rename from app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/UserColumns.kt rename to app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/UsersColumns.kt index d1b2d0d49..a79ce1e10 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/UserColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/UsersColumns.kt @@ -2,7 +2,7 @@ package dev.ragnarok.fenrir.db.column import android.provider.BaseColumns -object UserColumns : BaseColumns { +object UsersColumns : BaseColumns { /** * The table name of books = "books" */ diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/GroupsDetColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/UsersDetailsColumns.kt similarity index 70% rename from app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/GroupsDetColumns.kt rename to app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/UsersDetailsColumns.kt index cfe02f769..e70fd7726 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/GroupsDetColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/UsersDetailsColumns.kt @@ -2,8 +2,8 @@ package dev.ragnarok.fenrir.db.column import android.provider.BaseColumns -object GroupsDetColumns : BaseColumns { - const val TABLENAME = "groups_det" +object UsersDetailsColumns : BaseColumns { + const val TABLENAME = "users_details" const val DATA = "data" const val FULL_ID = TABLENAME + "." + BaseColumns._ID const val FULL_DATA = "$TABLENAME.$DATA" diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/VideoColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/VideosColumns.kt similarity index 98% rename from app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/VideoColumns.kt rename to app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/VideosColumns.kt index 58512dccd..caca65384 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/VideoColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/VideosColumns.kt @@ -2,7 +2,7 @@ package dev.ragnarok.fenrir.db.column import android.provider.BaseColumns -object VideoColumns : BaseColumns { +object VideosColumns : BaseColumns { const val TABLENAME = "videos" const val VIDEO_ID = "video_id" const val OWNER_ID = "owner_id" diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/attachments/WallAttachmentsColumns.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/attachments/WallsAttachmentsColumns.kt similarity index 76% rename from app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/attachments/WallAttachmentsColumns.kt rename to app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/attachments/WallsAttachmentsColumns.kt index e906f9420..1d31b354f 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/attachments/WallAttachmentsColumns.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/column/attachments/WallsAttachmentsColumns.kt @@ -2,8 +2,8 @@ package dev.ragnarok.fenrir.db.column.attachments import android.provider.BaseColumns -object WallAttachmentsColumns : BaseColumns { - const val TABLENAME = "wall_attachments" +object WallsAttachmentsColumns : BaseColumns { + const val TABLENAME = "walls_attachments" const val P_ID = "post_id" const val DATA = "data" const val FULL_ID = TABLENAME + "." + BaseColumns._ID diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/AttachmentsStorage.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/AttachmentsStorage.kt index 6e762d18e..4e0db9406 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/AttachmentsStorage.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/AttachmentsStorage.kt @@ -12,7 +12,7 @@ import dev.ragnarok.fenrir.db.FenrirContentProvider.Companion.getMessagesAttachm import dev.ragnarok.fenrir.db.FenrirContentProvider.Companion.getPostsAttachmentsContentUriFor import dev.ragnarok.fenrir.db.column.attachments.CommentsAttachmentsColumns import dev.ragnarok.fenrir.db.column.attachments.MessagesAttachmentsColumns -import dev.ragnarok.fenrir.db.column.attachments.WallAttachmentsColumns +import dev.ragnarok.fenrir.db.column.attachments.WallsAttachmentsColumns import dev.ragnarok.fenrir.db.interfaces.Cancelable import dev.ragnarok.fenrir.db.interfaces.IAttachmentsStorage import dev.ragnarok.fenrir.db.model.entity.DboEntity @@ -206,7 +206,7 @@ internal class AttachmentsStorage(base: AppStorages) : AbsStorage(base), IAttach when (type) { AttachToType.COMMENT -> return CommentsAttachmentsColumns.C_ID AttachToType.MESSAGE -> return MessagesAttachmentsColumns.M_ID - AttachToType.POST -> return WallAttachmentsColumns.P_ID + AttachToType.POST -> return WallsAttachmentsColumns.P_ID } throw IllegalArgumentException() } @@ -215,7 +215,7 @@ internal class AttachmentsStorage(base: AppStorages) : AbsStorage(base), IAttach when (type) { AttachToType.COMMENT -> return CommentsAttachmentsColumns.DATA AttachToType.MESSAGE -> return MessagesAttachmentsColumns.DATA - AttachToType.POST -> return WallAttachmentsColumns.DATA + AttachToType.POST -> return WallsAttachmentsColumns.DATA } throw IllegalArgumentException() } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/DialogsStorage.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/DialogsStorage.kt index f97ec7251..411b66a64 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/DialogsStorage.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/DialogsStorage.kt @@ -19,7 +19,7 @@ import dev.ragnarok.fenrir.db.model.PeerPatch import dev.ragnarok.fenrir.db.model.entity.DialogDboEntity import dev.ragnarok.fenrir.db.model.entity.KeyboardEntity import dev.ragnarok.fenrir.db.model.entity.MessageDboEntity -import dev.ragnarok.fenrir.db.model.entity.SimpleDialogEntity +import dev.ragnarok.fenrir.db.model.entity.PeerDialogEntity import dev.ragnarok.fenrir.getBlob import dev.ragnarok.fenrir.getBoolean import dev.ragnarok.fenrir.getInt @@ -98,19 +98,20 @@ internal class DialogsStorage(base: AppStorages) : AbsStorage(base), IDialogsSto return Completable.create { emitter: CompletableEmitter -> val start = System.currentTimeMillis() val uri = getDialogsContentUriFor(accountId) + val peersUri = getPeersContentUriFor(accountId) val operations = ArrayList() if (clearBefore) { operations.add(ContentProviderOperation.newDelete(uri).build()) } for (entity in dbos) { - val simple = entity.simplify() + val peerDialog = entity.toPeerDialog() operations.add( ContentProviderOperation.newInsert(uri).withValues(createCv(entity)).build() ) operations.add( ContentProviderOperation - .newInsert(getPeersContentUriFor(accountId)) - .withValues(createPeerCv(simple)) + .newInsert(peersUri) + .withValues(createPeerCv(peerDialog)) .build() ) entity.message?.let { @@ -151,7 +152,7 @@ internal class DialogsStorage(base: AppStorages) : AbsStorage(base), IDialogsSto return cv } - private fun createPeerCv(entity: SimpleDialogEntity): ContentValues { + private fun createPeerCv(entity: PeerDialogEntity): ContentValues { val cv = ContentValues() cv.put(BaseColumns._ID, entity.peerId) cv.put(PeersColumns.UNREAD, entity.unreadCount) @@ -181,10 +182,11 @@ internal class DialogsStorage(base: AppStorages) : AbsStorage(base), IDialogsSto cv.put(PeersColumns.IS_GROUP_CHANNEL, entity.isGroupChannel) cv.put(PeersColumns.MAJOR_ID, entity.major_id) cv.put(PeersColumns.MINOR_ID, entity.minor_id) + cv.put(PeersColumns.LAST_MESSAGE_ID, entity.lastMessageId) return cv } - override fun saveSimple(accountId: Long, entity: SimpleDialogEntity): Completable { + override fun savePeerDialog(accountId: Long, entity: PeerDialogEntity): Completable { return Completable.create { emitter: CompletableEmitter -> val uri = getPeersContentUriFor(accountId) val operations = ArrayList() @@ -261,8 +263,8 @@ internal class DialogsStorage(base: AppStorages) : AbsStorage(base), IDialogsSto } } - override fun findSimple(accountId: Long, peerId: Long): Single> { - return Single.create { emitter: SingleEmitter> -> + override fun findPeerDialog(accountId: Long, peerId: Long): Single> { + return Single.create { emitter: SingleEmitter> -> val projection = arrayOf( PeersColumns.UNREAD, PeersColumns.TITLE, @@ -284,12 +286,12 @@ internal class DialogsStorage(base: AppStorages) : AbsStorage(base), IDialogsSto uri, projection, PeersColumns.FULL_ID + " = ?", arrayOf(peerId.toString()), null ) - var entity: SimpleDialogEntity? = null + var entity: PeerDialogEntity? = null if (cursor != null) { if (cursor.moveToNext()) { val pinJson = cursor.getBlob(PeersColumns.PINNED) val keyboardJson = cursor.getBlob(PeersColumns.KEYBOARD) - entity = SimpleDialogEntity(peerId) + entity = PeerDialogEntity(peerId) .setUnreadCount(cursor.getInt(PeersColumns.UNREAD)) .setTitle(cursor.getString(PeersColumns.TITLE)) .setPhoto200(cursor.getString(PeersColumns.PHOTO_200)) diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/DocsStorage.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/DocsStorage.kt index 230406c10..d5614af5f 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/DocsStorage.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/DocsStorage.kt @@ -5,7 +5,7 @@ import android.content.ContentValues import android.database.Cursor import dev.ragnarok.fenrir.db.FenrirContentProvider import dev.ragnarok.fenrir.db.FenrirContentProvider.Companion.getDocsContentUriFor -import dev.ragnarok.fenrir.db.column.DocColumns +import dev.ragnarok.fenrir.db.column.DocsColumns import dev.ragnarok.fenrir.db.interfaces.IDocsStorage import dev.ragnarok.fenrir.db.model.entity.DocumentDboEntity import dev.ragnarok.fenrir.db.model.entity.DocumentDboEntity.GraffitiDbo @@ -36,10 +36,10 @@ internal class DocsStorage(base: AppStorages) : AbsStorage(base), IDocsStorage { val args: Array val filter = criteria.filter if (filter != null && filter != DocFilter.Type.ALL) { - where = DocColumns.OWNER_ID + " = ? AND " + DocColumns.TYPE + " = ?" + where = DocsColumns.OWNER_ID + " = ? AND " + DocsColumns.TYPE + " = ?" args = arrayOf(criteria.ownerId.toString(), filter.toString()) } else { - where = DocColumns.OWNER_ID + " = ?" + where = DocsColumns.OWNER_ID + " = ?" args = arrayOf(criteria.ownerId.toString()) } val cursor = contentResolver.query(uri, null, where, args, null) @@ -71,49 +71,49 @@ internal class DocsStorage(base: AppStorages) : AbsStorage(base), IDocsStorage { if (clearBeforeInsert) { operations.add( ContentProviderOperation.newDelete(uri) - .withSelection(DocColumns.OWNER_ID + " = ?", arrayOf(ownerId.toString())) + .withSelection(DocsColumns.OWNER_ID + " = ?", arrayOf(ownerId.toString())) .build() ) } for (entity in entities) { val cv = ContentValues() - cv.put(DocColumns.DOC_ID, entity.id) - cv.put(DocColumns.OWNER_ID, entity.ownerId) - cv.put(DocColumns.TITLE, entity.title) - cv.put(DocColumns.SIZE, entity.size) - cv.put(DocColumns.EXT, entity.ext) - cv.put(DocColumns.URL, entity.url) - cv.put(DocColumns.DATE, entity.date) - cv.put(DocColumns.TYPE, entity.type) - cv.put(DocColumns.ACCESS_KEY, entity.accessKey) + cv.put(DocsColumns.DOC_ID, entity.id) + cv.put(DocsColumns.OWNER_ID, entity.ownerId) + cv.put(DocsColumns.TITLE, entity.title) + cv.put(DocsColumns.SIZE, entity.size) + cv.put(DocsColumns.EXT, entity.ext) + cv.put(DocsColumns.URL, entity.url) + cv.put(DocsColumns.DATE, entity.date) + cv.put(DocsColumns.TYPE, entity.type) + cv.put(DocsColumns.ACCESS_KEY, entity.accessKey) entity.photo.ifNonNull({ cv.put( - DocColumns.PHOTO, + DocsColumns.PHOTO, MsgPack.encodeToByteArrayEx(PhotoSizeEntity.serializer(), it) ) }, { cv.putNull( - DocColumns.PHOTO + DocsColumns.PHOTO ) }) entity.graffiti.ifNonNull({ cv.put( - DocColumns.GRAFFITI, + DocsColumns.GRAFFITI, MsgPack.encodeToByteArrayEx(GraffitiDbo.serializer(), it) ) }, { cv.putNull( - DocColumns.GRAFFITI + DocsColumns.GRAFFITI ) }) entity.video.ifNonNull({ cv.put( - DocColumns.VIDEO, + DocsColumns.VIDEO, MsgPack.encodeToByteArrayEx(VideoPreviewDbo.serializer(), it) ) }, { cv.putNull( - DocColumns.VIDEO + DocsColumns.VIDEO ) }) operations.add( @@ -131,7 +131,7 @@ internal class DocsStorage(base: AppStorages) : AbsStorage(base), IDocsStorage { override fun delete(accountId: Long, docId: Int, ownerId: Long): Completable { return Completable.fromAction { val uri = getDocsContentUriFor(accountId) - val where = DocColumns.DOC_ID + " = ? AND " + DocColumns.OWNER_ID + " = ?" + val where = DocsColumns.DOC_ID + " = ? AND " + DocsColumns.OWNER_ID + " = ?" val args = arrayOf(docId.toString(), ownerId.toString()) contentResolver.delete(uri, where, args) } @@ -139,19 +139,19 @@ internal class DocsStorage(base: AppStorages) : AbsStorage(base), IDocsStorage { companion object { internal fun map(cursor: Cursor): DocumentDboEntity { - val id = cursor.getInt(DocColumns.DOC_ID) - val ownerId = cursor.getLong(DocColumns.OWNER_ID) + val id = cursor.getInt(DocsColumns.DOC_ID) + val ownerId = cursor.getLong(DocsColumns.OWNER_ID) val document = DocumentDboEntity().set(id, ownerId) - .setTitle(cursor.getString(DocColumns.TITLE)) - .setSize(cursor.getLong(DocColumns.SIZE)) - .setExt(cursor.getString(DocColumns.EXT)) - .setUrl(cursor.getString(DocColumns.URL)) - .setType(cursor.getInt(DocColumns.TYPE)) - .setDate(cursor.getLong(DocColumns.DATE)) - .setAccessKey(cursor.getString(DocColumns.ACCESS_KEY)) - val photoJson = cursor.getBlob(DocColumns.PHOTO) - val graffitiJson = cursor.getBlob(DocColumns.GRAFFITI) - val videoJson = cursor.getBlob(DocColumns.VIDEO) + .setTitle(cursor.getString(DocsColumns.TITLE)) + .setSize(cursor.getLong(DocsColumns.SIZE)) + .setExt(cursor.getString(DocsColumns.EXT)) + .setUrl(cursor.getString(DocsColumns.URL)) + .setType(cursor.getInt(DocsColumns.TYPE)) + .setDate(cursor.getLong(DocsColumns.DATE)) + .setAccessKey(cursor.getString(DocsColumns.ACCESS_KEY)) + val photoJson = cursor.getBlob(DocsColumns.PHOTO) + val graffitiJson = cursor.getBlob(DocsColumns.GRAFFITI) + val videoJson = cursor.getBlob(DocsColumns.VIDEO) if (photoJson.nonNullNoEmpty()) { document.setPhoto( MsgPack.decodeFromByteArrayEx( diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/FaveStorage.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/FaveStorage.kt index adebc8ee2..b58b849c4 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/FaveStorage.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/FaveStorage.kt @@ -16,10 +16,10 @@ import dev.ragnarok.fenrir.db.FenrirContentProvider.Companion.getFaveUsersConten import dev.ragnarok.fenrir.db.FenrirContentProvider.Companion.getFaveVideosContentUriFor import dev.ragnarok.fenrir.db.column.FaveArticlesColumns import dev.ragnarok.fenrir.db.column.FaveLinksColumns -import dev.ragnarok.fenrir.db.column.FavePageColumns +import dev.ragnarok.fenrir.db.column.FavePagesColumns import dev.ragnarok.fenrir.db.column.FavePhotosColumns import dev.ragnarok.fenrir.db.column.FavePostsColumns -import dev.ragnarok.fenrir.db.column.FaveProductColumns +import dev.ragnarok.fenrir.db.column.FaveProductsColumns import dev.ragnarok.fenrir.db.column.FaveVideosColumns import dev.ragnarok.fenrir.db.interfaces.IFaveStorage import dev.ragnarok.fenrir.db.model.entity.ArticleDboEntity @@ -395,7 +395,7 @@ internal class FaveStorage(mRepositoryContext: AppStorages) : AbsStorage(mReposi } private fun mapProduct(cursor: Cursor): MarketDboEntity { - val json = cursor.getBlob(FaveProductColumns.PRODUCT)!! + val json = cursor.getBlob(FaveProductsColumns.PRODUCT)!! return MsgPack.decodeFromByteArrayEx(MarketDboEntity.serializer(), json) } @@ -503,7 +503,7 @@ internal class FaveStorage(mRepositoryContext: AppStorages) : AbsStorage(mReposi val dbo = products[i] val cv = ContentValues() cv.put( - FaveProductColumns.PRODUCT, + FaveProductsColumns.PRODUCT, MsgPack.encodeToByteArrayEx(MarketDboEntity.serializer(), dbo) ) val index = addToListAndReturnIndex( @@ -607,9 +607,9 @@ internal class FaveStorage(mRepositoryContext: AppStorages) : AbsStorage(mReposi internal fun createFaveCv(dbo: FavePageEntity): ContentValues { val cv = ContentValues() cv.put(BaseColumns._ID, dbo.id) - cv.put(FavePageColumns.DESCRIPTION, dbo.description) - cv.put(FavePageColumns.FAVE_TYPE, dbo.faveType) - cv.put(FavePageColumns.UPDATED_TIME, dbo.updateDate) + cv.put(FavePagesColumns.DESCRIPTION, dbo.description) + cv.put(FavePagesColumns.FAVE_TYPE, dbo.faveType) + cv.put(FavePagesColumns.UPDATED_TIME, dbo.updateDate) return cv } @@ -623,9 +623,9 @@ internal class FaveStorage(mRepositoryContext: AppStorages) : AbsStorage(mReposi internal fun mapFaveUserDbo(cursor: Cursor, accountId: Long): FavePageEntity { return FavePageEntity(cursor.getLong(BaseColumns._ID)) - .setDescription(cursor.getString(FavePageColumns.DESCRIPTION)) - .setUpdateDate(cursor.getLong(FavePageColumns.UPDATED_TIME)) - .setFaveType(cursor.getString(FavePageColumns.FAVE_TYPE)) + .setDescription(cursor.getString(FavePagesColumns.DESCRIPTION)) + .setUpdateDate(cursor.getLong(FavePagesColumns.UPDATED_TIME)) + .setFaveType(cursor.getString(FavePagesColumns.FAVE_TYPE)) .setUser( mapUser( accountId, @@ -636,9 +636,9 @@ internal class FaveStorage(mRepositoryContext: AppStorages) : AbsStorage(mReposi internal fun mapFaveGroupDbo(cursor: Cursor, accountId: Long): FavePageEntity { return FavePageEntity(cursor.getLong(BaseColumns._ID)) - .setDescription(cursor.getString(FavePageColumns.DESCRIPTION)) - .setUpdateDate(cursor.getLong(FavePageColumns.UPDATED_TIME)) - .setFaveType(cursor.getString(FavePageColumns.FAVE_TYPE)) + .setDescription(cursor.getString(FavePagesColumns.DESCRIPTION)) + .setUpdateDate(cursor.getLong(FavePagesColumns.UPDATED_TIME)) + .setFaveType(cursor.getString(FavePagesColumns.FAVE_TYPE)) .setGroup( mapGroup( accountId, diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/FeedbackStorage.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/FeedbackStorage.kt index b5d55870a..6920a6267 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/FeedbackStorage.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/FeedbackStorage.kt @@ -6,7 +6,7 @@ import android.database.Cursor import android.provider.BaseColumns import dev.ragnarok.fenrir.db.FenrirContentProvider import dev.ragnarok.fenrir.db.FenrirContentProvider.Companion.getNotificationsContentUriFor -import dev.ragnarok.fenrir.db.column.NotificationColumns +import dev.ragnarok.fenrir.db.column.NotificationsColumns import dev.ragnarok.fenrir.db.interfaces.IFeedbackStorage import dev.ragnarok.fenrir.db.model.entity.OwnerEntities import dev.ragnarok.fenrir.db.model.entity.feedback.FeedbackEntity @@ -39,9 +39,9 @@ internal class FeedbackStorage(context: AppStorages) : AbsStorage(context), IFee for (i in dbos.indices) { val dbo = dbos[i] val cv = ContentValues() - cv.put(NotificationColumns.DATE, dbo.date) + cv.put(NotificationsColumns.DATE, dbo.date) cv.put( - NotificationColumns.CONTENT_PACK, + NotificationsColumns.CONTENT_PACK, MsgPack.encodeToByteArrayEx(FeedbackEntity.serializer(), dbo) ) val index = addToListAndReturnIndex( @@ -76,7 +76,7 @@ internal class FeedbackStorage(context: AppStorages) : AbsStorage(context), IFee null, where, args, - NotificationColumns.DATE + " DESC" + NotificationsColumns.DATE + " DESC" ) } else { context.contentResolver.query( @@ -84,7 +84,7 @@ internal class FeedbackStorage(context: AppStorages) : AbsStorage(context), IFee null, null, null, - NotificationColumns.DATE + " DESC" + NotificationsColumns.DATE + " DESC" ) } val dtos: MutableList = ArrayList(safeCountOf(cursor)) @@ -103,7 +103,7 @@ internal class FeedbackStorage(context: AppStorages) : AbsStorage(context), IFee } private fun mapDto(cursor: Cursor): FeedbackEntity { - val data = cursor.getBlob(NotificationColumns.CONTENT_PACK)!! + val data = cursor.getBlob(NotificationsColumns.CONTENT_PACK)!! return MsgPack.decodeFromByteArrayEx(FeedbackEntity.serializer(), data) } @@ -127,9 +127,9 @@ internal class FeedbackStorage(context: AppStorages) : AbsStorage(context), IFee for (i in dbos.indices) { val dbo = dbos[i] val cv = ContentValues() - cv.put(NotificationColumns.DATE, dbo.time) + cv.put(NotificationsColumns.DATE, dbo.time) cv.put( - NotificationColumns.CONTENT_PACK, + NotificationsColumns.CONTENT_PACK, MsgPack.encodeToByteArrayEx(FeedbackVKOfficial.serializer(), dbo) ) val index = addToListAndReturnIndex( @@ -163,7 +163,7 @@ internal class FeedbackStorage(context: AppStorages) : AbsStorage(context), IFee null, where, args, - NotificationColumns.DATE + " DESC" + NotificationsColumns.DATE + " DESC" ) } else { context.contentResolver.query( @@ -171,7 +171,7 @@ internal class FeedbackStorage(context: AppStorages) : AbsStorage(context), IFee null, null, null, - NotificationColumns.DATE + " DESC" + NotificationsColumns.DATE + " DESC" ) } val dtos: MutableList = ArrayList(safeCountOf(cursor)) @@ -190,7 +190,7 @@ internal class FeedbackStorage(context: AppStorages) : AbsStorage(context), IFee } private fun mapDtoOfficial(cursor: Cursor): FeedbackVKOfficial { - val data = cursor.getBlob(NotificationColumns.CONTENT_PACK)!! + val data = cursor.getBlob(NotificationsColumns.CONTENT_PACK)!! return MsgPack.decodeFromByteArrayEx(FeedbackVKOfficial.serializer(), data) } } \ No newline at end of file diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/KeysPersistStorage.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/KeysPersistStorage.kt index 82f98bf4e..722c95f53 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/KeysPersistStorage.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/KeysPersistStorage.kt @@ -5,7 +5,7 @@ import android.database.Cursor import android.provider.BaseColumns import dev.ragnarok.fenrir.crypt.AesKeyPair import dev.ragnarok.fenrir.db.FenrirContentProvider.Companion.getKeysContentUriFor -import dev.ragnarok.fenrir.db.column.KeyColumns +import dev.ragnarok.fenrir.db.column.EncryptionKeysForMessagesColumns import dev.ragnarok.fenrir.db.interfaces.IKeysStorage import dev.ragnarok.fenrir.exception.DatabaseException import dev.ragnarok.fenrir.getInt @@ -24,14 +24,14 @@ import io.reactivex.rxjava3.core.SingleEmitter internal class KeysPersistStorage(context: AppStorages) : AbsStorage(context), IKeysStorage { private fun map(cursor: Cursor): AesKeyPair { return AesKeyPair() - .setVersion(cursor.getInt(KeyColumns.VERSION)) - .setPeerId(cursor.getLong(KeyColumns.PEER_ID)) - .setSessionId(cursor.getLong(KeyColumns.SESSION_ID)) - .setDate(cursor.getLong(KeyColumns.DATE)) - .setStartMessageId(cursor.getInt(KeyColumns.START_SESSION_MESSAGE_ID)) - .setEndMessageId(cursor.getInt(KeyColumns.END_SESSION_MESSAGE_ID)) - .setHisAesKey(cursor.getString(KeyColumns.IN_KEY)) - .setMyAesKey(cursor.getString(KeyColumns.OUT_KEY)) + .setVersion(cursor.getInt(EncryptionKeysForMessagesColumns.VERSION)) + .setPeerId(cursor.getLong(EncryptionKeysForMessagesColumns.PEER_ID)) + .setSessionId(cursor.getLong(EncryptionKeysForMessagesColumns.SESSION_ID)) + .setDate(cursor.getLong(EncryptionKeysForMessagesColumns.DATE)) + .setStartMessageId(cursor.getInt(EncryptionKeysForMessagesColumns.START_SESSION_MESSAGE_ID)) + .setEndMessageId(cursor.getInt(EncryptionKeysForMessagesColumns.END_SESSION_MESSAGE_ID)) + .setHisAesKey(cursor.getString(EncryptionKeysForMessagesColumns.IN_KEY)) + .setMyAesKey(cursor.getString(EncryptionKeysForMessagesColumns.OUT_KEY)) } override fun saveKeyPair(pair: AesKeyPair): Completable { @@ -43,14 +43,14 @@ internal class KeysPersistStorage(context: AppStorages) : AbsStorage(context), I return@create } val cv = ContentValues() - cv.put(KeyColumns.VERSION, pair.version) - cv.put(KeyColumns.PEER_ID, pair.peerId) - cv.put(KeyColumns.SESSION_ID, pair.sessionId) - cv.put(KeyColumns.DATE, pair.date) - cv.put(KeyColumns.START_SESSION_MESSAGE_ID, pair.startMessageId) - cv.put(KeyColumns.END_SESSION_MESSAGE_ID, pair.endMessageId) - cv.put(KeyColumns.OUT_KEY, pair.myAesKey) - cv.put(KeyColumns.IN_KEY, pair.hisAesKey) + cv.put(EncryptionKeysForMessagesColumns.VERSION, pair.version) + cv.put(EncryptionKeysForMessagesColumns.PEER_ID, pair.peerId) + cv.put(EncryptionKeysForMessagesColumns.SESSION_ID, pair.sessionId) + cv.put(EncryptionKeysForMessagesColumns.DATE, pair.date) + cv.put(EncryptionKeysForMessagesColumns.START_SESSION_MESSAGE_ID, pair.startMessageId) + cv.put(EncryptionKeysForMessagesColumns.END_SESSION_MESSAGE_ID, pair.endMessageId) + cv.put(EncryptionKeysForMessagesColumns.OUT_KEY, pair.myAesKey) + cv.put(EncryptionKeysForMessagesColumns.IN_KEY, pair.hisAesKey) val uri = getKeysContentUriFor(pair.accountId) context.contentResolver.insert(uri, cv) e.onComplete() @@ -82,7 +82,7 @@ internal class KeysPersistStorage(context: AppStorages) : AbsStorage(context), I .query( uri, null, - KeyColumns.PEER_ID + " = ?", + EncryptionKeysForMessagesColumns.PEER_ID + " = ?", arrayOf(peerId.toString()), BaseColumns._ID ) @@ -107,7 +107,7 @@ internal class KeysPersistStorage(context: AppStorages) : AbsStorage(context), I .query( uri, null, - KeyColumns.PEER_ID + " = ?", + EncryptionKeysForMessagesColumns.PEER_ID + " = ?", arrayOf(peerId.toString()), BaseColumns._ID + " DESC LIMIT 1" ) @@ -129,7 +129,7 @@ internal class KeysPersistStorage(context: AppStorages) : AbsStorage(context), I .query( uri, null, - KeyColumns.SESSION_ID + " = ?", + EncryptionKeysForMessagesColumns.SESSION_ID + " = ?", arrayOf(sessionId.toString()), null ) diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/MessagesStorage.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/MessagesStorage.kt index ebfb5d9cd..9dc04784f 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/MessagesStorage.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/MessagesStorage.kt @@ -7,7 +7,7 @@ import dev.ragnarok.fenrir.db.AttachToType import dev.ragnarok.fenrir.db.FenrirContentProvider import dev.ragnarok.fenrir.db.FenrirContentProvider.Companion.getMessageContentUriFor import dev.ragnarok.fenrir.db.RecordNotFoundException -import dev.ragnarok.fenrir.db.column.MessageColumns +import dev.ragnarok.fenrir.db.column.MessagesColumns import dev.ragnarok.fenrir.db.impl.AttachmentsStorage.Companion.appendAttachOperationWithBackReference import dev.ragnarok.fenrir.db.impl.AttachmentsStorage.Companion.appendAttachOperationWithStableAttachToId import dev.ragnarok.fenrir.db.interfaces.Cancelable @@ -58,10 +58,10 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS if (clearHistory) { val uri = getMessageContentUriFor(accountId) val where = - MessageColumns.PEER_ID + " = ? AND " + MessageColumns.ATTACH_TO + " = ? AND " + MessageColumns.STATUS + " = ?" + MessagesColumns.PEER_ID + " = ? AND " + MessagesColumns.ATTACH_TO + " = ? AND " + MessagesColumns.STATUS + " = ?" val args = arrayOf( peerId.toString(), - MessageColumns.DONT_ATTACH.toString(), + MessagesColumns.DONT_ATTACH.toString(), MessageStatus.SENT.toString() ) operations.add( @@ -103,14 +103,14 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS ): Single> { return Single.create { emitter: SingleEmitter> -> val uri = getMessageContentUriFor(accountId) - val projection = arrayOf(MessageColumns._ID) - val where = MessageColumns.PEER_ID + " = ?" + - " AND " + MessageColumns.STATUS + " = ?" + - " AND " + MessageColumns.ATTACH_TO + " = ?" + - " AND " + MessageColumns.DELETED + " = ?" + val projection = arrayOf(MessagesColumns._ID) + val where = MessagesColumns.PEER_ID + " = ?" + + " AND " + MessagesColumns.STATUS + " = ?" + + " AND " + MessagesColumns.ATTACH_TO + " = ?" + + " AND " + MessagesColumns.DELETED + " = ?" val args = arrayOf( peerId.toString(), MessageStatus.SENT.toString(), - MessageColumns.DONT_ATTACH.toString(), + MessagesColumns.DONT_ATTACH.toString(), "0" ) val cursor = contentResolver.query( @@ -118,12 +118,12 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS projection, where, args, - MessageColumns.FULL_ID + " DESC LIMIT 1" + MessagesColumns.FULL_ID + " DESC LIMIT 1" ) var id: Int? = null if (cursor != null) { if (cursor.moveToNext()) { - id = cursor.getInt(MessageColumns._ID) + id = cursor.getInt(MessagesColumns._ID) } cursor.close() } @@ -135,18 +135,18 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS val where: String val args: Array if (criteria.startMessageId == null) { - where = MessageColumns.PEER_ID + " = ?" + - " AND " + MessageColumns.ATTACH_TO + " = ?" + - " AND " + MessageColumns.STATUS + " != ?" + where = MessagesColumns.PEER_ID + " = ?" + + " AND " + MessagesColumns.ATTACH_TO + " = ?" + + " AND " + MessagesColumns.STATUS + " != ?" args = arrayOf( criteria.peerId.toString(), "0", MessageStatus.EDITING.toString() ) } else { - where = MessageColumns.PEER_ID + " = ?" + - " AND " + MessageColumns.ATTACH_TO + " = ? " + - " AND " + MessageColumns.FULL_ID + " < ? " + - " AND " + MessageColumns.STATUS + " != ?" + where = MessagesColumns.PEER_ID + " = ?" + + " AND " + MessagesColumns.ATTACH_TO + " = ? " + + " AND " + MessagesColumns.FULL_ID + " < ? " + + " AND " + MessagesColumns.STATUS + " != ?" args = arrayOf( criteria.peerId.toString(), "0", criteria.startMessageId.toString(), MessageStatus.EDITING.toString() @@ -195,23 +195,23 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS return Single.create { emitter: SingleEmitter -> val operations = ArrayList() val cv = ContentValues() - cv.put(MessageColumns.PEER_ID, peerId) - cv.put(MessageColumns.FROM_ID, patch.senderId) - cv.put(MessageColumns.DATE, patch.date) + cv.put(MessagesColumns.PEER_ID, peerId) + cv.put(MessagesColumns.FROM_ID, patch.senderId) + cv.put(MessagesColumns.DATE, patch.date) //cv.put(MessageColumns.READ_STATE, patch.isRead()); - cv.put(MessageColumns.OUT, patch.isOut) + cv.put(MessagesColumns.OUT, patch.isOut) //cv.put(MessageColumns.TITLE, patch.getTitle()); - cv.put(MessageColumns.BODY, patch.body) - cv.put(MessageColumns.ENCRYPTED, patch.isEncrypted) - cv.put(MessageColumns.IMPORTANT, patch.isImportant) - cv.put(MessageColumns.DELETED, patch.isDeleted) - cv.put(MessageColumns.FORWARD_COUNT, safeCountOf(patch.forward)) - cv.put(MessageColumns.HAS_ATTACHMENTS, patch.attachments.nonNullNoEmpty()) - cv.put(MessageColumns.STATUS, patch.status) - cv.put(MessageColumns.ATTACH_TO, MessageColumns.DONT_ATTACH) + cv.put(MessagesColumns.BODY, patch.body) + cv.put(MessagesColumns.ENCRYPTED, patch.isEncrypted) + cv.put(MessagesColumns.IMPORTANT, patch.isImportant) + cv.put(MessagesColumns.DELETED, patch.isDeleted) + cv.put(MessagesColumns.FORWARD_COUNT, safeCountOf(patch.forward)) + cv.put(MessagesColumns.HAS_ATTACHMENTS, patch.attachments.nonNullNoEmpty()) + cv.put(MessagesColumns.STATUS, patch.status) + cv.put(MessagesColumns.ATTACH_TO, MessagesColumns.DONT_ATTACH) patch.extras.ifNonNull({ cv.put( - MessageColumns.EXTRAS, + MessagesColumns.EXTRAS, MsgPack.encodeToByteArrayEx( MapSerializer(Int.serializer(), String.serializer()), it @@ -219,19 +219,19 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS ) }, { cv.putNull( - MessageColumns.EXTRAS + MessagesColumns.EXTRAS ) }) - cv.put(MessageColumns.PAYLOAD, patch.payload) + cv.put(MessagesColumns.PAYLOAD, patch.payload) patch.keyboard.ifNonNull({ cv.put( - MessageColumns.KEYBOARD, + MessagesColumns.KEYBOARD, MsgPack.encodeToByteArrayEx(KeyboardEntity.serializer(), it) ) }, { cv.putNull( - MessageColumns.KEYBOARD + MessagesColumns.KEYBOARD ) }) @@ -274,26 +274,26 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS val uri = getMessageContentUriFor(accountId) val operations = ArrayList() val cv = ContentValues() - cv.put(MessageColumns.FROM_ID, patch.senderId) - cv.put(MessageColumns.DATE, patch.date) + cv.put(MessagesColumns.FROM_ID, patch.senderId) + cv.put(MessagesColumns.DATE, patch.date) //cv.put(MessageColumns.READ_STATE, patch.isRead()); - cv.put(MessageColumns.OUT, patch.isOut) + cv.put(MessagesColumns.OUT, patch.isOut) //cv.put(MessageColumns.TITLE, patch.getTitle()); - cv.put(MessageColumns.BODY, patch.body) - cv.put(MessageColumns.ENCRYPTED, patch.isEncrypted) - cv.put(MessageColumns.IMPORTANT, patch.isImportant) - cv.put(MessageColumns.DELETED, patch.isDeleted) - cv.put(MessageColumns.FORWARD_COUNT, safeCountOf(patch.forward)) + cv.put(MessagesColumns.BODY, patch.body) + cv.put(MessagesColumns.ENCRYPTED, patch.isEncrypted) + cv.put(MessagesColumns.IMPORTANT, patch.isImportant) + cv.put(MessagesColumns.DELETED, patch.isDeleted) + cv.put(MessagesColumns.FORWARD_COUNT, safeCountOf(patch.forward)) cv.put( - MessageColumns.HAS_ATTACHMENTS, + MessagesColumns.HAS_ATTACHMENTS, count + safeCountOf(patch.attachments) > 0 ) - cv.put(MessageColumns.STATUS, patch.status) - cv.put(MessageColumns.ATTACH_TO, MessageColumns.DONT_ATTACH) + cv.put(MessagesColumns.STATUS, patch.status) + cv.put(MessagesColumns.ATTACH_TO, MessagesColumns.DONT_ATTACH) patch.extras.ifNonNull({ cv.put( - MessageColumns.EXTRAS, + MessagesColumns.EXTRAS, MsgPack.encodeToByteArrayEx( MapSerializer( Int.serializer(), @@ -303,22 +303,22 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS ) }, { cv.putNull( - MessageColumns.EXTRAS + MessagesColumns.EXTRAS ) }) - cv.put(MessageColumns.PAYLOAD, patch.payload) + cv.put(MessagesColumns.PAYLOAD, patch.payload) patch.keyboard.ifNonNull({ cv.put( - MessageColumns.KEYBOARD, + MessagesColumns.KEYBOARD, MsgPack.encodeToByteArrayEx(KeyboardEntity.serializer(), it) ) }, { cv.putNull( - MessageColumns.KEYBOARD + MessagesColumns.KEYBOARD ) }) - val where = MessageColumns._ID + " = ?" + val where = MessagesColumns._ID + " = ?" val args = arrayOf(messageId.toString()) operations.add( ContentProviderOperation.newUpdate(uri).withValues(cv) @@ -373,12 +373,12 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS override fun findDraftMessage(accountId: Long, peerId: Long): Maybe { return Maybe.create { e: MaybeEmitter -> - val columns = arrayOf(MessageColumns._ID, MessageColumns.BODY) + val columns = arrayOf(MessagesColumns._ID, MessagesColumns.BODY) val uri = getMessageContentUriFor(accountId) val cursor = context.contentResolver.query( uri, columns, - MessageColumns.PEER_ID + " = ? AND " + MessageColumns.STATUS + " = ?", + MessagesColumns.PEER_ID + " = ? AND " + MessagesColumns.STATUS + " = ?", arrayOf(peerId.toString(), MessageStatus.EDITING.toString()), null ) @@ -386,8 +386,8 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS var message: DraftMessage? = null if (cursor != null) { if (cursor.moveToNext()) { - val id = cursor.getInt(MessageColumns._ID) - val body = cursor.getString(MessageColumns.BODY) + val id = cursor.getInt(MessagesColumns._ID) + val body = cursor.getString(MessagesColumns.BODY) message = DraftMessage(id, body) } cursor.close() @@ -408,9 +408,9 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS val start = System.currentTimeMillis() val uri = getMessageContentUriFor(accountId) val cv = ContentValues() - cv.put(MessageColumns.BODY, body) - cv.put(MessageColumns.PEER_ID, peerId) - cv.put(MessageColumns.STATUS, MessageStatus.EDITING) + cv.put(MessagesColumns.BODY, body) + cv.put(MessagesColumns.PEER_ID, peerId) + cv.put(MessagesColumns.STATUS, MessageStatus.EDITING) val cr = contentResolver var existDraftMessageId = findDraftMessageId(accountId, peerId) //.blockingGet(); @@ -418,7 +418,7 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS cr.update( uri, cv, - MessageColumns._ID + " = ?", + MessagesColumns._ID + " = ?", arrayOf(existDraftMessageId.toString()) ) } else { @@ -437,18 +437,18 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS for (patch in patches) { val cv = ContentValues() if (patch.deletion != null) { - cv.put(MessageColumns.DELETED, patch.deletion?.deleted == true) - cv.put(MessageColumns.DELETED_FOR_ALL, patch.deletion?.deletedForAll == true) + cv.put(MessagesColumns.DELETED, patch.deletion?.deleted == true) + cv.put(MessagesColumns.DELETED_FOR_ALL, patch.deletion?.deletedForAll == true) } if (patch.important != null) { - cv.put(MessageColumns.IMPORTANT, patch.important?.important == true) + cv.put(MessagesColumns.IMPORTANT, patch.important?.important == true) } if (cv.size() == 0) continue operations.add( ContentProviderOperation.newUpdate(uri) .withValues(cv) .withSelection( - MessageColumns._ID + " = ?", + MessagesColumns._ID + " = ?", arrayOf(patch.messageId.toString()) ) .build() @@ -463,15 +463,15 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS return Single.fromCallable { val cursor = contentResolver.query( getMessageContentUriFor(accountId), - arrayOf(MessageColumns.STATUS), - MessageColumns.FULL_ID + " = ?", + arrayOf(MessagesColumns.STATUS), + MessagesColumns.FULL_ID + " = ?", arrayOf(dbid.toString()), null ) var result: Int? = null if (cursor != null) { if (cursor.moveToNext()) { - result = cursor.getInt(MessageColumns.STATUS) + result = cursor.getInt(MessagesColumns.STATUS) } cursor.close() } @@ -483,19 +483,19 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS } private fun findDraftMessageId(accountId: Long, peerId: Long): Int? { - val columns = arrayOf(MessageColumns._ID) + val columns = arrayOf(MessagesColumns._ID) val uri = getMessageContentUriFor(accountId) val cursor = context.contentResolver.query( uri, columns, - MessageColumns.PEER_ID + " = ? AND " + MessageColumns.STATUS + " = ?", + MessagesColumns.PEER_ID + " = ? AND " + MessagesColumns.STATUS + " = ?", arrayOf(peerId.toString(), MessageStatus.EDITING.toString()), null ) var id: Int? = null if (cursor != null) { if (cursor.moveToNext()) { - id = cursor.getInt(MessageColumns._ID) + id = cursor.getInt(MessagesColumns._ID) } cursor.close() } @@ -510,14 +510,14 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS ): Completable { return Completable.create { e: CompletableEmitter -> val contentValues = ContentValues() - contentValues.put(MessageColumns.STATUS, status) + contentValues.put(MessagesColumns.STATUS, status) if (vkid != null) { - contentValues.put(MessageColumns._ID, vkid) + contentValues.put(MessagesColumns._ID, vkid) } val uri = getMessageContentUriFor(accountId) val count = context.contentResolver.update( uri, contentValues, - MessageColumns._ID + " = ?", arrayOf(messageId.toString()) + MessagesColumns._ID + " = ?", arrayOf(messageId.toString()) ) if (count > 0) { e.onComplete() @@ -533,7 +533,7 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS val uri = getMessageContentUriFor(accountId) val count = context.contentResolver.delete( uri, - MessageColumns._ID + " = ?", + MessagesColumns._ID + " = ?", arrayOf(messageId.toString()) ) e.onSuccess(count > 0) @@ -544,7 +544,7 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS return Single.create { e: SingleEmitter -> val copy: Set = HashSet(ids) val uri = getMessageContentUriFor(accountId) - val where = MessageColumns.FULL_ID + " IN(" + join(",", copy) + ")" + val where = MessagesColumns.FULL_ID + " IN(" + join(",", copy) + ")" val count = context.contentResolver.delete(uri, where, null) e.onSuccess(count > 0) } @@ -558,9 +558,9 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS return Completable.create { e: CompletableEmitter -> val copy: Set = HashSet(ids) val contentValues = ContentValues() - contentValues.put(MessageColumns.STATUS, status) + contentValues.put(MessagesColumns.STATUS, status) val uri = getMessageContentUriFor(accountId) - val where = MessageColumns.FULL_ID + " IN(" + join(",", copy) + ")" + val where = MessagesColumns.FULL_ID + " IN(" + join(",", copy) + ")" val count = context.contentResolver.update( uri, contentValues, where, null @@ -577,12 +577,12 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS return Single.create { e: SingleEmitter> -> val copy: MutableSet = HashSet(ids) val uri = getMessageContentUriFor(accountId) - val projection = arrayOf(MessageColumns._ID) - val where = MessageColumns.FULL_ID + " IN(" + join(",", copy) + ")" + val projection = arrayOf(MessagesColumns._ID) + val where = MessagesColumns.FULL_ID + " IN(" + join(",", copy) + ")" val cursor = contentResolver.query(uri, projection, where, null, null) if (cursor != null) { while (cursor.moveToNext()) { - val id = cursor.getInt(MessageColumns._ID) + val id = cursor.getInt(MessagesColumns._ID) copy.remove(id) } cursor.close() @@ -598,9 +598,10 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS cancelable: Cancelable ): List { val uri = getMessageContentUriFor(accountId) - val where = MessageColumns.ATTACH_TO + " = ?" + val where = MessagesColumns.ATTACH_TO + " = ?" val args = arrayOf(attachTo.toString()) - val cursor = contentResolver.query(uri, null, where, args, MessageColumns.FULL_ID + " DESC") + val cursor = + contentResolver.query(uri, null, where, args, MessagesColumns.FULL_ID + " DESC") val dbos: MutableList = ArrayList(safeCountOf(cursor)) if (cursor != null) { while (cursor.moveToNext()) { @@ -630,10 +631,10 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS val where: String val args: Array? if (ids.size == 1) { - where = MessageColumns._ID + " = ?" + where = MessagesColumns._ID + " = ?" args = arrayOf(ids[0].toString()) } else { - where = MessageColumns.FULL_ID + " IN (" + join(",", ids) + ")" + where = MessagesColumns.FULL_ID + " IN (" + join(",", ids) + ")" args = null } val cursor = context.contentResolver.query(uri, null, where, args, null) @@ -669,9 +670,9 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS withForwardMessages: Boolean ): Single>> { return Single.create { emitter: SingleEmitter>> -> - val where = MessageColumns.STATUS + " = ?" + val where = MessagesColumns.STATUS + " = ?" val args = arrayOf(MessageStatus.QUEUE.toString()) - val orderBy = MessageColumns._ID + " ASC LIMIT 1" + val orderBy = MessagesColumns._ID + " ASC LIMIT 1" for (accountId in accountIds) { if (emitter.isDisposed) { break @@ -705,9 +706,9 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS override fun notifyMessageHasAttachments(accountId: Long, messageId: Int): Completable { return Completable.fromAction { val cv = ContentValues() - cv.put(MessageColumns.HAS_ATTACHMENTS, true) + cv.put(MessagesColumns.HAS_ATTACHMENTS, true) val uri = getMessageContentUriFor(accountId) - val where = MessageColumns._ID + " = ?" + val where = MessagesColumns._ID + " = ?" val args = arrayOf(messageId.toString()) contentResolver.update(uri, cv, where, args) } @@ -722,10 +723,10 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS val uri = getMessageContentUriFor(accountId) val cursor = context.contentResolver.query( uri, - arrayOf(MessageColumns.ORIGINAL_ID, MessageColumns.PEER_ID), - MessageColumns.ATTACH_TO + " = ?", + arrayOf(MessagesColumns.ORIGINAL_ID, MessagesColumns.PEER_ID), + MessagesColumns.ATTACH_TO + " = ?", arrayOf(attachTo.toString()), - MessageColumns.FULL_ID + " DESC" + MessagesColumns.FULL_ID + " DESC" ) val ids = ArrayList(safeCountOf(cursor)) var from_peer: Long? = null @@ -738,9 +739,9 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS if (isFirst) { isFirst = false from_peer = - cursor.getLong(MessageColumns.PEER_ID) + cursor.getLong(MessagesColumns.PEER_ID) } - ids.add(cursor.getInt(MessageColumns.ORIGINAL_ID)) + ids.add(cursor.getInt(MessagesColumns.ORIGINAL_ID)) } cursor.close() } @@ -749,7 +750,7 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS } companion object { - private const val ORDER_BY = MessageColumns.FULL_STATUS + ", " + MessageColumns.FULL_ID + private const val ORDER_BY = MessagesColumns.FULL_STATUS + ", " + MessagesColumns.FULL_ID fun appendDboOperation( accountId: Long, dbo: MessageDboEntity, @@ -760,37 +761,37 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS val cv = ContentValues() if (attachToId != null) { // если есть ID сообщения, к которому прикреплено dbo - cv.put(MessageColumns.ATTACH_TO, attachToId) + cv.put(MessagesColumns.ATTACH_TO, attachToId) } else if (attachToIndex == null) { // если сообщение не прикреплено к другому - cv.put(MessageColumns._ID, dbo.id) - cv.put(MessageColumns.ATTACH_TO, MessageColumns.DONT_ATTACH) + cv.put(MessagesColumns._ID, dbo.id) + cv.put(MessagesColumns.ATTACH_TO, MessagesColumns.DONT_ATTACH) } - cv.put(MessageColumns.PEER_ID, dbo.peerId) - cv.put(MessageColumns.FROM_ID, dbo.fromId) - cv.put(MessageColumns.DATE, dbo.date) + cv.put(MessagesColumns.PEER_ID, dbo.peerId) + cv.put(MessagesColumns.FROM_ID, dbo.fromId) + cv.put(MessagesColumns.DATE, dbo.date) //cv.put(MessageColumns.READ_STATE, dbo.isRead()); - cv.put(MessageColumns.OUT, dbo.isOut) + cv.put(MessagesColumns.OUT, dbo.isOut) //cv.put(MessageColumns.TITLE, dbo.getTitle()); - cv.put(MessageColumns.BODY, dbo.body) - cv.put(MessageColumns.ENCRYPTED, dbo.isEncrypted) - cv.put(MessageColumns.IMPORTANT, dbo.isImportant) - cv.put(MessageColumns.DELETED, dbo.isDeleted) - cv.put(MessageColumns.FORWARD_COUNT, dbo.forwardCount) - cv.put(MessageColumns.HAS_ATTACHMENTS, dbo.isHasAttachments) - cv.put(MessageColumns.STATUS, dbo.status) - cv.put(MessageColumns.ORIGINAL_ID, dbo.originalId) - cv.put(MessageColumns.ACTION, dbo.action) - cv.put(MessageColumns.ACTION_MID, dbo.actionMemberId) - cv.put(MessageColumns.ACTION_EMAIL, dbo.actionEmail) - cv.put(MessageColumns.ACTION_TEXT, dbo.actionText) - cv.put(MessageColumns.PHOTO_50, dbo.photo50) - cv.put(MessageColumns.PHOTO_100, dbo.photo100) - cv.put(MessageColumns.PHOTO_200, dbo.photo200) - cv.put(MessageColumns.RANDOM_ID, dbo.randomId) + cv.put(MessagesColumns.BODY, dbo.body) + cv.put(MessagesColumns.ENCRYPTED, dbo.isEncrypted) + cv.put(MessagesColumns.IMPORTANT, dbo.isImportant) + cv.put(MessagesColumns.DELETED, dbo.isDeleted) + cv.put(MessagesColumns.FORWARD_COUNT, dbo.forwardCount) + cv.put(MessagesColumns.HAS_ATTACHMENTS, dbo.isHasAttachments) + cv.put(MessagesColumns.STATUS, dbo.status) + cv.put(MessagesColumns.ORIGINAL_ID, dbo.originalId) + cv.put(MessagesColumns.ACTION, dbo.action) + cv.put(MessagesColumns.ACTION_MID, dbo.actionMemberId) + cv.put(MessagesColumns.ACTION_EMAIL, dbo.actionEmail) + cv.put(MessagesColumns.ACTION_TEXT, dbo.actionText) + cv.put(MessagesColumns.PHOTO_50, dbo.photo50) + cv.put(MessagesColumns.PHOTO_100, dbo.photo100) + cv.put(MessagesColumns.PHOTO_200, dbo.photo200) + cv.put(MessagesColumns.RANDOM_ID, dbo.randomId) dbo.extras.ifNonNull({ cv.put( - MessageColumns.EXTRAS, + MessagesColumns.EXTRAS, MsgPack.encodeToByteArrayEx( MapSerializer(Int.serializer(), String.serializer()), it @@ -798,29 +799,29 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS ) }, { cv.putNull( - MessageColumns.EXTRAS + MessagesColumns.EXTRAS ) }) dbo.keyboard.ifNonNull({ cv.put( - MessageColumns.KEYBOARD, + MessagesColumns.KEYBOARD, MsgPack.encodeToByteArrayEx(KeyboardEntity.serializer(), it) ) }, { cv.putNull( - MessageColumns.KEYBOARD + MessagesColumns.KEYBOARD ) }) - cv.put(MessageColumns.UPDATE_TIME, dbo.updateTime) - cv.put(MessageColumns.PAYLOAD, dbo.payload) + cv.put(MessagesColumns.UPDATE_TIME, dbo.updateTime) + cv.put(MessagesColumns.PAYLOAD, dbo.payload) val uri = getMessageContentUriFor(accountId) val builder = ContentProviderOperation.newInsert(uri) .withValues(cv) // если сообщение прикреплено к другому, но его ID на данный момент неизвестен if (attachToId == null && attachToIndex != null) { - builder.withValueBackReference(MessageColumns.ATTACH_TO, attachToIndex) + builder.withValueBackReference(MessagesColumns.ATTACH_TO, attachToIndex) } val index = addToListAndReturnIndex(target, builder.build()) if (dbo.isHasAttachments) { @@ -848,15 +849,15 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS internal fun baseMapDbo(cursor: Cursor): MessageDboEntity { @MessageStatus val status = - cursor.getInt(MessageColumns.STATUS) + cursor.getInt(MessagesColumns.STATUS) @ChatAction val action = - cursor.getInt(MessageColumns.ACTION) - val id = cursor.getInt(MessageColumns._ID) - val peerId = cursor.getLong(MessageColumns.PEER_ID) - val fromId = cursor.getLong(MessageColumns.FROM_ID) + cursor.getInt(MessagesColumns.ACTION) + val id = cursor.getInt(MessagesColumns._ID) + val peerId = cursor.getLong(MessagesColumns.PEER_ID) + val fromId = cursor.getLong(MessagesColumns.FROM_ID) var extras: Map? = null var keyboard: KeyboardEntity? = null - val extrasText = cursor.getBlob(MessageColumns.EXTRAS) + val extrasText = cursor.getBlob(MessagesColumns.EXTRAS) if (extrasText.nonNullNoEmpty()) { extras = MsgPack.decodeFromByteArrayEx( MapSerializer( @@ -866,35 +867,35 @@ internal class MessagesStorage(base: AppStorages) : AbsStorage(base), IMessagesS ) } val keyboardText = - cursor.getBlob(MessageColumns.KEYBOARD) + cursor.getBlob(MessagesColumns.KEYBOARD) if (keyboardText.nonNullNoEmpty()) { keyboard = MsgPack.decodeFromByteArrayEx(KeyboardEntity.serializer(), keyboardText) } return MessageDboEntity().set(id, peerId, fromId) - .setEncrypted(cursor.getBoolean(MessageColumns.ENCRYPTED)) + .setEncrypted(cursor.getBoolean(MessagesColumns.ENCRYPTED)) .setStatus(status) .setAction(action) .setExtras(extras) - .setBody(cursor.getString(MessageColumns.BODY)) //.setRead(cursor.getBoolean(MessageColumns.READ_STATE)) - .setOut(cursor.getBoolean(MessageColumns.OUT)) + .setBody(cursor.getString(MessagesColumns.BODY)) //.setRead(cursor.getBoolean(MessageColumns.READ_STATE)) + .setOut(cursor.getBoolean(MessagesColumns.OUT)) .setStatus(status) - .setDate(cursor.getLong(MessageColumns.DATE)) - .setHasAttachments(cursor.getBoolean(MessageColumns.HAS_ATTACHMENTS)) - .setForwardCount(cursor.getInt(MessageColumns.FORWARD_COUNT)) - .setDeleted(cursor.getBoolean(MessageColumns.DELETED)) - .setDeletedForAll(cursor.getBoolean(MessageColumns.DELETED_FOR_ALL)) //.setTitle(cursor.getString(MessageColumns.TITLE)) - .setOriginalId(cursor.getInt(MessageColumns.ORIGINAL_ID)) - .setImportant(cursor.getBoolean(MessageColumns.IMPORTANT)) + .setDate(cursor.getLong(MessagesColumns.DATE)) + .setHasAttachments(cursor.getBoolean(MessagesColumns.HAS_ATTACHMENTS)) + .setForwardCount(cursor.getInt(MessagesColumns.FORWARD_COUNT)) + .setDeleted(cursor.getBoolean(MessagesColumns.DELETED)) + .setDeletedForAll(cursor.getBoolean(MessagesColumns.DELETED_FOR_ALL)) //.setTitle(cursor.getString(MessageColumns.TITLE)) + .setOriginalId(cursor.getInt(MessagesColumns.ORIGINAL_ID)) + .setImportant(cursor.getBoolean(MessagesColumns.IMPORTANT)) .setAction(action) - .setActionMemberId(cursor.getLong(MessageColumns.ACTION_MID)) - .setActionEmail(cursor.getString(MessageColumns.ACTION_EMAIL)) - .setActionText(cursor.getString(MessageColumns.ACTION_TEXT)) - .setPhoto50(cursor.getString(MessageColumns.PHOTO_50)) - .setPhoto100(cursor.getString(MessageColumns.PHOTO_100)) - .setPhoto200(cursor.getString(MessageColumns.PHOTO_200)) - .setRandomId(cursor.getLong(MessageColumns.RANDOM_ID)) - .setUpdateTime(cursor.getLong(MessageColumns.UPDATE_TIME)) - .setPayload(cursor.getString(MessageColumns.PAYLOAD)) + .setActionMemberId(cursor.getLong(MessagesColumns.ACTION_MID)) + .setActionEmail(cursor.getString(MessagesColumns.ACTION_EMAIL)) + .setActionText(cursor.getString(MessagesColumns.ACTION_TEXT)) + .setPhoto50(cursor.getString(MessagesColumns.PHOTO_50)) + .setPhoto100(cursor.getString(MessagesColumns.PHOTO_100)) + .setPhoto200(cursor.getString(MessagesColumns.PHOTO_200)) + .setRandomId(cursor.getLong(MessagesColumns.RANDOM_ID)) + .setUpdateTime(cursor.getLong(MessagesColumns.UPDATE_TIME)) + .setPayload(cursor.getString(MessagesColumns.PAYLOAD)) .setKeyboard(keyboard) } } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/OwnersStorage.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/OwnersStorage.kt index 61a022e87..d95204f47 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/OwnersStorage.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/OwnersStorage.kt @@ -64,7 +64,7 @@ internal class OwnersStorage(context: AppStorages) : AbsStorage(context), IOwner var details: UserDetailsEntity? = null if (cursor != null) { if (cursor.moveToNext()) { - val json = cursor.getBlob(UsersDetColumns.DATA) + val json = cursor.getBlob(UsersDetailsColumns.DATA) if (json.nonNullNoEmpty()) { details = MsgPack.decodeFromByteArrayEx(UserDetailsEntity.serializer(), json) @@ -88,7 +88,7 @@ internal class OwnersStorage(context: AppStorages) : AbsStorage(context), IOwner var details: CommunityDetailsEntity? = null if (cursor != null) { if (cursor.moveToNext()) { - val json = cursor.getBlob(GroupsDetColumns.DATA) + val json = cursor.getBlob(GroupsDetailsColumns.DATA) if (json.nonNullNoEmpty()) { details = MsgPack.decodeFromByteArrayEx(CommunityDetailsEntity.serializer(), json) @@ -109,7 +109,7 @@ internal class OwnersStorage(context: AppStorages) : AbsStorage(context), IOwner val cv = ContentValues() cv.put(BaseColumns._ID, groupId) cv.put( - GroupsDetColumns.DATA, + GroupsDetailsColumns.DATA, MsgPack.encodeToByteArrayEx(CommunityDetailsEntity.serializer(), dbo) ) val uri = getGroupsDetContentUriFor(accountId) @@ -126,7 +126,7 @@ internal class OwnersStorage(context: AppStorages) : AbsStorage(context), IOwner val cv = ContentValues() cv.put(BaseColumns._ID, userId) cv.put( - UsersDetColumns.DATA, + UsersDetailsColumns.DATA, MsgPack.encodeToByteArrayEx(UserDetailsEntity.serializer(), dbo) ) val uri = getUserDetContentUriFor(accountId) @@ -143,12 +143,12 @@ internal class OwnersStorage(context: AppStorages) : AbsStorage(context), IOwner for (patch in patches) { val cv = ContentValues() patch.status.requireNonNull { - cv.put(UserColumns.USER_STATUS, it.status) + cv.put(UsersColumns.USER_STATUS, it.status) } patch.online.requireNonNull { - cv.put(UserColumns.ONLINE, it.isOnline) - cv.put(UserColumns.LAST_SEEN, it.lastSeen) - cv.put(UserColumns.PLATFORM, it.platform) + cv.put(UsersColumns.ONLINE, it.isOnline) + cv.put(UsersColumns.LAST_SEEN, it.lastSeen) + cv.put(UsersColumns.PLATFORM, it.platform) } if (cv.size() > 0) { operations.add( @@ -199,7 +199,7 @@ internal class OwnersStorage(context: AppStorages) : AbsStorage(context), IOwner override fun getLocalizedUserActivity(accountId: Long, userId: Long): Maybe { return Maybe.create { e: MaybeEmitter -> - val uProjection = arrayOf(UserColumns.LAST_SEEN, UserColumns.ONLINE, UserColumns.SEX) + val uProjection = arrayOf(UsersColumns.LAST_SEEN, UsersColumns.ONLINE, UsersColumns.SEX) val uri = getUserContentUriFor(accountId) val where = BaseColumns._ID + " = ?" val args = arrayOf(userId.toString()) @@ -207,10 +207,10 @@ internal class OwnersStorage(context: AppStorages) : AbsStorage(context), IOwner if (cursor != null) { if (cursor.moveToNext()) { val online = - cursor.getBoolean(UserColumns.ONLINE) + cursor.getBoolean(UsersColumns.ONLINE) val lastSeen = - cursor.getLong(UserColumns.LAST_SEEN) - val sex = cursor.getInt(UserColumns.SEX) + cursor.getLong(UsersColumns.LAST_SEEN) + val sex = cursor.getInt(UsersColumns.SEX) val userActivityLine = getUserActivityLine(context, lastSeen, online, sex, false) e.onSuccess(userActivityLine) @@ -261,7 +261,7 @@ internal class OwnersStorage(context: AppStorages) : AbsStorage(context), IOwner override fun findUserByDomain(accountId: Long, domain: String?): Single> { return Single.create { emitter: SingleEmitter> -> val uri = getUserContentUriFor(accountId) - val where = UserColumns.DOMAIN + " LIKE ?" + val where = UsersColumns.DOMAIN + " LIKE ?" val args = arrayOf(domain) val cursor = contentResolver.query(uri, null, where, args, null) var entity: UserEntity? = null @@ -278,8 +278,8 @@ internal class OwnersStorage(context: AppStorages) : AbsStorage(context), IOwner override fun findFriendBirtday(accountId: Long): Single> { return Single.create { val uri = getUserContentUriFor(accountId) - val where = UserColumns.BDATE + " IS NOT NULL AND " + UserColumns.IS_FRIEND + " = 1" - val cursor = contentResolver.query(uri, null, where, null, UserColumns.BDATE + " DESC") + val where = UsersColumns.BDATE + " IS NOT NULL AND " + UsersColumns.IS_FRIEND + " = 1" + val cursor = contentResolver.query(uri, null, where, null, UsersColumns.BDATE + " DESC") val listEntity: ArrayList = ArrayList() while (cursor?.moveToNext() == true) { Entity2Model.map(mapUserDbo(cursor))?.let { it1 -> listEntity.add(it1) } @@ -295,7 +295,7 @@ internal class OwnersStorage(context: AppStorages) : AbsStorage(context), IOwner ): Single> { return Single.create { emitter: SingleEmitter> -> val uri = getGroupsContentUriFor(accountId) - val where = GroupColumns.SCREEN_NAME + " LIKE ?" + val where = GroupsColumns.SCREEN_NAME + " LIKE ?" val args = arrayOf(domain) val cursor = contentResolver.query(uri, null, where, args, null) var entity: CommunityEntity? = null @@ -527,99 +527,99 @@ internal class OwnersStorage(context: AppStorages) : AbsStorage(context), IOwner private fun createCv(dbo: CommunityEntity): ContentValues { val cv = ContentValues() cv.put(BaseColumns._ID, dbo.id) - cv.put(GroupColumns.NAME, dbo.name) - cv.put(GroupColumns.SCREEN_NAME, dbo.screenName) - cv.put(GroupColumns.IS_CLOSED, dbo.closed) - cv.put(GroupColumns.IS_BLACK_LISTED, dbo.isBlacklisted) - cv.put(GroupColumns.IS_VERIFIED, dbo.isVerified) - cv.put(GroupColumns.HAS_UNSEEN_STORIES, dbo.hasUnseenStories) - cv.put(GroupColumns.IS_ADMIN, dbo.isAdmin) - cv.put(GroupColumns.ADMIN_LEVEL, dbo.adminLevel) - cv.put(GroupColumns.IS_MEMBER, dbo.isMember) - cv.put(GroupColumns.MEMBER_STATUS, dbo.memberStatus) - cv.put(GroupColumns.MEMBERS_COUNT, dbo.membersCount) - cv.put(GroupColumns.TYPE, dbo.type) - cv.put(GroupColumns.PHOTO_50, dbo.photo50) - cv.put(GroupColumns.PHOTO_100, dbo.photo100) - cv.put(GroupColumns.PHOTO_200, dbo.photo200) + cv.put(GroupsColumns.NAME, dbo.name) + cv.put(GroupsColumns.SCREEN_NAME, dbo.screenName) + cv.put(GroupsColumns.IS_CLOSED, dbo.closed) + cv.put(GroupsColumns.IS_BLACK_LISTED, dbo.isBlacklisted) + cv.put(GroupsColumns.IS_VERIFIED, dbo.isVerified) + cv.put(GroupsColumns.HAS_UNSEEN_STORIES, dbo.hasUnseenStories) + cv.put(GroupsColumns.IS_ADMIN, dbo.isAdmin) + cv.put(GroupsColumns.ADMIN_LEVEL, dbo.adminLevel) + cv.put(GroupsColumns.IS_MEMBER, dbo.isMember) + cv.put(GroupsColumns.MEMBER_STATUS, dbo.memberStatus) + cv.put(GroupsColumns.MEMBERS_COUNT, dbo.membersCount) + cv.put(GroupsColumns.TYPE, dbo.type) + cv.put(GroupsColumns.PHOTO_50, dbo.photo50) + cv.put(GroupsColumns.PHOTO_100, dbo.photo100) + cv.put(GroupsColumns.PHOTO_200, dbo.photo200) return cv } private fun createCv(dbo: UserEntity): ContentValues { val cv = ContentValues() cv.put(BaseColumns._ID, dbo.id) - cv.put(UserColumns.FIRST_NAME, dbo.firstName) - cv.put(UserColumns.LAST_NAME, dbo.lastName) - cv.put(UserColumns.ONLINE, dbo.isOnline) - cv.put(UserColumns.ONLINE_MOBILE, dbo.isOnlineMobile) - cv.put(UserColumns.ONLINE_APP, dbo.onlineApp) - cv.put(UserColumns.PHOTO_50, dbo.photo50) - cv.put(UserColumns.PHOTO_100, dbo.photo100) - cv.put(UserColumns.PHOTO_200, dbo.photo200) - cv.put(UserColumns.PHOTO_MAX, dbo.photoMax) - cv.put(UserColumns.LAST_SEEN, dbo.lastSeen) - cv.put(UserColumns.PLATFORM, dbo.platform) - cv.put(UserColumns.USER_STATUS, dbo.status) - cv.put(UserColumns.SEX, dbo.sex) - cv.put(UserColumns.DOMAIN, dbo.domain) - cv.put(UserColumns.IS_FRIEND, dbo.isFriend) - cv.put(UserColumns.FRIEND_STATUS, dbo.friendStatus) - cv.put(UserColumns.WRITE_MESSAGE_STATUS, dbo.canWritePrivateMessage) - cv.put(UserColumns.BDATE, dbo.bdate) - cv.put(UserColumns.IS_USER_BLACK_LIST, dbo.blacklisted_by_me) - cv.put(UserColumns.IS_BLACK_LISTED, dbo.blacklisted) - cv.put(UserColumns.IS_VERIFIED, dbo.isVerified) - cv.put(UserColumns.HAS_UNSEEN_STORIES, dbo.hasUnseenStories) - cv.put(UserColumns.IS_CAN_ACCESS_CLOSED, dbo.isCan_access_closed) - cv.put(UserColumns.MAIDEN_NAME, dbo.maiden_name) + cv.put(UsersColumns.FIRST_NAME, dbo.firstName) + cv.put(UsersColumns.LAST_NAME, dbo.lastName) + cv.put(UsersColumns.ONLINE, dbo.isOnline) + cv.put(UsersColumns.ONLINE_MOBILE, dbo.isOnlineMobile) + cv.put(UsersColumns.ONLINE_APP, dbo.onlineApp) + cv.put(UsersColumns.PHOTO_50, dbo.photo50) + cv.put(UsersColumns.PHOTO_100, dbo.photo100) + cv.put(UsersColumns.PHOTO_200, dbo.photo200) + cv.put(UsersColumns.PHOTO_MAX, dbo.photoMax) + cv.put(UsersColumns.LAST_SEEN, dbo.lastSeen) + cv.put(UsersColumns.PLATFORM, dbo.platform) + cv.put(UsersColumns.USER_STATUS, dbo.status) + cv.put(UsersColumns.SEX, dbo.sex) + cv.put(UsersColumns.DOMAIN, dbo.domain) + cv.put(UsersColumns.IS_FRIEND, dbo.isFriend) + cv.put(UsersColumns.FRIEND_STATUS, dbo.friendStatus) + cv.put(UsersColumns.WRITE_MESSAGE_STATUS, dbo.canWritePrivateMessage) + cv.put(UsersColumns.BDATE, dbo.bdate) + cv.put(UsersColumns.IS_USER_BLACK_LIST, dbo.blacklisted_by_me) + cv.put(UsersColumns.IS_BLACK_LISTED, dbo.blacklisted) + cv.put(UsersColumns.IS_VERIFIED, dbo.isVerified) + cv.put(UsersColumns.HAS_UNSEEN_STORIES, dbo.hasUnseenStories) + cv.put(UsersColumns.IS_CAN_ACCESS_CLOSED, dbo.isCan_access_closed) + cv.put(UsersColumns.MAIDEN_NAME, dbo.maiden_name) return cv } internal fun mapCommunityDbo(cursor: Cursor): CommunityEntity { return CommunityEntity(cursor.getLong(BaseColumns._ID)) - .setName(cursor.getString(GroupColumns.NAME)) - .setScreenName(cursor.getString(GroupColumns.SCREEN_NAME)) - .setClosed(cursor.getInt(GroupColumns.IS_CLOSED)) - .setVerified(cursor.getBoolean(GroupColumns.IS_VERIFIED)) - .setHasUnseenStories(cursor.getBoolean(GroupColumns.HAS_UNSEEN_STORIES)) - .setBlacklisted(cursor.getBoolean(GroupColumns.IS_BLACK_LISTED)) - .setAdmin(cursor.getBoolean(GroupColumns.IS_ADMIN)) - .setAdminLevel(cursor.getInt(GroupColumns.ADMIN_LEVEL)) - .setMember(cursor.getBoolean(GroupColumns.IS_MEMBER)) - .setMemberStatus(cursor.getInt(GroupColumns.MEMBER_STATUS)) - .setMembersCount(cursor.getInt(GroupColumns.MEMBERS_COUNT)) - .setType(cursor.getInt(GroupColumns.TYPE)) - .setPhoto50(cursor.getString(GroupColumns.PHOTO_50)) - .setPhoto100(cursor.getString(GroupColumns.PHOTO_100)) - .setPhoto200(cursor.getString(GroupColumns.PHOTO_200)) + .setName(cursor.getString(GroupsColumns.NAME)) + .setScreenName(cursor.getString(GroupsColumns.SCREEN_NAME)) + .setClosed(cursor.getInt(GroupsColumns.IS_CLOSED)) + .setVerified(cursor.getBoolean(GroupsColumns.IS_VERIFIED)) + .setHasUnseenStories(cursor.getBoolean(GroupsColumns.HAS_UNSEEN_STORIES)) + .setBlacklisted(cursor.getBoolean(GroupsColumns.IS_BLACK_LISTED)) + .setAdmin(cursor.getBoolean(GroupsColumns.IS_ADMIN)) + .setAdminLevel(cursor.getInt(GroupsColumns.ADMIN_LEVEL)) + .setMember(cursor.getBoolean(GroupsColumns.IS_MEMBER)) + .setMemberStatus(cursor.getInt(GroupsColumns.MEMBER_STATUS)) + .setMembersCount(cursor.getInt(GroupsColumns.MEMBERS_COUNT)) + .setType(cursor.getInt(GroupsColumns.TYPE)) + .setPhoto50(cursor.getString(GroupsColumns.PHOTO_50)) + .setPhoto100(cursor.getString(GroupsColumns.PHOTO_100)) + .setPhoto200(cursor.getString(GroupsColumns.PHOTO_200)) } internal fun mapUserDbo(cursor: Cursor): UserEntity { return UserEntity(cursor.getLong(BaseColumns._ID)) - .setFirstName(cursor.getString(UserColumns.FIRST_NAME)) - .setLastName(cursor.getString(UserColumns.LAST_NAME)) - .setOnline(cursor.getBoolean(UserColumns.ONLINE)) - .setOnlineMobile(cursor.getBoolean(UserColumns.ONLINE_MOBILE)) - .setOnlineApp(cursor.getInt(UserColumns.ONLINE_APP)) - .setPhoto50(cursor.getString(UserColumns.PHOTO_50)) - .setPhoto100(cursor.getString(UserColumns.PHOTO_100)) - .setPhoto200(cursor.getString(UserColumns.PHOTO_200)) - .setPhotoMax(cursor.getString(UserColumns.PHOTO_MAX)) - .setLastSeen(cursor.getLong(UserColumns.LAST_SEEN)) - .setPlatform(cursor.getInt(UserColumns.PLATFORM)) - .setStatus(cursor.getString(UserColumns.USER_STATUS)) - .setSex(cursor.getInt(UserColumns.SEX)) - .setDomain(cursor.getString(UserColumns.DOMAIN)) - .setFriend(cursor.getBoolean(UserColumns.IS_FRIEND)) - .setFriendStatus(cursor.getInt(UserColumns.FRIEND_STATUS)) - .setCanWritePrivateMessage(cursor.getBoolean(UserColumns.WRITE_MESSAGE_STATUS)) - .setBdate(cursor.getString(UserColumns.BDATE)) - .setBlacklisted_by_me(cursor.getBoolean(UserColumns.IS_USER_BLACK_LIST)) - .setBlacklisted(cursor.getBoolean(UserColumns.IS_BLACK_LISTED)) - .setVerified(cursor.getBoolean(UserColumns.IS_VERIFIED)) - .setHasUnseenStories(cursor.getBoolean(UserColumns.HAS_UNSEEN_STORIES)) - .setCan_access_closed(cursor.getBoolean(UserColumns.IS_CAN_ACCESS_CLOSED)) - .setMaiden_name(cursor.getString(UserColumns.MAIDEN_NAME)) + .setFirstName(cursor.getString(UsersColumns.FIRST_NAME)) + .setLastName(cursor.getString(UsersColumns.LAST_NAME)) + .setOnline(cursor.getBoolean(UsersColumns.ONLINE)) + .setOnlineMobile(cursor.getBoolean(UsersColumns.ONLINE_MOBILE)) + .setOnlineApp(cursor.getInt(UsersColumns.ONLINE_APP)) + .setPhoto50(cursor.getString(UsersColumns.PHOTO_50)) + .setPhoto100(cursor.getString(UsersColumns.PHOTO_100)) + .setPhoto200(cursor.getString(UsersColumns.PHOTO_200)) + .setPhotoMax(cursor.getString(UsersColumns.PHOTO_MAX)) + .setLastSeen(cursor.getLong(UsersColumns.LAST_SEEN)) + .setPlatform(cursor.getInt(UsersColumns.PLATFORM)) + .setStatus(cursor.getString(UsersColumns.USER_STATUS)) + .setSex(cursor.getInt(UsersColumns.SEX)) + .setDomain(cursor.getString(UsersColumns.DOMAIN)) + .setFriend(cursor.getBoolean(UsersColumns.IS_FRIEND)) + .setFriendStatus(cursor.getInt(UsersColumns.FRIEND_STATUS)) + .setCanWritePrivateMessage(cursor.getBoolean(UsersColumns.WRITE_MESSAGE_STATUS)) + .setBdate(cursor.getString(UsersColumns.BDATE)) + .setBlacklisted_by_me(cursor.getBoolean(UsersColumns.IS_USER_BLACK_LIST)) + .setBlacklisted(cursor.getBoolean(UsersColumns.IS_BLACK_LISTED)) + .setVerified(cursor.getBoolean(UsersColumns.IS_VERIFIED)) + .setHasUnseenStories(cursor.getBoolean(UsersColumns.HAS_UNSEEN_STORIES)) + .setCan_access_closed(cursor.getBoolean(UsersColumns.IS_CAN_ACCESS_CLOSED)) + .setMaiden_name(cursor.getString(UsersColumns.MAIDEN_NAME)) } } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/RelativeshipStorage.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/RelativeshipStorage.kt index 511e1d1e1..07420d319 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/RelativeshipStorage.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/RelativeshipStorage.kt @@ -8,8 +8,8 @@ import dev.ragnarok.fenrir.db.FenrirContentProvider import dev.ragnarok.fenrir.db.FenrirContentProvider.Companion.getFriendListsContentUriFor import dev.ragnarok.fenrir.db.FenrirContentProvider.Companion.getRelativeshipContentUriFor import dev.ragnarok.fenrir.db.column.FriendListsColumns -import dev.ragnarok.fenrir.db.column.RelationshipColumns -import dev.ragnarok.fenrir.db.column.RelationshipColumns.getCV +import dev.ragnarok.fenrir.db.column.RelationshipsColumns +import dev.ragnarok.fenrir.db.column.RelationshipsColumns.getCV import dev.ragnarok.fenrir.db.impl.OwnersStorage.Companion.appendCommunitiesInsertOperation import dev.ragnarok.fenrir.db.impl.OwnersStorage.Companion.appendUsersInsertOperation import dev.ragnarok.fenrir.db.interfaces.IRelativeshipStorage @@ -69,7 +69,7 @@ internal class RelativeshipStorage(base: AppStorages) : AbsStorage(base), IRelat accountId, users, objectId, - RelationshipColumns.TYPE_FRIEND, + RelationshipsColumns.TYPE_FRIEND, clearBeforeStore ) } @@ -104,7 +104,7 @@ internal class RelativeshipStorage(base: AppStorages) : AbsStorage(base), IRelat accountId, users, objectId, - RelationshipColumns.TYPE_FOLLOWER, + RelationshipsColumns.TYPE_FOLLOWER, clearBeforeStore ) } @@ -119,7 +119,7 @@ internal class RelativeshipStorage(base: AppStorages) : AbsStorage(base), IRelat accountId, users, objectId, - RelationshipColumns.TYPE_REQUESTS, + RelationshipsColumns.TYPE_REQUESTS, clearBeforeStore ) } @@ -134,30 +134,30 @@ internal class RelativeshipStorage(base: AppStorages) : AbsStorage(base), IRelat accountId, users, objectId, - RelationshipColumns.TYPE_GROUP_MEMBER, + RelationshipsColumns.TYPE_GROUP_MEMBER, clearBeforeStore ) } override fun getGroupMembers(accountId: Long, groupId: Long): Single> { - return getUsersForType(accountId, groupId, RelationshipColumns.TYPE_GROUP_MEMBER) + return getUsersForType(accountId, groupId, RelationshipsColumns.TYPE_GROUP_MEMBER) } override fun getFriends(accountId: Long, objectId: Long): Single> { - return getUsersForType(accountId, objectId, RelationshipColumns.TYPE_FRIEND) + return getUsersForType(accountId, objectId, RelationshipsColumns.TYPE_FRIEND) } override fun getFollowers(accountId: Long, objectId: Long): Single> { - return getUsersForType(accountId, objectId, RelationshipColumns.TYPE_FOLLOWER) + return getUsersForType(accountId, objectId, RelationshipsColumns.TYPE_FOLLOWER) } override fun getRequests(accountId: Long): Single> { - return getUsersForType(accountId, accountId, RelationshipColumns.TYPE_REQUESTS) + return getUsersForType(accountId, accountId, RelationshipsColumns.TYPE_REQUESTS) } override fun getCommunities(accountId: Long, ownerId: Long): Single> { return Single.create { emitter: SingleEmitter> -> - val cursor = getCursorForType(accountId, ownerId, RelationshipColumns.TYPE_MEMBER) + val cursor = getCursorForType(accountId, ownerId, RelationshipsColumns.TYPE_MEMBER) val dbos: MutableList = ArrayList(safeCountOf(cursor)) if (cursor != null) { while (cursor.moveToNext()) { @@ -186,14 +186,14 @@ internal class RelativeshipStorage(base: AppStorages) : AbsStorage(base), IRelat clearOperationFor( accountId, userId, - RelationshipColumns.TYPE_MEMBER + RelationshipsColumns.TYPE_MEMBER ) ) } for (dbo in communities) { operations.add( ContentProviderOperation.newInsert(uri) - .withValues(getCV(userId, -dbo.id, RelationshipColumns.TYPE_MEMBER)) + .withValues(getCV(userId, -dbo.id, RelationshipsColumns.TYPE_MEMBER)) .build() ) } @@ -206,7 +206,7 @@ internal class RelativeshipStorage(base: AppStorages) : AbsStorage(base), IRelat private fun getCursorForType(accountId: Long, objectId: Long, relationType: Int): Cursor? { val uri = getRelativeshipContentUriFor(accountId) val where = - RelationshipColumns.FULL_TYPE + " = ? AND " + RelationshipColumns.OBJECT_ID + " = ?" + RelationshipsColumns.FULL_TYPE + " = ? AND " + RelationshipsColumns.OBJECT_ID + " = ?" val args = arrayOf(relationType.toString(), objectId.toString()) return contentResolver.query(uri, null, where, args, null) } @@ -256,7 +256,7 @@ internal class RelativeshipStorage(base: AppStorages) : AbsStorage(base), IRelat ): ContentProviderOperation { val uri = getRelativeshipContentUriFor(accountId) val clearWhere = - RelationshipColumns.OBJECT_ID + " = ? AND " + RelationshipColumns.TYPE + " = ?" + RelationshipsColumns.OBJECT_ID + " = ? AND " + RelationshipsColumns.TYPE + " = ?" val clearWhereArgs = arrayOf(objectId.toString(), type.toString()) return ContentProviderOperation .newDelete(uri) @@ -266,51 +266,51 @@ internal class RelativeshipStorage(base: AppStorages) : AbsStorage(base), IRelat companion object { internal fun mapCommunity(cursor: Cursor): CommunityEntity { - return CommunityEntity(cursor.getLong(RelationshipColumns.SUBJECT_ID)) - .setName(cursor.getString(RelationshipColumns.FOREIGN_SUBJECT_GROUP_NAME)) - .setScreenName(cursor.getString(RelationshipColumns.FOREIGN_SUBJECT_GROUP_SCREEN_NAME)) - .setClosed(cursor.getInt(RelationshipColumns.FOREIGN_SUBJECT_GROUP_IS_CLOSED)) - .setBlacklisted(cursor.getBoolean(RelationshipColumns.FOREIGN_SUBJECT_GROUP_IS_BLACK_LISTED)) - .setVerified(cursor.getBoolean(RelationshipColumns.FOREIGN_SUBJECT_GROUP_IS_VERIFIED)) - .setAdmin(cursor.getBoolean(RelationshipColumns.FOREIGN_SUBJECT_GROUP_IS_ADMIN)) - .setAdminLevel(cursor.getInt(RelationshipColumns.FOREIGN_SUBJECT_GROUP_ADMIN_LEVEL)) - .setMember(cursor.getBoolean(RelationshipColumns.FOREIGN_SUBJECT_GROUP_IS_MEMBER)) - .setMemberStatus(cursor.getInt(RelationshipColumns.FOREIGN_SUBJECT_GROUP_MEMBER_STATUS)) - .setMembersCount(cursor.getInt(RelationshipColumns.FOREIGN_SUBJECT_GROUP_MEMBERS_COUNT)) - .setType(cursor.getInt(RelationshipColumns.FOREIGN_SUBJECT_GROUP_TYPE)) - .setHasUnseenStories(cursor.getBoolean(RelationshipColumns.FOREIGN_SUBJECT_GROUP_HAS_UNSEEN_STORIES)) - .setPhoto50(cursor.getString(RelationshipColumns.FOREIGN_SUBJECT_GROUP_PHOTO_50)) - .setPhoto100(cursor.getString(RelationshipColumns.FOREIGN_SUBJECT_GROUP_PHOTO_100)) - .setPhoto200(cursor.getString(RelationshipColumns.FOREIGN_SUBJECT_GROUP_PHOTO_200)) + return CommunityEntity(cursor.getLong(RelationshipsColumns.SUBJECT_ID)) + .setName(cursor.getString(RelationshipsColumns.FOREIGN_SUBJECT_GROUP_NAME)) + .setScreenName(cursor.getString(RelationshipsColumns.FOREIGN_SUBJECT_GROUP_SCREEN_NAME)) + .setClosed(cursor.getInt(RelationshipsColumns.FOREIGN_SUBJECT_GROUP_IS_CLOSED)) + .setBlacklisted(cursor.getBoolean(RelationshipsColumns.FOREIGN_SUBJECT_GROUP_IS_BLACK_LISTED)) + .setVerified(cursor.getBoolean(RelationshipsColumns.FOREIGN_SUBJECT_GROUP_IS_VERIFIED)) + .setAdmin(cursor.getBoolean(RelationshipsColumns.FOREIGN_SUBJECT_GROUP_IS_ADMIN)) + .setAdminLevel(cursor.getInt(RelationshipsColumns.FOREIGN_SUBJECT_GROUP_ADMIN_LEVEL)) + .setMember(cursor.getBoolean(RelationshipsColumns.FOREIGN_SUBJECT_GROUP_IS_MEMBER)) + .setMemberStatus(cursor.getInt(RelationshipsColumns.FOREIGN_SUBJECT_GROUP_MEMBER_STATUS)) + .setMembersCount(cursor.getInt(RelationshipsColumns.FOREIGN_SUBJECT_GROUP_MEMBERS_COUNT)) + .setType(cursor.getInt(RelationshipsColumns.FOREIGN_SUBJECT_GROUP_TYPE)) + .setHasUnseenStories(cursor.getBoolean(RelationshipsColumns.FOREIGN_SUBJECT_GROUP_HAS_UNSEEN_STORIES)) + .setPhoto50(cursor.getString(RelationshipsColumns.FOREIGN_SUBJECT_GROUP_PHOTO_50)) + .setPhoto100(cursor.getString(RelationshipsColumns.FOREIGN_SUBJECT_GROUP_PHOTO_100)) + .setPhoto200(cursor.getString(RelationshipsColumns.FOREIGN_SUBJECT_GROUP_PHOTO_200)) } internal fun mapDbo(cursor: Cursor): UserEntity { val gid = - abs(cursor.getLong(RelationshipColumns.SUBJECT_ID)) + abs(cursor.getLong(RelationshipsColumns.SUBJECT_ID)) return UserEntity(gid) - .setFirstName(cursor.getString(RelationshipColumns.FOREIGN_SUBJECT_USER_FIRST_NAME)) - .setLastName(cursor.getString(RelationshipColumns.FOREIGN_SUBJECT_USER_LAST_NAME)) - .setOnline(cursor.getBoolean(RelationshipColumns.FOREIGN_SUBJECT_USER_ONLINE)) - .setOnlineMobile(cursor.getBoolean(RelationshipColumns.FOREIGN_SUBJECT_USER_ONLINE)) - .setOnlineApp(cursor.getInt(RelationshipColumns.FOREIGN_SUBJECT_USER_ONLINE_APP)) - .setPhoto50(cursor.getString(RelationshipColumns.FOREIGN_SUBJECT_USER_PHOTO_50)) - .setPhoto100(cursor.getString(RelationshipColumns.FOREIGN_SUBJECT_USER_PHOTO_100)) - .setPhoto200(cursor.getString(RelationshipColumns.FOREIGN_SUBJECT_USER_PHOTO_200)) - .setPhotoMax(cursor.getString(RelationshipColumns.FOREIGN_SUBJECT_USER_PHOTO_MAX)) - .setLastSeen(cursor.getLong(RelationshipColumns.FOREIGN_SUBJECT_USER_LAST_SEEN)) - .setPlatform(cursor.getInt(RelationshipColumns.FOREIGN_SUBJECT_USER_PLATFORM)) - .setStatus(cursor.getString(RelationshipColumns.FOREIGN_SUBJECT_USER_STATUS)) - .setSex(cursor.getInt(RelationshipColumns.FOREIGN_SUBJECT_USER_SEX)) - .setFriend(cursor.getBoolean(RelationshipColumns.FOREIGN_SUBJECT_USER_IS_FRIEND)) - .setFriendStatus(cursor.getInt(RelationshipColumns.FOREIGN_SUBJECT_USER_FRIEND_STATUS)) - .setCanWritePrivateMessage(cursor.getBoolean(RelationshipColumns.FOREIGN_SUBJECT_USER_WRITE_MESSAGE_STATUS)) - .setBdate(cursor.getString(RelationshipColumns.FOREIGN_SUBJECT_USER_BDATE)) - .setBlacklisted_by_me(cursor.getBoolean(RelationshipColumns.FOREIGN_SUBJECT_USER_IS_USER_BLACK_LIST)) - .setBlacklisted(cursor.getBoolean(RelationshipColumns.FOREIGN_SUBJECT_USER_IS_BLACK_LISTED)) - .setCan_access_closed(cursor.getBoolean(RelationshipColumns.FOREIGN_SUBJECT_USER_IS_CAN_ACCESS_CLOSED)) - .setVerified(cursor.getBoolean(RelationshipColumns.FOREIGN_SUBJECT_USER_IS_VERIFIED)) - .setMaiden_name(cursor.getString(RelationshipColumns.FOREIGN_SUBJECT_USER_MAIDEN_NAME)) - .setHasUnseenStories(cursor.getBoolean(RelationshipColumns.FOREIGN_SUBJECT_USER_HAS_UNSEEN_STORIES)) + .setFirstName(cursor.getString(RelationshipsColumns.FOREIGN_SUBJECT_USER_FIRST_NAME)) + .setLastName(cursor.getString(RelationshipsColumns.FOREIGN_SUBJECT_USER_LAST_NAME)) + .setOnline(cursor.getBoolean(RelationshipsColumns.FOREIGN_SUBJECT_USER_ONLINE)) + .setOnlineMobile(cursor.getBoolean(RelationshipsColumns.FOREIGN_SUBJECT_USER_ONLINE)) + .setOnlineApp(cursor.getInt(RelationshipsColumns.FOREIGN_SUBJECT_USER_ONLINE_APP)) + .setPhoto50(cursor.getString(RelationshipsColumns.FOREIGN_SUBJECT_USER_PHOTO_50)) + .setPhoto100(cursor.getString(RelationshipsColumns.FOREIGN_SUBJECT_USER_PHOTO_100)) + .setPhoto200(cursor.getString(RelationshipsColumns.FOREIGN_SUBJECT_USER_PHOTO_200)) + .setPhotoMax(cursor.getString(RelationshipsColumns.FOREIGN_SUBJECT_USER_PHOTO_MAX)) + .setLastSeen(cursor.getLong(RelationshipsColumns.FOREIGN_SUBJECT_USER_LAST_SEEN)) + .setPlatform(cursor.getInt(RelationshipsColumns.FOREIGN_SUBJECT_USER_PLATFORM)) + .setStatus(cursor.getString(RelationshipsColumns.FOREIGN_SUBJECT_USER_STATUS)) + .setSex(cursor.getInt(RelationshipsColumns.FOREIGN_SUBJECT_USER_SEX)) + .setFriend(cursor.getBoolean(RelationshipsColumns.FOREIGN_SUBJECT_USER_IS_FRIEND)) + .setFriendStatus(cursor.getInt(RelationshipsColumns.FOREIGN_SUBJECT_USER_FRIEND_STATUS)) + .setCanWritePrivateMessage(cursor.getBoolean(RelationshipsColumns.FOREIGN_SUBJECT_USER_WRITE_MESSAGE_STATUS)) + .setBdate(cursor.getString(RelationshipsColumns.FOREIGN_SUBJECT_USER_BDATE)) + .setBlacklisted_by_me(cursor.getBoolean(RelationshipsColumns.FOREIGN_SUBJECT_USER_IS_USER_BLACK_LIST)) + .setBlacklisted(cursor.getBoolean(RelationshipsColumns.FOREIGN_SUBJECT_USER_IS_BLACK_LISTED)) + .setCan_access_closed(cursor.getBoolean(RelationshipsColumns.FOREIGN_SUBJECT_USER_IS_CAN_ACCESS_CLOSED)) + .setVerified(cursor.getBoolean(RelationshipsColumns.FOREIGN_SUBJECT_USER_IS_VERIFIED)) + .setMaiden_name(cursor.getString(RelationshipsColumns.FOREIGN_SUBJECT_USER_MAIDEN_NAME)) + .setHasUnseenStories(cursor.getBoolean(RelationshipsColumns.FOREIGN_SUBJECT_USER_HAS_UNSEEN_STORIES)) } } } \ No newline at end of file diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/StickersStorage.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/StickersStorage.kt index 09eb981e1..5ebd51229 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/StickersStorage.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/StickersStorage.kt @@ -4,7 +4,8 @@ import android.content.ContentValues import android.database.Cursor import android.provider.BaseColumns import dev.ragnarok.fenrir.db.TempDataHelper -import dev.ragnarok.fenrir.db.column.StickerSetColumns +import dev.ragnarok.fenrir.db.column.StickerSetsColumns +import dev.ragnarok.fenrir.db.column.StickerSetsCustomColumns import dev.ragnarok.fenrir.db.column.StickersKeywordsColumns import dev.ragnarok.fenrir.db.interfaces.IStickersStorage import dev.ragnarok.fenrir.db.model.entity.StickerDboEntity @@ -15,6 +16,7 @@ import dev.ragnarok.fenrir.getBoolean import dev.ragnarok.fenrir.getInt import dev.ragnarok.fenrir.getString import dev.ragnarok.fenrir.ifNonNull +import dev.ragnarok.fenrir.insert import dev.ragnarok.fenrir.settings.Settings import dev.ragnarok.fenrir.util.Exestime.log import dev.ragnarok.fenrir.util.Utils.safeCountOf @@ -33,10 +35,10 @@ internal class StickersStorage(base: AppStorages) : AbsStorage(base), IStickersS val db = TempDataHelper.helper.writableDatabase db.beginTransaction() try { - val whereDel = StickerSetColumns.ACCOUNT_ID + " = ?" - db.delete(StickerSetColumns.TABLENAME, whereDel, arrayOf(accountId.toString())) + val whereDel = StickerSetsColumns.ACCOUNT_ID + " = ?" + db.delete(StickerSetsColumns.TABLENAME, whereDel, arrayOf(accountId.toString())) for ((i, entity) in sets.withIndex()) { - db.insert(StickerSetColumns.TABLENAME, null, createCv(accountId, entity, i)) + db.insert(StickerSetsColumns.TABLENAME, null, createCv(accountId, entity, i)) } db.setTransactionSuccessful() db.endTransaction() @@ -49,14 +51,55 @@ internal class StickersStorage(base: AppStorages) : AbsStorage(base), IStickersS } } + override fun storeStickerSetsCustom( + accountId: Long, + sets: List + ): Completable { + return Completable.create { e: CompletableEmitter -> + val start = System.currentTimeMillis() + val db = TempDataHelper.helper.writableDatabase + db.beginTransaction() + try { + val whereDel = StickerSetsCustomColumns.ACCOUNT_ID + " = ?" + db.delete( + StickerSetsCustomColumns.TABLENAME, + whereDel, + arrayOf(accountId.toString()) + ) + for ((i, entity) in sets.withIndex()) { + db.insert( + StickerSetsCustomColumns.TABLENAME, + null, + createCvCustom(accountId, entity, i) + ) + } + db.setTransactionSuccessful() + db.endTransaction() + e.onComplete() + } catch (exception: Exception) { + db.endTransaction() + e.tryOnError(exception) + } + log("StickersStorage.storeStickerSetsCustom", start, "count: " + safeCountOf(sets)) + } + } + override fun clearAccount(accountId: Long): Completable { - Settings.get().other().del_last_stickers_sync(accountId) + Settings.get().other().del_last_sticker_sets_sync(accountId) + Settings.get().other().del_last_sticker_sets_custom_sync(accountId) + Settings.get().other().del_last_sticker_keywords_sync(accountId) return Completable.create { e: CompletableEmitter -> val db = TempDataHelper.helper.writableDatabase db.beginTransaction() try { - val whereDel = StickerSetColumns.ACCOUNT_ID + " = ?" - db.delete(StickerSetColumns.TABLENAME, whereDel, arrayOf(accountId.toString())) + val whereDel = StickerSetsColumns.ACCOUNT_ID + " = ?" + db.delete(StickerSetsColumns.TABLENAME, whereDel, arrayOf(accountId.toString())) + val whereDelC = StickerSetsCustomColumns.ACCOUNT_ID + " = ?" + db.delete( + StickerSetsCustomColumns.TABLENAME, + whereDelC, + arrayOf(accountId.toString()) + ) val whereDelK = StickersKeywordsColumns.ACCOUNT_ID + " = ?" db.delete( StickersKeywordsColumns.TABLENAME, @@ -103,14 +146,16 @@ internal class StickersStorage(base: AppStorages) : AbsStorage(base), IStickersS } } - override fun getPurchasedAndActive(accountId: Long): Single> { + override fun getStickerSets(accountId: Long): Single> { return Single.create { e: SingleEmitter> -> val start = System.currentTimeMillis() val where = - "${StickerSetColumns.ACCOUNT_ID} = ? AND ${StickerSetColumns.PURCHASED} = ? AND ${StickerSetColumns.ACTIVE} = ?" - val args = arrayOf(accountId.toString(), "1", "1") - val cursor = TempDataHelper.helper.readableDatabase.query( - StickerSetColumns.TABLENAME, + "${StickerSetsColumns.ACCOUNT_ID} = ?" + val whereCustom = + "${StickerSetsCustomColumns.ACCOUNT_ID} = ?" + val args = arrayOf(accountId.toString()) + var cursor = TempDataHelper.helper.writableDatabase.query( + StickerSetsColumns.TABLENAME, COLUMNS_STICKER_SET, where, args, @@ -127,6 +172,24 @@ internal class StickersStorage(base: AppStorages) : AbsStorage(base), IStickersS } stickers.sortWith(COMPARATOR_STICKER_SET) cursor.close() + + if (!e.isDisposed) { + cursor = TempDataHelper.helper.writableDatabase.query( + StickerSetsCustomColumns.TABLENAME, + COLUMNS_STICKER_SET_CUSTOM, + whereCustom, + args, + null, + null, + null + ) + while (cursor.moveToNext()) { + if (e.isDisposed) { + break + } + stickers.insert(0, mapStickerSetCustom(cursor)) + } + } e.onSuccess(stickers) log("StickersStorage.get", start, "count: " + stickers.size) } @@ -136,7 +199,7 @@ internal class StickersStorage(base: AppStorages) : AbsStorage(base), IStickersS return Single.create { e: SingleEmitter> -> val where = "${StickersKeywordsColumns.ACCOUNT_ID} = ?" val args = arrayOf(accountId.toString()) - val cursor = TempDataHelper.helper.readableDatabase.query( + val cursor = TempDataHelper.helper.writableDatabase.query( StickersKeywordsColumns.TABLENAME, KEYWORDS_STICKER_COLUMNS, where, @@ -151,9 +214,9 @@ internal class StickersStorage(base: AppStorages) : AbsStorage(base), IStickersS break } val entity = mapStickersKeywords(cursor) - for (v in entity.keywords.orEmpty()) { + for (v in entity.keywords) { if (s.equals(v, ignoreCase = true)) { - entity.stickers?.let { stickers.addAll(it) } + entity.stickers.let { stickers.addAll(it) } cursor.close() e.onSuccess(stickers) return@create @@ -168,14 +231,25 @@ internal class StickersStorage(base: AppStorages) : AbsStorage(base), IStickersS companion object { private val COLUMNS_STICKER_SET = arrayOf( BaseColumns._ID, - StickerSetColumns.ACCOUNT_ID, - StickerSetColumns.POSITION, - StickerSetColumns.TITLE, - StickerSetColumns.ICON, - StickerSetColumns.PURCHASED, - StickerSetColumns.PROMOTED, - StickerSetColumns.ACTIVE, - StickerSetColumns.STICKERS + StickerSetsColumns.ACCOUNT_ID, + StickerSetsColumns.POSITION, + StickerSetsColumns.TITLE, + StickerSetsColumns.ICON, + StickerSetsColumns.PURCHASED, + StickerSetsColumns.PROMOTED, + StickerSetsColumns.ACTIVE, + StickerSetsColumns.STICKERS + ) + private val COLUMNS_STICKER_SET_CUSTOM = arrayOf( + BaseColumns._ID, + StickerSetsCustomColumns.ACCOUNT_ID, + StickerSetsCustomColumns.POSITION, + StickerSetsCustomColumns.TITLE, + StickerSetsCustomColumns.ICON, + StickerSetsCustomColumns.PURCHASED, + StickerSetsCustomColumns.PROMOTED, + StickerSetsCustomColumns.ACTIVE, + StickerSetsCustomColumns.STICKERS ) private val KEYWORDS_STICKER_COLUMNS = arrayOf( BaseColumns._ID, @@ -191,31 +265,67 @@ internal class StickersStorage(base: AppStorages) : AbsStorage(base), IStickersS internal fun createCv(accountId: Long, entity: StickerSetEntity, pos: Int): ContentValues { val cv = ContentValues() cv.put(BaseColumns._ID, entity.id) - cv.put(StickerSetColumns.ACCOUNT_ID, accountId) - cv.put(StickerSetColumns.POSITION, pos) + cv.put(StickerSetsColumns.ACCOUNT_ID, accountId) + cv.put(StickerSetsColumns.POSITION, pos) + entity.icon.ifNonNull({ + cv.put( + StickerSetsColumns.ICON, + MsgPack.encodeToByteArrayEx( + ListSerializer(StickerSetEntity.Img.serializer()), + it + ) + ) + }, { + cv.putNull(StickerSetsColumns.ICON) + }) + cv.put(StickerSetsColumns.TITLE, entity.title) + cv.put(StickerSetsColumns.PURCHASED, entity.isPurchased) + cv.put(StickerSetsColumns.PROMOTED, entity.isPromoted) + cv.put(StickerSetsColumns.ACTIVE, entity.isActive) + + entity.stickers.ifNonNull({ + cv.put( + StickerSetsColumns.STICKERS, + MsgPack.encodeToByteArrayEx(ListSerializer(StickerDboEntity.serializer()), it) + ) + }, { + cv.putNull(StickerSetsColumns.STICKERS) + }) + return cv + } + + internal fun createCvCustom( + accountId: Long, + entity: StickerSetEntity, + pos: Int + ): ContentValues { + val cv = ContentValues() + cv.put(BaseColumns._ID, entity.id) + cv.put(StickerSetsCustomColumns.ACCOUNT_ID, accountId) + cv.put(StickerSetsCustomColumns.POSITION, pos) entity.icon.ifNonNull({ cv.put( - StickerSetColumns.ICON, + StickerSetsCustomColumns.ICON, MsgPack.encodeToByteArrayEx( ListSerializer(StickerSetEntity.Img.serializer()), it ) ) }, { - cv.putNull(StickerSetColumns.ICON) + cv.putNull(StickerSetsCustomColumns.ICON) }) - cv.put(StickerSetColumns.TITLE, entity.title) - cv.put(StickerSetColumns.PURCHASED, entity.isPurchased) - cv.put(StickerSetColumns.PROMOTED, entity.isPromoted) - cv.put(StickerSetColumns.ACTIVE, entity.isActive) + cv.put(StickerSetsCustomColumns.TITLE, entity.title) + cv.put(StickerSetsCustomColumns.PURCHASED, entity.isPurchased) + cv.put(StickerSetsCustomColumns.PROMOTED, entity.isPromoted) + cv.put(StickerSetsCustomColumns.ACTIVE, entity.isActive) entity.stickers.ifNonNull({ cv.put( - StickerSetColumns.STICKERS, + StickerSetsCustomColumns.STICKERS, MsgPack.encodeToByteArrayEx(ListSerializer(StickerDboEntity.serializer()), it) ) }, { - cv.putNull(StickerSetColumns.STICKERS) + cv.putNull(StickerSetsCustomColumns.STICKERS) }) return cv } @@ -248,8 +358,32 @@ internal class StickersStorage(base: AppStorages) : AbsStorage(base), IStickersS } internal fun mapStickerSet(cursor: Cursor): StickerSetEntity { - val stickersJson = cursor.getBlob(StickerSetColumns.STICKERS) - val iconJson = cursor.getBlob(StickerSetColumns.ICON) + val stickersJson = cursor.getBlob(StickerSetsColumns.STICKERS) + val iconJson = cursor.getBlob(StickerSetsColumns.ICON) + return StickerSetEntity(cursor.getInt(BaseColumns._ID)) + .setStickers( + if (stickersJson == null) null else MsgPack.decodeFromByteArrayEx( + ListSerializer(StickerDboEntity.serializer()), + stickersJson + ) + ) + .setActive(cursor.getBoolean(StickerSetsColumns.ACTIVE)) + .setPurchased(cursor.getBoolean(StickerSetsColumns.PURCHASED)) + .setPromoted(cursor.getBoolean(StickerSetsColumns.PROMOTED)) + .setIcon( + if (iconJson == null) null else MsgPack.decodeFromByteArrayEx( + ListSerializer( + StickerSetEntity.Img.serializer() + ), iconJson + ) + ) + .setPosition(cursor.getInt(StickerSetsColumns.POSITION)) + .setTitle(cursor.getString(StickerSetsColumns.TITLE)) + } + + internal fun mapStickerSetCustom(cursor: Cursor): StickerSetEntity { + val stickersJson = cursor.getBlob(StickerSetsCustomColumns.STICKERS) + val iconJson = cursor.getBlob(StickerSetsCustomColumns.ICON) return StickerSetEntity(cursor.getInt(BaseColumns._ID)) .setStickers( if (stickersJson == null) null else MsgPack.decodeFromByteArrayEx( @@ -257,9 +391,9 @@ internal class StickersStorage(base: AppStorages) : AbsStorage(base), IStickersS stickersJson ) ) - .setActive(cursor.getBoolean(StickerSetColumns.ACTIVE)) - .setPurchased(cursor.getBoolean(StickerSetColumns.PURCHASED)) - .setPromoted(cursor.getBoolean(StickerSetColumns.PROMOTED)) + .setActive(cursor.getBoolean(StickerSetsCustomColumns.ACTIVE)) + .setPurchased(cursor.getBoolean(StickerSetsCustomColumns.PURCHASED)) + .setPromoted(cursor.getBoolean(StickerSetsCustomColumns.PROMOTED)) .setIcon( if (iconJson == null) null else MsgPack.decodeFromByteArrayEx( ListSerializer( @@ -267,8 +401,8 @@ internal class StickersStorage(base: AppStorages) : AbsStorage(base), IStickersS ), iconJson ) ) - .setPosition(cursor.getInt(StickerSetColumns.POSITION)) - .setTitle(cursor.getString(StickerSetColumns.TITLE)) + .setPosition(cursor.getInt(StickerSetsCustomColumns.POSITION)) + .setTitle(cursor.getString(StickerSetsCustomColumns.TITLE)) } internal fun mapStickersKeywords(cursor: Cursor): StickersKeywordsEntity { @@ -277,12 +411,12 @@ internal class StickersStorage(base: AppStorages) : AbsStorage(base), IStickersS val keywordsJson = cursor.getBlob(StickersKeywordsColumns.KEYWORDS) return StickersKeywordsEntity( - if (keywordsJson == null) null else MsgPack.decodeFromByteArrayEx( + if (keywordsJson == null) emptyList() else MsgPack.decodeFromByteArrayEx( ListSerializer( String.serializer() ), keywordsJson ), - if (stickersJson == null) null else MsgPack.decodeFromByteArrayEx( + if (stickersJson == null) emptyList() else MsgPack.decodeFromByteArrayEx( ListSerializer( StickerDboEntity.serializer() ), stickersJson diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/TempDataStorage.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/TempDataStorage.kt index 6158f4e59..681df2fbb 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/TempDataStorage.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/impl/TempDataStorage.kt @@ -5,10 +5,10 @@ import android.content.Context import android.database.Cursor import android.provider.BaseColumns import dev.ragnarok.fenrir.db.TempDataHelper -import dev.ragnarok.fenrir.db.column.AudioColumns -import dev.ragnarok.fenrir.db.column.LogColumns +import dev.ragnarok.fenrir.db.column.AudiosColumns +import dev.ragnarok.fenrir.db.column.LogsColumns import dev.ragnarok.fenrir.db.column.SearchRequestColumns -import dev.ragnarok.fenrir.db.column.ShortcutColumns +import dev.ragnarok.fenrir.db.column.ShortcutsColumns import dev.ragnarok.fenrir.db.column.TempDataColumns import dev.ragnarok.fenrir.db.interfaces.ITempDataStorage import dev.ragnarok.fenrir.db.serialize.ISerializeAdapter @@ -46,7 +46,7 @@ class TempDataStorage internal constructor(context: Context) : ITempDataStorage val start = System.currentTimeMillis() val where = TempDataColumns.OWNER_ID + " = ? AND " + TempDataColumns.SOURCE_ID + " = ?" val args = arrayOf(ownerId.toString(), sourceId.toString()) - val cursor = helper.readableDatabase.query( + val cursor = helper.writableDatabase.query( TempDataColumns.TABLENAME, PROJECTION_TEMPORARY, where, args, null, null, null ) @@ -116,7 +116,7 @@ class TempDataStorage internal constructor(context: Context) : ITempDataStorage val start = System.currentTimeMillis() val where = SearchRequestColumns.SOURCE_ID + " = ?" val args = arrayOf(sourceId.toString()) - val cursor = helper.readableDatabase.query( + val cursor = helper.writableDatabase.query( SearchRequestColumns.TABLENAME, PROJECTION_SEARCH, where, args, null, null, BaseColumns._ID + " DESC" ) @@ -186,15 +186,15 @@ class TempDataStorage internal constructor(context: Context) : ITempDataStorage return@create } db.delete( - ShortcutColumns.TABLENAME, - ShortcutColumns.ACTION + " = ?", arrayOf(action) + ShortcutsColumns.TABLENAME, + ShortcutsColumns.ACTION + " = ?", arrayOf(action) ) try { val cv = ContentValues() - cv.put(ShortcutColumns.ACTION, action) - cv.put(ShortcutColumns.NAME, name) - cv.put(ShortcutColumns.COVER, cover) - db.insert(ShortcutColumns.TABLENAME, null, cv) + cv.put(ShortcutsColumns.ACTION, action) + cv.put(ShortcutsColumns.NAME, name) + cv.put(ShortcutsColumns.COVER, cover) + db.insert(ShortcutsColumns.TABLENAME, null, cv) if (!it.isDisposed) { db.setTransactionSuccessful() } @@ -217,14 +217,14 @@ class TempDataStorage internal constructor(context: Context) : ITempDataStorage try { for (i in list) { db.delete( - ShortcutColumns.TABLENAME, - ShortcutColumns.ACTION + " = ?", arrayOf(i.action) + ShortcutsColumns.TABLENAME, + ShortcutsColumns.ACTION + " = ?", arrayOf(i.action) ) val cv = ContentValues() - cv.put(ShortcutColumns.ACTION, i.action) - cv.put(ShortcutColumns.NAME, i.name) - cv.put(ShortcutColumns.COVER, i.cover) - db.insert(ShortcutColumns.TABLENAME, null, cv) + cv.put(ShortcutsColumns.ACTION, i.action) + cv.put(ShortcutsColumns.NAME, i.name) + cv.put(ShortcutsColumns.COVER, i.cover) + db.insert(ShortcutsColumns.TABLENAME, null, cv) } if (!it.isDisposed) { db.setTransactionSuccessful() @@ -240,8 +240,8 @@ class TempDataStorage internal constructor(context: Context) : ITempDataStorage return Completable.fromAction { val start = System.currentTimeMillis() val count = helper.writableDatabase.delete( - ShortcutColumns.TABLENAME, - ShortcutColumns.ACTION + " = ?", arrayOf(action) + ShortcutsColumns.TABLENAME, + ShortcutsColumns.ACTION + " = ?", arrayOf(action) ) log("SearchRequestHelperStorage.delete", start, "count: $count") } @@ -249,8 +249,8 @@ class TempDataStorage internal constructor(context: Context) : ITempDataStorage override fun getShortcutAll(): Single> { return Single.fromCallable { - val cursor = helper.readableDatabase.query( - ShortcutColumns.TABLENAME, + val cursor = helper.writableDatabase.query( + ShortcutsColumns.TABLENAME, PROJECTION_SHORTCUT, null, null, @@ -271,11 +271,11 @@ class TempDataStorage internal constructor(context: Context) : ITempDataStorage return Single.fromCallable { val now = System.currentTimeMillis() val cv = ContentValues() - cv.put(LogColumns.TYPE, type) - cv.put(LogColumns.TAG, tag) - cv.put(LogColumns.BODY, body) - cv.put(LogColumns.DATE, now) - val id = helper.writableDatabase.insert(LogColumns.TABLENAME, null, cv) + cv.put(LogsColumns.TYPE, type) + cv.put(LogsColumns.TAG, tag) + cv.put(LogsColumns.BODY, body) + cv.put(LogsColumns.DATE, now) + val id = helper.writableDatabase.insert(LogsColumns.TABLENAME, null, cv) LogEvent(id.toInt()) .setBody(body) .setTag(tag) @@ -287,8 +287,8 @@ class TempDataStorage internal constructor(context: Context) : ITempDataStorage override fun deleteAudio(sourceOwner: Long, id: Int, ownerId: Long): Completable { return Completable.fromAction { helper.writableDatabase.delete( - AudioColumns.TABLENAME, - AudioColumns.SOURCE_OWNER_ID + " = ? AND " + AudioColumns.AUDIO_ID + " = ? AND " + AudioColumns.AUDIO_OWNER_ID + " = ?", + AudiosColumns.TABLENAME, + AudiosColumns.SOURCE_OWNER_ID + " = ? AND " + AudiosColumns.AUDIO_ID + " = ? AND " + AudiosColumns.AUDIO_OWNER_ID + " = ?", arrayOf(sourceOwner.toString(), id.toString(), ownerId.toString()) ) } @@ -297,7 +297,7 @@ class TempDataStorage internal constructor(context: Context) : ITempDataStorage override fun deleteAudios(): Completable { return Completable.fromAction { helper.writableDatabase.delete( - AudioColumns.TABLENAME, + AudiosColumns.TABLENAME, null, null ) } @@ -305,14 +305,14 @@ class TempDataStorage internal constructor(context: Context) : ITempDataStorage override fun getAudiosAll(sourceOwner: Long): Single> { return Single.fromCallable { - val cursor = helper.readableDatabase.query( - AudioColumns.TABLENAME, + val cursor = helper.writableDatabase.query( + AudiosColumns.TABLENAME, PROJECTION_AUDIO, - AudioColumns.SOURCE_OWNER_ID + " = ?", + AudiosColumns.SOURCE_OWNER_ID + " = ?", arrayOf(sourceOwner.toString()), null, null, - AudioColumns.DATE + " DESC" + AudiosColumns.DATE + " DESC" ) val data: MutableList