Commit c0c0d08a authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Improve code.

parent 3eaba537
......@@ -47,31 +47,21 @@ class UserDetailsPresenter @Inject constructor(
view.showLoading()
dbManager.getUser(userId)?.let {
userEntity = it
val avatarUrl =
userEntity.username?.let { username ->
currentServer.avatarUrl(
username,
token?.userId,
token?.authToken
)
}
val avatarUrl = userEntity.username?.let { username ->
currentServer.avatarUrl(username, token?.userId, token?.authToken)
}
val username = userEntity.username
val name = userEntity.name
val utcOffset =
userEntity.utcOffset // TODO Convert UTC and display like the mockup
val utcOffset = userEntity.utcOffset // FIXME Convert UTC
if (avatarUrl != null || username != null || name != null || utcOffset != null) {
view.showUserDetailsAndActions(
avatarUrl = avatarUrl.toString(),
name = name,
username = username,
status = userEntity.status,
utcOffset = utcOffset.toString(),
isVideoCallAllowed = settings.isJitsiEnabled()
)
} else {
throw Exception()
}
view.showUserDetailsAndActions(
avatarUrl = avatarUrl,
name = name,
username = username,
status = userEntity.status,
utcOffset = utcOffset.toString(),
isVideoCallAllowed = settings.isJitsiEnabled()
)
}
} catch (ex: Exception) {
Timber.e(ex)
......
......@@ -16,7 +16,7 @@ interface UserDetailsView : LoadingView, MessageView {
* @param isVideoCallAllowed True if the video call is allowed, false otherwise.
*/
fun showUserDetailsAndActions(
avatarUrl: String,
avatarUrl: String?,
name: String?,
username: String?,
status: String?,
......
......@@ -79,14 +79,15 @@ class UserDetailsFragment : Fragment(), UserDetailsView {
}
override fun showUserDetailsAndActions(
avatarUrl: String,
avatarUrl: String?,
name: String?,
username: String?,
status: String?,
utcOffset: String?,
isVideoCallAllowed: Boolean
) {
val requestBuilder = Glide.with(this).load(avatarUrl)
val requestBuilder = Glide.with(this)
.load(avatarUrl)
.apply(RequestOptions.skipMemoryCacheOf(true))
.apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.NONE))
......@@ -97,14 +98,12 @@ class UserDetailsFragment : Fragment(), UserDetailsView {
requestBuilder.apply(RequestOptions.bitmapTransform(RoundedCorners(14)))
.into(image_avatar)
text_name.text = name ?: ""
text_username.text = username ?: ""
text_name.text = name ?: getString(R.string.msg_unknown)
text_username.text = username ?: getString(R.string.msg_unknown)
val userStatus = if(status != null) status.substring(0, 1).toUpperCase() + status.substring(1) else ""
text_description_status.text = userStatus
text_description_status.text = status?.capitalize() ?: getString(R.string.msg_unknown)
val userUtcOffset = if(utcOffset.equals("null")) getString(R.string.user_timezone_none) else utcOffset
text_description_timezone.text = userUtcOffset
text_description_timezone.text = utcOffset ?: getString(R.string.msg_unknown)
text_video_call.isVisible = isVideoCallAllowed
......
......@@ -366,7 +366,6 @@
<!-- User Details -->
<string name="timezone">المنظقة الزمنية</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report -->
<string name="submit">تأكيد</string>
......
......@@ -364,7 +364,6 @@
<!-- User Details -->
<string name="timezone">Zeitzone</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report -->
<string name="submit">Senden</string>
......
......@@ -366,7 +366,6 @@
<!-- User Details -->
<string name="timezone">Timezone</string> <!-- TODO - Add proper translation -->
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report -->
<string name="submit">Submit</string> <!--TODO - Add proper translation-->
......
......@@ -364,7 +364,6 @@
<!-- User Details -->
<string name="timezone">منطقه‌ی زمانی</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report -->
<string name="submit">واگذاری</string>
......
......@@ -365,7 +365,6 @@
<!-- User Details -->
<string name="timezone">Fuseau horaire</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report -->
<string name="submit">Soumettre</string>
......
......@@ -366,7 +366,6 @@
<!-- User Details -->
<string name="timezone">समय क्षेत्र</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report -->
<string name="submit">जमा करें</string>
......
......@@ -361,7 +361,6 @@
<!-- User Details -->
<string name="timezone">Fuso Orario</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report -->
<string name="submit">Invia</string>
......
......@@ -365,7 +365,6 @@
<!-- User Details -->
<string name="timezone">Timezone</string> <!--TODO - Add proper translation-->
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report -->
<string name="submit">Submit</string> <!--TODO - Add proper translation-->
......
......@@ -365,7 +365,6 @@
<!-- User Details -->
<string name="timezone">Fuso horário</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report -->
<string name="submit">Enviar</string>
......
......@@ -363,7 +363,6 @@
<!-- User Details -->
<string name="timezone">Fuso Horário</string>
<string name="status">Estado: %1$s</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report -->
<string name="submit">Enviar</string>
......
......@@ -362,7 +362,6 @@
<!-- User Details -->
<string name="timezone">Часовой пояс</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report -->
<string name="submit">Отправить</string>
......
......@@ -365,7 +365,6 @@
<!-- User Details -->
<string name="timezone">Timezone</string> <!--TODO - Add proper translation-->
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report -->
<string name="submit">Submit</string> <!--TODO - Add proper translation-->
......
......@@ -362,7 +362,6 @@
<!-- User Details -->
<string name="timezone">Timezone</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report -->
<string name="submit">Submit</string> <!-- TODO - Add proper translation -->
......
......@@ -364,7 +364,6 @@
<!-- User Details -->
<string name="timezone">时区</string>
<string name="status" translatable="false">状态: %1$s</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report -->
<string name="submit">提交</string>
......
......@@ -344,7 +344,6 @@
<!-- User Details -->
<string name="timezone">時區</string>
<string name="status" translatable="false">狀態: %1$s</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report -->
<string name="submit">提交</string>
......
......@@ -381,7 +381,6 @@ https://github.com/RocketChat/java-code-styles/blob/master/CODING_STYLE.md#strin
<string name="timezone">Timezone</string>
<string name="status" translatable="false">Status: %1$s</string>
<string name="user_detail_status" translatable="false">Status</string>
<string name="user_timezone_none">None</string>
<!-- Report -->
<string name="submit">Submit</string>
......
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