Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/develop' into fix/r…
Browse files Browse the repository at this point in the history
…eaction-paddings

# Conflicts:
#	app/src/main/kotlin/com/wire/android/ui/home/conversations/messages/item/RegularMessageItem.kt
  • Loading branch information
damian-kaczmarek committed Nov 27, 2024
2 parents 81ce83e + 04c9a3d commit 58366f6
Show file tree
Hide file tree
Showing 97 changed files with 1,987 additions and 601 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-edge-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,5 @@ jobs:
serviceAccountJson: service_account.json
packageName: com.wire.internal
releaseFiles: app/build/outputs/bundle/internalCompat/*.aab
track: alpha
track: production
status: completed
2 changes: 1 addition & 1 deletion .github/workflows/deploy-adr-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Deploy docs 🚀
if: github.event_name == 'push' && github.ref_name == 'develop'
uses: JamesIves/[email protected].8
uses: JamesIves/[email protected].9
with:
branch: gh-pages
clean: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-test-results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
uses: actions/checkout@v4

- name: Download and Extract Artifacts
uses: dawidd6/action-download-artifact@v4
uses: dawidd6/action-download-artifact@v6
with:
run_id: ${{ github.event.workflow_run.id }}
path: artifacts
Expand Down
41 changes: 41 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Contributing

## I want to contribute to Wire

You can contribute to Wire in several ways:

## Finding bugs

If you find a bug in how Wire apps work, please submit a ticket to [our support](https://support.wire.com) and we will keep you informed about the progress.
Alternatively, you can submit your finding on [wire issues](https://github.com/wireapp/wire/issues). Please make sure to provide as much information as possible to help us reproduce the issue.

## Contributing to the code

If you wish to contribute source code to one of our repositories you have to sign
our [Contributor Agreement](https://github.com/wireapp/wire/raw/master/assets/Wire%20Contributor%20Agreement.pdf)
first.

When you submit your first pull request, you can sign the agreement electronically by filling in the
required information. You will not have to sign it again for subsequent pull requests from the same
GitHub account.

When opening a pull request, please make sure to follow the next guidelines:

- Make sure to fill in the pull request template to the fullest extent possible, this will help us
understand faster the changes proposed.
- Make sure to run the tests and linters before submitting the pull request.
- Add the necessary tests for the changes you are proposing, this will help us ensure that the
changes are working as expected.

> [!NOTE]
> We accept only bug fixes and code improvements. We cannot accept new features, UI or UX changes – these are decided by Wire and built by the Wire development team.
## I want to help translate Wire

If you want to help Wire to speak more languages, please refer to our [site](https://support.wire.com/hc/en-us/articles/202856874-Language-support), to see the official list of supported languages and those who are open to contribute.

To do so, you will find instructions there, but you can do the following:

1. Create a [Crowdin account](https://crowdin.com/).
2. Request access to add translations in our [project](https://crowdin.com/project/wire-android-reloaded).
3. Translate away.
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,6 @@ It might be that after cloning the Android project, some build issues appear on
- There is a valid SDK path on your `local.properties` AND `kalium/local.properties` files pointing to the Android SDK folder. In Mac, that folder can be usually found under `sdk.dir=/Users/YOUR_USER_FOLDER/Library/Android/sdk`. The IDE **will not** create `kalium/local.properties` automatically, so you might want to copy/paste the one in the project root
- When you've already started working on the project adding some commits, it might occur that your local build breaks, if that is the case, make sure you've updated the `kalium` submodule reference by running: `git submodule update --remote --merge`

## Contributing

If you want to help Wire to speak more languages, please refer to our [site](https://support.wire.com/hc/en-us/articles/202856874-Language-support), to see the official list of supported languages and those who are open to contribute.

To do so, you will find instructions there, but you can do the following:

1. Create a [Crowdin account](https://crowdin.com/).
2. Request access to add translations in our [project](https://crowdin.com/project/wire-android-reloaded).
3. Translate away.

# App flavours

We have a few different app flavours with different intended usages. Each app flavour has a different icon background colour to enable easier distinction.
Expand Down Expand Up @@ -99,3 +89,7 @@ To see how they are customised in details, check [the flavour configuration file
## Build Types

The apps can be built for release or debugging. Debug versions might have extra debugging tools, are not minified, and can be profiled if needed. In general, debug builds _run slower_ due to the lack of minimisation.

## Contributing

If you want to contribute to Wire for Android, please refer to the [CONTRIBUTING.md](./CONTRIBUTING.md) file for more information.
8 changes: 8 additions & 0 deletions app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -492,4 +492,12 @@ class UseCaseModule {
@Provides
fun provideSendFCMTokenToAPIUseCase(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) =
coreLogic.getSessionScope(currentAccount).debug.sendFCMTokenToServer

@ViewModelScoped
@Provides
fun provideMigrateFromPersonalToTeamUseCase(
@KaliumCoreLogic coreLogic: CoreLogic,
@CurrentAccount currentAccount: UserId
) =
coreLogic.getSessionScope(currentAccount).migrateFromPersonalToTeam
}
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,14 @@ class ConversationModule {
@Provides
fun provideGetFavoriteFolderUseCase(conversationScope: ConversationScope) =
conversationScope.getFavoriteFolder

@ViewModelScoped
@Provides
fun provideAddConversationToFavoritesUseCase(conversationScope: ConversationScope) =
conversationScope.addConversationToFavorites

@ViewModelScoped
@Provides
fun provideRemoveConversationFromFavoritesUseCase(conversationScope: ConversationScope) =
conversationScope.removeConversationFromFavorites
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.wire.kalium.logic.data.conversation.ConversationDetails.Self
import com.wire.kalium.logic.data.conversation.ConversationDetailsWithEvents
import com.wire.kalium.logic.data.conversation.MutedConversationStatus
import com.wire.kalium.logic.data.conversation.UnreadEventCount
import com.wire.kalium.logic.data.id.TeamId
import com.wire.kalium.logic.data.message.UnreadEventType
import com.wire.kalium.logic.data.user.ConnectionState
import com.wire.kalium.logic.data.user.UserAvailabilityStatus
Expand All @@ -43,20 +44,21 @@ fun ConversationDetailsWithEvents.toConversationItem(
wireSessionImageLoader: WireSessionImageLoader,
userTypeMapper: UserTypeMapper,
searchQuery: String,
selfUserTeamId: TeamId?
): ConversationItem = when (val conversationDetails = this.conversationDetails) {
is Group -> {
ConversationItem.GroupConversation(
groupName = conversationDetails.conversation.name.orEmpty(),
conversationId = conversationDetails.conversation.id,
mutedStatus = conversationDetails.conversation.mutedStatus,
isLegalHold = conversationDetails.conversation.legalHoldStatus.showLegalHoldIndicator(),
showLegalHoldIndicator = conversationDetails.conversation.legalHoldStatus.showLegalHoldIndicator(),
lastMessageContent = lastMessage.toUIPreview(unreadEventCount),
badgeEventType = parseConversationEventType(
mutedStatus = conversationDetails.conversation.mutedStatus,
unreadEventCount = unreadEventCount
),
hasOnGoingCall = conversationDetails.hasOngoingCall && conversationDetails.isSelfUserMember,
isSelfUserCreator = conversationDetails.isSelfUserCreator,
isFromTheSameTeam = conversationDetails.conversation.teamId == selfUserTeamId,
isSelfUserMember = conversationDetails.isSelfUserMember,
teamId = conversationDetails.conversation.teamId,
selfMemberRole = conversationDetails.selfRole,
Expand All @@ -65,6 +67,7 @@ fun ConversationDetailsWithEvents.toConversationItem(
proteusVerificationStatus = conversationDetails.conversation.proteusVerificationStatus,
hasNewActivitiesToShow = hasNewActivitiesToShow,
searchQuery = searchQuery,
isFavorite = conversationDetails.isFavorite
)
}

Expand All @@ -83,7 +86,7 @@ fun ConversationDetailsWithEvents.toConversationItem(
),
conversationId = conversationDetails.conversation.id,
mutedStatus = conversationDetails.conversation.mutedStatus,
isLegalHold = conversationDetails.conversation.legalHoldStatus.showLegalHoldIndicator(),
showLegalHoldIndicator = conversationDetails.conversation.legalHoldStatus.showLegalHoldIndicator(),
lastMessageContent = lastMessage.toUIPreview(unreadEventCount),
badgeEventType = parsePrivateConversationEventType(
conversationDetails.otherUser.connectionStatus,
Expand All @@ -101,6 +104,7 @@ fun ConversationDetailsWithEvents.toConversationItem(
proteusVerificationStatus = conversationDetails.conversation.proteusVerificationStatus,
hasNewActivitiesToShow = hasNewActivitiesToShow,
searchQuery = searchQuery,
isFavorite = conversationDetails.isFavorite
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class MessageMapper @Inject constructor(
is SelfUser, null -> Membership.None
},
connectionState = getConnectionState(sender),
isLegalHold = sender?.isUnderLegalHold == true,
showLegalHoldIndicator = sender?.isUnderLegalHold == true,
messageTime = MessageTime(message.date),
messageStatus = getMessageStatus(message),
messageId = message.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ import android.content.Context
import android.media.MediaPlayer
import android.media.MediaPlayer.SEEK_CLOSEST_SYNC
import android.net.Uri
import com.wire.android.di.KaliumCoreLogic
import com.wire.kalium.logic.CoreLogic
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.feature.asset.GetMessageAssetUseCase
import com.wire.kalium.logic.feature.asset.MessageAssetResult
import com.wire.kalium.logic.feature.session.CurrentSessionResult
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.delay
Expand All @@ -34,14 +36,44 @@ import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.launch
import javax.inject.Inject
import javax.inject.Singleton

class ConversationAudioMessagePlayer
@Singleton
class ConversationAudioMessagePlayerProvider
@Inject constructor(
private val context: Context,
private val audioMediaPlayer: MediaPlayer,
private val getMessageAsset: GetMessageAssetUseCase
@KaliumCoreLogic private val coreLogic: CoreLogic,
) {
private var player: ConversationAudioMessagePlayer? = null
private var usageCount: Int = 0

@Synchronized
fun provide(): ConversationAudioMessagePlayer {
val player = player ?: ConversationAudioMessagePlayer(context, audioMediaPlayer, coreLogic).also { player = it }
usageCount++

return player
}

@Synchronized
fun onCleared() {
usageCount--
if (usageCount <= 0) {
player?.close()
player = null
}
}
}

class ConversationAudioMessagePlayer
internal constructor(
private val context: Context,
private val audioMediaPlayer: MediaPlayer,
@KaliumCoreLogic private val coreLogic: CoreLogic,
) {
private companion object {
const val UPDATE_POSITION_INTERVAL_IN_MS = 1000L
Expand Down Expand Up @@ -137,7 +169,7 @@ class ConversationAudioMessagePlayer
}

audioMessageStateHistory
}
}.onStart { emit(audioMessageStateHistory) }

private var currentAudioMessageId: String? = null

Expand Down Expand Up @@ -169,10 +201,10 @@ class ConversationAudioMessagePlayer
}

private suspend fun stopCurrentlyPlayingAudioMessage() {
if (currentAudioMessageId != null) {
val currentAudioState = audioMessageStateHistory[currentAudioMessageId]
currentAudioMessageId?.let {
val currentAudioState = audioMessageStateHistory[it]
if (currentAudioState?.audioMediaPlayingState != AudioMediaPlayingState.Fetching) {
stop(currentAudioMessageId!!)
stop(it)
}
}
}
Expand All @@ -194,14 +226,22 @@ class ConversationAudioMessagePlayer

coroutineScope {
launch {
val currentAccountResult = coreLogic.getGlobalScope().session.currentSession()
if (currentAccountResult is CurrentSessionResult.Failure) return@launch

audioMessageStateUpdate.emit(
AudioMediaPlayerStateUpdate.AudioMediaPlayingStateUpdate(
messageId,
AudioMediaPlayingState.Fetching
)
)

when (val result = getMessageAsset(conversationId, messageId).await()) {
val assetMessage = coreLogic
.getSessionScope((currentAccountResult as CurrentSessionResult.Success).accountInfo.userId)
.messages
.getAssetMessage(conversationId, messageId)

when (val result = assetMessage.await()) {
is MessageAssetResult.Success -> {
audioMessageStateUpdate.emit(
AudioMediaPlayerStateUpdate.AudioMediaPlayingStateUpdate(
Expand All @@ -219,9 +259,7 @@ class ConversationAudioMessagePlayer
)
audioMediaPlayer.prepare()

if (position != null) {
audioMediaPlayer.seekTo(position)
}
if (position != null) audioMediaPlayer.seekTo(position)

audioMediaPlayer.start()

Expand Down Expand Up @@ -292,7 +330,7 @@ class ConversationAudioMessagePlayer
)
}

fun close() {
audioMediaPlayer.release()
internal fun close() {
audioMediaPlayer.reset()
}
}
7 changes: 7 additions & 0 deletions app/src/main/kotlin/com/wire/android/model/SnackBarMessage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ interface SnackBarMessage {
val uiText: UIText
val actionLabel: UIText? get() = null
}

data class DefaultSnackBarMessage(
override val uiText: UIText,
override val actionLabel: UIText? = null
) : SnackBarMessage

fun UIText.asSnackBarMessage(actionLabel: UIText? = null): SnackBarMessage = DefaultSnackBarMessage(this, actionLabel)
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ fun OngoingCallScreen(
clearVideoPreview = sharedCallingViewModel::clearVideoPreview,
onCollapse = onCollapse,
requestVideoStreams = ongoingCallViewModel::requestVideoStreams,
onSelectedParticipant = ongoingCallViewModel::onSelectedParticipant,
selectedParticipantForFullScreen = ongoingCallViewModel.selectedParticipant,
hideDoubleTapToast = ongoingCallViewModel::hideDoubleTapToast,
onCameraPermissionPermanentlyDenied = onCameraPermissionPermanentlyDenied,
participants = sharedCallingViewModel.participantsState,
Expand Down Expand Up @@ -289,6 +291,8 @@ private fun OngoingCallContent(
hideDoubleTapToast: () -> Unit,
onCameraPermissionPermanentlyDenied: () -> Unit,
requestVideoStreams: (participants: List<UICallParticipant>) -> Unit,
onSelectedParticipant: (selectedParticipant: SelectedParticipant) -> Unit,
selectedParticipantForFullScreen: SelectedParticipant,
participants: PersistentList<UICallParticipant>,
inPictureInPictureMode: Boolean,
currentUserId: UserId,
Expand All @@ -303,7 +307,6 @@ private fun OngoingCallContent(
)

var shouldOpenFullScreen by remember { mutableStateOf(false) }
var selectedParticipantForFullScreen by remember { mutableStateOf(SelectedParticipant()) }

WireBottomSheetScaffold(
sheetDragHandle = null,
Expand Down Expand Up @@ -391,11 +394,14 @@ private fun OngoingCallContent(
selectedParticipant = selectedParticipantForFullScreen,
height = this@BoxWithConstraints.maxHeight - dimensions().spacing4x,
closeFullScreen = {
onSelectedParticipant(SelectedParticipant())
shouldOpenFullScreen = !shouldOpenFullScreen
},
onBackButtonClicked = {
onSelectedParticipant(SelectedParticipant())
shouldOpenFullScreen = !shouldOpenFullScreen
},
requestVideoStreams = requestVideoStreams,
setVideoPreview = setVideoPreview,
clearVideoPreview = clearVideoPreview,
participants = participants
Expand All @@ -412,7 +418,7 @@ private fun OngoingCallContent(
requestVideoStreams = requestVideoStreams,
currentUserId = currentUserId,
onDoubleTap = { selectedParticipant ->
selectedParticipantForFullScreen = selectedParticipant
onSelectedParticipant(selectedParticipant)
shouldOpenFullScreen = !shouldOpenFullScreen
},
)
Expand Down Expand Up @@ -580,6 +586,8 @@ fun PreviewOngoingCallContent(participants: PersistentList<UICallParticipant>) {
participants = participants,
inPictureInPictureMode = false,
currentUserId = UserId("userId", "domain"),
onSelectedParticipant = {},
selectedParticipantForFullScreen = SelectedParticipant(),
)
}

Expand Down
Loading

0 comments on commit 58366f6

Please sign in to comment.