mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 02:25:19 +00:00
add UI options for delete messages
This commit is contained in:
parent
4f89c33676
commit
aad58043d3
@ -1167,6 +1167,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun deleteMessages(messages: Set<MessageRecord>) {
|
override fun deleteMessages(messages: Set<MessageRecord>) {
|
||||||
|
if (thread.isOpenGroupRecipient) {
|
||||||
val messageCount = messages.size
|
val messageCount = messages.size
|
||||||
val builder = AlertDialog.Builder(this)
|
val builder = AlertDialog.Builder(this)
|
||||||
builder.setTitle(resources.getQuantityString(R.plurals.ConversationFragment_delete_selected_messages, messageCount, messageCount))
|
builder.setTitle(resources.getQuantityString(R.plurals.ConversationFragment_delete_selected_messages, messageCount, messageCount))
|
||||||
@ -1183,6 +1184,24 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
endActionMode()
|
endActionMode()
|
||||||
}
|
}
|
||||||
builder.show()
|
builder.show()
|
||||||
|
} else {
|
||||||
|
val bottomSheet = DeleteOptionsBottomSheet()
|
||||||
|
bottomSheet.recipient = thread
|
||||||
|
bottomSheet.onDeleteForMeTapped = {
|
||||||
|
for (message in messages) {
|
||||||
|
this.deleteLocally(message)
|
||||||
|
}
|
||||||
|
bottomSheet.dismiss()
|
||||||
|
}
|
||||||
|
bottomSheet.onDeleteForEveryoneTapped = {
|
||||||
|
for (message in messages) {
|
||||||
|
this.deleteForEveryone(message)
|
||||||
|
}
|
||||||
|
bottomSheet.dismiss()
|
||||||
|
}
|
||||||
|
bottomSheet.onCancelTapped = { bottomSheet.dismiss() }
|
||||||
|
bottomSheet.show(supportFragmentManager, bottomSheet.tag)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun banUser(messages: Set<MessageRecord>) {
|
override fun banUser(messages: Set<MessageRecord>) {
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
package org.thoughtcrime.securesms.conversation.v2
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.view.isVisible
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||||
|
import kotlinx.android.synthetic.main.fragment_conversation_bottom_sheet.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_delete_message_bottom_sheet.*
|
||||||
|
import network.loki.messenger.R
|
||||||
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
|
import org.thoughtcrime.securesms.util.UiModeUtilities
|
||||||
|
|
||||||
|
class DeleteOptionsBottomSheet: BottomSheetDialogFragment(), View.OnClickListener {
|
||||||
|
|
||||||
|
lateinit var recipient: Recipient
|
||||||
|
|
||||||
|
var onDeleteForMeTapped: (() -> Unit?)? = null
|
||||||
|
var onDeleteForEveryoneTapped: (() -> Unit)? = null
|
||||||
|
var onCancelTapped: (() -> Unit)? = null
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
|
return inflater.inflate(R.layout.fragment_delete_message_bottom_sheet, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onClick(v: View?) {
|
||||||
|
when (v) {
|
||||||
|
deleteForMeTextView -> onDeleteForMeTapped?.invoke()
|
||||||
|
deleteForEveryoneTextView -> onDeleteForEveryoneTapped?.invoke()
|
||||||
|
cancelTextView -> onCancelTapped?.invoke()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
if (!this::recipient.isInitialized) { return dismiss() }
|
||||||
|
if (!recipient.isGroupRecipient) {
|
||||||
|
deleteForEveryoneTextView.text = resources.getString(R.string.delete_message_for_me_and_recipient, recipient.name)
|
||||||
|
}
|
||||||
|
deleteForMeTextView.setOnClickListener(this)
|
||||||
|
deleteForEveryoneTextView.setOnClickListener(this)
|
||||||
|
cancelTextView.setOnClickListener(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
super.onStart()
|
||||||
|
val window = dialog?.window ?: return
|
||||||
|
val isLightMode = UiModeUtilities.isDayUiMode(requireContext())
|
||||||
|
window.setDimAmount(if (isLightMode) 0.1f else 0.75f)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
app:behavior_hideable="true"
|
||||||
|
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/deleteForMeTextView"
|
||||||
|
style="@style/BottomSheetActionItem"
|
||||||
|
android:text="@string/delete_message_for_me"
|
||||||
|
android:textColor="@color/core_red"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/deleteForEveryoneTextView"
|
||||||
|
style="@style/BottomSheetActionItem"
|
||||||
|
android:text="@string/delete_message_for_everyone"
|
||||||
|
android:textColor="@color/core_red"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/cancelTextView"
|
||||||
|
style="@style/BottomSheetActionItem"
|
||||||
|
android:text="@string/cancel" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user