Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fga/message bubbles #4937

Merged
merged 43 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
9a5934d
Bubbles: R&D try to find the best way to provide dynamic layout
Dec 16, 2021
e540b26
Merge develop into feature/fga/message_bubbles
Jan 4, 2022
bde1df0
Bubbles: continue R&D on UI
Jan 5, 2022
ad63d3d
Bubbles: still R&D. Not sure how to handle every event types.
Jan 6, 2022
f7c9b36
Bubbles: continue exploration
Jan 11, 2022
af542a8
Bubbles: start adding "theming" mechanism
Jan 11, 2022
f7df0b8
Bubbles: fix recycling issue
Jan 12, 2022
32e72f5
Bubbles: add quick settings (temporary)
Jan 12, 2022
37af93f
Bubbles: fix avatar/name visibility in modern layout
Jan 12, 2022
b9cc795
Bubbles : fix background colors
Jan 13, 2022
baee076
Bubbles: fix types using wrong layout
Jan 13, 2022
5ac1552
Bubbles: some clean up
Jan 13, 2022
d06df45
Merge branch 'develop' into feature/fga/message_bubbles
Jan 13, 2022
1108ef9
Bubbles: make it works for file, voice and polls. Also add parity for…
Jan 14, 2022
7ff8483
Merge branch 'develop' into feature/fga/message_bubbles
Jan 17, 2022
a9e7c45
Fix url preview sizing
Jan 18, 2022
5ee4984
Bubbles: handle images and make small refactoring
Jan 18, 2022
ac0c262
Bubbles: update sticker handling
Jan 19, 2022
2d9454c
Bubbles: first iteration on url preview
Jan 19, 2022
8c4dff4
Bubbles: change again url preview
Jan 20, 2022
713f6f7
Timeline: Add spacing to quote
Jan 21, 2022
1580269
Bubbles: move settings to timeline section
Jan 21, 2022
608d8a5
Bubbles: change colors
Jan 24, 2022
8f0e103
Bubbles: make round style algorithm more accurate
Jan 24, 2022
a9fe21e
Timeline html rendering: handle code tags
Jan 27, 2022
4de421d
Timeline html rendering: better reply and pill
Jan 27, 2022
881b063
Bubbles: remove emote from bubble (keep right/left alignment)
Jan 27, 2022
ed9adf8
Bubbles: fix paddings
Jan 27, 2022
c14eb05
Merge branch 'develop' into feature/fga/message_bubbles
Jan 27, 2022
b79a5fd
Bubble: move overlay view to MessageBubbleView (and fix corner radius)
Jan 28, 2022
35674ad
Bubbles: handle location sharing (need updates)
Jan 28, 2022
c425701
Bubbles: handle ripple effect
Jan 28, 2022
fd99d6d
Bubbles: start fixing RTL
Jan 28, 2022
820bc64
Bubble: introduce CornersRadius
Jan 31, 2022
38f1bbd
RTL: better support for some TextViews
Jan 31, 2022
825c2ca
Merge branch 'develop' into feature/fga/message_bubbles
Feb 1, 2022
5081006
Bubbles: update media sizing (including LocationItem)
Feb 1, 2022
cfda76b
Timeline: avoid overflow on getViewType
Feb 1, 2022
1bf2523
Merge branch 'develop' into feature/fga/message_bubbles
Feb 2, 2022
9e00867
Bubbles: clean up after review
Feb 2, 2022
2e2da16
Bubbles: merge develop
Feb 3, 2022
0423431
Bubble: get LayoutDirection (RTL) from current Locale
Feb 3, 2022
02de636
Bubbles: add CHANGELOG file
Feb 3, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Tint color is provided by the theme -->
<solid android:color="@android:color/black" />
<size
android:width="240dp"
android:height="44dp" />
<corners
android:bottomLeftRadius="12dp"
android:bottomRightRadius="12dp"
Expand Down
8 changes: 3 additions & 5 deletions library/ui-styles/src/main/res/drawable/file_progress_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item android:id="@android:id/background">
<shape>
<corners android:radius="8dp" />
<solid android:color="?vctr_room_active_widgets_banner_bg" />
<shape android:shape="oval">
<solid android:color="?vctr_system" />
</shape>
</item>

<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="8dp" />
<shape android:shape="oval">
<solid android:color="@color/vctr_notice_secondary_alpha12" />
</shape>
</clip>
Expand Down
1 change: 1 addition & 0 deletions library/ui-styles/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,5 @@
<attr name="vctr_presence_indicator_offline" format="color" />
<color name="vctr_presence_indicator_offline_light">@color/palette_gray_100</color>
<color name="vctr_presence_indicator_offline_dark">@color/palette_gray_450</color>

</resources>
11 changes: 11 additions & 0 deletions library/ui-styles/src/main/res/values/colors_message_bubble.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<!-- Timeline bubble background colors -->
<attr name="vctr_message_bubble_inbound" format="color" />
<color name="vctr_message_bubble_inbound_light">#E8EDF4</color>
<color name="vctr_message_bubble_inbound_dark">#21262C</color>
<attr name="vctr_message_bubble_outbound" format="color" />
<color name="vctr_message_bubble_outbound_light">#E7F8F3</color>
<color name="vctr_message_bubble_outbound_dark">#133A34</color>
</resources>
9 changes: 9 additions & 0 deletions library/ui-styles/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<dimen name="item_decoration_left_margin">72dp</dimen>
<dimen name="item_event_message_state_size">16dp</dimen>

<dimen name="item_event_message_media_button_size">32dp</dimen>

<dimen name="chat_avatar_size">40dp</dimen>
<dimen name="member_list_avatar_size">60dp</dimen>

Expand Down Expand Up @@ -42,6 +44,7 @@

<!-- Preview Url -->
<dimen name="preview_url_view_corner_radius">8dp</dimen>
<dimen name="preview_url_view_image_max_height">160dp</dimen>

<dimen name="menu_item_icon_size">24dp</dimen>
<dimen name="menu_item_size">48dp</dimen>
Expand All @@ -52,6 +55,12 @@
<dimen name="composer_attachment_size">52dp</dimen>
<dimen name="composer_attachment_margin">1dp</dimen>


<dimen name="chat_bubble_margin_start">28dp</dimen>
<dimen name="chat_bubble_margin_end">62dp</dimen>
<dimen name="chat_bubble_fixed_size">300dp</dimen>
<dimen name="chat_bubble_corner_radius">12dp</dimen>

<!-- Onboarding -->
<item name="ftue_auth_gutter_start_percent" format="float" type="dimen">0.05</item>
<item name="ftue_auth_gutter_end_percent" format="float" type="dimen">0.95</item>
Expand Down
11 changes: 11 additions & 0 deletions library/ui-styles/src/main/res/values/stylable_message_bubble.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<declare-styleable name="MessageBubble">
<attr name="incoming_style" format="boolean" />
<attr name="show_time_overlay" format="boolean" />
<attr name="is_first" format="boolean" />
<attr name="is_last" format="boolean" />
</declare-styleable>

</resources>
1 change: 1 addition & 0 deletions library/ui-styles/src/main/res/values/styles_progress.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<style name="Widget.Vector.ProgressBar.Horizontal.File">
<item name="android:indeterminateOnly">false</item>
<item name="android:progressDrawable">@drawable/file_progress_bar</item>
<item name="android:progressBackgroundTint">?android:colorBackground</item>
<item name="android:minHeight">10dp</item>
<item name="android:maxHeight">40dp</item>
</style>
Expand Down
23 changes: 17 additions & 6 deletions library/ui-styles/src/main/res/values/styles_timeline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@
<style name="TimelineContentStubBaseParams">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginStart">8dp</item>
<item name="android:layout_marginLeft">8dp</item>
<item name="android:layout_marginEnd">8dp</item>
<item name="android:layout_marginRight">8dp</item>
<item name="android:layout_marginBottom">4dp</item>
<item name="android:layout_marginTop">4dp</item>
</style>

<style name="TimelineContentStubContainerParams">
<item name="android:paddingStart">8dp</item>
<item name="android:paddingEnd">8dp</item>
<item name="android:paddingTop">4dp</item>
<item name="android:paddingBottom">4dp</item>
</style>

<style name="TimelineContentMediaPillStyle">
<item name="android:paddingStart">8dp</item>
<item name="android:paddingEnd">8dp</item>
<item name="android:paddingTop">6dp</item>
<item name="android:paddingBottom">6dp</item>
<item name="minHeight">48dp</item>
<item name="android:background">@drawable/bg_media_pill</item>
<item name="android:backgroundTint">?vctr_content_quinary</item>
</style>

</resources>
2 changes: 2 additions & 0 deletions library/ui-styles/src/main/res/values/theme_dark.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
<item name="vctr_waiting_background_color">@color/vctr_waiting_background_color_dark</item>
<item name="vctr_chat_effect_snow_background">@color/vctr_chat_effect_snow_background_dark</item>
<item name="vctr_toolbar_background">@color/element_system_dark</item>
<item name="vctr_message_bubble_inbound">@color/vctr_message_bubble_inbound_dark</item>
<item name="vctr_message_bubble_outbound">@color/vctr_message_bubble_outbound_dark</item>

<!-- room message colors -->
<item name="vctr_notice_secondary">#61708B</item>
Expand Down
2 changes: 2 additions & 0 deletions library/ui-styles/src/main/res/values/theme_light.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
<item name="vctr_waiting_background_color">@color/vctr_waiting_background_color_light</item>
<item name="vctr_chat_effect_snow_background">@color/vctr_chat_effect_snow_background_light</item>
<item name="vctr_toolbar_background">@color/element_background_light</item>
<item name="vctr_message_bubble_inbound">@color/vctr_message_bubble_inbound_light</item>
<item name="vctr_message_bubble_outbound">@color/vctr_message_bubble_outbound_light</item>

<!-- room message colors -->
<item name="vctr_notice_secondary">#61708B</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,9 @@ data class PreviewUrlData(
// Value of field "og:description"
val description: String?,
// Value of field "og:image"
val mxcUrl: String?
val mxcUrl: String?,
// Value of field "og:image:width"
val imageWidth: Int?,
// Value of field "og:image:height"
val imageHeight: Int?
)
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ internal class RealmSessionStoreMigration @Inject constructor(
) : RealmMigration {

companion object {
const val SESSION_STORE_SCHEMA_VERSION = 22L
const val SESSION_STORE_SCHEMA_VERSION = 23L
}

/**
Expand Down Expand Up @@ -92,6 +92,7 @@ internal class RealmSessionStoreMigration @Inject constructor(
if (oldVersion <= 19) migrateTo20(realm)
if (oldVersion <= 20) migrateTo21(realm)
if (oldVersion <= 21) migrateTo22(realm)
if (oldVersion <= 22) migrateTo23(realm)
}

private fun migrateTo1(realm: DynamicRealm) {
Expand Down Expand Up @@ -462,4 +463,13 @@ internal class RealmSessionStoreMigration @Inject constructor(
}
?.addRealmObjectField(EventEntityFields.THREAD_SUMMARY_LATEST_MESSAGE.`$`, eventEntity)
}

private fun migrateTo23(realm: DynamicRealm) {
Timber.d("Step 22 -> 23")
realm.schema.get("PreviewUrlCacheEntity")
?.addField(PreviewUrlCacheEntityFields.IMAGE_WIDTH, Int::class.java)
?.setNullable(PreviewUrlCacheEntityFields.IMAGE_WIDTH, true)
?.addField(PreviewUrlCacheEntityFields.IMAGE_HEIGHT, Int::class.java)
?.setNullable(PreviewUrlCacheEntityFields.IMAGE_HEIGHT, true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ internal open class PreviewUrlCacheEntity(
var title: String? = null,
var description: String? = null,
var mxcUrl: String? = null,

var imageWidth: Int? = null,
var imageHeight: Int? = null,
var lastUpdatedTimestamp: Long = 0L
) : RealmObject() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ internal class DefaultGetPreviewUrlTask @Inject constructor(

override suspend fun execute(params: GetPreviewUrlTask.Params): PreviewUrlData {
return when (params.cacheStrategy) {
CacheStrategy.NoCache -> doRequest(params.url, params.timestamp)
is CacheStrategy.TtlCache -> doRequestWithCache(
CacheStrategy.NoCache -> doRequest(params.url, params.timestamp)
is CacheStrategy.TtlCache -> doRequestWithCache(
params.url,
params.timestamp,
params.cacheStrategy.validityDurationInMillis,
Expand Down Expand Up @@ -77,7 +77,9 @@ internal class DefaultGetPreviewUrlTask @Inject constructor(
siteName = (get("og:site_name") as? String)?.unescapeHtml(),
title = (get("og:title") as? String)?.unescapeHtml(),
description = (get("og:description") as? String)?.unescapeHtml(),
mxcUrl = get("og:image") as? String
mxcUrl = get("og:image") as? String,
imageHeight = (get("og:image:height") as? Double)?.toInt(),
imageWidth = (get("og:image:width") as? Double)?.toInt(),
)
}

Expand Down Expand Up @@ -114,7 +116,8 @@ internal class DefaultGetPreviewUrlTask @Inject constructor(
previewUrlCacheEntity.title = data.title
previewUrlCacheEntity.description = data.description
previewUrlCacheEntity.mxcUrl = data.mxcUrl

previewUrlCacheEntity.imageHeight = data.imageHeight
previewUrlCacheEntity.imageWidth = data.imageWidth
previewUrlCacheEntity.lastUpdatedTimestamp = Date().time
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ internal fun PreviewUrlCacheEntity.toDomain() = PreviewUrlData(
siteName = siteName,
title = title,
description = description,
mxcUrl = mxcUrl
mxcUrl = mxcUrl,
imageWidth = imageWidth,
imageHeight = imageHeight
)
Original file line number Diff line number Diff line change
Expand Up @@ -382,20 +382,28 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec
(0 until modelCache.size).forEach { position ->
val event = currentSnapshot[position]
val nextEvent = currentSnapshot.nextOrNull(position)
val prevEvent = currentSnapshot.prevOrNull(position)
val nextDisplayableEvent = currentSnapshot.subList(position + 1, currentSnapshot.size).firstOrNull {
timelineEventVisibilityHelper.shouldShowEvent(
timelineEvent = it,
highlightedEventId = partialState.highlightedEventId,
isFromThreadTimeline = partialState.isFromThreadTimeline(),
rootThreadEventId = partialState.rootThreadEventId)
}
// Should be build if not cached or if model should be refreshed
if (modelCache[position] == null || modelCache[position]?.isCacheable(partialState) == false) {
val prevEvent = currentSnapshot.prevOrNull(position)
val prevDisplayableEvent = currentSnapshot.subList(0, position).lastOrNull {
timelineEventVisibilityHelper.shouldShowEvent(
timelineEvent = it,
highlightedEventId = partialState.highlightedEventId,
isFromThreadTimeline = partialState.isFromThreadTimeline(),
rootThreadEventId = partialState.rootThreadEventId)
}
val nextDisplayableEvent = currentSnapshot.subList(position + 1, currentSnapshot.size).firstOrNull {
timelineEventVisibilityHelper.shouldShowEvent(
timelineEvent = it,
highlightedEventId = partialState.highlightedEventId,
isFromThreadTimeline = partialState.isFromThreadTimeline(),
rootThreadEventId = partialState.rootThreadEventId)
}
val timelineEventsGroup = timelineEventsGroups.getOrNull(event)
val params = TimelineItemFactoryParams(
event = event,
prevEvent = prevEvent,
prevDisplayableEvent = prevDisplayableEvent,
nextEvent = nextEvent,
nextDisplayableEvent = nextDisplayableEvent,
partialState = partialState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class EncryptedItemFactory @Inject constructor(private val messageInformationDat
callback = params.callback,
threadDetails = threadDetails)
return MessageTextItem_()
.layout(informationData.messageLayout.layoutRes)
.leftGuideline(avatarSizeProvider.leftGuideline)
.highlighted(params.isHighlighted)
.attributes(attributes)
Expand Down
Loading