Add info action wiring in calls tab.

This commit is contained in:
Alex Hart
2023-03-15 16:22:46 -03:00
committed by Greyson Parrelli
parent 7521520b26
commit 8ca596580c
8 changed files with 59 additions and 11 deletions

View File

@@ -6,6 +6,7 @@ import androidx.fragment.app.Fragment
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.components.menu.ActionItem
import org.thoughtcrime.securesms.components.menu.SignalContextMenu
import org.thoughtcrime.securesms.components.settings.conversation.ConversationSettingsActivity
import org.thoughtcrime.securesms.conversation.ConversationIntents
import org.thoughtcrime.securesms.database.CallTable
import org.thoughtcrime.securesms.util.CommunicationActions
@@ -69,7 +70,8 @@ class CallLogContextMenu(
iconRes = R.drawable.symbol_info_24,
title = fragment.getString(R.string.CallContextMenu__info)
) {
// TODO
val intent = ConversationSettingsActivity.forCall(fragment.requireContext(), call.peer)
fragment.startActivity(intent)
}
}
@@ -91,7 +93,7 @@ class CallLogContextMenu(
iconRes = R.drawable.symbol_trash_24,
title = fragment.getString(R.string.CallContextMenu__delete)
) {
// TODO [alex] what does this actually delete
// TODO [alex] Delete message by message id
}
}

View File

@@ -2,7 +2,6 @@ package org.thoughtcrime.securesms.components.settings
import android.os.Bundle
import androidx.activity.OnBackPressedCallback
import androidx.annotation.Discouraged
import androidx.navigation.NavController
import androidx.navigation.Navigation
import androidx.navigation.fragment.NavHostFragment
@@ -11,7 +10,10 @@ import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.util.DynamicNoActionBarTheme
import org.thoughtcrime.securesms.util.DynamicTheme
@Discouraged("The DSL API can be completely replaced by compose. See ComposeFragment or ComposeBottomSheetFragment for an alternative to this API")
/**
* The DSL API can be completely replaced by compose.
* See ComposeFragment or ComposeBottomSheetFragment for an alternative to this API"
*/
open class DSLSettingsActivity : PassphraseRequiredActivity() {
protected open val dynamicTheme: DynamicTheme = DynamicNoActionBarTheme()

View File

@@ -6,7 +6,6 @@ import android.os.Bundle
import android.view.View
import android.widget.EdgeEffect
import androidx.annotation.CallSuper
import androidx.annotation.Discouraged
import androidx.annotation.LayoutRes
import androidx.annotation.MenuRes
import androidx.annotation.StringRes
@@ -21,7 +20,10 @@ import org.thoughtcrime.securesms.util.Material3OnScrollHelper
import org.thoughtcrime.securesms.util.adapter.mapping.MappingAdapter
import java.lang.UnsupportedOperationException
@Discouraged("The DSL API can be completely replaced by compose. See ComposeFragment or ComposeBottomSheetFragment for an alternative to this API")
/**
* The DSL API can be completely replaced by compose.
* See ComposeFragment or ComposeBottomSheetFragment for an alternative to this API
*/
abstract class DSLSettingsFragment(
@StringRes private val titleId: Int = -1,
@MenuRes private val menuId: Int = -1,

View File

@@ -13,6 +13,7 @@ import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.components.settings.DSLSettingsActivity
import org.thoughtcrime.securesms.groups.GroupId
import org.thoughtcrime.securesms.groups.ParcelableGroupId
import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.recipients.RecipientId
import org.thoughtcrime.securesms.util.DynamicConversationSettingsTheme
import org.thoughtcrime.securesms.util.DynamicTheme
@@ -84,6 +85,23 @@ class ConversationSettingsActivity : DSLSettingsActivity(), ConversationSettings
.putExtra(ARG_START_BUNDLE, startBundle)
}
@JvmStatic
fun forCall(context: Context, callPeer: Recipient): Intent {
val startBundleBuilder = if (callPeer.isGroup) {
ConversationSettingsFragmentArgs.Builder(null, ParcelableGroupId.from(callPeer.requireGroupId()))
} else {
ConversationSettingsFragmentArgs.Builder(callPeer.id, null)
}
val startBundle = startBundleBuilder
.setIsCallInfo(true)
.build()
.toBundle()
return getIntent(context)
.putExtra(ARG_START_BUNDLE, startBundle)
}
private fun getIntent(context: Context): Intent {
return Intent(context, ConversationSettingsActivity::class.java)
.putExtra(ARG_NAV_GRAPH, R.navigation.conversation_settings)

View File

@@ -128,6 +128,7 @@ class ConversationSettingsFragment : DSLSettingsFragment(
ConversationSettingsViewModel.Factory(
recipientId = args.recipientId,
groupId = ParcelableGroupId.get(groupId),
isCallInfo = args.isCallInfo,
repository = ConversationSettingsRepository(requireContext())
)
}
@@ -180,6 +181,7 @@ class ConversationSettingsFragment : DSLSettingsFragment(
progress.dismiss()
}
}
REQUEST_CODE_RETURN_FROM_MEDIA -> viewModel.refreshSharedMedia()
REQUEST_CODE_ADD_CONTACT -> viewModel.refreshRecipient()
REQUEST_CODE_VIEW_CONTACT -> viewModel.refreshRecipient()
@@ -376,6 +378,13 @@ class ConversationSettingsFragment : DSLSettingsFragment(
customPref(
ButtonStripPreference.Model(
state = state.buttonStripState,
onMessageClick = {
val intent = ConversationIntents
.createBuilder(requireContext(), state.recipient.id, state.threadId)
.build()
startActivity(intent)
},
onAddToStoryClick = {
if (state.recipient.isPushV2Group && state.requireGroupSettingsState().isAnnouncementGroup && !state.requireGroupSettingsState().isSelfAdmin) {
MaterialAlertDialogBuilder(requireContext())
@@ -491,6 +500,7 @@ class ConversationSettingsFragment : DSLSettingsFragment(
}
)
}
ContactLinkState.ADD -> {
@Suppress("DEPRECATION")
clickPref(
@@ -505,6 +515,7 @@ class ConversationSettingsFragment : DSLSettingsFragment(
}
)
}
ContactLinkState.NONE -> {
}
}

View File

@@ -128,6 +128,7 @@ sealed class ConversationSettingsViewModel(
private class RecipientSettingsViewModel(
private val recipientId: RecipientId,
private val isCallInfo: Boolean,
private val repository: ConversationSettingsRepository
) : ConversationSettingsViewModel(
repository,
@@ -151,12 +152,13 @@ sealed class ConversationSettingsViewModel(
state.copy(
recipient = recipient,
buttonStripState = ButtonStripPreference.State(
isMessageAvailable = isCallInfo,
isVideoAvailable = recipient.registered == RecipientTable.RegisteredState.REGISTERED && !recipient.isSelf && !recipient.isBlocked && !recipient.isReleaseNotes,
isAudioAvailable = isAudioAvailable,
isAudioSecure = recipient.registered == RecipientTable.RegisteredState.REGISTERED,
isMuted = recipient.isMuted,
isMuteAvailable = !recipient.isSelf,
isSearchAvailable = true
isSearchAvailable = !isCallInfo
),
disappearingMessagesLifespan = recipient.expiresInSeconds,
canModifyBlockedState = !recipient.isSelf && RecipientUtil.isBlockable(recipient),
@@ -256,6 +258,7 @@ sealed class ConversationSettingsViewModel(
private class GroupSettingsViewModel(
private val groupId: GroupId,
private val isCallInfo: Boolean,
private val repository: ConversationSettingsRepository
) : ConversationSettingsViewModel(repository, SpecificSettingsState.GroupSettingsState(groupId)) {
@@ -271,12 +274,13 @@ sealed class ConversationSettingsViewModel(
state.copy(
recipient = recipient,
buttonStripState = ButtonStripPreference.State(
isMessageAvailable = isCallInfo,
isVideoAvailable = recipient.isPushV2Group && !recipient.isBlocked && isActive,
isAudioAvailable = false,
isAudioSecure = recipient.isPushV2Group,
isMuted = recipient.isMuted,
isMuteAvailable = true,
isSearchAvailable = true,
isSearchAvailable = !isCallInfo,
isAddToStoryAvailable = recipient.isPushV2Group && !recipient.isBlocked && isActive && !SignalStore.storyValues().isFeatureDisabled
),
canModifyBlockedState = RecipientUtil.isBlockable(recipient),
@@ -479,6 +483,7 @@ sealed class ConversationSettingsViewModel(
class Factory(
private val recipientId: RecipientId? = null,
private val groupId: GroupId? = null,
private val isCallInfo: Boolean,
private val repository: ConversationSettingsRepository
) : ViewModelProvider.Factory {
@@ -486,8 +491,8 @@ sealed class ConversationSettingsViewModel(
return requireNotNull(
modelClass.cast(
when {
recipientId != null -> RecipientSettingsViewModel(recipientId, repository)
groupId != null -> GroupSettingsViewModel(groupId, repository)
recipientId != null -> RecipientSettingsViewModel(recipientId, isCallInfo, repository)
groupId != null -> GroupSettingsViewModel(groupId, isCallInfo, repository)
else -> error("One of RecipientId or GroupId required.")
}
)

View File

@@ -20,7 +20,10 @@ fun configure(init: DSLConfiguration.() -> Unit): DSLConfiguration {
return configuration
}
@Discouraged("The DSL API can be completely replaced by compose. See ComposeFragment or ComposeBottomSheetFragment for an alternative to this API")
/**
* The DSL API can be completely replaced by compose.
* See ComposeFragment or ComposeBottomSheetFragment for an alternative to this API
*/
class DSLConfiguration {
private val children = arrayListOf<MappingModel<*>>()

View File

@@ -47,6 +47,11 @@
app:argType="android.os.Parcelable"
app:nullable="true" />
<argument
android:name="is_call_info"
app:argType="boolean"
android:defaultValue="false" />
<action
android:id="@+id/action_conversationSettingsFragment_to_soundsAndNotificationsSettingsFragment"
app:destination="@id/soundsAndNotificationsSettingsFragment"