Create base DatabaseFactory.kt and adapt to CounterDatabase.kt
* CountersDatabaseFactory.kt renamed to CounterDatabase.kt * CountersDatabase.kt renamed to CounterDao.kt MAILAND-1186 # Conflicts: # app/src/main/java/ch/protonmail/android/jobs/FetchMessageCountsJob.kt # Conflicts: # app/src/main/java/ch/protonmail/android/api/models/room/counters/CountersDatabase.kt # app/src/main/java/ch/protonmail/android/api/segments/event/EventHandler.kt
This commit is contained in:
parent
c3056a0ab8
commit
980b83cd83
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
*
|
||||
* ProtonMail 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.
|
||||
*
|
||||
*
|
||||
* ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
@ -34,11 +34,11 @@ import kotlin.test.Test
|
|||
|
||||
/**
|
||||
* Created by Kamil Rajtar on 05.09.18. */
|
||||
internal class CountersDatabaseTest {
|
||||
internal class CounterDaoTest {
|
||||
|
||||
private val context = ApplicationProvider.getApplicationContext<ProtonMailApplication>()
|
||||
private var databaseFactory = Room.inMemoryDatabaseBuilder(context, CountersDatabaseFactory::class.java).build()
|
||||
private var database = databaseFactory.getDatabase()
|
||||
private var databaseFactory = Room.inMemoryDatabaseBuilder(context, CounterDatabase::class.java).build()
|
||||
private var database = databaseFactory.getDao()
|
||||
|
||||
@get:Rule
|
||||
var instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||
|
@ -92,7 +92,7 @@ internal class CountersDatabaseTest {
|
|||
Assert.assertThat(actualTotalLabelsSet, containsInAnyOrder(expectedTotalLabelsMatcher))
|
||||
}
|
||||
|
||||
private fun CountersDatabase.populate() {
|
||||
private fun CounterDao.populate() {
|
||||
insertAllUnreadLocations(unreadLocations)
|
||||
insertAllUnreadLabels(unreadLabels)
|
||||
refreshTotalCounters(totalLocations, totalLabels)
|
|
@ -103,8 +103,8 @@ import ch.protonmail.android.adapters.swipe.SwipeAction
|
|||
import ch.protonmail.android.adapters.swipe.TrashSwipeHandler
|
||||
import ch.protonmail.android.api.models.MessageCount
|
||||
import ch.protonmail.android.api.models.SimpleMessage
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabase
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabaseFactory
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDatabase
|
||||
import ch.protonmail.android.api.models.room.counters.TotalLabelCounter
|
||||
import ch.protonmail.android.api.models.room.counters.TotalLocationCounter
|
||||
import ch.protonmail.android.api.models.room.messages.Label
|
||||
|
@ -219,7 +219,7 @@ class MailboxActivity :
|
|||
IMoveMessagesListener,
|
||||
DialogInterface.OnDismissListener {
|
||||
|
||||
private lateinit var countersDatabase: CountersDatabase
|
||||
private lateinit var counterDao: CounterDao
|
||||
private lateinit var pendingActionsDatabase: PendingActionsDatabase
|
||||
|
||||
@Inject
|
||||
|
@ -256,8 +256,8 @@ class MailboxActivity :
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
countersDatabase = CountersDatabaseFactory.getInstance(this, userManager.requireCurrentUserId())
|
||||
.getDatabase()
|
||||
counterDao = CounterDatabase.getInstance(this, userManager.requireCurrentUserId())
|
||||
.getDao()
|
||||
pendingActionsDatabase = PendingActionsDatabaseFactory.getInstance(this).getDatabase()
|
||||
|
||||
// force reload of MessageDetailsRepository's internal dependencies in case we just switched user
|
||||
|
@ -577,7 +577,7 @@ class MailboxActivity :
|
|||
val currentUserId = userManager.requireCurrentUserId()
|
||||
|
||||
mJobManager.start()
|
||||
countersDatabase = CountersDatabaseFactory.getInstance(this, currentUserId).getDatabase()
|
||||
counterDao = CounterDatabase.getInstance(this, currentUserId).getDao()
|
||||
pendingActionsDatabase = PendingActionsDatabaseFactory.getInstance(this).getDatabase()
|
||||
messageDetailsRepository.reloadDependenciesForUser(currentUserId)
|
||||
|
||||
|
@ -1165,9 +1165,9 @@ class MailboxActivity :
|
|||
}
|
||||
val response = event.unreadMessagesResponse ?: return
|
||||
val messageCountsList = response.counts ?: emptyList()
|
||||
countersDatabase = CountersDatabaseFactory
|
||||
.getInstance(applicationContext, userManager.requireCurrentUserId()).getDatabase()
|
||||
OnMessageCountsListTask(WeakReference(this), countersDatabase, messageCountsList).execute()
|
||||
counterDao = CounterDatabase
|
||||
.getInstance(applicationContext, userManager.requireCurrentUserId()).getDao()
|
||||
OnMessageCountsListTask(WeakReference(this), counterDao, messageCountsList).execute()
|
||||
refreshDrawer()
|
||||
//endregion
|
||||
}
|
||||
|
@ -1536,7 +1536,7 @@ class MailboxActivity :
|
|||
}
|
||||
RefreshEmptyViewTask(
|
||||
WeakReference(this),
|
||||
countersDatabase,
|
||||
counterDao,
|
||||
messagesDatabase,
|
||||
newMessageLocationType,
|
||||
mailboxLabelId
|
||||
|
@ -1781,7 +1781,7 @@ class MailboxActivity :
|
|||
startFetchFirstPageByLabel(fromInt(newLocation), labelId, false)
|
||||
RefreshEmptyViewTask(
|
||||
this.mailboxActivity,
|
||||
mailboxActivity.countersDatabase,
|
||||
mailboxActivity.counterDao,
|
||||
mailboxActivity.messagesDatabase,
|
||||
locationToSet,
|
||||
labelId
|
||||
|
@ -1939,12 +1939,12 @@ class MailboxActivity :
|
|||
|
||||
private class OnMessageCountsListTask internal constructor(
|
||||
private val mailboxActivity: WeakReference<MailboxActivity>,
|
||||
private val countersDatabase: CountersDatabase,
|
||||
private val counterDao: CounterDao,
|
||||
private val messageCountsList: List<MessageCount>
|
||||
) : AsyncTask<Unit, Unit, Int>() {
|
||||
|
||||
override fun doInBackground(vararg params: Unit): Int {
|
||||
val totalInbox = countersDatabase.findTotalLocationById(MessageLocationType.INBOX.messageLocationTypeValue)
|
||||
val totalInbox = counterDao.findTotalLocationById(MessageLocationType.INBOX.messageLocationTypeValue)
|
||||
return totalInbox?.count ?: -1
|
||||
}
|
||||
|
||||
|
@ -1982,7 +1982,7 @@ class MailboxActivity :
|
|||
}
|
||||
}
|
||||
mailboxActivity.setRefreshing(false)
|
||||
RefreshTotalCountersTask(countersDatabase, locationCounters, labelCounters).execute()
|
||||
RefreshTotalCountersTask(counterDao, locationCounters, labelCounters).execute()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
*
|
||||
* ProtonMail 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.
|
||||
*
|
||||
*
|
||||
* ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
package ch.protonmail.android.activities.mailbox
|
||||
|
||||
import android.os.AsyncTask
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabase
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao
|
||||
import ch.protonmail.android.api.models.room.messages.MessagesDatabase
|
||||
import ch.protonmail.android.core.Constants
|
||||
import java.lang.ref.WeakReference
|
||||
|
@ -30,7 +30,7 @@ import java.util.concurrent.TimeUnit
|
|||
*/
|
||||
internal class RefreshEmptyViewTask(
|
||||
private val mailboxActivityWeakReference: WeakReference<MailboxActivity>,
|
||||
private val countersDatabase: CountersDatabase,
|
||||
private val counterDao: CounterDao,
|
||||
private val messagesDatabase: MessagesDatabase,
|
||||
private val mailboxLocation: Constants.MessageLocationType,
|
||||
private val labelId: String?
|
||||
|
@ -45,9 +45,9 @@ internal class RefreshEmptyViewTask(
|
|||
val counter = if (listOf(
|
||||
Constants.MessageLocationType.LABEL,
|
||||
Constants.MessageLocationType.LABEL_FOLDER).contains(mailboxLocation)) {
|
||||
labelId?.let(countersDatabase::findTotalLabelById)
|
||||
labelId?.let(counterDao::findTotalLabelById)
|
||||
} else {
|
||||
countersDatabase.findTotalLocationById(mailboxLocation.messageLocationTypeValue)
|
||||
counterDao.findTotalLocationById(mailboxLocation.messageLocationTypeValue)
|
||||
}
|
||||
|
||||
val localCounter = if (listOf(
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
*
|
||||
* ProtonMail 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.
|
||||
*
|
||||
*
|
||||
* ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
@ -20,19 +20,19 @@ package ch.protonmail.android.activities.mailbox
|
|||
|
||||
import android.os.AsyncTask
|
||||
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabase
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao
|
||||
import ch.protonmail.android.api.models.room.counters.TotalLabelCounter
|
||||
import ch.protonmail.android.api.models.room.counters.TotalLocationCounter
|
||||
|
||||
/**
|
||||
* Created by Kamil Rajtar on 21.08.18.
|
||||
*/
|
||||
internal class RefreshTotalCountersTask(private val countersDatabase:CountersDatabase,
|
||||
private val locationCounters:List<TotalLocationCounter>,
|
||||
private val labelCounters:List<TotalLabelCounter>):AsyncTask<Void,Void,Void>() {
|
||||
internal class RefreshTotalCountersTask(private val counterDao:CounterDao,
|
||||
private val locationCounters:List<TotalLocationCounter>,
|
||||
private val labelCounters:List<TotalLabelCounter>):AsyncTask<Void,Void,Void>() {
|
||||
|
||||
override fun doInBackground(vararg voids:Void):Void? {
|
||||
countersDatabase.refreshTotalCounters(locationCounters,labelCounters)
|
||||
counterDao.refreshTotalCounters(locationCounters,labelCounters)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,8 +59,8 @@ import ch.protonmail.android.api.models.room.attachmentMetadata.AttachmentMetada
|
|||
import ch.protonmail.android.api.models.room.attachmentMetadata.AttachmentMetadataDatabaseFactory
|
||||
import ch.protonmail.android.api.models.room.contacts.ContactsDatabase
|
||||
import ch.protonmail.android.api.models.room.contacts.ContactsDatabaseFactory
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabase
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabaseFactory
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDatabase
|
||||
import ch.protonmail.android.api.models.room.messages.MessagesDatabase
|
||||
import ch.protonmail.android.api.models.room.messages.MessagesDatabaseFactory
|
||||
import ch.protonmail.android.api.models.room.notifications.NotificationsDatabase
|
||||
|
@ -119,7 +119,7 @@ abstract class BaseSettingsActivity : BaseConnectivityActivity() {
|
|||
var messagesDatabase: MessagesDatabase? = null
|
||||
private var searchDatabase: MessagesDatabase? = null
|
||||
private var notificationsDatabase: NotificationsDatabase? = null
|
||||
var countersDatabase: CountersDatabase? = null
|
||||
var counterDao: CounterDao? = null
|
||||
var attachmentMetadataDatabase: AttachmentMetadataDatabase? = null
|
||||
var pendingActionsDatabase: PendingActionsDatabase? = null
|
||||
var sharedPreferences: SharedPreferences? = null
|
||||
|
@ -159,7 +159,7 @@ abstract class BaseSettingsActivity : BaseConnectivityActivity() {
|
|||
messagesDatabase = MessagesDatabaseFactory.getInstance(applicationContext).getDatabase()
|
||||
searchDatabase = MessagesDatabaseFactory.getSearchDatabase(applicationContext).getDatabase()
|
||||
notificationsDatabase = NotificationsDatabaseFactory.getInstance(applicationContext).getDatabase()
|
||||
countersDatabase = CountersDatabaseFactory.getInstance(applicationContext).getDatabase()
|
||||
counterDao = CounterDatabase.getInstance(applicationContext).getDao()
|
||||
attachmentMetadataDatabase = AttachmentMetadataDatabaseFactory.getInstance(applicationContext).getDatabase()
|
||||
pendingActionsDatabase = PendingActionsDatabaseFactory.getInstance(applicationContext).getDatabase()
|
||||
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this@BaseSettingsActivity)
|
||||
|
@ -419,7 +419,7 @@ abstract class BaseSettingsActivity : BaseConnectivityActivity() {
|
|||
messagesDatabase,
|
||||
searchDatabase,
|
||||
notificationsDatabase,
|
||||
countersDatabase,
|
||||
counterDao,
|
||||
attachmentMetadataDatabase,
|
||||
pendingActionsDatabase,
|
||||
true
|
||||
|
|
|
@ -21,8 +21,8 @@ package ch.protonmail.android.api.models
|
|||
import android.content.Context
|
||||
import ch.protonmail.android.api.models.room.contacts.ContactsDao
|
||||
import ch.protonmail.android.api.models.room.contacts.ContactsDatabaseFactory
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDao
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabaseFactory
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDatabase
|
||||
import ch.protonmail.android.api.models.room.messages.MessagesDao
|
||||
import ch.protonmail.android.api.models.room.messages.MessagesDatabaseFactory
|
||||
import ch.protonmail.android.api.models.room.notifications.NotificationsDatabaseFactory
|
||||
|
@ -73,12 +73,8 @@ class DatabaseProvider @Inject constructor(
|
|||
fun provideMessagesDatabaseFactory(username: String?) =
|
||||
MessagesDatabaseFactory.getInstance(context, username)
|
||||
|
||||
fun provideCountersDao(userId: Id? = null): CountersDao =
|
||||
provideCountersDao(userId?.let { findUsernameForUserId.blocking(it) }?.s)
|
||||
|
||||
@Deprecated("Get by user Id", ReplaceWith("provideCountersDao(userId)"))
|
||||
fun provideCountersDao(username: String?): CountersDao =
|
||||
CountersDatabaseFactory.getInstance(context, username).getDatabase()
|
||||
fun provideCountersDao(userId: Id): CounterDao =
|
||||
CounterDatabase.getInstance(context, userId).getDao()
|
||||
|
||||
fun providePendingActionsDao(userId: Id? = null): PendingActionsDao =
|
||||
providePendingActionsDao(userId?.let { findUsernameForUserId.blocking(it) }?.s)
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* ProtonMail 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.
|
||||
*
|
||||
* ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
package ch.protonmail.android.api.models.room.counters
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
// region constants
|
||||
const val COLUMN_COUNTER_ID = "id"
|
||||
const val COLUMN_COUNTER_COUNT = "count"
|
||||
// endregion
|
||||
|
||||
/**
|
||||
* Created by Kamil Rajtar on 21.08.18.
|
||||
*/
|
||||
|
||||
open class Counter<K:Any>(
|
||||
@PrimaryKey
|
||||
@ColumnInfo(name = COLUMN_COUNTER_ID)
|
||||
val id: K,
|
||||
@ColumnInfo(name = COLUMN_COUNTER_COUNT)
|
||||
var count: Int = 0) {
|
||||
|
||||
fun increment() {
|
||||
count+=1
|
||||
}
|
||||
|
||||
fun increment(by:Int) {
|
||||
count+=by
|
||||
}
|
||||
|
||||
fun decrement() {
|
||||
if(count>0) {
|
||||
count-=1
|
||||
}
|
||||
}
|
||||
|
||||
fun decrement(by:Int) {
|
||||
if(count-by>=0) {
|
||||
count-=by
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* ProtonMail 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.
|
||||
*
|
||||
* ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
package ch.protonmail.android.api.models.room.counters
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Base64
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
import ch.protonmail.android.domain.entity.Id
|
||||
import ch.protonmail.android.utils.extensions.app
|
||||
import me.proton.core.util.kotlin.unsupported
|
||||
|
||||
@Database(
|
||||
entities = [
|
||||
UnreadLabelCounter::class,
|
||||
UnreadLocationCounter::class,
|
||||
TotalLabelCounter::class,
|
||||
TotalLocationCounter::class],
|
||||
version = 1
|
||||
)
|
||||
abstract class CountersDatabaseFactory : RoomDatabase() {
|
||||
abstract fun getDatabase(): CountersDatabase
|
||||
|
||||
companion object {
|
||||
private const val DEFAULT_DATABASE_FILENAME = "UnreadCountersDatabase.db"
|
||||
private val DATABASES = mutableMapOf<Id, CountersDatabaseFactory>()
|
||||
|
||||
@Synchronized
|
||||
fun getInstance(context: Context, userId: Id): CountersDatabaseFactory =
|
||||
DATABASES.getOrPut(userId) { buildDatabase(context, userId) }
|
||||
|
||||
@JvmOverloads
|
||||
@Synchronized
|
||||
@Deprecated(
|
||||
"Use with user Id",
|
||||
ReplaceWith("getInstance(context, userId)"),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
fun getInstance(context: Context, username: String? = null): CountersDatabaseFactory {
|
||||
unsupported
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun deleteDb(context: Context, userId: Id) {
|
||||
val username = usernameForUserId(context, userId)
|
||||
|
||||
val baseFileName = databaseName(username)
|
||||
val databaseFile = context.getDatabasePath(baseFileName)
|
||||
val databaseFileShm = context.getDatabasePath("$baseFileName-shm")
|
||||
val databaseFileWal = context.getDatabasePath("$baseFileName-wal")
|
||||
|
||||
if (databaseFile.exists()) databaseFile.delete()
|
||||
if (databaseFileShm.exists()) databaseFileShm.delete()
|
||||
if (databaseFileWal.exists()) databaseFileWal.delete()
|
||||
|
||||
DATABASES.remove(userId)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
@Deprecated(
|
||||
"Use with user Id",
|
||||
ReplaceWith("deleteDb(context, userId)"),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
fun deleteDb(context: Context, username: String) {
|
||||
unsupported
|
||||
}
|
||||
|
||||
private fun buildDatabase(context: Context, userId: Id): CountersDatabaseFactory {
|
||||
val username = usernameForUserId(context, userId)
|
||||
|
||||
// region migrate old single-user database to multi-user
|
||||
val baseFileName = databaseName(username)
|
||||
|
||||
context.getDatabasePath(DEFAULT_DATABASE_FILENAME)
|
||||
.renameTo(context.getDatabasePath(baseFileName))
|
||||
|
||||
context.getDatabasePath("$DEFAULT_DATABASE_FILENAME-shm")
|
||||
.renameTo(context.getDatabasePath("$baseFileName-shm"))
|
||||
|
||||
context.getDatabasePath("$DEFAULT_DATABASE_FILENAME-wal")
|
||||
.renameTo(context.getDatabasePath("$baseFileName-wal"))
|
||||
// endregion
|
||||
|
||||
return Room.databaseBuilder(context.applicationContext, CountersDatabaseFactory::class.java, baseFileName)
|
||||
.fallbackToDestructiveMigration()
|
||||
.build()
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
"Use with user Id",
|
||||
ReplaceWith("buildDatabase(context, userId)"),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
private fun buildDatabase(context: Context, username: String): CountersDatabaseFactory {
|
||||
unsupported
|
||||
}
|
||||
|
||||
private fun usernameForUserId(context: Context, userId: Id): String {
|
||||
val user = context.app.userManager.getUserBlocking(userId)
|
||||
return user.name.s
|
||||
}
|
||||
|
||||
private fun databaseName(username: String) =
|
||||
"${Base64.encodeToString(username.toByteArray(), Base64.NO_WRAP)}-$DEFAULT_DATABASE_FILENAME"
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* ProtonMail 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.
|
||||
*
|
||||
* ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
package ch.protonmail.android.api.models.room.counters
|
||||
|
||||
import androidx.room.Entity
|
||||
|
||||
// region constants
|
||||
const val TABLE_TOTAL_LABEL_COUNTERS = "totalLabelCounters"
|
||||
// endregion
|
||||
|
||||
/**
|
||||
* Created by dkadrikj on 15.9.15.
|
||||
*/
|
||||
|
||||
@Entity(tableName = TABLE_TOTAL_LABEL_COUNTERS)
|
||||
class TotalLabelCounter(id:String,count:Int=0):Counter<String>(id,count)
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* ProtonMail 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.
|
||||
*
|
||||
* ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
package ch.protonmail.android.api.models.room.counters
|
||||
|
||||
import androidx.room.Entity
|
||||
|
||||
// region constants
|
||||
const val TABLE_TOTAL_LOCATION_COUNTERS = "totalLocationCounters"
|
||||
// endregion
|
||||
|
||||
/**
|
||||
* Created by dkadrikj on 15.9.15.
|
||||
*/
|
||||
|
||||
@Entity(tableName = TABLE_TOTAL_LOCATION_COUNTERS)
|
||||
class TotalLocationCounter(id: Int, count: Int = 0) : Counter<Int>(id, count)
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* ProtonMail 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.
|
||||
*
|
||||
* ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
package ch.protonmail.android.api.models.room.counters
|
||||
|
||||
import androidx.room.Entity
|
||||
|
||||
// region constants
|
||||
const val TABLE_UNREAD_LABEL_COUNTERS = "unreadLabelCounters"
|
||||
// endregion
|
||||
|
||||
/**
|
||||
* Created by dkadrikj on 15.9.15.
|
||||
*/
|
||||
|
||||
@Entity(tableName = TABLE_UNREAD_LABEL_COUNTERS)
|
||||
class UnreadLabelCounter(id: String, count: Int = 0) : Counter<String>(id, count)
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* ProtonMail 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.
|
||||
*
|
||||
* ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
package ch.protonmail.android.api.models.room.counters
|
||||
|
||||
import androidx.room.Entity
|
||||
|
||||
// region constants
|
||||
const val TABLE_UNREAD_LOCATION_COUNTERS = "unreadLocationCounters"
|
||||
//endregion
|
||||
|
||||
/**
|
||||
* Created by dkadrikj on 15.9.15.
|
||||
*/
|
||||
|
||||
@Entity(tableName = TABLE_UNREAD_LOCATION_COUNTERS)
|
||||
class UnreadLocationCounter(id: Int, count: Int = 0) : Counter<Int>(id, count)
|
|
@ -43,7 +43,7 @@ import ch.protonmail.android.api.models.room.contacts.ContactEmailContactLabelJo
|
|||
import ch.protonmail.android.api.models.room.contacts.ContactLabel
|
||||
import ch.protonmail.android.api.models.room.contacts.ContactsDao
|
||||
import ch.protonmail.android.api.models.room.contacts.ContactsDatabase
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDao
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao
|
||||
import ch.protonmail.android.api.models.room.messages.Label
|
||||
import ch.protonmail.android.api.models.room.messages.Message
|
||||
import ch.protonmail.android.api.models.room.messages.MessageSender
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
*
|
||||
* ProtonMail 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.
|
||||
*
|
||||
*
|
||||
* ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
package ch.protonmail.android.api.models.room.counters
|
||||
package ch.protonmail.android.data.local
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.room.Dao
|
||||
|
@ -24,18 +24,24 @@ import androidx.room.Insert
|
|||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import androidx.room.Transaction
|
||||
|
||||
// TODO remove when we change name of this class to CountersDao and *Factory to *Database
|
||||
typealias CountersDao = CountersDatabase
|
||||
import ch.protonmail.android.data.local.model.COLUMN_COUNTER_ID
|
||||
import ch.protonmail.android.data.local.model.TABLE_TOTAL_LABEL_COUNTERS
|
||||
import ch.protonmail.android.data.local.model.TABLE_TOTAL_LOCATION_COUNTERS
|
||||
import ch.protonmail.android.data.local.model.TABLE_UNREAD_LABEL_COUNTERS
|
||||
import ch.protonmail.android.data.local.model.TABLE_UNREAD_LOCATION_COUNTERS
|
||||
import ch.protonmail.android.data.local.model.TotalLabelCounter
|
||||
import ch.protonmail.android.data.local.model.TotalLocationCounter
|
||||
import ch.protonmail.android.data.local.model.UnreadLabelCounter
|
||||
import ch.protonmail.android.data.local.model.UnreadLocationCounter
|
||||
|
||||
@Dao
|
||||
abstract class CountersDatabase {
|
||||
abstract class CounterDao {
|
||||
|
||||
//region Unread Labels Counters
|
||||
@Query("SELECT * FROM $TABLE_UNREAD_LABEL_COUNTERS")
|
||||
abstract fun findAllUnreadLabels(): LiveData<List<UnreadLabelCounter>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_UNREAD_LABEL_COUNTERS WHERE ${COLUMN_COUNTER_ID}=:labelId")
|
||||
@Query("SELECT * FROM $TABLE_UNREAD_LABEL_COUNTERS WHERE $COLUMN_COUNTER_ID=:labelId")
|
||||
abstract fun findUnreadLabelById(labelId: String): UnreadLabelCounter?
|
||||
|
||||
@Query("DELETE FROM $TABLE_UNREAD_LABEL_COUNTERS")
|
||||
|
@ -46,11 +52,10 @@ abstract class CountersDatabase {
|
|||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
abstract fun insertAllUnreadLabels(unreadLabels: Collection<UnreadLabelCounter>)
|
||||
|
||||
//endregion
|
||||
|
||||
//region Unread Locations Counters
|
||||
@Query("SELECT * FROM $TABLE_UNREAD_LOCATION_COUNTERS WHERE ${COLUMN_COUNTER_ID}=:locationId")
|
||||
@Query("SELECT * FROM $TABLE_UNREAD_LOCATION_COUNTERS WHERE $COLUMN_COUNTER_ID=:locationId")
|
||||
abstract fun findUnreadLocationById(locationId: Int): UnreadLocationCounter?
|
||||
|
||||
@Query("SELECT * FROM $TABLE_UNREAD_LOCATION_COUNTERS")
|
||||
|
@ -68,9 +73,9 @@ abstract class CountersDatabase {
|
|||
|
||||
@Transaction
|
||||
open fun updateUnreadCounters(
|
||||
locations: Collection<UnreadLocationCounter>,
|
||||
labels: Collection<UnreadLabelCounter>
|
||||
) {
|
||||
locations: Collection<UnreadLocationCounter>,
|
||||
labels: Collection<UnreadLabelCounter>
|
||||
) {
|
||||
clearUnreadLocationsTable()
|
||||
clearUnreadLabelsTable()
|
||||
insertAllUnreadLocations(locations)
|
||||
|
@ -81,7 +86,7 @@ abstract class CountersDatabase {
|
|||
@Query("SELECT * FROM $TABLE_TOTAL_LABEL_COUNTERS")
|
||||
abstract fun findAllTotalLabels(): LiveData<List<TotalLabelCounter>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_TOTAL_LABEL_COUNTERS WHERE ${COLUMN_COUNTER_ID}=:labelId")
|
||||
@Query("SELECT * FROM $TABLE_TOTAL_LABEL_COUNTERS WHERE $COLUMN_COUNTER_ID=:labelId")
|
||||
abstract fun findTotalLabelById(labelId: String): TotalLabelCounter?
|
||||
|
||||
@Query("DELETE FROM $TABLE_TOTAL_LABEL_COUNTERS")
|
||||
|
@ -92,7 +97,7 @@ abstract class CountersDatabase {
|
|||
//endregion
|
||||
|
||||
//region Total Location Counters
|
||||
@Query("SELECT * FROM $TABLE_TOTAL_LOCATION_COUNTERS WHERE ${COLUMN_COUNTER_ID}=:locationId")
|
||||
@Query("SELECT * FROM $TABLE_TOTAL_LOCATION_COUNTERS WHERE $COLUMN_COUNTER_ID=:locationId")
|
||||
abstract fun findTotalLocationById(locationId: Int): TotalLocationCounter?
|
||||
|
||||
@Query("SELECT * FROM $TABLE_TOTAL_LOCATION_COUNTERS")
|
||||
|
@ -122,4 +127,5 @@ abstract class CountersDatabase {
|
|||
insertTotalLocations(locations)
|
||||
}
|
||||
//endregion
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* ProtonMail 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.
|
||||
*
|
||||
* ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
package ch.protonmail.android.data.local
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Database
|
||||
import androidx.room.RoomDatabase
|
||||
import ch.protonmail.android.data.local.model.TotalLabelCounter
|
||||
import ch.protonmail.android.data.local.model.TotalLocationCounter
|
||||
import ch.protonmail.android.data.local.model.UnreadLabelCounter
|
||||
import ch.protonmail.android.data.local.model.UnreadLocationCounter
|
||||
import me.proton.core.util.kotlin.unsupported
|
||||
|
||||
@Database(
|
||||
entities = [
|
||||
UnreadLabelCounter::class,
|
||||
UnreadLocationCounter::class,
|
||||
TotalLabelCounter::class,
|
||||
TotalLocationCounter::class],
|
||||
version = 1
|
||||
)
|
||||
abstract class CounterDatabase : RoomDatabase() {
|
||||
|
||||
abstract fun getDao(): CounterDao
|
||||
|
||||
companion object : DatabaseFactory<CounterDatabase>(
|
||||
CounterDatabase::class,
|
||||
"UnreadCountersDatabase.db"
|
||||
) {
|
||||
|
||||
@JvmOverloads
|
||||
@Synchronized
|
||||
@Deprecated(
|
||||
"Use with user Id",
|
||||
ReplaceWith("CounterDatabase.getInstance(context, userId)"),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
fun getInstance(context: Context, username: String? = null): CounterDatabase {
|
||||
unsupported
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
@Deprecated(
|
||||
"Use with user Id",
|
||||
ReplaceWith("CounterDatabase.deleteDatabase(context, userId)"),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
fun deleteDb(context: Context, username: String) {
|
||||
unsupported
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* ProtonMail 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.
|
||||
*
|
||||
* ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
package ch.protonmail.android.data.local
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Base64
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
import ch.protonmail.android.domain.entity.Id
|
||||
import ch.protonmail.android.utils.extensions.app
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
open class DatabaseFactory<T : RoomDatabase>(
|
||||
private val databaseClass: KClass<T>,
|
||||
private val baseDatabaseName: String
|
||||
) {
|
||||
|
||||
private val cache = mutableMapOf<Id, T>()
|
||||
|
||||
@Synchronized
|
||||
fun getInstance(context: Context, userId: Id): T =
|
||||
cache.getOrPut(userId) { buildDatabase(context, userId) }
|
||||
|
||||
@Synchronized
|
||||
fun deleteDatabase(context: Context, userId: Id) {
|
||||
val username = CounterDatabase.usernameForUserId(context, userId)
|
||||
|
||||
val baseFileName = CounterDatabase.databaseName(username)
|
||||
val databaseFile = context.getDatabasePath(baseFileName)
|
||||
val databaseFileShm = context.getDatabasePath("$baseFileName-shm")
|
||||
val databaseFileWal = context.getDatabasePath("$baseFileName-wal")
|
||||
|
||||
if (databaseFile.exists()) databaseFile.delete()
|
||||
if (databaseFileShm.exists()) databaseFileShm.delete()
|
||||
if (databaseFileWal.exists()) databaseFileWal.delete()
|
||||
|
||||
cache.remove(userId)
|
||||
}
|
||||
|
||||
private fun buildDatabase(
|
||||
context: Context,
|
||||
userId: Id
|
||||
): T {
|
||||
val username = usernameForUserId(context, userId)
|
||||
|
||||
val baseFileName = databaseName(username)
|
||||
migrateDatabase(context, baseFileName)
|
||||
|
||||
return Room.databaseBuilder(context.applicationContext, databaseClass.java, baseFileName)
|
||||
.fallbackToDestructiveMigration()
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun migrateDatabase(context: Context, baseFileName: String) {
|
||||
|
||||
context.getDatabasePath(baseFileName)
|
||||
.renameTo(context.getDatabasePath(baseFileName))
|
||||
|
||||
context.getDatabasePath("$baseFileName-shm")
|
||||
.renameTo(context.getDatabasePath("$baseFileName-shm"))
|
||||
|
||||
context.getDatabasePath("$baseFileName-wal")
|
||||
.renameTo(context.getDatabasePath("$baseFileName-wal"))
|
||||
}
|
||||
|
||||
protected fun usernameForUserId(context: Context, userId: Id): String {
|
||||
val user = context.app.userManager.getUserBlocking(userId)
|
||||
return user.name.s
|
||||
}
|
||||
|
||||
protected fun databaseName(username: String) =
|
||||
"${Base64.encodeToString(username.toByteArray(), Base64.NO_WRAP)}-$baseDatabaseName"
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* ProtonMail 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.
|
||||
*
|
||||
* ProtonMail 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 ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
package ch.protonmail.android.data.local.model
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
const val COLUMN_COUNTER_ID = "id"
|
||||
const val COLUMN_COUNTER_COUNT = "count"
|
||||
|
||||
const val TABLE_TOTAL_LABEL_COUNTERS = "totalLabelCounters"
|
||||
const val TABLE_TOTAL_LOCATION_COUNTERS = "totalLocationCounters"
|
||||
const val TABLE_UNREAD_LABEL_COUNTERS = "unreadLabelCounters"
|
||||
const val TABLE_UNREAD_LOCATION_COUNTERS = "unreadLocationCounters"
|
||||
|
||||
open class Counter<K : Any>(
|
||||
|
||||
@PrimaryKey
|
||||
@ColumnInfo(name = COLUMN_COUNTER_ID)
|
||||
val id: K,
|
||||
|
||||
@ColumnInfo(name = COLUMN_COUNTER_COUNT)
|
||||
var count: Int = 0
|
||||
) {
|
||||
|
||||
fun increment() {
|
||||
count += 1
|
||||
}
|
||||
|
||||
fun increment(by: Int) {
|
||||
count += by
|
||||
}
|
||||
|
||||
fun decrement() {
|
||||
if (count > 0) {
|
||||
count -= 1
|
||||
}
|
||||
}
|
||||
|
||||
fun decrement(by: Int) {
|
||||
if (count - by >= 0) {
|
||||
count -= by
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Entity(tableName = TABLE_TOTAL_LABEL_COUNTERS)
|
||||
class TotalLabelCounter(id: String, count: Int = 0) : Counter<String>(id, count)
|
||||
|
||||
@Entity(tableName = TABLE_TOTAL_LOCATION_COUNTERS)
|
||||
class TotalLocationCounter(id: Int, count: Int = 0) : Counter<Int>(id, count)
|
||||
|
||||
@Entity(tableName = TABLE_UNREAD_LABEL_COUNTERS)
|
||||
class UnreadLabelCounter(id: String, count: Int = 0) : Counter<String>(id, count)
|
||||
|
||||
@Entity(tableName = TABLE_UNREAD_LOCATION_COUNTERS)
|
||||
class UnreadLocationCounter(id: Int, count: Int = 0) : Counter<Int>(id, count)
|
|
@ -24,8 +24,8 @@ import ch.protonmail.android.api.models.room.attachmentMetadata.AttachmentMetada
|
|||
import ch.protonmail.android.api.models.room.attachmentMetadata.AttachmentMetadataDatabaseFactory
|
||||
import ch.protonmail.android.api.models.room.contacts.ContactsDatabase
|
||||
import ch.protonmail.android.api.models.room.contacts.ContactsDatabaseFactory
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabase
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabaseFactory
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDatabase
|
||||
import ch.protonmail.android.api.models.room.messages.MessagesDatabase
|
||||
import ch.protonmail.android.api.models.room.messages.MessagesDatabaseFactory
|
||||
import ch.protonmail.android.api.models.room.pendingActions.PendingActionsDatabase
|
||||
|
@ -41,6 +41,29 @@ import javax.inject.Named
|
|||
@InstallIn(SingletonComponent::class)
|
||||
object DatabaseModule {
|
||||
|
||||
@Provides
|
||||
fun provideAttachmentMetadataDatabase(context: Context, userManager: UserManager): AttachmentMetadataDatabase =
|
||||
AttachmentMetadataDatabaseFactory.getInstance(context, userManager.username).getDatabase()
|
||||
|
||||
|
||||
@Provides
|
||||
fun provideContactsDatabaseFactory(context: Context, userManager: UserManager): ContactsDatabaseFactory =
|
||||
ContactsDatabaseFactory.getInstance(context, userManager.username)
|
||||
|
||||
@Provides
|
||||
fun provideContactsDatabase(factory: ContactsDatabaseFactory): ContactsDatabase =
|
||||
factory.getDatabase()
|
||||
|
||||
|
||||
@Provides
|
||||
fun provideCounterDatabase(context: Context, userManager: UserManager): CounterDatabase =
|
||||
CounterDatabase.getInstance(context, userManager.requireCurrentUserId())
|
||||
|
||||
@Provides
|
||||
fun provideCounterDao(database: CounterDatabase): CounterDao =
|
||||
database.getDao()
|
||||
|
||||
|
||||
@Provides
|
||||
@Named("messages_factory")
|
||||
fun provideMessagesDatabaseFactory(context: Context, userManager: UserManager): MessagesDatabaseFactory =
|
||||
|
@ -52,11 +75,16 @@ object DatabaseModule {
|
|||
@Named("messages_factory") messagesDatabaseFactory: MessagesDatabaseFactory
|
||||
): MessagesDatabase = messagesDatabaseFactory.getDatabase()
|
||||
|
||||
|
||||
@Provides
|
||||
@Named("messages_search")
|
||||
fun provideSearchMessagesDatabase(
|
||||
@Named("messages_search_factory") messagesDatabaseFactory: MessagesDatabaseFactory
|
||||
): MessagesDatabase = messagesDatabaseFactory.getDatabase()
|
||||
fun providePendingActionsDatabaseFactory(context: Context, userManager: UserManager) =
|
||||
PendingActionsDatabaseFactory.getInstance(context, userManager.username)
|
||||
|
||||
@Provides
|
||||
fun providePendingActionsDatabase(
|
||||
pendingActionsDatabaseFactory: PendingActionsDatabaseFactory
|
||||
): PendingActionsDatabase = pendingActionsDatabaseFactory.getDatabase()
|
||||
|
||||
|
||||
@Provides
|
||||
@Named("messages_search_factory")
|
||||
|
@ -64,24 +92,9 @@ object DatabaseModule {
|
|||
MessagesDatabaseFactory.getSearchDatabase(context)
|
||||
|
||||
@Provides
|
||||
fun providePendingActionsDatabase(
|
||||
pendingActionsDatabaseFactory: PendingActionsDatabaseFactory
|
||||
): PendingActionsDatabase = pendingActionsDatabaseFactory.getDatabase()
|
||||
|
||||
@Provides
|
||||
fun providePendingActionsDatabaseFactory(context: Context, userManager: UserManager) =
|
||||
PendingActionsDatabaseFactory.getInstance(context, userManager.username)
|
||||
|
||||
@Provides
|
||||
fun provideAttachmentMetadataDatabase(context: Context, userManager: UserManager): AttachmentMetadataDatabase =
|
||||
AttachmentMetadataDatabaseFactory.getInstance(context, userManager.username).getDatabase()
|
||||
|
||||
@Provides
|
||||
fun provideContactsDatabaseFactory(context: Context, userManager: UserManager): ContactsDatabaseFactory =
|
||||
ContactsDatabaseFactory.getInstance(context, userManager.username)
|
||||
|
||||
@Provides
|
||||
fun provideContactsDatabase(factory: ContactsDatabaseFactory): ContactsDatabase =
|
||||
factory.getDatabase()
|
||||
@Named("messages_search")
|
||||
fun provideSearchMessagesDatabase(
|
||||
@Named("messages_search_factory") messagesDatabaseFactory: MessagesDatabaseFactory
|
||||
): MessagesDatabase = messagesDatabaseFactory.getDatabase()
|
||||
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ import com.birbit.android.jobqueue.Params;
|
|||
import java.util.List;
|
||||
|
||||
import ch.protonmail.android.api.models.IDList;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.UnreadLabelCounter;
|
||||
import ch.protonmail.android.api.models.room.messages.Message;
|
||||
import ch.protonmail.android.core.Constants;
|
||||
|
@ -62,9 +62,9 @@ public class ApplyLabelJob extends ProtonMailEndlessJob {
|
|||
}
|
||||
|
||||
private void countUnread(@NonNull ModificationMethod modificationMethod) {
|
||||
final CountersDatabase countersDatabase = CountersDatabaseFactory.Companion
|
||||
final CounterDao counterDao = CounterDatabase.Companion
|
||||
.getInstance(getApplicationContext())
|
||||
.getDatabase();
|
||||
.getDao();
|
||||
int totalUnread = 0;
|
||||
for (String messageId : messageIds) {
|
||||
Message message = getMessageDetailsRepository().findMessageByIdBlocking(messageId);
|
||||
|
@ -76,7 +76,7 @@ public class ApplyLabelJob extends ProtonMailEndlessJob {
|
|||
}
|
||||
}
|
||||
|
||||
UnreadLabelCounter unreadLabelCounter = countersDatabase.findUnreadLabelById(labelId);
|
||||
UnreadLabelCounter unreadLabelCounter = counterDao.findUnreadLabelById(labelId);
|
||||
if (unreadLabelCounter != null) {
|
||||
switch(modificationMethod)
|
||||
{
|
||||
|
@ -87,7 +87,7 @@ public class ApplyLabelJob extends ProtonMailEndlessJob {
|
|||
unreadLabelCounter.decrement(totalUnread);
|
||||
break;
|
||||
}
|
||||
countersDatabase.insertUnreadLabel(unreadLabelCounter);
|
||||
counterDao.insertUnreadLabel(unreadLabelCounter);
|
||||
AppUtil.postEventOnUi(new RefreshDrawerEvent());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,8 @@
|
|||
package ch.protonmail.android.jobs
|
||||
|
||||
import ch.protonmail.android.api.interceptors.UserIdTag
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabaseFactory
|
||||
import ch.protonmail.android.api.models.room.counters.UnreadLabelCounter
|
||||
import ch.protonmail.android.api.models.room.counters.UnreadLocationCounter
|
||||
import ch.protonmail.android.data.local.*
|
||||
import ch.protonmail.android.data.local.model.*
|
||||
import ch.protonmail.android.core.Constants
|
||||
import ch.protonmail.android.core.ProtonMailApplication
|
||||
import ch.protonmail.android.domain.entity.Id
|
||||
|
@ -67,7 +66,7 @@ class FetchMessageCountsJob(
|
|||
}
|
||||
|
||||
val unreadCountersDatabase =
|
||||
CountersDatabaseFactory.getInstance(ProtonMailApplication.getApplication(), username).getDatabase()
|
||||
CounterDatabase.getInstance(ProtonMailApplication.getApplication(), username).getDao()
|
||||
unreadCountersDatabase.updateUnreadCounters(unreadLocationCounters, unreadLabelCounters)
|
||||
|
||||
AppUtil.postEventOnUi(MessageCountsEvent(Status.SUCCESS, countersResponse))
|
||||
|
|
|
@ -27,8 +27,8 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import ch.protonmail.android.api.models.IDList;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.UnreadLocationCounter;
|
||||
import ch.protonmail.android.api.models.room.messages.Message;
|
||||
import ch.protonmail.android.api.models.room.messages.MessagesDatabase;
|
||||
|
@ -53,9 +53,9 @@ public class MoveToFolderJob extends ProtonMailBaseJob {
|
|||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
final CountersDatabase countersDatabase = CountersDatabaseFactory.Companion
|
||||
final CounterDao counterDao = CounterDatabase.Companion
|
||||
.getInstance(getApplicationContext())
|
||||
.getDatabase();
|
||||
.getDao();
|
||||
int totalUnread = 0;
|
||||
for (String id : mMessageIds) {
|
||||
final Message message = getMessageDetailsRepository().findMessageByIdBlocking(id);
|
||||
|
@ -65,19 +65,19 @@ public class MoveToFolderJob extends ProtonMailBaseJob {
|
|||
message.addLabels(Arrays.asList(mLabelId));
|
||||
message.removeLabels(Arrays.asList(String.valueOf(location)));
|
||||
}
|
||||
if (markMessageLocally(countersDatabase, message)) {
|
||||
if (markMessageLocally(counterDao, message)) {
|
||||
totalUnread++;
|
||||
}
|
||||
getMessageDetailsRepository().saveMessageInDB(message);
|
||||
}
|
||||
}
|
||||
|
||||
UnreadLocationCounter unreadLocationCounter = countersDatabase.findUnreadLocationById(Constants.MessageLocationType.SPAM.getMessageLocationTypeValue());
|
||||
UnreadLocationCounter unreadLocationCounter = counterDao.findUnreadLocationById(Constants.MessageLocationType.SPAM.getMessageLocationTypeValue());
|
||||
if (unreadLocationCounter == null) {
|
||||
return;
|
||||
}
|
||||
unreadLocationCounter.increment(totalUnread);
|
||||
countersDatabase.insertUnreadLocation(unreadLocationCounter);
|
||||
counterDao.insertUnreadLocation(unreadLocationCounter);
|
||||
AppUtil.postEventOnUi(new RefreshDrawerEvent());
|
||||
}
|
||||
|
||||
|
@ -87,13 +87,13 @@ public class MoveToFolderJob extends ProtonMailBaseJob {
|
|||
getApi().labelMessages(body);
|
||||
}
|
||||
|
||||
private boolean markMessageLocally(CountersDatabase countersDatabase, Message message) {
|
||||
private boolean markMessageLocally(CounterDao counterDao, Message message) {
|
||||
boolean unreadIncrease = false;
|
||||
if (!message.isRead()) {
|
||||
UnreadLocationCounter unreadLocationCounter = countersDatabase.findUnreadLocationById(message.getLocation());
|
||||
UnreadLocationCounter unreadLocationCounter = counterDao.findUnreadLocationById(message.getLocation());
|
||||
if (unreadLocationCounter != null) {
|
||||
unreadLocationCounter.decrement();
|
||||
countersDatabase.insertUnreadLocation(unreadLocationCounter);
|
||||
counterDao.insertUnreadLocation(unreadLocationCounter);
|
||||
}
|
||||
unreadIncrease = true;
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import ch.protonmail.android.api.models.IDList;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.UnreadLocationCounter;
|
||||
import ch.protonmail.android.api.models.room.messages.Message;
|
||||
import ch.protonmail.android.core.Constants;
|
||||
|
@ -53,14 +53,14 @@ public class PostArchiveJob extends ProtonMailCounterJob {
|
|||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
final CountersDatabase countersDatabase = CountersDatabaseFactory.Companion
|
||||
final CounterDao counterDao = CounterDatabase.Companion
|
||||
.getInstance(getApplicationContext())
|
||||
.getDatabase();
|
||||
.getDao();
|
||||
int totalUnread = 0;
|
||||
for (String id : mMessageIds) {
|
||||
final Message message = getMessageDetailsRepository().findMessageByIdBlocking(id);
|
||||
if (message != null) {
|
||||
if (markMessageLocally(countersDatabase, message)) {
|
||||
if (markMessageLocally(counterDao, message)) {
|
||||
totalUnread++;
|
||||
}
|
||||
if (mFolderIds != null) {
|
||||
|
@ -74,23 +74,23 @@ public class PostArchiveJob extends ProtonMailCounterJob {
|
|||
}
|
||||
}
|
||||
|
||||
UnreadLocationCounter unreadLocationCounter = countersDatabase.findUnreadLocationById(Constants.MessageLocationType.ARCHIVE.getMessageLocationTypeValue());
|
||||
UnreadLocationCounter unreadLocationCounter = counterDao.findUnreadLocationById(Constants.MessageLocationType.ARCHIVE.getMessageLocationTypeValue());
|
||||
if (unreadLocationCounter == null) {
|
||||
return;
|
||||
}
|
||||
unreadLocationCounter.increment(totalUnread);
|
||||
countersDatabase.insertUnreadLocation(unreadLocationCounter);
|
||||
counterDao.insertUnreadLocation(unreadLocationCounter);
|
||||
AppUtil.postEventOnUi(new RefreshDrawerEvent());
|
||||
}
|
||||
|
||||
private boolean markMessageLocally(CountersDatabase countersDatabase,
|
||||
private boolean markMessageLocally(CounterDao counterDao,
|
||||
Message message) {
|
||||
boolean unreadIncrease = false;
|
||||
if (!message.isRead()) {
|
||||
UnreadLocationCounter unreadLocationCounter = countersDatabase.findUnreadLocationById(message.getLocation());
|
||||
UnreadLocationCounter unreadLocationCounter = counterDao.findUnreadLocationById(message.getLocation());
|
||||
if (unreadLocationCounter != null) {
|
||||
unreadLocationCounter.decrement();
|
||||
countersDatabase.insertUnreadLocation(unreadLocationCounter);
|
||||
counterDao.insertUnreadLocation(unreadLocationCounter);
|
||||
}
|
||||
unreadIncrease = true;
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import ch.protonmail.android.api.models.IDList;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.UnreadLocationCounter;
|
||||
import ch.protonmail.android.api.models.room.messages.Message;
|
||||
import ch.protonmail.android.core.Constants;
|
||||
|
@ -53,18 +53,18 @@ public class PostInboxJob extends ProtonMailCounterJob {
|
|||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
final CountersDatabase countersDatabase = CountersDatabaseFactory.Companion.getInstance(
|
||||
getApplicationContext()).getDatabase();
|
||||
final CounterDao counterDao = CounterDatabase.Companion.getInstance(
|
||||
getApplicationContext()).getDao();
|
||||
|
||||
int totalUnread = 0;
|
||||
for (String id : mMessageIds) {
|
||||
final Message message = getMessageDetailsRepository().findMessageByIdBlocking(id);
|
||||
if (message != null) {
|
||||
if (!message.isRead()) {
|
||||
UnreadLocationCounter unreadLocationCounter = countersDatabase.findUnreadLocationById(message.getLocation());
|
||||
UnreadLocationCounter unreadLocationCounter = counterDao.findUnreadLocationById(message.getLocation());
|
||||
if (unreadLocationCounter != null) {
|
||||
unreadLocationCounter.decrement();
|
||||
countersDatabase.insertUnreadLocation(unreadLocationCounter);
|
||||
counterDao.insertUnreadLocation(unreadLocationCounter);
|
||||
}
|
||||
totalUnread++;
|
||||
}
|
||||
|
@ -80,12 +80,12 @@ public class PostInboxJob extends ProtonMailCounterJob {
|
|||
}
|
||||
}
|
||||
|
||||
UnreadLocationCounter unreadLocationCounter = countersDatabase.findUnreadLocationById(Constants.MessageLocationType.INBOX.getMessageLocationTypeValue());
|
||||
UnreadLocationCounter unreadLocationCounter = counterDao.findUnreadLocationById(Constants.MessageLocationType.INBOX.getMessageLocationTypeValue());
|
||||
if (unreadLocationCounter == null) {
|
||||
return;
|
||||
}
|
||||
unreadLocationCounter.increment(totalUnread);
|
||||
countersDatabase.insertUnreadLocation(unreadLocationCounter);
|
||||
counterDao.insertUnreadLocation(unreadLocationCounter);
|
||||
AppUtil.postEventOnUi(new RefreshDrawerEvent());
|
||||
}
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import ch.protonmail.android.api.models.IDList;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.UnreadLocationCounter;
|
||||
import ch.protonmail.android.api.models.room.messages.Message;
|
||||
import ch.protonmail.android.core.Constants;
|
||||
|
@ -43,9 +43,9 @@ public class PostReadJob extends ProtonMailEndlessJob {
|
|||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
final CountersDatabase countersDatabase = CountersDatabaseFactory.Companion
|
||||
final CounterDao counterDao = CounterDatabase.Companion
|
||||
.getInstance(getApplicationContext())
|
||||
.getDatabase();
|
||||
.getDao();
|
||||
Constants.MessageLocationType messageLocation = Constants.MessageLocationType.INVALID;
|
||||
boolean starred = false;
|
||||
for (String id : mMessageIds) {
|
||||
|
@ -59,7 +59,7 @@ public class PostReadJob extends ProtonMailEndlessJob {
|
|||
}
|
||||
|
||||
if (messageLocation != Constants.MessageLocationType.INVALID) {
|
||||
UnreadLocationCounter unreadLocationCounter = countersDatabase.findUnreadLocationById(messageLocation.getMessageLocationTypeValue());
|
||||
UnreadLocationCounter unreadLocationCounter = counterDao.findUnreadLocationById(messageLocation.getMessageLocationTypeValue());
|
||||
if (unreadLocationCounter == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -67,13 +67,13 @@ public class PostReadJob extends ProtonMailEndlessJob {
|
|||
List<UnreadLocationCounter> countersToUpdate = new ArrayList<>();
|
||||
countersToUpdate.add(unreadLocationCounter);
|
||||
if (starred) {
|
||||
UnreadLocationCounter starredUnread = countersDatabase.findUnreadLocationById(Constants.MessageLocationType.STARRED.getMessageLocationTypeValue());
|
||||
UnreadLocationCounter starredUnread = counterDao.findUnreadLocationById(Constants.MessageLocationType.STARRED.getMessageLocationTypeValue());
|
||||
if (starredUnread != null) {
|
||||
starredUnread.decrement();
|
||||
countersToUpdate.add(starredUnread);
|
||||
}
|
||||
}
|
||||
countersDatabase.insertAllUnreadLocations(countersToUpdate);
|
||||
counterDao.insertAllUnreadLocations(countersToUpdate);
|
||||
}
|
||||
AppUtil.postEventOnUi(new RefreshDrawerEvent());
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import ch.protonmail.android.api.models.IDList;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.UnreadLocationCounter;
|
||||
import ch.protonmail.android.api.models.room.messages.Message;
|
||||
import ch.protonmail.android.core.Constants;
|
||||
|
@ -53,14 +53,14 @@ public class PostSpamJob extends ProtonMailCounterJob {
|
|||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
final CountersDatabase countersDatabase = CountersDatabaseFactory.Companion
|
||||
final CounterDao counterDao = CounterDatabase.Companion
|
||||
.getInstance(getApplicationContext())
|
||||
.getDatabase();
|
||||
.getDao();
|
||||
int totalUnread = 0;
|
||||
for (String id : mMessageIds) {
|
||||
final Message message = getMessageDetailsRepository().findMessageByIdBlocking(id);
|
||||
if (message != null) {
|
||||
if (markMessageLocally(countersDatabase,message)) {
|
||||
if (markMessageLocally(counterDao,message)) {
|
||||
totalUnread++;
|
||||
}
|
||||
if (!TextUtils.isEmpty(mFolderId)) {
|
||||
|
@ -69,22 +69,22 @@ public class PostSpamJob extends ProtonMailCounterJob {
|
|||
}
|
||||
}
|
||||
|
||||
UnreadLocationCounter unreadLocationCounter = countersDatabase.findUnreadLocationById(Constants.MessageLocationType.SPAM.getMessageLocationTypeValue());
|
||||
UnreadLocationCounter unreadLocationCounter = counterDao.findUnreadLocationById(Constants.MessageLocationType.SPAM.getMessageLocationTypeValue());
|
||||
if (unreadLocationCounter == null) {
|
||||
return;
|
||||
}
|
||||
unreadLocationCounter.increment(totalUnread);
|
||||
countersDatabase.insertUnreadLocation(unreadLocationCounter);
|
||||
counterDao.insertUnreadLocation(unreadLocationCounter);
|
||||
AppUtil.postEventOnUi(new RefreshDrawerEvent());
|
||||
}
|
||||
|
||||
private boolean markMessageLocally(CountersDatabase countersDatabase, Message message) {
|
||||
private boolean markMessageLocally(CounterDao counterDao, Message message) {
|
||||
boolean unreadIncrease = false;
|
||||
if (!message.isRead()) {
|
||||
UnreadLocationCounter unreadLocationCounter = countersDatabase.findUnreadLocationById(message.getLocation());
|
||||
UnreadLocationCounter unreadLocationCounter = counterDao.findUnreadLocationById(message.getLocation());
|
||||
if (unreadLocationCounter != null) {
|
||||
unreadLocationCounter.decrement();
|
||||
countersDatabase.insertUnreadLocation(unreadLocationCounter);
|
||||
counterDao.insertUnreadLocation(unreadLocationCounter);
|
||||
}
|
||||
unreadIncrease = true;
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import ch.protonmail.android.api.models.IDList;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.UnreadLocationCounter;
|
||||
import ch.protonmail.android.api.models.room.messages.Message;
|
||||
import ch.protonmail.android.core.Constants;
|
||||
|
@ -47,19 +47,19 @@ public class PostTrashJob extends ProtonMailCounterJob {
|
|||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
final CountersDatabase countersDatabase = CountersDatabaseFactory.Companion
|
||||
final CounterDao counterDao = CounterDatabase.Companion
|
||||
.getInstance(getApplicationContext())
|
||||
.getDatabase();
|
||||
.getDao();
|
||||
|
||||
int totalUnread = 0;
|
||||
for (String id : mMessageIds) {
|
||||
Message message = getMessageDetailsRepository().findMessageByIdBlocking(id);
|
||||
if (message != null) {
|
||||
if (!message.isRead()) {
|
||||
UnreadLocationCounter unreadLocationCounter = countersDatabase.findUnreadLocationById(message.getLocation());
|
||||
UnreadLocationCounter unreadLocationCounter = counterDao.findUnreadLocationById(message.getLocation());
|
||||
if (unreadLocationCounter != null) {
|
||||
unreadLocationCounter.decrement();
|
||||
countersDatabase.insertUnreadLocation(unreadLocationCounter);
|
||||
counterDao.insertUnreadLocation(unreadLocationCounter);
|
||||
}
|
||||
totalUnread++;
|
||||
}
|
||||
|
@ -78,12 +78,12 @@ public class PostTrashJob extends ProtonMailCounterJob {
|
|||
|
||||
}
|
||||
}
|
||||
UnreadLocationCounter unreadLocationCounter = countersDatabase.findUnreadLocationById(Constants.MessageLocationType.TRASH.getMessageLocationTypeValue());
|
||||
UnreadLocationCounter unreadLocationCounter = counterDao.findUnreadLocationById(Constants.MessageLocationType.TRASH.getMessageLocationTypeValue());
|
||||
if (unreadLocationCounter == null) {
|
||||
return;
|
||||
}
|
||||
unreadLocationCounter.increment(totalUnread);
|
||||
countersDatabase.insertUnreadLocation(unreadLocationCounter);
|
||||
counterDao.insertUnreadLocation(unreadLocationCounter);
|
||||
AppUtil.postEventOnUi(new RefreshDrawerEvent());
|
||||
}
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import ch.protonmail.android.api.models.IDList;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.UnreadLocationCounter;
|
||||
import ch.protonmail.android.api.models.room.messages.Message;
|
||||
import ch.protonmail.android.core.Constants;
|
||||
|
@ -57,18 +57,18 @@ public class PostTrashJobV2 extends ProtonMailCounterJob {
|
|||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
final CountersDatabase countersDatabase = CountersDatabaseFactory.Companion
|
||||
final CounterDao counterDao = CounterDatabase.Companion
|
||||
.getInstance(getApplicationContext())
|
||||
.getDatabase();
|
||||
.getDao();
|
||||
int totalUnread = 0;
|
||||
for (String id : mMessageIds) {
|
||||
Message message = getMessageDetailsRepository().findMessageByIdBlocking(id);
|
||||
if (message != null) {
|
||||
if (!message.isRead()) {
|
||||
UnreadLocationCounter unreadLocationCounter = countersDatabase.findUnreadLocationById(message.getLocation());
|
||||
UnreadLocationCounter unreadLocationCounter = counterDao.findUnreadLocationById(message.getLocation());
|
||||
if (unreadLocationCounter != null) {
|
||||
unreadLocationCounter.decrement();
|
||||
countersDatabase.insertUnreadLocation(unreadLocationCounter);
|
||||
counterDao.insertUnreadLocation(unreadLocationCounter);
|
||||
}
|
||||
totalUnread++;
|
||||
}
|
||||
|
@ -94,12 +94,12 @@ public class PostTrashJobV2 extends ProtonMailCounterJob {
|
|||
}
|
||||
}
|
||||
|
||||
UnreadLocationCounter unreadLocationCounter = countersDatabase.findUnreadLocationById(Constants.MessageLocationType.TRASH.getMessageLocationTypeValue());
|
||||
UnreadLocationCounter unreadLocationCounter = counterDao.findUnreadLocationById(Constants.MessageLocationType.TRASH.getMessageLocationTypeValue());
|
||||
if (unreadLocationCounter == null) {
|
||||
return;
|
||||
}
|
||||
unreadLocationCounter.increment(totalUnread);
|
||||
countersDatabase.insertUnreadLocation(unreadLocationCounter);
|
||||
counterDao.insertUnreadLocation(unreadLocationCounter);
|
||||
|
||||
AppUtil.postEventOnUi(new RefreshDrawerEvent());
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import ch.protonmail.android.api.models.IDList;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.UnreadLocationCounter;
|
||||
import ch.protonmail.android.api.models.room.messages.Message;
|
||||
import ch.protonmail.android.core.Constants;
|
||||
|
@ -43,9 +43,9 @@ public class PostUnreadJob extends ProtonMailEndlessJob {
|
|||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
final CountersDatabase countersDatabase = CountersDatabaseFactory.Companion
|
||||
final CounterDao counterDao = CounterDatabase.Companion
|
||||
.getInstance(getApplicationContext())
|
||||
.getDatabase();
|
||||
.getDao();
|
||||
Constants.MessageLocationType messageLocation = Constants.MessageLocationType.INVALID;
|
||||
boolean starred = false;
|
||||
for (String id : mMessageIds) {
|
||||
|
@ -59,7 +59,7 @@ public class PostUnreadJob extends ProtonMailEndlessJob {
|
|||
}
|
||||
|
||||
if (messageLocation != Constants.MessageLocationType.INVALID) {
|
||||
UnreadLocationCounter unreadLocationCounter = countersDatabase.findUnreadLocationById(messageLocation.getMessageLocationTypeValue());
|
||||
UnreadLocationCounter unreadLocationCounter = counterDao.findUnreadLocationById(messageLocation.getMessageLocationTypeValue());
|
||||
if (unreadLocationCounter == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -67,13 +67,13 @@ public class PostUnreadJob extends ProtonMailEndlessJob {
|
|||
List<UnreadLocationCounter> countersToUpdate = new ArrayList<>();
|
||||
countersToUpdate.add(unreadLocationCounter);
|
||||
if (starred) {
|
||||
UnreadLocationCounter starredUnread = countersDatabase.findUnreadLocationById(Constants.MessageLocationType.STARRED.getMessageLocationTypeValue());
|
||||
UnreadLocationCounter starredUnread = counterDao.findUnreadLocationById(Constants.MessageLocationType.STARRED.getMessageLocationTypeValue());
|
||||
if (starredUnread != null) {
|
||||
starredUnread.increment();
|
||||
countersToUpdate.add(starredUnread);
|
||||
}
|
||||
}
|
||||
countersDatabase.insertAllUnreadLocations(countersToUpdate);
|
||||
counterDao.insertAllUnreadLocations(countersToUpdate);
|
||||
}
|
||||
AppUtil.postEventOnUi(new RefreshDrawerEvent());
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import ch.protonmail.android.api.models.IDList;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.UnreadLocationCounter;
|
||||
import ch.protonmail.android.api.models.room.messages.Message;
|
||||
import ch.protonmail.android.core.Constants;
|
||||
|
@ -43,7 +43,7 @@ public class PostUnstarJob extends ProtonMailEndlessJob {
|
|||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
final CountersDatabase countersDatabase = CountersDatabaseFactory.Companion.getInstance(getApplicationContext()).getDatabase();
|
||||
final CounterDao counterDao = CounterDatabase.Companion.getInstance(getApplicationContext()).getDao();
|
||||
|
||||
for (String id : mMessageIds) {
|
||||
getMessageDetailsRepository().updateStarred(id, false);
|
||||
|
@ -57,7 +57,7 @@ public class PostUnstarJob extends ProtonMailEndlessJob {
|
|||
}
|
||||
|
||||
if (messageLocation != Constants.MessageLocationType.INVALID && isUnread) {
|
||||
UnreadLocationCounter unreadLocationCounter = countersDatabase.findUnreadLocationById(messageLocation.getMessageLocationTypeValue());
|
||||
UnreadLocationCounter unreadLocationCounter = counterDao.findUnreadLocationById(messageLocation.getMessageLocationTypeValue());
|
||||
if (unreadLocationCounter == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -65,13 +65,13 @@ public class PostUnstarJob extends ProtonMailEndlessJob {
|
|||
List<UnreadLocationCounter> countersToUpdate = new ArrayList<>();
|
||||
countersToUpdate.add(unreadLocationCounter);
|
||||
|
||||
UnreadLocationCounter starredUnread = countersDatabase.findUnreadLocationById(Constants.MessageLocationType.STARRED.getMessageLocationTypeValue());
|
||||
UnreadLocationCounter starredUnread = counterDao.findUnreadLocationById(Constants.MessageLocationType.STARRED.getMessageLocationTypeValue());
|
||||
if (starredUnread != null) {
|
||||
starredUnread.increment();
|
||||
countersToUpdate.add(starredUnread);
|
||||
}
|
||||
|
||||
countersDatabase.insertAllUnreadLocations(countersToUpdate);
|
||||
counterDao.insertAllUnreadLocations(countersToUpdate);
|
||||
}
|
||||
AppUtil.postEventOnUi(new RefreshDrawerEvent());
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ import com.birbit.android.jobqueue.Params;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.UnreadLocationCounter;
|
||||
import ch.protonmail.android.api.models.room.messages.Message;
|
||||
import ch.protonmail.android.core.Constants;
|
||||
|
@ -47,8 +47,8 @@ public abstract class ProtonMailCounterJob extends ProtonMailEndlessJob {
|
|||
|
||||
@Override
|
||||
protected void onProtonCancel(int cancelReason, @Nullable Throwable throwable) {
|
||||
final CountersDatabase countersDatabase = CountersDatabaseFactory.Companion.getInstance(
|
||||
getApplicationContext()).getDatabase();
|
||||
final CounterDao counterDao = CounterDatabase.Companion.getInstance(
|
||||
getApplicationContext()).getDao();
|
||||
|
||||
int totalUnread = 0;
|
||||
List<String> messageIds = getMessageIds();
|
||||
|
@ -56,22 +56,22 @@ public abstract class ProtonMailCounterJob extends ProtonMailEndlessJob {
|
|||
final Message message = getMessageDetailsRepository().findMessageByIdBlocking(id);
|
||||
if (message != null) {
|
||||
if ( !message.isRead() ) {
|
||||
UnreadLocationCounter unreadLocationCounter = countersDatabase.findUnreadLocationById(message.getLocation());
|
||||
UnreadLocationCounter unreadLocationCounter = counterDao.findUnreadLocationById(message.getLocation());
|
||||
if (unreadLocationCounter != null) {
|
||||
unreadLocationCounter.increment();
|
||||
countersDatabase.insertUnreadLocation(unreadLocationCounter);
|
||||
counterDao.insertUnreadLocation(unreadLocationCounter);
|
||||
}
|
||||
totalUnread++;
|
||||
}
|
||||
}
|
||||
}
|
||||
UnreadLocationCounter unreadLocationCounter = countersDatabase.findUnreadLocationById(getMessageLocation().getMessageLocationTypeValue());
|
||||
UnreadLocationCounter unreadLocationCounter = counterDao.findUnreadLocationById(getMessageLocation().getMessageLocationTypeValue());
|
||||
|
||||
if (unreadLocationCounter == null) {
|
||||
return;
|
||||
}
|
||||
unreadLocationCounter.decrement(totalUnread);
|
||||
countersDatabase.insertUnreadLocation(unreadLocationCounter);
|
||||
counterDao.insertUnreadLocation(unreadLocationCounter);
|
||||
AppUtil.postEventOnUi(new RefreshDrawerEvent());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ import com.birbit.android.jobqueue.Params;
|
|||
import java.util.List;
|
||||
|
||||
import ch.protonmail.android.api.models.IDList;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.UnreadLabelCounter;
|
||||
import ch.protonmail.android.api.models.room.messages.Message;
|
||||
import ch.protonmail.android.core.Constants;
|
||||
|
@ -46,9 +46,9 @@ public class RemoveLabelJob extends ProtonMailBaseJob {
|
|||
|
||||
@Override
|
||||
protected void onProtonCancel(int cancelReason, @Nullable Throwable throwable) {
|
||||
final CountersDatabase countersDatabase = CountersDatabaseFactory.Companion
|
||||
final CounterDao counterDao = CounterDatabase.Companion
|
||||
.getInstance(getApplicationContext())
|
||||
.getDatabase();
|
||||
.getDao();
|
||||
int totalUnread = 0;
|
||||
for (String messageId : messageIds) {
|
||||
Message message = getMessageDetailsRepository().findMessageByIdBlocking(messageId);
|
||||
|
@ -60,19 +60,19 @@ public class RemoveLabelJob extends ProtonMailBaseJob {
|
|||
}
|
||||
}
|
||||
|
||||
UnreadLabelCounter unreadLabelCounter = countersDatabase.findUnreadLabelById(labelId);
|
||||
UnreadLabelCounter unreadLabelCounter = counterDao.findUnreadLabelById(labelId);
|
||||
if (unreadLabelCounter == null) {
|
||||
return;
|
||||
}
|
||||
unreadLabelCounter.increment(totalUnread);
|
||||
countersDatabase.insertUnreadLabel(unreadLabelCounter);
|
||||
counterDao.insertUnreadLabel(unreadLabelCounter);
|
||||
AppUtil.postEventOnUi(new RefreshDrawerEvent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
final CountersDatabase countersDatabase = CountersDatabaseFactory.Companion.getInstance(
|
||||
getApplicationContext()).getDatabase();
|
||||
final CounterDao counterDao = CounterDatabase.Companion.getInstance(
|
||||
getApplicationContext()).getDao();
|
||||
|
||||
int totalUnread = 0;
|
||||
for (String messageId : messageIds) {
|
||||
|
@ -85,12 +85,12 @@ public class RemoveLabelJob extends ProtonMailBaseJob {
|
|||
}
|
||||
}
|
||||
|
||||
UnreadLabelCounter unreadLabelCounter = countersDatabase.findUnreadLabelById(labelId);
|
||||
UnreadLabelCounter unreadLabelCounter = counterDao.findUnreadLabelById(labelId);
|
||||
if (unreadLabelCounter == null) {
|
||||
return;
|
||||
}
|
||||
unreadLabelCounter.decrement(totalUnread);
|
||||
countersDatabase.insertUnreadLabel(unreadLabelCounter);
|
||||
counterDao.insertUnreadLabel(unreadLabelCounter);
|
||||
AppUtil.postEventOnUi(new RefreshDrawerEvent());
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ import ch.protonmail.android.api.models.room.attachmentMetadata.AttachmentMetada
|
|||
import ch.protonmail.android.api.models.room.attachmentMetadata.AttachmentMetadataDatabase;
|
||||
import ch.protonmail.android.api.models.room.attachmentMetadata.AttachmentMetadataDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.contacts.ContactsDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDatabase;
|
||||
import ch.protonmail.android.api.models.room.messages.Message;
|
||||
import ch.protonmail.android.api.models.room.messages.MessagesDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.notifications.NotificationsDatabaseFactory;
|
||||
|
@ -118,7 +118,7 @@ public class AttachmentClearingService extends ProtonJobIntentService {
|
|||
ContactsDatabaseFactory.Companion.deleteDb(context, username);
|
||||
MessagesDatabaseFactory.Companion.deleteDb(context, username);
|
||||
NotificationsDatabaseFactory.Companion.deleteDb(context, username);
|
||||
CountersDatabaseFactory.Companion.deleteDb(context, username);
|
||||
CounterDatabase.Companion.deleteDb(context, username);
|
||||
AttachmentMetadataDatabaseFactory.Companion.deleteDb(context, username);
|
||||
PendingActionsDatabaseFactory.Companion.deleteDb(context, username);
|
||||
}
|
||||
|
|
|
@ -50,8 +50,8 @@ import ch.protonmail.android.api.models.room.attachmentMetadata.AttachmentMetada
|
|||
import ch.protonmail.android.api.models.room.attachmentMetadata.AttachmentMetadataDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.contacts.ContactsDatabase;
|
||||
import ch.protonmail.android.api.models.room.contacts.ContactsDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabase;
|
||||
import ch.protonmail.android.api.models.room.counters.CountersDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDao;
|
||||
import ch.protonmail.android.api.models.room.counters.CounterDatabase;
|
||||
import ch.protonmail.android.api.models.room.messages.MessagesDatabase;
|
||||
import ch.protonmail.android.api.models.room.messages.MessagesDatabaseFactory;
|
||||
import ch.protonmail.android.api.models.room.notifications.NotificationsDatabase;
|
||||
|
@ -172,7 +172,7 @@ public class AppUtil {
|
|||
MessagesDatabaseFactory.Companion.getInstance(context, username).getDatabase(),
|
||||
MessagesDatabaseFactory.Companion.getSearchDatabase(context).getDatabase(),
|
||||
NotificationsDatabaseFactory.Companion.getInstance(context, username).getDatabase(),
|
||||
CountersDatabaseFactory.Companion.getInstance(context, username).getDatabase(),
|
||||
CounterDatabase.Companion.getInstance(context, username).getDao(),
|
||||
AttachmentMetadataDatabaseFactory.Companion.getInstance(context, username).getDatabase(),
|
||||
PendingActionsDatabaseFactory.Companion.getInstance(context, username).getDatabase(),
|
||||
clearDoneListener, clearContacts);
|
||||
|
@ -181,7 +181,7 @@ public class AppUtil {
|
|||
MessagesDatabaseFactory.Companion.getInstance(context).getDatabase(),
|
||||
MessagesDatabaseFactory.Companion.getSearchDatabase(context).getDatabase(),
|
||||
NotificationsDatabaseFactory.Companion.getInstance(context).getDatabase(),
|
||||
CountersDatabaseFactory.Companion.getInstance(context).getDatabase(),
|
||||
CounterDatabase.Companion.getInstance(context).getDao(),
|
||||
AttachmentMetadataDatabaseFactory.Companion.getInstance(context).getDatabase(),
|
||||
PendingActionsDatabaseFactory.Companion.getInstance(context).getDatabase(),
|
||||
clearDoneListener, clearContacts);
|
||||
|
@ -324,12 +324,12 @@ public class AppUtil {
|
|||
final MessagesDatabase messagesDatabase,
|
||||
final MessagesDatabase searchDatabase,
|
||||
final NotificationsDatabase notificationsDatabase,
|
||||
final CountersDatabase countersDatabase,
|
||||
final CounterDao counterDao,
|
||||
final AttachmentMetadataDatabase attachmentMetadataDatabase,
|
||||
final PendingActionsDatabase pendingActionsDatabase,
|
||||
final boolean clearContacts
|
||||
) {
|
||||
clearStorage(contactsDatabase, messagesDatabase, searchDatabase, notificationsDatabase, countersDatabase,
|
||||
clearStorage(contactsDatabase, messagesDatabase, searchDatabase, notificationsDatabase, counterDao,
|
||||
attachmentMetadataDatabase, pendingActionsDatabase, null, clearContacts);
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ public class AppUtil {
|
|||
final MessagesDatabase messagesDatabase,
|
||||
final MessagesDatabase searchDatabase,
|
||||
final NotificationsDatabase notificationsDatabase,
|
||||
final CountersDatabase countersDatabase,
|
||||
final CounterDao counterDao,
|
||||
final AttachmentMetadataDatabase attachmentMetadataDatabase,
|
||||
final PendingActionsDatabase pendingActionsDatabase,
|
||||
final IDBClearDone clearDone,
|
||||
|
@ -364,10 +364,10 @@ public class AppUtil {
|
|||
searchDatabase.clearAttachmentsCache();
|
||||
searchDatabase.clearLabelsCache();
|
||||
notificationsDatabase.clearNotificationCache();
|
||||
countersDatabase.clearUnreadLocationsTable();
|
||||
countersDatabase.clearUnreadLabelsTable();
|
||||
countersDatabase.clearTotalLocationsTable();
|
||||
countersDatabase.clearTotalLabelsTable();
|
||||
counterDao.clearUnreadLocationsTable();
|
||||
counterDao.clearUnreadLabelsTable();
|
||||
counterDao.clearTotalLocationsTable();
|
||||
counterDao.clearTotalLabelsTable();
|
||||
attachmentMetadataDatabase.clearAttachmentMetadataCache();
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue