Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/github_actions/gradle/wrapper-…
Browse files Browse the repository at this point in the history
…validation-action-3.3.0
  • Loading branch information
vitorhugods authored Apr 16, 2024
2 parents 7c448df + 1486bba commit 2eade6e
Show file tree
Hide file tree
Showing 53 changed files with 698 additions and 389 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.longPreferencesKey
import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.datastore.preferences.preferencesDataStore
import com.wire.kalium.logic.data.user.UserAvailabilityStatus
Expand Down Expand Up @@ -60,6 +61,12 @@ class UserDataStore(private val context: Context, userId: UserId) {
context.dataStore.edit { it.clear() }
}

fun lastBackupDateSeconds(): Flow<Long?> = context.dataStore.data.map { it[LAST_BACKUP_DATE_INSTANT] }

suspend fun setLastBackupDateSeconds(timeStampSeconds: Long) {
context.dataStore.edit { it[LAST_BACKUP_DATE_INSTANT] = timeStampSeconds }
}

private fun getStatusKey(status: UserAvailabilityStatus) = when (status) {
UserAvailabilityStatus.AVAILABLE -> SHOW_STATUS_RATIONALE_AVAILABLE
UserAvailabilityStatus.BUSY -> SHOW_STATUS_RATIONALE_BUSY
Expand All @@ -81,6 +88,7 @@ class UserDataStore(private val context: Context, userId: UserId) {
private val SHOW_STATUS_RATIONALE_NONE = booleanPreferencesKey("show_status_rationale_none")
private val USER_AVATAR_ASSET_ID = stringPreferencesKey("user_avatar_asset_id")
private val INITIAL_SYNC_COMPLETED = booleanPreferencesKey("initial_sync_completed")
private val LAST_BACKUP_DATE_INSTANT = longPreferencesKey("last_backup_date_instant")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ package com.wire.android.mapper
import com.wire.android.R
import com.wire.android.ui.home.conversations.model.MessageBody
import com.wire.android.ui.home.conversations.model.UILastMessageContent
import com.wire.android.ui.markdown.MarkdownConstants
import com.wire.android.util.ui.UIText
import com.wire.android.util.ui.toUIText
import com.wire.kalium.logic.data.conversation.UnreadEventCount
import com.wire.kalium.logic.data.message.AssetType
import com.wire.kalium.logic.data.message.MessagePreview
Expand Down Expand Up @@ -254,7 +256,7 @@ fun MessagePreview.uiLastMessageContent(): UILastMessageContent {
is WithUser.Text -> UILastMessageContent.SenderWithMessage(
sender = userUIText,
message = (content as WithUser.Text).messageBody.let { UIText.DynamicString(it) },
separator = ": "
separator = ":${MarkdownConstants.NON_BREAKING_SPACE}"
)

is WithUser.Composite -> {
Expand All @@ -263,7 +265,7 @@ fun MessagePreview.uiLastMessageContent(): UILastMessageContent {
UILastMessageContent.SenderWithMessage(
sender = userUIText,
message = text,
separator = ": "
separator = ":${MarkdownConstants.NON_BREAKING_SPACE}"
)
}

Expand Down Expand Up @@ -335,6 +337,12 @@ fun MessagePreview.uiLastMessageContent(): UILastMessageContent {
MessagePreviewContent.VerificationChanged.DegradedProteus ->
UILastMessageContent.VerificationChanged(R.string.last_message_conversations_verification_degraded_proteus)

is MessagePreviewContent.Draft -> UILastMessageContent.SenderWithMessage(
UIText.StringResource(R.string.label_draft),
(content as MessagePreviewContent.Draft).message.toUIText(),
separator = ":${MarkdownConstants.NON_BREAKING_SPACE}"
)

Unknown -> UILastMessageContent.None
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ import com.wire.android.ui.theme.wireDimensions
import com.wire.android.ui.theme.wireTypography
import com.wire.android.util.deeplink.DeepLinkResult
import com.wire.android.util.dialogErrorStrings
import com.wire.android.util.ui.UIText
import kotlinx.coroutines.launch

@RootNavGraph
Expand Down Expand Up @@ -344,9 +345,10 @@ data class LoginDialogErrorData(
val dismissOnClickOutside: Boolean = true
)

enum class LoginTabItem(@StringRes override val titleResId: Int) : TabItem {
enum class LoginTabItem(@StringRes val titleResId: Int) : TabItem {
EMAIL(R.string.login_tab_email),
SSO(R.string.login_tab_sso);
override val title: UIText = UIText.StringResource(titleResId)
}

@Preview
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,14 @@ import kotlin.math.roundToInt
* the lambda receives elevation value for the [topBarHeader]
* @param topBarCollapsing collapsing part of the top bar
* @param topBarFooter bar under the [topBarCollapsing], moves with it and ends up directly under [topBarHeader] when collapsed
* @param snackbarHost component to host [Snackbar]s that are pushed to be shown via
* [SnackbarHostState.showSnackbar], typically a [SnackbarHost]
* @param content content of the screen
* @param bottomBar bottom bar of the screen, typically a [NavigationBar]
* @param floatingActionButton Main action button of the screen, typically a [FloatingActionButton]
* @param floatingActionButtonPosition position of the FAB on the screen. See [FabPosition].
* @param isSwipeable if true then collapsing is enabled
* @param snapOnFling on collapsing fling, only close the collapsible and don't carry the velocity to the scrollable
* @param keepElevationWhenCollapsed if true then keep showing elevation also when scrolling children after top bar is already collapsed;
* if false then hide elevation when approaching the end of the collapsing and don't show it when scrolling children
* @param content content of the screen
*/
@OptIn(ExperimentalMaterialApi::class)
@Composable
Expand All @@ -71,16 +69,16 @@ fun CollapsingTopBarScaffold(
topBarHeader: @Composable (elevation: Dp) -> Unit,
topBarCollapsing: @Composable () -> Unit,
topBarFooter: @Composable () -> Unit = {},
content: @Composable () -> Unit,
bottomBar: @Composable () -> Unit = {},
floatingActionButton: @Composable () -> Unit = {},
floatingActionButtonPosition: FabPosition = FabPosition.End,
isSwipeable: Boolean = true,
snapOnFling: Boolean = true,
keepElevationWhenCollapsed: Boolean = false
keepElevationWhenCollapsed: Boolean = false,
content: @Composable () -> Unit,
) {
val maxBarElevationPx = with(LocalDensity.current) { maxBarElevation.toPx() }
val swipeableState = rememberSwipeableState(initialValue = State.EXPANDED)
val swipeableState = rememberSwipeableState(initialValue = State.EXPANDED) // TODO: migrate to AnchoredDraggable
var nestedOffsetState by rememberSaveable { mutableStateOf(0f) }
var collapsingHeight by rememberSaveable { mutableStateOf(0) }
val topBarElevationState by remember {
Expand Down
19 changes: 6 additions & 13 deletions app/src/main/kotlin/com/wire/android/ui/common/WireTabRow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

package com.wire.android.ui.common

import androidx.annotation.StringRes
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.pager.PagerState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Divider
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Tab
import androidx.compose.material3.TabPosition
Expand All @@ -35,12 +35,10 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.foundation.pager.PagerState
import com.wire.android.ui.home.conversations.messagedetails.MessageDetailsTabItem
import com.wire.android.ui.theme.wireColorScheme
import com.wire.android.ui.theme.wireTypography
import com.wire.android.util.ui.UIText
import kotlin.math.absoluteValue

@Composable
Expand All @@ -49,7 +47,7 @@ fun WireTabRow(
selectedTabIndex: Int,
onTabChange: (Int) -> Unit,
containerColor: Color = MaterialTheme.colorScheme.background,
divider: @Composable () -> Unit = @Composable { Divider() },
divider: @Composable () -> Unit = @Composable { HorizontalDivider() },
upperCaseTitles: Boolean = true,
modifier: Modifier = Modifier
) {
Expand All @@ -64,11 +62,7 @@ fun WireTabRow(
) {
tabs.forEachIndexed { index, tabItem ->
val selected = selectedTabIndex == index
val text = if (tabItem is MessageDetailsTabItem) {
stringResource(id = tabItem.titleResId, tabItem.count)
} else {
stringResource(id = tabItem.titleResId)
}.let {
val text = tabItem.title.asString().let {
if (upperCaseTitles) it.uppercase() else it
}

Expand Down Expand Up @@ -108,6 +102,5 @@ fun PagerState.calculateCurrentTab() = // change the tab if we go over half the
if (this.currentPageOffsetFraction.absoluteValue > 0.5f) this.targetPage else this.currentPage

interface TabItem {
@get:StringRes
val titleResId: Int
val title: UIText
}
Original file line number Diff line number Diff line change
Expand Up @@ -1103,8 +1103,9 @@ private fun CoroutineScope.withSmoothScreenLoad(block: () -> Unit) = launch {
@Preview
@Composable
fun PreviewConversationScreen() {
val conversationId = ConversationId("value", "domain")
val messageComposerViewState = remember { mutableStateOf(MessageComposerViewState()) }
val messageCompositionState = remember { mutableStateOf(MessageComposition.DEFAULT) }
val messageCompositionState = remember { mutableStateOf(MessageComposition(conversationId)) }
val conversationScreenState = rememberConversationScreenState()
val messageComposerStateHolder = rememberMessageComposerStateHolder(
messageComposerViewState = messageComposerViewState,
Expand All @@ -1117,7 +1118,7 @@ fun PreviewConversationScreen() {
messageComposerViewState = messageComposerViewState,
conversationCallViewState = ConversationCallViewState(),
conversationInfoViewState = ConversationInfoViewState(
conversationId = ConversationId("value", "domain"),
conversationId = conversationId,
conversationName = UIText.DynamicString("Some test conversation")
),
conversationMessagesViewState = ConversationMessagesViewState(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class MessageComposerViewModel @Inject constructor(

fun saveDraft(messageDraft: MessageDraft) {
viewModelScope.launch {
saveMessageDraft(conversationId, messageDraft)
saveMessageDraft(messageDraft)
}
}
}
Loading

0 comments on commit 2eade6e

Please sign in to comment.