mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 04:58:45 +00:00
Prevent empty name folders.
This commit is contained in:
@@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.components.settings.app.chats.folders
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
@@ -150,6 +151,9 @@ class CreateFoldersFragment : ComposeFragment() {
|
||||
if (shouldExit) {
|
||||
navController.popBackStack()
|
||||
}
|
||||
},
|
||||
onShowToast = {
|
||||
Toast.makeText(requireContext(), R.string.CreateFoldersFragment__please_enter_name, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -176,7 +180,8 @@ fun CreateFolderScreen(
|
||||
onDeleteConfirmed: () -> Unit = {},
|
||||
onDeleteDismissed: () -> Unit = {},
|
||||
onCreateConfirmed: (Boolean) -> Unit = {},
|
||||
onCreateDismissed: (Boolean) -> Unit = {}
|
||||
onCreateDismissed: (Boolean) -> Unit = {},
|
||||
onShowToast: () -> Unit = {}
|
||||
) {
|
||||
var expandIncluded by remember { mutableStateOf(false) }
|
||||
var expandExcluded by remember { mutableStateOf(false) }
|
||||
@@ -370,10 +375,26 @@ fun CreateFolderScreen(
|
||||
} 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 = { onCreateConfirmed(true) },
|
||||
onClick = {
|
||||
if (state.currentFolder.name.isEmpty()) {
|
||||
onShowToast()
|
||||
} else {
|
||||
onCreateConfirmed(true)
|
||||
}
|
||||
},
|
||||
modifier = modifier
|
||||
.align(Alignment.BottomEnd)
|
||||
.padding(end = 16.dp, bottom = 16.dp)
|
||||
|
||||
@@ -5191,6 +5191,8 @@
|
||||
<string name="CreateFoldersFragment__delete_this_chat_folder">Delete this chat folder?</string>
|
||||
<!-- Option to see all of the chats if the chat list was too long and had been truncated -->
|
||||
<string name="CreateFoldersFragment__see_all">See all</string>
|
||||
<!-- Toast shown when trying to make a folder with no name -->
|
||||
<string name="CreateFoldersFragment__please_enter_name">Please enter a folder name</string>
|
||||
|
||||
<!-- ChooseChatsFragment -->
|
||||
<!-- Section title representing chat types that can be added to the folder -->
|
||||
|
||||
Reference in New Issue
Block a user