mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
PR feedback
This commit is contained in:
parent
f568553d21
commit
d08b4e1ea0
@ -2,7 +2,7 @@ Changes in RiotX 0.20.0 (2020-XX-XX)
|
|||||||
===================================================
|
===================================================
|
||||||
|
|
||||||
Features ✨:
|
Features ✨:
|
||||||
- Add Direct Shortcuts
|
- Add Direct Shortcuts (#652)
|
||||||
|
|
||||||
Improvements 🙌:
|
Improvements 🙌:
|
||||||
-
|
-
|
||||||
|
@ -146,7 +146,8 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable {
|
|||||||
promptCompleteSecurityIfNeeded()
|
promptCompleteSecurityIfNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
shortcutsHandler.observeRoomsAndBuildShortcuts(context = this)
|
shortcutsHandler.observeRoomsAndBuildShortcuts()
|
||||||
|
.disposeOnDestroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun promptCompleteSecurityIfNeeded() {
|
private fun promptCompleteSecurityIfNeeded() {
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package im.vector.riotx.features.home
|
package im.vector.riotx.features.home
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
@ -28,6 +27,7 @@ import im.vector.matrix.android.api.util.toMatrixItem
|
|||||||
import im.vector.riotx.core.glide.GlideApp
|
import im.vector.riotx.core.glide.GlideApp
|
||||||
import im.vector.riotx.core.utils.DimensionConverter
|
import im.vector.riotx.core.utils.DimensionConverter
|
||||||
import im.vector.riotx.features.home.room.detail.RoomDetailActivity
|
import im.vector.riotx.features.home.room.detail.RoomDetailActivity
|
||||||
|
import io.reactivex.disposables.Disposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -36,15 +36,25 @@ private const val adaptiveIconSizeDp = 108
|
|||||||
private const val adaptiveIconOuterSidesDp = 18
|
private const val adaptiveIconOuterSidesDp = 18
|
||||||
|
|
||||||
class ShortcutsHandler @Inject constructor(
|
class ShortcutsHandler @Inject constructor(
|
||||||
|
private val context: Context,
|
||||||
private val homeRoomListStore: HomeRoomListDataSource,
|
private val homeRoomListStore: HomeRoomListDataSource,
|
||||||
private val avatarRenderer: AvatarRenderer,
|
private val avatarRenderer: AvatarRenderer,
|
||||||
private val dimensionConverter: DimensionConverter
|
private val dimensionConverter: DimensionConverter
|
||||||
) {
|
) {
|
||||||
|
private val adaptiveIconSize = dimensionConverter.dpToPx(adaptiveIconSizeDp)
|
||||||
|
private val adaptiveIconOuterSides = dimensionConverter.dpToPx(adaptiveIconOuterSidesDp)
|
||||||
|
private val iconSize by lazy {
|
||||||
|
if (useAdaptiveIcon) {
|
||||||
|
adaptiveIconSize - adaptiveIconOuterSides
|
||||||
|
} else {
|
||||||
|
dimensionConverter.dpToPx(72)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("CheckResult")
|
fun observeRoomsAndBuildShortcuts(): Disposable {
|
||||||
fun observeRoomsAndBuildShortcuts(context: Context) {
|
return homeRoomListStore
|
||||||
homeRoomListStore
|
|
||||||
.observe()
|
.observe()
|
||||||
|
.distinct()
|
||||||
.observeOn(Schedulers.computation())
|
.observeOn(Schedulers.computation())
|
||||||
.subscribe { rooms ->
|
.subscribe { rooms ->
|
||||||
val shortcuts = rooms
|
val shortcuts = rooms
|
||||||
@ -52,16 +62,7 @@ class ShortcutsHandler @Inject constructor(
|
|||||||
.take(n = 4) // Android only allows us to create 4 shortcuts
|
.take(n = 4) // Android only allows us to create 4 shortcuts
|
||||||
.map { room ->
|
.map { room ->
|
||||||
val intent = RoomDetailActivity.shortcutIntent(context, room.roomId)
|
val intent = RoomDetailActivity.shortcutIntent(context, room.roomId)
|
||||||
|
val bitmap = avatarRenderer.shortcutDrawable(context, GlideApp.with(context), room.toMatrixItem(), iconSize)
|
||||||
val adaptiveIconSize = dimensionConverter.dpToPx(adaptiveIconSizeDp)
|
|
||||||
val adaptiveIconOuterSides = dimensionConverter.dpToPx(adaptiveIconOuterSidesDp)
|
|
||||||
val size = if (useAdaptiveIcon) {
|
|
||||||
adaptiveIconSize - adaptiveIconOuterSides
|
|
||||||
} else {
|
|
||||||
dimensionConverter.dpToPx(72)
|
|
||||||
}
|
|
||||||
|
|
||||||
val bitmap = avatarRenderer.shortcutDrawable(context, GlideApp.with(context), room.toMatrixItem(), size)
|
|
||||||
|
|
||||||
ShortcutInfoCompat.Builder(context, room.roomId)
|
ShortcutInfoCompat.Builder(context, room.roomId)
|
||||||
.setShortLabel(room.displayName)
|
.setShortLabel(room.displayName)
|
||||||
|
Loading…
Reference in New Issue
Block a user