1
0
mirror of https://github.com/vector-im/riotX-android synced 2025-10-06 00:02:48 +02:00

Compare commits

...

5 Commits

Author SHA1 Message Date
Onuray Sahin
4f7be0571f Implement live location users bottom sheet with dummy data (waiting for other PRs for actual data). 2022-05-24 19:00:32 +03:00
Onuray Sahin
485d7e66b8 Create layout for live location users bottom sheet. 2022-05-24 18:59:56 +03:00
Onuray Sahin
0b72dda3af Create item layout for live location bottom sheet. 2022-05-23 18:06:11 +03:00
Onuray Sahin
3a1c155113 Create style for live location bottom sheet. 2022-05-23 16:57:41 +03:00
Onuray Sahin
4765a23c0e Create sample data for live location bottom sheet. 2022-05-23 16:57:03 +03:00
10 changed files with 330 additions and 0 deletions

View File

@@ -18,4 +18,27 @@
<item name="android:gravity">center</item>
</style>
<style name="TextAppearance.Vector.Body.BottomSheetDisplayName">
<item name="android:textSize">16sp</item>
</style>
<style name="TextAppearance.Vector.Body.BottomSheetRemainingTime">
<item name="android:textSize">12sp</item>
</style>
<style name="TextAppearance.Vector.Body.BottomSheetLastUpdatedAt">
<item name="android:textSize">12sp</item>
<item name="android:textColor">?vctr_content_tertiary</item>
</style>
<style name="Widget.Vector.Button.Text.BottomSheetStopSharing">
<item name="android:foreground">?selectableItemBackground</item>
<item name="android:background">@android:color/transparent</item>
<item name="android:textAppearance">@style/TextAppearance.Vector.Body.Medium</item>
<item name="android:textColor">?colorError</item>
<item name="android:padding">0dp</item>
<item name="android:gravity">center</item>
</style>
</resources>

View File

@@ -0,0 +1,14 @@
{
"data": [
{
"displayName": "Amandine",
"remainingTime": "9min left",
"lastUpdatedAt": "Updated 12min ago"
},
{
"displayName": "You",
"remainingTime": "19min left",
"lastUpdatedAt": "Updated 1min ago"
}
]
}

View File

@@ -23,7 +23,10 @@ import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.core.extensions.addFragment
import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivityLocationSharingBinding
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.location.live.map.bottomsheet.LiveLocationUsersBottomSheet
import kotlinx.parcelize.Parcelize
import javax.inject.Inject
@Parcelize
data class LocationSharingArgs(
@@ -36,6 +39,8 @@ data class LocationSharingArgs(
@AndroidEntryPoint
class LocationSharingActivity : VectorBaseActivity<ActivityLocationSharingBinding>() {
@Inject lateinit var avatarRenderer: AvatarRenderer
override fun getBinding() = ActivityLocationSharingBinding.inflate(layoutInflater)
override fun initUiAndData() {
@@ -66,6 +71,8 @@ class LocationSharingActivity : VectorBaseActivity<ActivityLocationSharingBindin
}
}
}
LiveLocationUsersBottomSheet(avatarRenderer).show(supportFragmentManager, "LiveLocationUsersBottomSheet")
}
companion object {

View File

@@ -0,0 +1,79 @@
/*
* Copyright (c) 2022 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.app.features.location.live.map.bottomsheet
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.core.view.isVisible
import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import im.vector.app.R
import im.vector.app.core.epoxy.VectorEpoxyHolder
import im.vector.app.core.epoxy.VectorEpoxyModel
import im.vector.app.core.epoxy.onClick
import im.vector.app.features.home.AvatarRenderer
import org.matrix.android.sdk.api.util.MatrixItem
@EpoxyModelClass(layout = R.layout.item_live_location_users_bottom_sheet)
abstract class LiveLocationUserItem : VectorEpoxyModel<LiveLocationUserItem.Holder>() {
interface Callback {
fun onStopSharingClicked()
}
@EpoxyAttribute
var callback: Callback? = null
@EpoxyAttribute
lateinit var matrixItem: MatrixItem
@EpoxyAttribute
lateinit var avatarRenderer: AvatarRenderer
@EpoxyAttribute
var remainingTime: String? = null
@EpoxyAttribute
var lastUpdatedAt: String? = null
@EpoxyAttribute
var showStopSharingButton: Boolean = false
override fun bind(holder: Holder) {
super.bind(holder)
avatarRenderer.render(matrixItem, holder.itemUserAvatarImageView)
holder.itemUserDisplayNameTextView.text = matrixItem.displayName
holder.itemRemainingTimeTextView.text = remainingTime
holder.itemLastUpdatedAtTextView.text = lastUpdatedAt
holder.itemStopSharingButton.isVisible = showStopSharingButton
if (showStopSharingButton) {
holder.itemStopSharingButton.onClick {
callback?.onStopSharingClicked()
}
}
}
class Holder : VectorEpoxyHolder() {
val itemUserAvatarImageView by bind<ImageView>(R.id.itemUserAvatarImageView)
val itemUserDisplayNameTextView by bind<TextView>(R.id.itemUserDisplayNameTextView)
val itemRemainingTimeTextView by bind<TextView>(R.id.itemRemainingTimeTextView)
val itemLastUpdatedAtTextView by bind<TextView>(R.id.itemLastUpdatedAtTextView)
val itemStopSharingButton by bind<Button>(R.id.itemStopSharingButton)
}
}

View File

@@ -0,0 +1,102 @@
/*
* Copyright (c) 2022 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.app.features.location.live.map.bottomsheet
import android.content.res.ColorStateList
import android.content.res.Resources
import android.graphics.Color
import android.graphics.PorterDuff
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.airbnb.epoxy.SimpleEpoxyController
import com.google.android.material.bottomsheet.BottomSheetBehavior
import im.vector.app.core.epoxy.BottomSheetDividerItem_
import im.vector.app.core.extensions.configureWith
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment
import im.vector.app.core.utils.DimensionConverter
import im.vector.app.databinding.BottomSheetLiveLocationUsersBinding
import im.vector.app.features.home.AvatarRenderer
import org.matrix.android.sdk.api.util.MatrixItem
class LiveLocationUsersBottomSheet(
private var avatarRenderer: AvatarRenderer
) : VectorBaseBottomSheetDialogFragment<BottomSheetLiveLocationUsersBinding>() {
private var bottomSheetBehavior: BottomSheetBehavior<View>? = null
private val controller = SimpleEpoxyController()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val layoutParams = view.layoutParams
layoutParams.height = Resources.getSystem().displayMetrics.heightPixels
view.layoutParams = layoutParams
view.requestLayout()
views.bottomSheetRecyclerView.configureWith(controller, hasFixedSize = false)
val models = dummyData.mapIndexed { index, item ->
listOf(
LiveLocationUserItem_().apply {
id(index)
matrixItem(item)
avatarRenderer(this@LiveLocationUsersBottomSheet.avatarRenderer)
remainingTime("9min left")
lastUpdatedAt("Updated 2min ago")
showStopSharingButton(index == 1)
},
BottomSheetDividerItem_().apply {
id("divider_$index")
}
)
}
controller.setModels(models.flatten())
}
override fun onStart() {
super.onStart()
val bottomSheet = (view?.parent as View)
bottomSheet.backgroundTintMode = PorterDuff.Mode.CLEAR
bottomSheet.backgroundTintList = ColorStateList.valueOf(Color.TRANSPARENT)
bottomSheet.setBackgroundColor(Color.TRANSPARENT)
bottomSheetBehavior = BottomSheetBehavior.from(view?.parent as View)
bottomSheetBehavior?.setPeekHeight(DimensionConverter(resources).dpToPx(200), false)
}
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetLiveLocationUsersBinding {
return BottomSheetLiveLocationUsersBinding.inflate(inflater, container, false)
}
companion object {
// Waiting for other PR to be merged
private val dummyData = mutableListOf<MatrixItem>().apply {
repeat(5) {
add(
MatrixItem.UserItem(
"@test_$it:matrix.org",
"Test_$it",
"https://matrix-client.matrix.org/_matrix/media/r0/download/matrix.org/vQMHeiAfRxrEENOFnIMccZoI"
)
)
}
}
}
}

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:topLeftRadius="16dp"
android:topRightRadius="16dp" />
<solid android:color="?android:colorBackground" />
</shape>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<size android:width="36dp" android:height="6dp" />
<solid android:color="?vctr_content_quinary" />
<corners android:radius="3dp" />
</shape>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_live_location_users_bottom_sheet">
<View
android:id="@+id/bottomSheetHandle"
android:layout_width="36dp"
android:layout_height="6dp"
android:layout_marginTop="12dp"
android:background="@drawable/ic_bottom_sheet_handle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/bottomSheetRecyclerView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/bottomSheetHandle"
tools:listitem="@layout/item_live_location_users_bottom_sheet" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="80dp">
<ImageView
android:id="@+id/itemUserAvatarImageView"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="16dp"
android:layout_marginTop="12dp"
android:importantForAccessibility="no"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@sample/user_round_avatars" />
<TextView
android:id="@+id/itemUserDisplayNameTextView"
style="@style/TextAppearance.Vector.Body.BottomSheetDisplayName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
app:layout_constraintStart_toEndOf="@id/itemUserAvatarImageView"
app:layout_constraintTop_toTopOf="@id/itemUserAvatarImageView"
tools:text="@sample/live_location_users.json/data/displayName" />
<TextView
android:id="@+id/itemRemainingTimeTextView"
style="@style/TextAppearance.Vector.Body.BottomSheetRemainingTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
app:layout_constraintStart_toStartOf="@id/itemUserDisplayNameTextView"
app:layout_constraintTop_toBottomOf="@id/itemUserDisplayNameTextView"
tools:text="@sample/live_location_users.json/data/remainingTime" />
<TextView
android:id="@+id/itemLastUpdatedAtTextView"
style="@style/TextAppearance.Vector.Body.BottomSheetLastUpdatedAt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
app:layout_constraintStart_toStartOf="@id/itemRemainingTimeTextView"
app:layout_constraintTop_toBottomOf="@id/itemRemainingTimeTextView"
tools:text="@sample/live_location_users.json/data/lastUpdatedAt" />
<Button
android:id="@+id/itemStopSharingButton"
style="@style/Widget.Vector.Button.Text.BottomSheetStopSharing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:text="@string/live_location_bottom_sheet_stop_sharing"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -3037,6 +3037,7 @@
<string name="live_location_sharing_notification_description">Location sharing is in progress</string>
<string name="labs_enable_live_location">Enable Live Location Sharing</string>
<string name="labs_enable_live_location_summary">Temporary implementation: locations persist in room history</string>
<string name="live_location_bottom_sheet_stop_sharing">Stop sharing</string>
<string name="message_bubbles">Show Message bubbles</string>