feat: add more conversation settings options and notification settings
parent
880a3f603c
commit
f08ae7a874
@ -0,0 +1,59 @@
|
||||
package org.thoughtcrime.securesms.conversation.settings
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import network.loki.messenger.databinding.ActivityConversationNotificationSettingsBinding
|
||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||
import org.thoughtcrime.securesms.conversation.v2.ConversationActivityV2
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class ConversationNotificationSettingsActivity: PassphraseRequiredActionBarActivity(), View.OnClickListener {
|
||||
|
||||
lateinit var binding: ActivityConversationNotificationSettingsBinding
|
||||
@Inject lateinit var threadDb: ThreadDatabase
|
||||
@Inject lateinit var recipientDb: RecipientDatabase
|
||||
val recipient by lazy {
|
||||
if (threadId == -1L) null
|
||||
else threadDb.getRecipientForThreadId(threadId)
|
||||
}
|
||||
var threadId: Long = -1
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
val recipient = recipient ?: return
|
||||
if (v === binding.notifyAll) {
|
||||
// set notify type
|
||||
recipientDb.setNotifyType(recipient, RecipientDatabase.NOTIFY_TYPE_ALL)
|
||||
} else if (v === binding.notifyMentions) {
|
||||
recipientDb.setNotifyType(recipient, RecipientDatabase.NOTIFY_TYPE_MENTIONS)
|
||||
} else if (v === binding.notifyMute) {
|
||||
recipientDb.setNotifyType(recipient, RecipientDatabase.NOTIFY_TYPE_NONE)
|
||||
}
|
||||
updateValues()
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?, ready: Boolean) {
|
||||
super.onCreate(savedInstanceState, ready)
|
||||
binding = ActivityConversationNotificationSettingsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
threadId = intent.getLongExtra(ConversationActivityV2.THREAD_ID, -1L)
|
||||
if (threadId == -1L) finish()
|
||||
updateValues()
|
||||
with (binding) {
|
||||
notifyAll.setOnClickListener(this@ConversationNotificationSettingsActivity)
|
||||
notifyMentions.setOnClickListener(this@ConversationNotificationSettingsActivity)
|
||||
notifyMute.setOnClickListener(this@ConversationNotificationSettingsActivity)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateValues() {
|
||||
val notifyType = recipient?.notifyType ?: return
|
||||
binding.notifyAllButton.isSelected = notifyType == RecipientDatabase.NOTIFY_TYPE_ALL
|
||||
binding.notifyMentionsButton.isSelected = notifyType == RecipientDatabase.NOTIFY_TYPE_MENTIONS
|
||||
binding.notifyMuteButton.isSelected = notifyType == RecipientDatabase.NOTIFY_TYPE_NONE
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package org.thoughtcrime.securesms.conversation.settings
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.activity.result.contract.ActivityResultContract
|
||||
import org.thoughtcrime.securesms.conversation.v2.ConversationActivityV2
|
||||
|
||||
class ConversationNotificationSettingsActivityContract: ActivityResultContract<Long, Unit>() {
|
||||
|
||||
override fun createIntent(context: Context, input: Long?): Intent =
|
||||
Intent(context, ConversationNotificationSettingsActivity::class.java).apply {
|
||||
putExtra(ConversationActivityV2.THREAD_ID, input)
|
||||
}
|
||||
|
||||
override fun parseResult(resultCode: Int, intent: Intent?) { /* do nothing */ }
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<TextView
|
||||
android:background="@drawable/preference_top"
|
||||
android:paddingTop="@dimen/small_spacing"
|
||||
android:id="@+id/notifyAll"
|
||||
style="@style/TextAppearance.Session.ConversationSettings.Option"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:text="@string/notify_type_all"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="72dp"/>
|
||||
<View
|
||||
android:layout_marginTop="@dimen/small_spacing"
|
||||
app:layout_constraintTop_toTopOf="@+id/notifyAll"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/notifyAll"
|
||||
app:layout_constraintEnd_toEndOf="@+id/notifyAll"
|
||||
android:layout_marginEnd="54dp"
|
||||
android:id="@+id/notifyAllButton"
|
||||
android:padding="@dimen/small_spacing"
|
||||
android:layout_width="@dimen/small_radial_size"
|
||||
android:layout_height="@dimen/small_radial_size"
|
||||
android:background="@drawable/padded_circle_accent_select"
|
||||
android:foreground="@drawable/radial_multi_select"/>
|
||||
<TextView
|
||||
app:layout_constraintTop_toBottomOf="@+id/notifyAll"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:id="@+id/notifyMentions"
|
||||
style="@style/TextAppearance.Session.ConversationSettings.Option"
|
||||
android:background="@drawable/preference_middle"
|
||||
android:text="@string/notify_type_mentions"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/setting_button_height"/>
|
||||
<View
|
||||
app:layout_constraintTop_toTopOf="@+id/notifyMentions"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/notifyMentions"
|
||||
app:layout_constraintEnd_toEndOf="@+id/notifyMentions"
|
||||
android:layout_marginEnd="54dp"
|
||||
android:id="@+id/notifyMentionsButton"
|
||||
android:layout_width="@dimen/small_radial_size"
|
||||
android:layout_height="@dimen/small_radial_size"
|
||||
android:background="@drawable/padded_circle_accent_select"
|
||||
android:foreground="@drawable/radial_multi_select"/>
|
||||
<TextView
|
||||
android:paddingBottom="@dimen/small_spacing"
|
||||
app:layout_constraintTop_toBottomOf="@+id/notifyMentions"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:id="@+id/notifyMute"
|
||||
style="@style/TextAppearance.Session.ConversationSettings.Option"
|
||||
android:background="@drawable/preference_bottom"
|
||||
android:text="@string/notify_type_mute"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="72dp"/>
|
||||
<View
|
||||
android:layout_marginBottom="@dimen/small_spacing"
|
||||
app:layout_constraintTop_toTopOf="@+id/notifyMute"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/notifyMute"
|
||||
app:layout_constraintEnd_toEndOf="@+id/notifyMute"
|
||||
android:layout_marginEnd="54dp"
|
||||
android:id="@+id/notifyMuteButton"
|
||||
android:layout_width="@dimen/small_radial_size"
|
||||
android:layout_height="@dimen/small_radial_size"
|
||||
android:background="@drawable/padded_circle_accent_select"
|
||||
android:foreground="@drawable/radial_multi_select"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue