diff --git a/app/src/main/java/com/nextcloud/talk/application/NextcloudTalkApplication.kt b/app/src/main/java/com/nextcloud/talk/application/NextcloudTalkApplication.kt index 2a09f74d8..7b3336d9c 100644 --- a/app/src/main/java/com/nextcloud/talk/application/NextcloudTalkApplication.kt +++ b/app/src/main/java/com/nextcloud/talk/application/NextcloudTalkApplication.kt @@ -265,12 +265,16 @@ class NextcloudTalkApplication : MultiDexApplication(), LifecycleObserver { val database = object : SqlCipherDatabaseSource( this, Models.DEFAULT, - this.resources.getString(R.string.nc_app_product_name).lowercase(Locale.getDefault()) - .replace(" ", "_").trim { it <= ' ' } + ".sqlite", + this + .resources + .getString(R.string.nc_app_product_name) + .lowercase(Locale.getDefault()) + .replace(" ", "_") + .trim { it <= ' ' } + + ".sqlite", this.getString(R.string.nc_talk_database_encryption_key), DatabaseModule.DB_VERSION ) { - override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) { checkAndUpdateCipherMigrationStatus(newVersion, appPreferences) super.onUpgrade(db, oldVersion, newVersion) diff --git a/app/src/main/java/com/nextcloud/talk/dagger/modules/DatabaseModule.java b/app/src/main/java/com/nextcloud/talk/dagger/modules/DatabaseModule.java index 148c574cf..87be3413f 100644 --- a/app/src/main/java/com/nextcloud/talk/dagger/modules/DatabaseModule.java +++ b/app/src/main/java/com/nextcloud/talk/dagger/modules/DatabaseModule.java @@ -1,22 +1,23 @@ /* + * Nextcloud Talk application * - * Nextcloud Talk application + * @author Andy Scherzinger + * @author Mario Danic + * Copyright (C) 2022 Andy Scherzinger + * Copyright (C) 2017 Mario Danic * - * @author Mario Danic - * Copyright (C) 2017 Mario Danic (mario@lovelyhq.com) + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.nextcloud.talk.dagger.modules; @@ -44,24 +45,33 @@ public class DatabaseModule { @Provides @Singleton public SqlCipherDatabaseSource provideSqlCipherDatabaseSource(@NonNull final Context context) { - return new SqlCipherDatabaseSource(context, Models.DEFAULT, - context.getResources().getString(R.string.nc_app_product_name).toLowerCase() - .replace(" ", "_").trim() + ".sqlite", - context.getString(R.string.nc_talk_database_encryption_key), DB_VERSION); + return new SqlCipherDatabaseSource( + context, + Models.DEFAULT, + context + .getResources() + .getString(R.string.nc_app_product_name) + .toLowerCase() + .replace(" ", "_") + .trim() + + ".sqlite", + context.getString(R.string.nc_talk_database_encryption_key), + DB_VERSION); } @Provides @Singleton - public ReactiveEntityStore provideDataStore(@NonNull final SqlCipherDatabaseSource sqlCipherDatabaseSource) { + public ReactiveEntityStore provideDataStore( + @NonNull final SqlCipherDatabaseSource sqlCipherDatabaseSource) { final Configuration configuration = sqlCipherDatabaseSource.getConfiguration(); - return ReactiveSupport.toReactiveStore(new EntityDataStore(configuration)); + return ReactiveSupport.toReactiveStore(new EntityDataStore<>(configuration)); } @Provides @Singleton public AppPreferences providePreferences(@NonNull final Context poContext) { - AppPreferences p = StoreBox.create(poContext, AppPreferences.class); - p.removeLinkPreviews(); - return p; + AppPreferences preferences = StoreBox.create(poContext, AppPreferences.class); + preferences.removeLinkPreviews(); + return preferences; } }