-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2046 from Infomaniak/modal-block-user
Add Dialog to confirm we want to block a user
- Loading branch information
Showing
11 changed files
with
182 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...src/main/java/com/infomaniak/mail/ui/main/thread/actions/ConfirmationToBlockUserDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Infomaniak Mail - Android | ||
* Copyright (C) 2024 Infomaniak Network SA | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.infomaniak.mail.ui.main.thread.actions | ||
|
||
import android.content.Context | ||
import androidx.appcompat.app.AlertDialog | ||
import com.google.android.material.dialog.MaterialAlertDialogBuilder | ||
import com.infomaniak.lib.core.utils.context | ||
import com.infomaniak.mail.R | ||
import com.infomaniak.mail.data.models.message.Message | ||
import com.infomaniak.mail.databinding.DialogConfirmationToBlockUserBinding | ||
import com.infomaniak.mail.ui.alertDialogs.BaseAlertDialog | ||
import dagger.hilt.android.qualifiers.ActivityContext | ||
import dagger.hilt.android.scopes.ActivityScoped | ||
import javax.inject.Inject | ||
import com.infomaniak.lib.core.R as RCore | ||
|
||
@ActivityScoped | ||
class ConfirmationToBlockUserDialog @Inject constructor( | ||
@ActivityContext private val activityContext: Context, | ||
) : BaseAlertDialog(activityContext) { | ||
|
||
private val binding: DialogConfirmationToBlockUserBinding by lazy { | ||
DialogConfirmationToBlockUserBinding.inflate(activity.layoutInflater) | ||
} | ||
|
||
private var onPositiveButtonClick: ((Message?) -> Unit)? = null | ||
private var messageOfUserToBlock: Message? = null | ||
|
||
override val alertDialog: AlertDialog = with(binding) { | ||
MaterialAlertDialogBuilder(context) | ||
.setView(root) | ||
.setPositiveButton(R.string.buttonConfirm) { _, _ -> | ||
onPositiveButtonClick?.invoke(messageOfUserToBlock) | ||
} | ||
.setNegativeButton(RCore.string.buttonCancel, null) | ||
.create() | ||
} | ||
|
||
override fun resetCallbacks() { | ||
onPositiveButtonClick = null | ||
} | ||
|
||
fun show(message: Message) = with(binding) { | ||
messageOfUserToBlock = message | ||
val recipient = message.from[0] | ||
val title = recipient.name.ifBlank { recipient.email } | ||
blockExpeditorTitle.text = activityContext.getString(R.string.blockExpeditorTitle, title) | ||
blockExpeditorDescription.text = activityContext.getString(R.string.confirmationToBlockAnExpeditorText, recipient.email) | ||
alertDialog.show() | ||
} | ||
|
||
fun setPositiveButtonCallback(onPositiveButtonClick: (Message?) -> Unit) { | ||
this.onPositiveButtonClick = onPositiveButtonClick | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
app/src/main/res/layout/dialog_confirmation_to_block_user.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="utf-8"?><!-- | ||
~ Infomaniak Mail - Android | ||
~ Copyright (C) 2024 Infomaniak Network SA | ||
~ | ||
~ This program is free software: you can redistribute it and/or modify | ||
~ it under the terms of the GNU General Public License as published by | ||
~ the Free Software Foundation, either version 3 of the License, or | ||
~ (at your option) any later version. | ||
~ | ||
~ This program is distributed in the hope that it will be useful, | ||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
~ GNU General Public License for more details. | ||
~ | ||
~ You should have received a copy of the GNU General Public License | ||
~ along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
android:paddingHorizontal="@dimen/marginStandard" | ||
android:paddingVertical="@dimen/marginStandardSmall"> | ||
|
||
<TextView | ||
android:id="@+id/blockExpeditorTitle" | ||
style="@style/BottomSheetTitle" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="@dimen/marginStandard" | ||
tools:text="Block Jean-Michel" /> | ||
|
||
<TextView | ||
android:id="@+id/blockExpeditorDescription" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="@dimen/marginStandardMedium" | ||
tools:text="@string/confirmationToBlockAnExpeditorText" /> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters