Display avatar in fullscreen.

This commit is contained in:
onurays 2020-02-26 12:12:49 +03:00
parent 30432cd3f4
commit 1a273407de
8 changed files with 138 additions and 0 deletions

View File

@ -11,6 +11,7 @@ Features ✨:
Improvements 🙌:
- Migrate to binary QR code verification (#994)
- Share action is added to room profile and room member profile (#858)
- Display avatar in fullscreen (#861)
Bugfix 🐛:
- Account creation: wrongly hints that an email can be used to create an account (#941)

View File

@ -40,6 +40,7 @@
android:name=".features.login.LoginActivity"
android:windowSoftInputMode="adjustResize" />
<activity android:name=".features.media.ImageMediaViewerActivity" />
<activity android:name=".features.media.BigImageViewerActivity" />
<activity
android:name=".features.rageshake.BugReportActivity"
android:label="@string/title_activity_bug_report" />

View File

@ -40,6 +40,7 @@ import im.vector.riotx.features.home.room.list.actions.RoomListQuickActionsBotto
import im.vector.riotx.features.invite.VectorInviteView
import im.vector.riotx.features.link.LinkHandlerActivity
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.VideoMediaViewerActivity
import im.vector.riotx.features.navigation.Navigator
@ -151,6 +152,8 @@ interface ScreenComponent {
fun inject(deviceListBottomSheet: DeviceListBottomSheet)
fun inject(bigImageViewerActivity: BigImageViewerActivity)
@Component.Factory
interface Factory {
fun create(vectorComponent: VectorComponent,

View File

@ -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(imageMediaViewerToolbar)
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)
}
}
}
}

View File

@ -22,6 +22,8 @@ import android.os.Parcelable
import android.view.MenuItem
import android.view.View
import androidx.appcompat.app.AlertDialog
import androidx.core.app.ActivityOptionsCompat
import androidx.core.view.ViewCompat
import androidx.core.view.isVisible
import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.Incomplete
@ -42,6 +44,7 @@ import im.vector.riotx.core.platform.VectorBaseFragment
import im.vector.riotx.core.utils.startSharePlainTextIntent
import im.vector.riotx.features.crypto.verification.VerificationBottomSheet
import im.vector.riotx.features.home.AvatarRenderer
import im.vector.riotx.features.media.BigImageViewerActivity
import im.vector.riotx.features.roommemberprofile.devices.DeviceListBottomSheet
import kotlinx.android.parcel.Parcelize
import kotlinx.android.synthetic.main.fragment_matrix_profile.*
@ -192,6 +195,15 @@ class RoomMemberProfileFragment @Inject constructor(
} else {
memberProfileDecorationImageView.isVisible = false
}
memberProfileAvatarView.setOnClickListener { view ->
userMatrixItem.avatarUrl
?.takeIf { it.isNotBlank() }
?.let { avatarUrl ->
val title = userMatrixItem.displayName ?: ""
onAvatarClicked(view, title, avatarUrl)
}
}
}
}
memberProfilePowerLevelView.setTextOrHide(state.userPowerLevelString())
@ -227,4 +239,10 @@ class RoomMemberProfileFragment @Inject constructor(
private fun handleShareRoomMemberProfile(permalink: String) {
startSharePlainTextIntent(fragment = this, chooserTitle = null, text = permalink)
}
private fun onAvatarClicked(view: View, title: String, avatarUrl: String) {
val intent = BigImageViewerActivity.newIntent(context!!, title, avatarUrl)
val options = ActivityOptionsCompat.makeSceneTransitionAnimation(requireActivity(), view, ViewCompat.getTransitionName(view) ?: "")
startActivity(intent, options.toBundle())
}
}

View File

@ -22,6 +22,8 @@ import android.os.Parcelable
import android.view.MenuItem
import android.view.View
import androidx.appcompat.app.AlertDialog
import androidx.core.app.ActivityOptionsCompat
import androidx.core.view.ViewCompat
import androidx.core.view.isVisible
import com.airbnb.mvrx.args
import com.airbnb.mvrx.fragmentViewModel
@ -44,6 +46,7 @@ import im.vector.riotx.features.home.room.list.actions.RoomListActionsArgs
import im.vector.riotx.features.home.room.list.actions.RoomListQuickActionsBottomSheet
import im.vector.riotx.features.home.room.list.actions.RoomListQuickActionsSharedAction
import im.vector.riotx.features.home.room.list.actions.RoomListQuickActionsSharedActionViewModel
import im.vector.riotx.features.media.BigImageViewerActivity
import kotlinx.android.parcel.Parcelize
import kotlinx.android.synthetic.main.fragment_matrix_profile.*
import kotlinx.android.synthetic.main.view_stub_room_profile_header.*
@ -164,6 +167,15 @@ class RoomProfileFragment @Inject constructor(
roomProfileDecorationImageView.isVisible = it.roomEncryptionTrustLevel != null
roomProfileDecorationImageView.setImageResource(it.roomEncryptionTrustLevel.toImageRes())
matrixProfileDecorationToolbarAvatarImageView.setImageResource(it.roomEncryptionTrustLevel.toImageRes())
roomProfileAvatarView.setOnClickListener { view ->
matrixItem.avatarUrl
?.takeIf { it.isNotBlank() }
?.let { avatarUrl ->
val title = state.roomSummary()?.displayName ?: ""
onAvatarClicked(view, title, avatarUrl)
}
}
}
}
roomProfileController.setData(state)
@ -211,4 +223,10 @@ class RoomProfileFragment @Inject constructor(
private fun onShareRoomProfile(permalink: String) {
startSharePlainTextIntent(fragment = this, chooserTitle = null, text = permalink)
}
private fun onAvatarClicked(view: View, title: String, avatarUrl: String) {
val intent = BigImageViewerActivity.newIntent(context!!, title, avatarUrl)
val options = ActivityOptionsCompat.makeSceneTransitionAnimation(requireActivity(), view, ViewCompat.getTransitionName(view) ?: "")
startActivity(intent, options.toBundle())
}
}

View File

@ -0,0 +1,28 @@
<?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/imageMediaViewerToolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="4dp"
android:transitionName="toolbar"
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/imageMediaViewerToolbar"
app:optimizeDisplay="true" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -12,6 +12,7 @@
android:layout_width="128dp"
android:layout_height="128dp"
android:layout_marginBottom="16dp"
android:transitionName="roomProfileAvatarView"
app:layout_constraintBottom_toTopOf="@+id/roomProfileNameView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"