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( ...@@ -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.toString(), 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,7 +16,7 @@ interface UserDetailsView : LoadingView, MessageView { ...@@ -16,7 +16,7 @@ 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?,
......
...@@ -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,14 +98,12 @@ class UserDetailsFragment : Fragment(), UserDetailsView { ...@@ -97,14 +98,12 @@ 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)
val userStatus = if(status != null) status.substring(0, 1).toUpperCase() + status.substring(1) else "" text_description_status.text = status?.capitalize() ?: getString(R.string.msg_unknown)
text_description_status.text = userStatus
val userUtcOffset = if(utcOffset.equals("null")) getString(R.string.user_timezone_none) else utcOffset text_description_timezone.text = utcOffset ?: getString(R.string.msg_unknown)
text_description_timezone.text = userUtcOffset
text_video_call.isVisible = isVideoCallAllowed text_video_call.isVisible = isVideoCallAllowed
......
...@@ -366,7 +366,6 @@ ...@@ -366,7 +366,6 @@
<!-- User Details --> <!-- User Details -->
<string name="timezone">المنظقة الزمنية</string> <string name="timezone">المنظقة الزمنية</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report --> <!-- Report -->
<string name="submit">تأكيد</string> <string name="submit">تأكيد</string>
......
...@@ -364,7 +364,6 @@ ...@@ -364,7 +364,6 @@
<!-- User Details --> <!-- User Details -->
<string name="timezone">Zeitzone</string> <string name="timezone">Zeitzone</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report --> <!-- Report -->
<string name="submit">Senden</string> <string name="submit">Senden</string>
......
...@@ -366,7 +366,6 @@ ...@@ -366,7 +366,6 @@
<!-- User Details --> <!-- User Details -->
<string name="timezone">Timezone</string> <!-- TODO - Add proper translation --> <string name="timezone">Timezone</string> <!-- TODO - Add proper translation -->
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report --> <!-- Report -->
<string name="submit">Submit</string> <!--TODO - Add proper translation--> <string name="submit">Submit</string> <!--TODO - Add proper translation-->
......
...@@ -364,7 +364,6 @@ ...@@ -364,7 +364,6 @@
<!-- User Details --> <!-- User Details -->
<string name="timezone">منطقه‌ی زمانی</string> <string name="timezone">منطقه‌ی زمانی</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report --> <!-- Report -->
<string name="submit">واگذاری</string> <string name="submit">واگذاری</string>
......
...@@ -365,7 +365,6 @@ ...@@ -365,7 +365,6 @@
<!-- User Details --> <!-- User Details -->
<string name="timezone">Fuseau horaire</string> <string name="timezone">Fuseau horaire</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report --> <!-- Report -->
<string name="submit">Soumettre</string> <string name="submit">Soumettre</string>
......
...@@ -366,7 +366,6 @@ ...@@ -366,7 +366,6 @@
<!-- User Details --> <!-- User Details -->
<string name="timezone">समय क्षेत्र</string> <string name="timezone">समय क्षेत्र</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report --> <!-- Report -->
<string name="submit">जमा करें</string> <string name="submit">जमा करें</string>
......
...@@ -361,7 +361,6 @@ ...@@ -361,7 +361,6 @@
<!-- User Details --> <!-- User Details -->
<string name="timezone">Fuso Orario</string> <string name="timezone">Fuso Orario</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report --> <!-- Report -->
<string name="submit">Invia</string> <string name="submit">Invia</string>
......
...@@ -365,7 +365,6 @@ ...@@ -365,7 +365,6 @@
<!-- User Details --> <!-- User Details -->
<string name="timezone">Timezone</string> <!--TODO - Add proper translation--> <string name="timezone">Timezone</string> <!--TODO - Add proper translation-->
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report --> <!-- Report -->
<string name="submit">Submit</string> <!--TODO - Add proper translation--> <string name="submit">Submit</string> <!--TODO - Add proper translation-->
......
...@@ -365,7 +365,6 @@ ...@@ -365,7 +365,6 @@
<!-- User Details --> <!-- User Details -->
<string name="timezone">Fuso horário</string> <string name="timezone">Fuso horário</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report --> <!-- Report -->
<string name="submit">Enviar</string> <string name="submit">Enviar</string>
......
...@@ -363,7 +363,6 @@ ...@@ -363,7 +363,6 @@
<!-- User Details --> <!-- User Details -->
<string name="timezone">Fuso Horário</string> <string name="timezone">Fuso Horário</string>
<string name="status">Estado: %1$s</string> <string name="status">Estado: %1$s</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report --> <!-- Report -->
<string name="submit">Enviar</string> <string name="submit">Enviar</string>
......
...@@ -362,7 +362,6 @@ ...@@ -362,7 +362,6 @@
<!-- User Details --> <!-- User Details -->
<string name="timezone">Часовой пояс</string> <string name="timezone">Часовой пояс</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report --> <!-- Report -->
<string name="submit">Отправить</string> <string name="submit">Отправить</string>
......
...@@ -365,7 +365,6 @@ ...@@ -365,7 +365,6 @@
<!-- User Details --> <!-- User Details -->
<string name="timezone">Timezone</string> <!--TODO - Add proper translation--> <string name="timezone">Timezone</string> <!--TODO - Add proper translation-->
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report --> <!-- Report -->
<string name="submit">Submit</string> <!--TODO - Add proper translation--> <string name="submit">Submit</string> <!--TODO - Add proper translation-->
......
...@@ -362,7 +362,6 @@ ...@@ -362,7 +362,6 @@
<!-- User Details --> <!-- User Details -->
<string name="timezone">Timezone</string> <string name="timezone">Timezone</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report --> <!-- Report -->
<string name="submit">Submit</string> <!-- TODO - Add proper translation --> <string name="submit">Submit</string> <!-- TODO - Add proper translation -->
......
...@@ -364,7 +364,6 @@ ...@@ -364,7 +364,6 @@
<!-- User Details --> <!-- User Details -->
<string name="timezone">时区</string> <string name="timezone">时区</string>
<string name="status" translatable="false">状态: %1$s</string> <string name="status" translatable="false">状态: %1$s</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report --> <!-- Report -->
<string name="submit">提交</string> <string name="submit">提交</string>
......
...@@ -344,7 +344,6 @@ ...@@ -344,7 +344,6 @@
<!-- User Details --> <!-- User Details -->
<string name="timezone">時區</string> <string name="timezone">時區</string>
<string name="status" translatable="false">狀態: %1$s</string> <string name="status" translatable="false">狀態: %1$s</string>
<string name="user_timezone_none">None</string><!-- TODO Add translation -->
<!-- Report --> <!-- Report -->
<string name="submit">提交</string> <string name="submit">提交</string>
......
...@@ -381,7 +381,6 @@ https://github.com/RocketChat/java-code-styles/blob/master/CODING_STYLE.md#strin ...@@ -381,7 +381,6 @@ https://github.com/RocketChat/java-code-styles/blob/master/CODING_STYLE.md#strin
<string name="timezone">Timezone</string> <string name="timezone">Timezone</string>
<string name="status" translatable="false">Status: %1$s</string> <string name="status" translatable="false">Status: %1$s</string>
<string name="user_detail_status" translatable="false">Status</string> <string name="user_detail_status" translatable="false">Status</string>
<string name="user_timezone_none">None</string>
<!-- Report --> <!-- Report -->
<string name="submit">Submit</string> <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