mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Merge pull request #1076 from vector-im/feature/fullscreen_avatar
Display avatar in fullscreen.
This commit is contained in:
commit
674450ef29
@ -11,6 +11,7 @@ Features ✨:
|
|||||||
Improvements 🙌:
|
Improvements 🙌:
|
||||||
- Migrate to binary QR code verification (#994)
|
- Migrate to binary QR code verification (#994)
|
||||||
- Share action is added to room profile and room member profile (#858)
|
- Share action is added to room profile and room member profile (#858)
|
||||||
|
- Display avatar in fullscreen (#861)
|
||||||
- Fix some performance issues with crypto
|
- Fix some performance issues with crypto
|
||||||
|
|
||||||
Bugfix 🐛:
|
Bugfix 🐛:
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
android:name=".features.login.LoginActivity"
|
android:name=".features.login.LoginActivity"
|
||||||
android:windowSoftInputMode="adjustResize" />
|
android:windowSoftInputMode="adjustResize" />
|
||||||
<activity android:name=".features.media.ImageMediaViewerActivity" />
|
<activity android:name=".features.media.ImageMediaViewerActivity" />
|
||||||
|
<activity android:name=".features.media.BigImageViewerActivity" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".features.rageshake.BugReportActivity"
|
android:name=".features.rageshake.BugReportActivity"
|
||||||
android:label="@string/title_activity_bug_report" />
|
android:label="@string/title_activity_bug_report" />
|
||||||
|
@ -41,6 +41,7 @@ import im.vector.riotx.features.home.room.list.actions.RoomListQuickActionsBotto
|
|||||||
import im.vector.riotx.features.invite.VectorInviteView
|
import im.vector.riotx.features.invite.VectorInviteView
|
||||||
import im.vector.riotx.features.link.LinkHandlerActivity
|
import im.vector.riotx.features.link.LinkHandlerActivity
|
||||||
import im.vector.riotx.features.login.LoginActivity
|
import im.vector.riotx.features.login.LoginActivity
|
||||||
|
import im.vector.riotx.features.media.BigImageViewerActivity
|
||||||
import im.vector.riotx.features.media.ImageMediaViewerActivity
|
import im.vector.riotx.features.media.ImageMediaViewerActivity
|
||||||
import im.vector.riotx.features.media.VideoMediaViewerActivity
|
import im.vector.riotx.features.media.VideoMediaViewerActivity
|
||||||
import im.vector.riotx.features.navigation.Navigator
|
import im.vector.riotx.features.navigation.Navigator
|
||||||
@ -154,6 +155,8 @@ interface ScreenComponent {
|
|||||||
|
|
||||||
fun inject(activity: SharedSecureStorageActivity)
|
fun inject(activity: SharedSecureStorageActivity)
|
||||||
|
|
||||||
|
fun inject(bigImageViewerActivity: BigImageViewerActivity)
|
||||||
|
|
||||||
@Component.Factory
|
@Component.Factory
|
||||||
interface Factory {
|
interface Factory {
|
||||||
fun create(vectorComponent: VectorComponent,
|
fun create(vectorComponent: VectorComponent,
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020 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.riotx.features.media
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.core.net.toUri
|
||||||
|
import im.vector.riotx.R
|
||||||
|
import im.vector.riotx.core.di.ActiveSessionHolder
|
||||||
|
import im.vector.riotx.core.di.ScreenComponent
|
||||||
|
import im.vector.riotx.core.platform.VectorBaseActivity
|
||||||
|
import kotlinx.android.synthetic.main.activity_big_image_viewer.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class BigImageViewerActivity : VectorBaseActivity() {
|
||||||
|
|
||||||
|
@Inject lateinit var sessionHolder: ActiveSessionHolder
|
||||||
|
|
||||||
|
private val imageUrl by lazy { intent.getStringExtra(EXTRA_IMAGE_URL) }
|
||||||
|
|
||||||
|
override fun injectWith(injector: ScreenComponent) {
|
||||||
|
injector.inject(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.activity_big_image_viewer)
|
||||||
|
|
||||||
|
setSupportActionBar(bigImageViewerToolbar)
|
||||||
|
supportActionBar?.apply {
|
||||||
|
title = intent.getStringExtra(EXTRA_TITLE)
|
||||||
|
setHomeButtonEnabled(true)
|
||||||
|
setDisplayHomeAsUpEnabled(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
val contentUrlResolver = sessionHolder.getActiveSession().contentUrlResolver()
|
||||||
|
val fullSize = contentUrlResolver.resolveFullSize(imageUrl)
|
||||||
|
bigImageViewerImageView.showImage(fullSize?.toUri())
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
private const val EXTRA_TITLE = "EXTRA_TITLE"
|
||||||
|
private const val EXTRA_IMAGE_URL = "EXTRA_IMAGE_URL"
|
||||||
|
|
||||||
|
fun newIntent(context: Context, title: String?, imageUrl: String): Intent {
|
||||||
|
return Intent(context, BigImageViewerActivity::class.java).apply {
|
||||||
|
putExtra(EXTRA_TITLE, title)
|
||||||
|
putExtra(EXTRA_IMAGE_URL, imageUrl)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -19,7 +19,10 @@ package im.vector.riotx.features.navigation
|
|||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.view.View
|
||||||
|
import androidx.core.app.ActivityOptionsCompat
|
||||||
import androidx.core.app.TaskStackBuilder
|
import androidx.core.app.TaskStackBuilder
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
import im.vector.matrix.android.api.session.crypto.sas.IncomingSasVerificationTransaction
|
import im.vector.matrix.android.api.session.crypto.sas.IncomingSasVerificationTransaction
|
||||||
import im.vector.matrix.android.api.session.crypto.sas.VerificationMethod
|
import im.vector.matrix.android.api.session.crypto.sas.VerificationMethod
|
||||||
import im.vector.matrix.android.api.session.room.model.roomdirectory.PublicRoom
|
import im.vector.matrix.android.api.session.room.model.roomdirectory.PublicRoom
|
||||||
@ -36,6 +39,7 @@ import im.vector.riotx.features.debug.DebugMenuActivity
|
|||||||
import im.vector.riotx.features.home.room.detail.RoomDetailActivity
|
import im.vector.riotx.features.home.room.detail.RoomDetailActivity
|
||||||
import im.vector.riotx.features.home.room.detail.RoomDetailArgs
|
import im.vector.riotx.features.home.room.detail.RoomDetailArgs
|
||||||
import im.vector.riotx.features.home.room.filtered.FilteredRoomsActivity
|
import im.vector.riotx.features.home.room.filtered.FilteredRoomsActivity
|
||||||
|
import im.vector.riotx.features.media.BigImageViewerActivity
|
||||||
import im.vector.riotx.features.roomdirectory.RoomDirectoryActivity
|
import im.vector.riotx.features.roomdirectory.RoomDirectoryActivity
|
||||||
import im.vector.riotx.features.roomdirectory.createroom.CreateRoomActivity
|
import im.vector.riotx.features.roomdirectory.createroom.CreateRoomActivity
|
||||||
import im.vector.riotx.features.roomdirectory.roompreview.RoomPreviewActivity
|
import im.vector.riotx.features.roomdirectory.roompreview.RoomPreviewActivity
|
||||||
@ -175,6 +179,14 @@ class DefaultNavigator @Inject constructor(
|
|||||||
context.startActivity(RoomProfileActivity.newIntent(context, roomId))
|
context.startActivity(RoomProfileActivity.newIntent(context, roomId))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun openBigImageViewer(activity: Activity, sharedElement: View?, title: String, avatarUrl: String) {
|
||||||
|
val intent = BigImageViewerActivity.newIntent(activity, title, avatarUrl)
|
||||||
|
val options = sharedElement?.let {
|
||||||
|
ActivityOptionsCompat.makeSceneTransitionAnimation(activity, it, ViewCompat.getTransitionName(it) ?: "")
|
||||||
|
}
|
||||||
|
activity.startActivity(intent, options?.toBundle())
|
||||||
|
}
|
||||||
|
|
||||||
private fun startActivity(context: Context, intent: Intent, buildTask: Boolean) {
|
private fun startActivity(context: Context, intent: Intent, buildTask: Boolean) {
|
||||||
if (buildTask) {
|
if (buildTask) {
|
||||||
val stackBuilder = TaskStackBuilder.create(context)
|
val stackBuilder = TaskStackBuilder.create(context)
|
||||||
|
@ -18,6 +18,7 @@ package im.vector.riotx.features.navigation
|
|||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.view.View
|
||||||
import im.vector.matrix.android.api.session.room.model.roomdirectory.PublicRoom
|
import im.vector.matrix.android.api.session.room.model.roomdirectory.PublicRoom
|
||||||
import im.vector.riotx.features.settings.VectorSettingsActivity
|
import im.vector.riotx.features.settings.VectorSettingsActivity
|
||||||
import im.vector.riotx.features.share.SharedData
|
import im.vector.riotx.features.share.SharedData
|
||||||
@ -59,4 +60,6 @@ interface Navigator {
|
|||||||
fun openRoomMemberProfile(userId: String, roomId: String?, context: Context, buildTask: Boolean = false)
|
fun openRoomMemberProfile(userId: String, roomId: String?, context: Context, buildTask: Boolean = false)
|
||||||
|
|
||||||
fun openRoomProfile(context: Context, roomId: String)
|
fun openRoomProfile(context: Context, roomId: String)
|
||||||
|
|
||||||
|
fun openBigImageViewer(activity: Activity, sharedElement: View?, title: String, avatarUrl: String)
|
||||||
}
|
}
|
||||||
|
@ -192,6 +192,10 @@ class RoomMemberProfileFragment @Inject constructor(
|
|||||||
} else {
|
} else {
|
||||||
memberProfileDecorationImageView.isVisible = false
|
memberProfileDecorationImageView.isVisible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memberProfileAvatarView.setOnClickListener { view ->
|
||||||
|
onAvatarClicked(view, userMatrixItem)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memberProfilePowerLevelView.setTextOrHide(state.userPowerLevelString())
|
memberProfilePowerLevelView.setTextOrHide(state.userPowerLevelString())
|
||||||
@ -227,4 +231,13 @@ class RoomMemberProfileFragment @Inject constructor(
|
|||||||
private fun handleShareRoomMemberProfile(permalink: String) {
|
private fun handleShareRoomMemberProfile(permalink: String) {
|
||||||
startSharePlainTextIntent(fragment = this, chooserTitle = null, text = permalink)
|
startSharePlainTextIntent(fragment = this, chooserTitle = null, text = permalink)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun onAvatarClicked(view: View, userMatrixItem: MatrixItem) {
|
||||||
|
userMatrixItem.avatarUrl
|
||||||
|
?.takeIf { it.isNotBlank() }
|
||||||
|
?.let { avatarUrl ->
|
||||||
|
val title = userMatrixItem.getBestName()
|
||||||
|
navigator.openBigImageViewer(requireActivity(), view, title, avatarUrl)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import com.airbnb.mvrx.args
|
|||||||
import com.airbnb.mvrx.fragmentViewModel
|
import com.airbnb.mvrx.fragmentViewModel
|
||||||
import com.airbnb.mvrx.withState
|
import com.airbnb.mvrx.withState
|
||||||
import im.vector.matrix.android.api.session.room.notification.RoomNotificationState
|
import im.vector.matrix.android.api.session.room.notification.RoomNotificationState
|
||||||
|
import im.vector.matrix.android.api.util.MatrixItem
|
||||||
import im.vector.matrix.android.api.util.toMatrixItem
|
import im.vector.matrix.android.api.util.toMatrixItem
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import im.vector.riotx.core.animations.AppBarStateChangeListener
|
import im.vector.riotx.core.animations.AppBarStateChangeListener
|
||||||
@ -164,6 +165,10 @@ class RoomProfileFragment @Inject constructor(
|
|||||||
roomProfileDecorationImageView.isVisible = it.roomEncryptionTrustLevel != null
|
roomProfileDecorationImageView.isVisible = it.roomEncryptionTrustLevel != null
|
||||||
roomProfileDecorationImageView.setImageResource(it.roomEncryptionTrustLevel.toImageRes())
|
roomProfileDecorationImageView.setImageResource(it.roomEncryptionTrustLevel.toImageRes())
|
||||||
matrixProfileDecorationToolbarAvatarImageView.setImageResource(it.roomEncryptionTrustLevel.toImageRes())
|
matrixProfileDecorationToolbarAvatarImageView.setImageResource(it.roomEncryptionTrustLevel.toImageRes())
|
||||||
|
|
||||||
|
roomProfileAvatarView.setOnClickListener { view ->
|
||||||
|
onAvatarClicked(view, matrixItem)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
roomProfileController.setData(state)
|
roomProfileController.setData(state)
|
||||||
@ -211,4 +216,13 @@ class RoomProfileFragment @Inject constructor(
|
|||||||
private fun onShareRoomProfile(permalink: String) {
|
private fun onShareRoomProfile(permalink: String) {
|
||||||
startSharePlainTextIntent(fragment = this, chooserTitle = null, text = permalink)
|
startSharePlainTextIntent(fragment = this, chooserTitle = null, text = permalink)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun onAvatarClicked(view: View, matrixItem: MatrixItem.RoomItem) {
|
||||||
|
matrixItem.avatarUrl
|
||||||
|
?.takeIf { it.isNotBlank() }
|
||||||
|
?.let { avatarUrl ->
|
||||||
|
val title = matrixItem.getBestName()
|
||||||
|
navigator.openBigImageViewer(requireActivity(), view, title, avatarUrl)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
27
vector/src/main/res/layout/activity_big_image_viewer.xml
Normal file
27
vector/src/main/res/layout/activity_big_image_viewer.xml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?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"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/bigImageViewerToolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:elevation="4dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<com.github.piasy.biv.view.BigImageView
|
||||||
|
android:id="@+id/bigImageViewerImageView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:failureImageInitScaleType="center"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/bigImageViewerToolbar"
|
||||||
|
app:optimizeDisplay="true" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -12,6 +12,7 @@
|
|||||||
android:layout_width="128dp"
|
android:layout_width="128dp"
|
||||||
android:layout_height="128dp"
|
android:layout_height="128dp"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="16dp"
|
||||||
|
android:transitionName="roomProfileAvatarView"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/roomProfileNameView"
|
app:layout_constraintBottom_toTopOf="@+id/roomProfileNameView"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
Loading…
Reference in New Issue
Block a user