Unverified Commit 723d155d authored by Filipe Brito's avatar Filipe Brito Committed by GitHub

Merge pull request #2273 from Cool-fire/issue-profile-render

[FIX] Fixes unable to see other User profile details
parents 1fd253cc 0c89d0b6
...@@ -47,31 +47,21 @@ class UserDetailsPresenter @Inject constructor( ...@@ -47,31 +47,21 @@ class UserDetailsPresenter @Inject constructor(
view.showLoading() view.showLoading()
dbManager.getUser(userId)?.let { dbManager.getUser(userId)?.let {
userEntity = it userEntity = it
val avatarUrl = val avatarUrl = userEntity.username?.let { username ->
userEntity.username?.let { username -> currentServer.avatarUrl(username, token?.userId, token?.authToken)
currentServer.avatarUrl( }
username,
token?.userId,
token?.authToken
)
}
val username = userEntity.username val username = userEntity.username
val name = userEntity.name val name = userEntity.name
val utcOffset = val utcOffset = userEntity.utcOffset // FIXME Convert UTC
userEntity.utcOffset // TODO Convert UTC and display like the mockup
if (avatarUrl != null && username != null && name != null && utcOffset != null) { view.showUserDetailsAndActions(
view.showUserDetailsAndActions( avatarUrl = avatarUrl,
avatarUrl = avatarUrl, name = name,
name = name, username = username,
username = username, status = userEntity.status,
status = userEntity.status, utcOffset = utcOffset.toString(),
utcOffset = utcOffset.toString(), isVideoCallAllowed = settings.isJitsiEnabled()
isVideoCallAllowed = settings.isJitsiEnabled() )
)
} else {
throw Exception()
}
} }
} catch (ex: Exception) { } catch (ex: Exception) {
Timber.e(ex) Timber.e(ex)
......
...@@ -16,11 +16,11 @@ interface UserDetailsView : LoadingView, MessageView { ...@@ -16,11 +16,11 @@ interface UserDetailsView : LoadingView, MessageView {
* @param isVideoCallAllowed True if the video call is allowed, false otherwise. * @param isVideoCallAllowed True if the video call is allowed, false otherwise.
*/ */
fun showUserDetailsAndActions( fun showUserDetailsAndActions(
avatarUrl: String, avatarUrl: String?,
name: String, name: String?,
username: String, username: String?,
status: String, status: String?,
utcOffset: String, utcOffset: String?,
isVideoCallAllowed: Boolean isVideoCallAllowed: Boolean
) )
} }
...@@ -79,14 +79,15 @@ class UserDetailsFragment : Fragment(), UserDetailsView { ...@@ -79,14 +79,15 @@ class UserDetailsFragment : Fragment(), UserDetailsView {
} }
override fun showUserDetailsAndActions( override fun showUserDetailsAndActions(
avatarUrl: String, avatarUrl: String?,
name: String, name: String?,
username: String, username: String?,
status: String, status: String?,
utcOffset: String, utcOffset: String?,
isVideoCallAllowed: Boolean isVideoCallAllowed: Boolean
) { ) {
val requestBuilder = Glide.with(this).load(avatarUrl) val requestBuilder = Glide.with(this)
.load(avatarUrl)
.apply(RequestOptions.skipMemoryCacheOf(true)) .apply(RequestOptions.skipMemoryCacheOf(true))
.apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.NONE)) .apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.NONE))
...@@ -97,19 +98,21 @@ class UserDetailsFragment : Fragment(), UserDetailsView { ...@@ -97,19 +98,21 @@ class UserDetailsFragment : Fragment(), UserDetailsView {
requestBuilder.apply(RequestOptions.bitmapTransform(RoundedCorners(14))) requestBuilder.apply(RequestOptions.bitmapTransform(RoundedCorners(14)))
.into(image_avatar) .into(image_avatar)
text_name.text = name text_name.text = name ?: getString(R.string.msg_unknown)
text_username.text = username text_username.text = username ?: getString(R.string.msg_unknown)
text_description_status.text = status.substring(0, 1).toUpperCase() + status.substring(1)
text_description_timezone.text = utcOffset
// We should also setup the user details listeners. text_description_status.text = status?.capitalize() ?: getString(R.string.msg_unknown)
text_message.setOnClickListener { presenter.createDirectMessage(username) }
text_description_timezone.text = utcOffset ?: getString(R.string.msg_unknown)
text_video_call.isVisible = isVideoCallAllowed
if (isVideoCallAllowed) { // We should also setup the user details listeners.
text_video_call.isVisible = true username?.run {
text_video_call.setOnClickListener { presenter.toVideoConference(username) } text_message.setOnClickListener { presenter.createDirectMessage(this) }
} else { if (isVideoCallAllowed) {
text_video_call.isVisible = false text_video_call.setOnClickListener { presenter.toVideoConference(this) }
}
} }
} }
......
...@@ -143,6 +143,6 @@ ...@@ -143,6 +143,6 @@
android:id="@+id/group_user_details" android:id="@+id/group_user_details"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:constraint_referenced_ids="image_blur, image_avatar, text_name, text_username, text_message, text_title_status, text_description_status, text_title_timezone, text_description_timezone" /> app:constraint_referenced_ids="image_blur, image_avatar, text_name, text_username, text_message, text_title_status, text_description_status, text_title_timezone, text_description_timezone, text_video_call" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment