Fix various UI bugs for chat folders.

This commit is contained in:
Michelle Tang
2024-11-01 16:28:45 -04:00
committed by GitHub
parent 90ff3d1e32
commit d115835606
5 changed files with 56 additions and 65 deletions

View File

@@ -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 = {

View File

@@ -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 ||

View File

@@ -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))
}
}

View File

@@ -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()
}

View File

@@ -9,29 +9,6 @@
android:background="?android:windowBackground"
tools:viewBindingIgnore="true">
<ViewStub
android:id="@+id/voice_note_player"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inflatedId="@+id/voice_note_player"
android:layout="@layout/voice_note_player_stub"
app:layout_constraintTop_toTopOf="parent" />
<ViewStub
android:id="@+id/banner_compose_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inflatedId="@+id/banner_compose_view"
android:layout="@layout/conversation_list_banner_view"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.Barrier
android:id="@+id/banner_barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="voice_note_player,banner_compose_view" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/chat_folder_list"
android:layout_width="match_parent"
@@ -42,13 +19,36 @@
android:visibility="gone"
tools:visibility="visible"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/banner_barrier" />
app:layout_constraintTop_toTopOf="parent" />
<ViewStub
android:id="@+id/voice_note_player"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inflatedId="@+id/voice_note_player"
android:layout="@layout/voice_note_player_stub"
app:layout_constraintTop_toBottomOf="@id/chat_folder_list" />
<ViewStub
android:id="@+id/banner_compose_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inflatedId="@+id/banner_compose_view"
android:layout="@layout/conversation_list_banner_view"
app:layout_constraintTop_toBottomOf="@id/voice_note_player" />
<androidx.constraintlayout.widget.Barrier
android:id="@+id/banner_barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="voice_note_player,banner_compose_view" />
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/chat_folder_list">
app:layout_constraintTop_toBottomOf="@id/banner_barrier">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/recycler_coordinator_app_bar"