Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@
android:screenOrientation="portrait" />
<activity android:name="org.thoughtcrime.securesms.preferences.appearance.AppearanceSettingsActivity"
android:screenOrientation="portrait"/>
<activity android:name="org.thoughtcrime.securesms.conversation.disappearingmessages.DisappearingMessagesActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.Session.DayNight.NoActionBar" />
<activity android:name="org.thoughtcrime.securesms.groups.GroupMembersActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.Session.DayNight.NoActionBar" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class DisappearingMessagesViewModel @AssistedInject constructor(
@Assisted private val address: Address,
@Assisted("isNewConfigEnabled") private val isNewConfigEnabled: Boolean,
@Assisted("showDebugOptions") private val showDebugOptions: Boolean,
@Assisted private val navigator: UINavigator<ConversationSettingsDestination>,
@param:ApplicationContext private val context: Context,
private val disappearingMessages: DisappearingMessages,
private val navigator: UINavigator<ConversationSettingsDestination>,
private val recipientRepository: RecipientRepository,
) : ViewModel() {

Expand Down Expand Up @@ -96,7 +96,8 @@ class DisappearingMessagesViewModel @AssistedInject constructor(
fun create(
address: Address,
@Assisted("isNewConfigEnabled") isNewConfigEnabled: Boolean,
@Assisted("showDebugOptions") showDebugOptions: Boolean
@Assisted("showDebugOptions") showDebugOptions: Boolean,
navigator: UINavigator<ConversationSettingsDestination>
): DisappearingMessagesViewModel
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ import org.thoughtcrime.securesms.audio.AudioRecorderHandle
import org.thoughtcrime.securesms.audio.recordAudio
import org.thoughtcrime.securesms.components.TypingStatusSender
import org.thoughtcrime.securesms.components.emoji.RecentEmojiPageModel
import org.thoughtcrime.securesms.conversation.disappearingmessages.DisappearingMessagesActivity
import org.thoughtcrime.securesms.conversation.v2.ConversationReactionOverlay.OnActionSelectedListener
import org.thoughtcrime.securesms.conversation.v2.ConversationReactionOverlay.OnReactionSelectedListener
import org.thoughtcrime.securesms.conversation.v2.ConversationViewModel.Commands.ShowOpenUrlDialog
Expand All @@ -150,6 +149,7 @@ import org.thoughtcrime.securesms.conversation.v2.messages.VisibleMessageViewDel
import org.thoughtcrime.securesms.conversation.v2.search.SearchBottomBar
import org.thoughtcrime.securesms.conversation.v2.search.SearchViewModel
import org.thoughtcrime.securesms.conversation.v2.settings.ConversationSettingsActivity
import org.thoughtcrime.securesms.conversation.v2.settings.ConversationSettingsDestination
import org.thoughtcrime.securesms.conversation.v2.settings.notification.NotificationSettingsActivity
import org.thoughtcrime.securesms.conversation.v2.utilities.AttachmentManager
import org.thoughtcrime.securesms.conversation.v2.utilities.MentionUtilities
Expand Down Expand Up @@ -692,9 +692,11 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
}

is ConversationUiEvent.ShowDisappearingMessages -> {
val intent = Intent(this@ConversationActivityV2, DisappearingMessagesActivity::class.java).apply {
putExtra(DisappearingMessagesActivity.ARG_ADDRESS, event.address)
}
val intent = ConversationSettingsActivity.createIntent(
context = this@ConversationActivityV2,
address = event.address,
startDestination = ConversationSettingsDestination.RouteDisappearingMessages
)
startActivity(intent)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ class ConversationViewModel @AssistedInject constructor(
}
}

_uiEvents.tryEmit(ConversationUiEvent.ShowDisappearingMessages(convo.address))
_uiEvents.tryEmit(ConversationUiEvent.ShowDisappearingMessages(address))
}
}

Expand Down Expand Up @@ -1455,7 +1455,7 @@ data class UiMessage(val id: Long, val message: String)

sealed interface ConversationUiEvent {
data class NavigateToConversation(val address: Address.Conversable) : ConversationUiEvent
data class ShowDisappearingMessages(val address: Address) : ConversationUiEvent
data class ShowDisappearingMessages(val address: Address.Conversable) : ConversationUiEvent
data class ShowNotificationSettings(val address: Address) : ConversationUiEvent
data class ShowGroupMembers(val groupAddress: Address.Group) : ConversationUiEvent
data class ShowConversationSettings(val threadAddress: Address.Conversable) : ConversationUiEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,39 @@ import androidx.core.content.IntentCompat
import dagger.hilt.android.AndroidEntryPoint
import org.session.libsession.utilities.Address
import org.thoughtcrime.securesms.FullComposeScreenLockActivity
import org.thoughtcrime.securesms.ui.UINavigator
import javax.inject.Inject

@AndroidEntryPoint
class ConversationSettingsActivity: FullComposeScreenLockActivity() {

companion object {
const val THREAD_ADDRESS = "conversation_settings_thread_address"
private const val THREAD_ADDRESS = "conversation_settings_thread_address"
private const val EXTRA_START_DESTINATION = "start_destination"

fun createIntent(context: Context, address: Address.Conversable): Intent {
fun createIntent(
context: Context,
address: Address.Conversable,
startDestination: ConversationSettingsDestination = ConversationSettingsDestination.RouteConversationSettings
): Intent {
return Intent(context, ConversationSettingsActivity::class.java).apply {
putExtra(THREAD_ADDRESS, address)
putExtra(EXTRA_START_DESTINATION, startDestination)
}
}
}

@Inject
lateinit var navigator: UINavigator<ConversationSettingsDestination>

@Composable
override fun ComposeContent() {
val startDestination = IntentCompat.getParcelableExtra(
intent,
EXTRA_START_DESTINATION,
ConversationSettingsDestination::class.java
) ?: ConversationSettingsDestination.RouteConversationSettings

ConversationSettingsNavHost(
address = requireNotNull(IntentCompat.getParcelableExtra(intent, THREAD_ADDRESS, Address.Conversable::class.java)) {
"ConversationSettingsActivity requires an Address to be passed in the intent."
},
navigator = navigator,
startDestination = startDestination,
returnResult = { code, value ->
setResult(RESULT_OK, Intent().putExtra(code, value))
finish()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.thoughtcrime.securesms.conversation.v2.settings

import android.annotation.SuppressLint
import android.os.Parcelable
import androidx.compose.animation.ExperimentalSharedTransitionApi
import androidx.compose.animation.SharedTransitionLayout
import androidx.compose.runtime.Composable
Expand All @@ -14,6 +15,7 @@ import androidx.lifecycle.repeatOnLifecycle
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.rememberNavController
import androidx.navigation.toRoute
import kotlinx.parcelize.Parcelize
import kotlinx.serialization.Serializable
import network.loki.messenger.BuildConfig
import org.session.libsession.messaging.messages.ExpirationConfiguration
Expand All @@ -39,11 +41,13 @@ import org.thoughtcrime.securesms.ui.UINavigator
import org.thoughtcrime.securesms.ui.horizontalSlideComposable

// Destinations
sealed interface ConversationSettingsDestination {
sealed interface ConversationSettingsDestination: Parcelable {
@Serializable
@Parcelize
data object RouteConversationSettings: ConversationSettingsDestination

@Serializable
@Parcelize
data class RouteGroupMembers private constructor(
private val address: String
): ConversationSettingsDestination {
Expand All @@ -53,6 +57,7 @@ sealed interface ConversationSettingsDestination {
}

@Serializable
@Parcelize
data class RouteManageMembers private constructor(
private val address: String
): ConversationSettingsDestination {
Expand All @@ -62,6 +67,7 @@ sealed interface ConversationSettingsDestination {
}

@Serializable
@Parcelize
data class RouteInviteToGroup private constructor(
private val address: String,
val excludingAccountIDs: List<String>
Expand All @@ -73,15 +79,19 @@ sealed interface ConversationSettingsDestination {
}

@Serializable
@Parcelize
data object RouteDisappearingMessages: ConversationSettingsDestination

@Serializable
@Parcelize
data object RouteAllMedia: ConversationSettingsDestination

@Serializable
@Parcelize
data object RouteNotifications: ConversationSettingsDestination

@Serializable
@Parcelize
data class RouteInviteToCommunity(
val communityUrl: String
): ConversationSettingsDestination
Expand All @@ -92,12 +102,21 @@ sealed interface ConversationSettingsDestination {
@Composable
fun ConversationSettingsNavHost(
address: Address.Conversable,
navigator: UINavigator<ConversationSettingsDestination>,
startDestination: ConversationSettingsDestination = RouteConversationSettings,
returnResult: (String, Boolean) -> Unit,
onBack: () -> Unit
){
SharedTransitionLayout {
val navController = rememberNavController()
val navigator: UINavigator<ConversationSettingsDestination> = remember { UINavigator() }

val handleBack: () -> Unit = {
if (navController.previousBackStackEntry != null) {
navController.navigateUp()
} else {
onBack() // Finish activity if at root
}
}

ObserveAsEvents(flow = navigator.navigationActions) { action ->
when (action) {
Expand All @@ -107,7 +126,7 @@ fun ConversationSettingsNavHost(
action.navOptions(this)
}

NavigationAction.NavigateUp -> navController.navigateUp()
NavigationAction.NavigateUp -> handleBack()

is NavigationAction.NavigateToIntent -> {
navController.context.startActivity(action.intent)
Expand All @@ -119,12 +138,12 @@ fun ConversationSettingsNavHost(
}
}

NavHost(navController = navController, startDestination = RouteConversationSettings) {
NavHost(navController = navController, startDestination = startDestination) {
// Conversation Settings
horizontalSlideComposable<RouteConversationSettings> {
val viewModel =
hiltViewModel<ConversationSettingsViewModel, ConversationSettingsViewModel.Factory> { factory ->
factory.create(address)
factory.create(address, navigator)
}

val lifecycleOwner = LocalLifecycleOwner.current
Expand Down Expand Up @@ -154,7 +173,7 @@ fun ConversationSettingsNavHost(
GroupMembersScreen(
viewModel = viewModel,
onBack = dropUnlessResumed {
navController.popBackStack()
handleBack()
},
)
}
Expand All @@ -178,7 +197,7 @@ fun ConversationSettingsNavHost(
)
},
onBack = dropUnlessResumed {
navController.popBackStack()
handleBack()
},
)
}
Expand Down Expand Up @@ -208,10 +227,10 @@ fun ConversationSettingsNavHost(
//send invites from the manage group screen
editGroupViewModel.onContactSelected(viewModel.currentSelected)

navController.popBackStack()
handleBack()
},
onBack = dropUnlessResumed {
navController.popBackStack()
handleBack()
},
banner = {
GroupMinimumVersionBanner()
Expand Down Expand Up @@ -244,7 +263,7 @@ fun ConversationSettingsNavHost(
viewModel.clearSelection()
},
onBack = dropUnlessResumed {
navController.popBackStack()
handleBack()
},
)
}
Expand All @@ -256,14 +275,15 @@ fun ConversationSettingsNavHost(
factory.create(
address = address,
isNewConfigEnabled = ExpirationConfiguration.isNewConfigEnabled,
showDebugOptions = BuildConfig.BUILD_TYPE != "release"
showDebugOptions = BuildConfig.BUILD_TYPE != "release",
navigator = navigator
)
}

DisappearingMessagesScreen(
viewModel = viewModel,
onBack = dropUnlessResumed {
navController.popBackStack()
handleBack()
},
)
}
Expand All @@ -278,7 +298,7 @@ fun ConversationSettingsNavHost(
MediaOverviewScreen(
viewModel = viewModel,
onClose = dropUnlessResumed {
navController.popBackStack()
handleBack()
},
)
}
Expand All @@ -293,7 +313,7 @@ fun ConversationSettingsNavHost(
NotificationSettingsScreen(
viewModel = viewModel,
onBack = dropUnlessResumed {
navController.popBackStack()
handleBack()
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ import org.thoughtcrime.securesms.util.AvatarUtils
@HiltViewModel(assistedFactory = ConversationSettingsViewModel.Factory::class)
class ConversationSettingsViewModel @AssistedInject constructor(
@Assisted private val address: Address.Conversable,
@Assisted private val navigator: UINavigator<ConversationSettingsDestination>,
@param:ApplicationContext private val context: Context,
private val avatarUtils: AvatarUtils,
private val repository: ConversationRepository,
private val configFactory: ConfigFactoryProtocol,
private val storage: StorageProtocol,
private val conversationRepository: ConversationRepository,
private val navigator: UINavigator<ConversationSettingsDestination>,
private val groupManagerV2: GroupManagerV2,
private val groupManager: GroupManagerV2,
private val openGroupManager: OpenGroupManager,
Expand Down Expand Up @@ -1385,7 +1385,10 @@ class ConversationSettingsViewModel @AssistedInject constructor(

@AssistedFactory
interface Factory {
fun create(address: Address.Conversable): ConversationSettingsViewModel
fun create(
address: Address.Conversable,
navigator: UINavigator<ConversationSettingsDestination>
): ConversationSettingsViewModel
}

data class UIState(
Expand Down
Loading