Skip to content

Added migration to Paging v3 #1808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion FlowCrypt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ android {
kotlinOptions {
jvmTarget = "11"
//need for ACRA, maybe will be deleted in the upcoming updates
freeCompilerArgs = ['-Xjvm-default=enable']
freeCompilerArgs += ['-Xjvm-default=enable']
freeCompilerArgs += ["-Xopt-in=kotlin.RequiresOptIn"]
}

packagingOptions {
Expand Down Expand Up @@ -382,6 +383,7 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.0-rc01'
implementation 'androidx.room:room-runtime:2.4.2'
implementation 'androidx.room:room-ktx:2.4.2'
implementation 'androidx.room:room-paging:2.4.2'
implementation 'androidx.paging:paging-runtime-ktx:3.1.1'
implementation 'androidx.preference:preference-ktx:1.2.0'
implementation 'androidx.core:core-ktx:1.7.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class FoldersManager constructor(val account: String) {
sentFolder?.let { return it }

for (localFolder in allFolders) {
if (localFolder.fullName.toUpperCase(Locale.US) in arrayOf("INBOX/SENT", "SENT")) {
if (localFolder.fullName.uppercase(Locale.US) in arrayOf("INBOX/SENT", "SENT")) {
sentFolder = localFolder
}
}
Expand Down Expand Up @@ -404,8 +404,8 @@ class FoldersManager constructor(val account: String) {
* @return [FolderType].
*/
fun getFolderType(localFolder: LocalFolder?): FolderType? {
val folderTypes = FolderType.values()
val attributes = localFolder?.attributes ?: emptyList()
val folderTypes = FolderType.values()

for (attribute in attributes) {
for (folderType in folderTypes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class JavaEmailConstants {

const val DEFAULT_FETCH_BUFFER = 1024 * 1024
const val ATTACHMENTS_FETCH_BUFFER = 1024 * 256
const val COUNT_OF_LOADED_EMAILS_BY_STEP = 45

/*IMAP*/
const val PROPERTY_NAME_MAIL_IMAP_SSL_ENABLE = "mail.imap.ssl.enable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ class GmailApiHelper {
"CATEGORY_PROMOTIONS",
"CATEGORY_SOCIAL"
)
private const val COUNT_OF_LOADED_EMAILS_BY_STEP =
JavaEmailConstants.COUNT_OF_LOADED_EMAILS_BY_STEP.toLong()

private val FULL_INFO_WITHOUT_DATA = listOf(
"id",
Expand Down Expand Up @@ -220,16 +218,19 @@ class GmailApiHelper {
}

suspend fun loadMsgsBaseInfo(
context: Context, accountEntity: AccountEntity, localFolder:
LocalFolder, nextPageToken: String? = null
context: Context,
accountEntity: AccountEntity,
localFolder: LocalFolder,
maxResults: Long,
nextPageToken: String? = null
): ListMessagesResponse = withContext(Dispatchers.IO) {
val gmailApiService = generateGmailApiService(context, accountEntity)
val request = gmailApiService
.users()
.messages()
.list(DEFAULT_USER_ID)
.setPageToken(nextPageToken)
.setMaxResults(COUNT_OF_LOADED_EMAILS_BY_STEP)
.setMaxResults(maxResults)

if (!localFolder.isAll()) {
request.labelIds = listOf(localFolder.fullName)
Expand Down Expand Up @@ -583,8 +584,11 @@ class GmailApiHelper {
}

suspend fun loadMsgsBaseInfoUsingSearch(
context: Context, accountEntity: AccountEntity,
localFolder: LocalFolder, nextPageToken: String? = null
context: Context,
accountEntity: AccountEntity,
localFolder: LocalFolder,
maxResults: Long,
nextPageToken: String? = null
):
ListMessagesResponse = withContext(Dispatchers.IO) {

Expand All @@ -601,7 +605,7 @@ class GmailApiHelper {
) as? GmailRawSearchTerm)?.pattern
)
.setPageToken(nextPageToken)
.setMaxResults(COUNT_OF_LOADED_EMAILS_BY_STEP)
.setMaxResults(maxResults)
return@withContext list.execute()
}

Expand Down
Loading