mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-03-01 22:22:15 +00:00
Fix various UI bugs for chat folders.
This commit is contained in:
@@ -62,7 +62,7 @@ class ChatsSettingsFragment : DSLSettingsFragment(R.string.preferences_chats__ch
|
||||
|
||||
sectionHeaderPref(R.string.ChatsSettingsFragment__chat_folders)
|
||||
|
||||
if (state.folderCount == 0) {
|
||||
if (state.folderCount == 1) {
|
||||
clickPref(
|
||||
title = DSLSettingsText.from(R.string.ChatsSettingsFragment__add_chat_folder),
|
||||
onClick = {
|
||||
|
||||
@@ -327,8 +327,7 @@ class ChatFoldersViewModel : ViewModel() {
|
||||
val originalFolder = state.value.originalFolder
|
||||
|
||||
return if (currentFolder.id == -1L) {
|
||||
currentFolder.name.isNotEmpty() &&
|
||||
(currentFolder.includedRecipients.isNotEmpty() || currentFolder.showIndividualChats || currentFolder.showGroupChats)
|
||||
currentFolder.includedRecipients.isNotEmpty() || currentFolder.showIndividualChats || currentFolder.showGroupChats
|
||||
} else {
|
||||
originalFolder != currentFolder ||
|
||||
originalFolder.includedRecipients != currentFolder.includedRecipients ||
|
||||
|
||||
@@ -364,42 +364,35 @@ fun CreateFolderScreen(
|
||||
}
|
||||
}
|
||||
|
||||
if (hasChanges && isNewFolder) {
|
||||
Buttons.MediumTonal(
|
||||
onClick = { onCreateConfirmed() },
|
||||
modifier = modifier
|
||||
.align(Alignment.BottomEnd)
|
||||
.padding(end = 16.dp, bottom = 16.dp)
|
||||
) {
|
||||
Text(text = stringResource(R.string.CreateFoldersFragment__create))
|
||||
}
|
||||
} else if (!isNewFolder) {
|
||||
Buttons.MediumTonal(
|
||||
colors = ButtonDefaults.filledTonalButtonColors(
|
||||
contentColor = if (state.currentFolder.name.isEmpty()) {
|
||||
MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f)
|
||||
} else {
|
||||
MaterialTheme.colorScheme.onSurface
|
||||
},
|
||||
containerColor = if (state.currentFolder.name.isEmpty()) {
|
||||
MaterialTheme.colorScheme.surfaceVariant
|
||||
} else {
|
||||
MaterialTheme.colorScheme.primaryContainer
|
||||
},
|
||||
disabledContainerColor = MaterialTheme.colorScheme.surfaceVariant
|
||||
),
|
||||
enabled = hasChanges,
|
||||
onClick = {
|
||||
if (state.currentFolder.name.isEmpty()) {
|
||||
onShowToast()
|
||||
} else {
|
||||
onCreateConfirmed()
|
||||
}
|
||||
Buttons.MediumTonal(
|
||||
colors = ButtonDefaults.filledTonalButtonColors(
|
||||
contentColor = if (state.currentFolder.name.isEmpty()) {
|
||||
MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f)
|
||||
} else {
|
||||
MaterialTheme.colorScheme.onSurface
|
||||
},
|
||||
modifier = modifier
|
||||
.align(Alignment.BottomEnd)
|
||||
.padding(end = 16.dp, bottom = 16.dp)
|
||||
) {
|
||||
containerColor = if (state.currentFolder.name.isEmpty()) {
|
||||
MaterialTheme.colorScheme.surfaceVariant
|
||||
} else {
|
||||
MaterialTheme.colorScheme.primaryContainer
|
||||
},
|
||||
disabledContainerColor = MaterialTheme.colorScheme.surfaceVariant
|
||||
),
|
||||
enabled = hasChanges,
|
||||
onClick = {
|
||||
if (state.currentFolder.name.isEmpty()) {
|
||||
onShowToast()
|
||||
} else {
|
||||
onCreateConfirmed()
|
||||
}
|
||||
},
|
||||
modifier = modifier
|
||||
.align(Alignment.BottomEnd)
|
||||
.padding(end = 16.dp, bottom = 16.dp)
|
||||
) {
|
||||
if (isNewFolder) {
|
||||
Text(text = stringResource(R.string.CreateFoldersFragment__create))
|
||||
} else {
|
||||
Text(text = stringResource(R.string.CreateFoldersFragment__save))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,13 +234,12 @@ class ChatFolderTables(context: Context?, databaseHelper: SignalDatabase?) : Dat
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of user-made folders
|
||||
* Returns the number of folders a user has, including the default 'All Chats'
|
||||
*/
|
||||
fun getFolderCount(): Int {
|
||||
return readableDatabase
|
||||
.count()
|
||||
.from(ChatFolderTable.TABLE_NAME)
|
||||
.where("${ChatFolderTable.FOLDER_TYPE} != ${ChatFolderRecord.FolderType.ALL.value}")
|
||||
.run()
|
||||
.readToSingleInt()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user