Skip to content

Commit cb7a741

Browse files
Merge pull request #9912 from rafaeltonholo/fix/6276/add-warning-in-app-notification-sent-folder-not-found
feat(notifications): trigger sent folder not found in-app notification on message compose
2 parents 9fc0f8d + 232f79a commit cb7a741

File tree

22 files changed

+445
-45
lines changed

22 files changed

+445
-45
lines changed

app-common/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ dependencies {
4040
implementation(projects.feature.account.avatar.impl)
4141
implementation(projects.feature.account.setup)
4242
implementation(projects.feature.mail.account.api)
43+
implementation(projects.feature.mail.message.composer)
4344
implementation(projects.feature.migration.provider)
4445
implementation(projects.feature.notification.api)
4546
implementation(projects.feature.notification.impl)

app-common/src/main/kotlin/net/thunderbird/app/common/feature/AppCommonFeatureModule.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package net.thunderbird.app.common.feature
33
import app.k9mail.feature.launcher.FeatureLauncherExternalContract
44
import app.k9mail.feature.launcher.di.featureLauncherModule
55
import net.thunderbird.app.common.feature.mail.appCommonFeatureMailModule
6+
import net.thunderbird.feature.mail.message.composer.inject.featureMessageComposerModule
67
import net.thunderbird.feature.navigation.drawer.api.NavigationDrawerExternalContract
78
import net.thunderbird.feature.notification.impl.inject.featureNotificationModule
89
import org.koin.android.ext.koin.androidContext
@@ -11,6 +12,7 @@ import org.koin.dsl.module
1112
internal val appCommonFeatureModule = module {
1213
includes(featureLauncherModule)
1314
includes(featureNotificationModule)
15+
includes(featureMessageComposerModule)
1416
includes(appCommonFeatureMailModule)
1517

1618
factory<FeatureLauncherExternalContract.AccountSetupFinishedLauncher> {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
plugins {
2+
id(ThunderbirdPlugins.Library.androidCompose)
3+
alias(libs.plugins.dev.mokkery)
4+
}
5+
6+
android {
7+
namespace = "net.thunderbird.feature.mail.message.composer"
8+
}
9+
10+
dependencies {
11+
implementation(projects.core.ui.compose.designsystem)
12+
implementation(projects.core.ui.theme.api)
13+
implementation(projects.feature.notification.api)
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package net.thunderbird.feature.mail.message.composer.dialog
2+
3+
import androidx.compose.foundation.layout.PaddingValues
4+
import androidx.compose.foundation.layout.padding
5+
import androidx.compose.runtime.Composable
6+
import androidx.compose.ui.Modifier
7+
import androidx.compose.ui.res.stringResource
8+
import app.k9mail.core.ui.compose.designsystem.atom.button.ButtonText
9+
import app.k9mail.core.ui.compose.designsystem.atom.icon.Icon
10+
import app.k9mail.core.ui.compose.designsystem.atom.icon.Icons
11+
import app.k9mail.core.ui.compose.designsystem.organism.BasicDialog
12+
import app.k9mail.core.ui.compose.theme2.MainTheme
13+
import net.thunderbird.feature.mail.message.composer.R
14+
15+
@Composable
16+
fun SentFolderNotFoundConfirmationDialog(
17+
showDialog: Boolean,
18+
onAssignSentFolderClick: () -> Unit,
19+
onSendAndDeleteClick: () -> Unit,
20+
onDismiss: () -> Unit,
21+
modifier: Modifier = Modifier,
22+
) {
23+
if (showDialog) {
24+
BasicDialog(
25+
headlineText = stringResource(R.string.sent_folder_not_found_dialog_title),
26+
supportingText = stringResource(R.string.sent_folder_not_found_dialog_supporting_text),
27+
content = {
28+
ButtonText(
29+
onClick = onAssignSentFolderClick,
30+
text = stringResource(R.string.sent_folder_not_found_dialog_assign_folder_action),
31+
leadingIcon = {
32+
Icon(
33+
imageVector = Icons.Outlined.Folder,
34+
contentDescription = null,
35+
modifier = Modifier.padding(end = MainTheme.spacings.half),
36+
)
37+
},
38+
)
39+
},
40+
buttons = {
41+
ButtonText(
42+
text = stringResource(R.string.sent_folder_not_found_dialog_cancel_action),
43+
onClick = onDismiss,
44+
)
45+
ButtonText(
46+
text = stringResource(R.string.sent_folder_not_found_dialog_send_and_delete_action),
47+
onClick = onSendAndDeleteClick,
48+
color = MainTheme.colors.error,
49+
)
50+
},
51+
onDismissRequest = onDismiss,
52+
contentPadding = PaddingValues(horizontal = MainTheme.spacings.default),
53+
modifier = modifier,
54+
)
55+
}
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package net.thunderbird.feature.mail.message.composer.dialog
2+
3+
import android.os.Bundle
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import android.view.Window
8+
import androidx.compose.ui.platform.ComposeView
9+
import androidx.core.os.bundleOf
10+
import androidx.fragment.app.DialogFragment
11+
import androidx.fragment.app.FragmentManager
12+
import androidx.fragment.app.setFragmentResult
13+
import net.thunderbird.core.ui.theme.api.FeatureThemeProvider
14+
import net.thunderbird.feature.mail.message.composer.dialog.SentFolderNotFoundConfirmationDialogFragmentFactory.Companion.ACCOUNT_UUID_ARG
15+
import net.thunderbird.feature.mail.message.composer.dialog.SentFolderNotFoundConfirmationDialogFragmentFactory.Companion.RESULT_CODE_ASSIGN_SENT_FOLDER_REQUEST_KEY
16+
import net.thunderbird.feature.mail.message.composer.dialog.SentFolderNotFoundConfirmationDialogFragmentFactory.Companion.RESULT_CODE_SEND_AND_DELETE_REQUEST_KEY
17+
import org.koin.android.ext.android.inject
18+
19+
class SentFolderNotFoundConfirmationDialogFragment : DialogFragment() {
20+
private val themeProvider: FeatureThemeProvider by inject<FeatureThemeProvider>()
21+
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
22+
val accountUuid = requireNotNull(requireArguments().getString(ACCOUNT_UUID_ARG)) {
23+
"The $ACCOUNT_UUID_ARG argument is missing from the arguments bundle."
24+
}
25+
dialog?.requestWindowFeature(Window.FEATURE_NO_TITLE)
26+
return ComposeView(requireContext()).apply {
27+
setContent {
28+
themeProvider.WithTheme {
29+
SentFolderNotFoundConfirmationDialog(
30+
showDialog = true,
31+
onAssignSentFolderClick = {
32+
dismiss()
33+
setFragmentResult(
34+
requestKey = RESULT_CODE_ASSIGN_SENT_FOLDER_REQUEST_KEY,
35+
result = bundleOf(ACCOUNT_UUID_ARG to accountUuid),
36+
)
37+
},
38+
onSendAndDeleteClick = {
39+
dismiss()
40+
setFragmentResult(
41+
requestKey = RESULT_CODE_SEND_AND_DELETE_REQUEST_KEY,
42+
result = bundleOf(ACCOUNT_UUID_ARG to accountUuid),
43+
)
44+
},
45+
onDismiss = ::dismiss,
46+
)
47+
}
48+
}
49+
}
50+
}
51+
52+
companion object Factory : SentFolderNotFoundConfirmationDialogFragmentFactory {
53+
private const val TAG = "SentFolderNotFoundConfirmationDialogFragment"
54+
override fun show(accountUuid: String, fragmentManager: FragmentManager) {
55+
SentFolderNotFoundConfirmationDialogFragment().apply {
56+
arguments = bundleOf(ACCOUNT_UUID_ARG to accountUuid)
57+
show(fragmentManager, TAG)
58+
}
59+
}
60+
}
61+
}
62+
63+
interface SentFolderNotFoundConfirmationDialogFragmentFactory {
64+
companion object {
65+
const val RESULT_CODE_ASSIGN_SENT_FOLDER_REQUEST_KEY =
66+
"SentFolderNotFoundConfirmationDialogFragmentFactory_assign_sent_folder"
67+
const val RESULT_CODE_SEND_AND_DELETE_REQUEST_KEY =
68+
"SentFolderNotFoundConfirmationDialogFragmentFactory_send_and_delete"
69+
const val ACCOUNT_UUID_ARG = "SetupArchiveFolderDialogFragmentFactory_accountUuid"
70+
}
71+
72+
fun show(accountUuid: String, fragmentManager: FragmentManager)
73+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package net.thunderbird.feature.mail.message.composer.inject
2+
3+
import net.thunderbird.feature.mail.message.composer.dialog.SentFolderNotFoundConfirmationDialogFragment
4+
import net.thunderbird.feature.mail.message.composer.dialog.SentFolderNotFoundConfirmationDialogFragmentFactory
5+
import org.koin.dsl.module
6+
7+
val featureMessageComposerModule = module {
8+
factory<SentFolderNotFoundConfirmationDialogFragmentFactory> {
9+
SentFolderNotFoundConfirmationDialogFragment.Factory
10+
}
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="sent_folder_not_found_dialog_title">Sent folder not found</string>
4+
<string name="sent_folder_not_found_dialog_supporting_text">To save this email after sending, set a Sent folder in Account Settings.</string>
5+
<string name="sent_folder_not_found_dialog_assign_folder_action">Assign Sent Folder</string>
6+
<string name="sent_folder_not_found_dialog_cancel_action">Cancel</string>
7+
<string name="sent_folder_not_found_dialog_send_and_delete_action">Send and Delete</string>
8+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package net.thunderbird.feature.notification.api.content
2+
3+
import app.k9mail.core.ui.compose.designsystem.atom.icon.Icons
4+
import app.k9mail.core.ui.compose.designsystem.atom.icon.outlined.Warning
5+
import net.thunderbird.feature.notification.api.ui.icon.NotificationIcon
6+
import net.thunderbird.feature.notification.api.ui.icon.NotificationIcons
7+
8+
internal actual val NotificationIcons.SentFolderNotFound: NotificationIcon
9+
get() = NotificationIcon(inAppNotificationIcon = Icons.Outlined.Warning)

feature/notification/api/src/commonMain/composeResources/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,14 @@
5656
<string name="notification_action_spam">Spam</string>
5757
<string name="notification_action_retry">Retry</string>
5858
<string name="notification_action_update_server_settings">Update Server Settings</string>
59+
<string name="notification_action_assign_sent_folder">Assign folder</string>
5960

6061
<string name="banner_inline_notification_check_error_notifications">Check Error Notifications</string>
6162
<string name="banner_inline_notification_some_messages_need_attention">Some messages need your attention.</string>
6263
<string name="banner_inline_notification_open_notifications">Open notifications</string>
6364
<string name="banner_inline_notification_learn_more">Learn more</string>
6465
<string name="banner_inline_notification_view_support_article">View support article</string>
66+
67+
<string name="sent_folder_not_found_title">Sent folder not available.</string>
6568
</resources>
69+

feature/notification/api/src/commonMain/kotlin/net/thunderbird/feature/notification/api/command/outcome/NotificationCommandOutcome.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ typealias NotificationCommandOutcome<TNotification> = Outcome<Success<TNotificat
2424
*/
2525
sealed interface Success<out TNotification : Notification> {
2626
val notificationId: NotificationId
27+
val rawNotificationId: Int
28+
@Discouraged("This is a utility getter to enable usage in Java code. Use notificationId instead.")
29+
get() = notificationId.value
2730
val command: NotificationCommand<out TNotification>?
2831

2932
/**

0 commit comments

Comments
 (0)