Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
8fef2381
Unverified
Commit
8fef2381
authored
Jan 15, 2018
by
Lucio Maciel
Committed by
GitHub
Jan 15, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #700 from filipedelimabrito/hotfix
[FIX][BUG] Hotfix before initial v2 release.
parents
0de209d8
7e08d07c
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
108 additions
and
62 deletions
+108
-62
DrawableHelper.kt
app/src/main/java/chat/rocket/android/app/DrawableHelper.kt
+1
-1
LoginFragment.kt
...t/rocket/android/authentication/login/ui/LoginFragment.kt
+1
-1
ServerPresenter.kt
...oid/authentication/server/presentation/ServerPresenter.kt
+32
-27
ServerView.kt
.../android/authentication/server/presentation/ServerView.kt
+7
-1
ServerFragment.kt
...rocket/android/authentication/server/ui/ServerFragment.kt
+2
-0
ChatRoomAdapter.kt
...n/java/chat/rocket/android/chatroom/ui/ChatRoomAdapter.kt
+4
-3
ChatRoomsAdapter.kt
...java/chat/rocket/android/chatrooms/ui/ChatRoomsAdapter.kt
+7
-5
UrlHelper.kt
app/src/main/java/chat/rocket/android/helper/UrlHelper.kt
+10
-1
avatar.xml
app/src/main/res/layout/avatar.xml
+25
-0
fragment_authentication_server.xml
app/src/main/res/layout/fragment_authentication_server.xml
+1
-0
item_chat.xml
app/src/main/res/layout/item_chat.xml
+8
-4
item_message.xml
app/src/main/res/layout/item_message.xml
+6
-17
strings.xml
app/src/main/res/values-pt-rBR/strings.xml
+2
-1
strings.xml
app/src/main/res/values/strings.xml
+2
-1
No files found.
app/src/main/java/chat/rocket/android/app/DrawableHelper.kt
View file @
8fef2381
...
...
@@ -135,7 +135,7 @@ object DrawableHelper {
.
beginConfig
()
.
useFont
(
Typeface
.
SANS_SERIF
)
.
endConfig
()
.
buildRound
(
TextHelper
.
getFirstCharacter
(
string
),
getAvatarBackgroundColor
(
string
)
)
.
buildRound
Rect
(
TextHelper
.
getFirstCharacter
(
string
),
getAvatarBackgroundColor
(
string
),
4
)
}
/**
...
...
app/src/main/java/chat/rocket/android/authentication/login/ui/LoginFragment.kt
View file @
8fef2381
...
...
@@ -194,7 +194,7 @@ class LoginFragment : Fragment(), LoginView {
private
fun
setupSignUpListener
()
{
val
signUp
=
getString
(
R
.
string
.
title_sign_up
)
val
newToRocketChat
=
String
.
format
(
getString
(
R
.
string
.
msg_new_
to_rocket_chat
),
signUp
)
val
newToRocketChat
=
String
.
format
(
getString
(
R
.
string
.
msg_new_
user
),
signUp
)
text_new_to_rocket_chat
.
text
=
newToRocketChat
...
...
app/src/main/java/chat/rocket/android/authentication/server/presentation/ServerPresenter.kt
View file @
8fef2381
...
...
@@ -3,6 +3,7 @@ package chat.rocket.android.authentication.server.presentation
import
chat.rocket.android.authentication.presentation.AuthenticationNavigator
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.helper.NetworkHelper
import
chat.rocket.android.helper.UrlHelper
import
chat.rocket.android.server.domain.*
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.launchUI
...
...
@@ -25,39 +26,43 @@ class ServerPresenter @Inject constructor(private val view: ServerView,
HIDE_MUTE_UNMUTE
,
HIDE_TYPE_RU
,
ACCOUNT_CUSTOM_FIELDS
)
fun
connect
(
server
:
String
)
{
try
{
client
=
factory
.
create
(
server
)
}
catch
(
exception
:
InvalidParameterException
)
{
exception
.
message
?.
let
{
view
.
showMessage
(
it
)
}.
ifNull
{
view
.
showGenericErrorMessage
()
if
(!
UrlHelper
.
isValidUrl
(
server
))
{
view
.
showInvalidServerUrl
()
}
else
{
try
{
client
=
factory
.
create
(
server
)
}
catch
(
exception
:
InvalidParameterException
)
{
exception
.
message
?.
let
{
view
.
showMessage
(
it
)
}.
ifNull
{
view
.
showGenericErrorMessage
()
}
return
}
return
}
client
.
let
{
rocketChatClient
->
launchUI
(
strategy
)
{
if
(
NetworkHelper
.
hasInternetAccess
())
{
view
.
showLoading
()
client
.
let
{
rocketChatClient
->
launchUI
(
strategy
)
{
if
(
NetworkHelper
.
hasInternetAccess
())
{
view
.
showLoading
()
try
{
val
settings
=
rocketChatClient
.
settings
(*
settingsFilter
)
settingsInteractor
.
save
(
server
,
settings
)
serverInteractor
.
save
(
server
)
try
{
val
settings
=
rocketChatClient
.
settings
(*
settingsFilter
)
settingsInteractor
.
save
(
server
,
settings
)
serverInteractor
.
save
(
server
)
navigator
.
toLogin
()
}
catch
(
exception
:
Exception
)
{
exception
.
message
?.
let
{
view
.
showMessage
(
it
)
}.
ifNull
{
view
.
showGenericErrorMessage
()
navigator
.
toLogin
()
}
catch
(
exception
:
Exception
)
{
exception
.
message
?.
let
{
view
.
showMessage
(
it
)
}.
ifNull
{
view
.
showGenericErrorMessage
()
}
}
finally
{
view
.
hideLoading
()
}
}
finally
{
view
.
hideLoading
()
}
else
{
view
.
showNoInternetConnection
()
}
}
else
{
view
.
showNoInternetConnection
()
}
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/server/presentation/ServerView.kt
View file @
8fef2381
...
...
@@ -4,4 +4,10 @@ import chat.rocket.android.core.behaviours.InternetView
import
chat.rocket.android.core.behaviours.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
interface
ServerView
:
LoadingView
,
MessageView
,
InternetView
\ No newline at end of file
interface
ServerView
:
LoadingView
,
MessageView
,
InternetView
{
/**
* Notifies the user about an invalid inputted server URL.
*/
fun
showInvalidServerUrl
()
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/authentication/server/ui/ServerFragment.kt
View file @
8fef2381
...
...
@@ -44,6 +44,8 @@ class ServerFragment : Fragment(), ServerView {
relative_layout
.
viewTreeObserver
.
removeOnGlobalLayoutListener
(
layoutListener
)
}
override
fun
showInvalidServerUrl
()
=
showMessage
(
getString
(
R
.
string
.
msg_invalid_server_url
))
override
fun
showLoading
()
{
enableUserInput
(
false
)
view_loading
.
setVisibility
(
true
)
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomAdapter.kt
View file @
8fef2381
...
...
@@ -15,6 +15,7 @@ import chat.rocket.android.util.textContent
import
chat.rocket.common.util.ifNull
import
chat.rocket.core.model.Message
import
com.facebook.drawee.view.SimpleDraweeView
import
kotlinx.android.synthetic.main.avatar.view.*
import
kotlinx.android.synthetic.main.item_message.view.*
class
ChatRoomAdapter
(
private
val
context
:
Context
,
...
...
@@ -43,16 +44,16 @@ class ChatRoomAdapter(private val context: Context,
inner
class
ViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
fun
bind
(
message
:
Message
)
=
with
(
itemView
)
{
bindUserAvatar
(
message
,
image_
user_avatar
,
image_unknown_use
r
)
bindUserAvatar
(
message
,
image_
avatar
,
image_unknown_avata
r
)
bindUserName
(
message
,
text_user_name
)
bindTime
(
message
,
text_message_time
)
bindContent
(
message
,
text_content
)
}
private
fun
bindUserAvatar
(
message
:
Message
,
drawee
:
SimpleDraweeView
,
imageUnknown
Use
r
:
ImageView
)
=
message
.
sender
?.
username
.
let
{
private
fun
bindUserAvatar
(
message
:
Message
,
drawee
:
SimpleDraweeView
,
imageUnknown
Avata
r
:
ImageView
)
=
message
.
sender
?.
username
.
let
{
drawee
.
setImageURI
(
UrlHelper
.
getAvatarUrl
(
serverUrl
,
it
.
toString
()))
}.
ifNull
{
imageUnknown
Use
r
.
setVisibility
(
true
)
imageUnknown
Avata
r
.
setVisibility
(
true
)
}
private
fun
bindUserName
(
message
:
Message
,
textView
:
TextView
)
=
message
.
sender
?.
username
.
let
{
...
...
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsAdapter.kt
View file @
8fef2381
...
...
@@ -16,6 +16,7 @@ import chat.rocket.android.util.textContent
import
chat.rocket.common.model.BaseRoom.RoomType
import
chat.rocket.core.model.ChatRoom
import
com.facebook.drawee.view.SimpleDraweeView
import
kotlinx.android.synthetic.main.avatar.view.*
import
kotlinx.android.synthetic.main.item_chat.view.*
class
ChatRoomsAdapter
(
private
val
context
:
Context
,
...
...
@@ -38,7 +39,7 @@ class ChatRoomsAdapter(private val context: Context,
inner
class
ViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
fun
bind
(
chatRoom
:
ChatRoom
)
=
with
(
itemView
)
{
bindAvatar
(
chatRoom
,
image_user
_avatar
,
image_room_avatar
)
bindAvatar
(
chatRoom
,
layout_avatar
,
image
_avatar
,
image_room_avatar
)
bindName
(
chatRoom
,
text_chat_name
)
bindLastMessageDateTime
(
chatRoom
,
text_last_message_date_time
)
bindLastMessage
(
chatRoom
,
text_last_message
)
...
...
@@ -47,14 +48,15 @@ class ChatRoomsAdapter(private val context: Context,
setOnClickListener
{
listener
(
chatRoom
)
}
}
private
fun
bindAvatar
(
chatRoom
:
ChatRoom
,
drawee
:
SimpleDraweeView
,
imageView
:
ImageView
)
{
private
fun
bindAvatar
(
chatRoom
:
ChatRoom
,
avatarLayout
:
View
,
drawee
:
SimpleDraweeView
,
imageView
:
ImageView
)
{
val
chatRoomName
=
chatRoom
.
name
if
(
chatRoom
.
type
==
RoomType
.
ONE_TO_ONE
)
{
val
serverUrl
=
chatRoom
.
client
.
url
drawee
.
setImageURI
(
UrlHelper
.
getAvatarUrl
(
serverUrl
,
chatRoomName
)
)
drawee
.
setVisibility
(
true
)
drawee
.
setImageURI
(
UrlHelper
.
getAvatarUrl
(
chatRoom
.
client
.
url
,
chatRoomName
))
imageView
.
setVisibility
(
false
)
avatarLayout
.
setVisibility
(
true
)
}
else
{
imageView
.
setImageDrawable
(
DrawableHelper
.
getTextDrawable
(
chatRoomName
))
avatarLayout
.
setVisibility
(
false
)
imageView
.
setVisibility
(
true
)
}
}
...
...
app/src/main/java/chat/rocket/android/helper/UrlHelper.kt
View file @
8fef2381
package
chat.rocket.android.helper
import
android.util.Patterns
object
UrlHelper
{
/**
...
...
@@ -9,7 +11,7 @@ object UrlHelper {
* @param avatarName The avatar name.
* @return The avatar URL.
*/
fun
getAvatarUrl
(
serverUrl
:
String
,
avatarName
:
String
):
String
=
removeTrailingSlash
(
serverUrl
)+
"/avatar/"
+
avatarName
fun
getAvatarUrl
(
serverUrl
:
String
,
avatarName
:
String
):
String
=
removeTrailingSlash
(
serverUrl
)
+
"/avatar/"
+
avatarName
/**
* Returns the server's Terms of Service URL.
...
...
@@ -40,4 +42,11 @@ object UrlHelper {
serverUrl
}
}
/**
* Checks if the given URL is valid or not.
* @param url The url to check its valid.
* @return True if url is valid, false otherwise.
*/
fun
isValidUrl
(
url
:
String
):
Boolean
=
Patterns
.
WEB_URL
.
matcher
(
url
).
matches
()
}
\ No newline at end of file
app/src/main/res/layout/avatar.xml
0 → 100644
View file @
8fef2381
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<com.facebook.drawee.view.SimpleDraweeView
android:id=
"@+id/image_avatar"
android:layout_width=
"40dp"
android:layout_height=
"40dp"
app:roundedCornerRadius=
"2dp"
/>
<!-- TODO define the correct bg color for this-->
<ImageView
android:id=
"@+id/image_unknown_avatar"
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:src=
"@drawable/ic_help_black_24dp"
android:tint=
"@color/colorAccent"
android:visibility=
"gone"
tools:ignore=
"contentDescription"
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/layout/fragment_authentication_server.xml
View file @
8fef2381
...
...
@@ -32,6 +32,7 @@
android:cursorVisible=
"false"
android:hint=
"@string/default_server"
android:imeOptions=
"actionDone"
android:digits=
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-/"
android:inputType=
"textUri"
android:paddingEnd=
"0dp"
android:paddingStart=
"0dp"
/>
...
...
app/src/main/res/layout/item_chat.xml
View file @
8fef2381
...
...
@@ -18,13 +18,17 @@
app:layout_constraintRight_toLeftOf=
"@+id/middle_container"
app:layout_constraintTop_toTopOf=
"parent"
>
<com.facebook.drawee.view.SimpleDraweeView
android:id=
"@+id/image_user_avatar"
<include
android:id=
"@+id/layout_avatar"
layout=
"@layout/avatar"
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:visibility=
"gone"
app:roundAsCircle=
"true"
/>
android:visibility=
"gone"
/>
<!-- We need to build the avatar with initials since the server returns a SVG file with a pre defined 50x50 pixel.
TODO: check to scale the SVG file on the app and remove the view bellow (or make the server to return a jpg file.
SVG scaling with fresco is impossible: http://frescolib.org/docs/resizing.html
-->
<ImageView
android:id=
"@+id/image_room_avatar"
android:layout_width=
"40dp"
...
...
app/src/main/res/layout/item_message.xml
View file @
8fef2381
...
...
@@ -9,25 +9,14 @@
android:layout_marginStart=
"@dimen/screen_edge_left_and_right_margins"
android:layout_marginTop=
"10dp"
>
<com.facebook.drawee.view.SimpleDraweeView
android:id=
"@+id/image_user_avatar"
android:layout_width=
"40dp"
android:layout_height=
"40dp"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:roundAsCircle=
"true"
/>
<!-- TODO define the correct bg color for this-->
<ImageView
android:id=
"@+id/image_unknown_user"
<include
android:id=
"@+id/layout_avatar"
layout=
"@layout/avatar"
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:src=
"@drawable/ic_help_black_24dp"
android:tint=
"@color/colorAccent"
android:visibility=
"gone"
android:layout_marginTop=
"7dp"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"contentDescription"
/>
app:layout_constraintTop_toTopOf=
"parent"
/>
<LinearLayout
android:id=
"@+id/top_container"
...
...
@@ -35,7 +24,7 @@
android:layout_height=
"wrap_content"
android:layout_marginStart=
"16dp"
android:orientation=
"horizontal"
app:layout_constraintLeft_toRightOf=
"@+id/
image_user
_avatar"
>
app:layout_constraintLeft_toRightOf=
"@+id/
layout
_avatar"
>
<TextView
android:id=
"@+id/text_user_name"
...
...
app/src/main/res/values-pt-rBR/strings.xml
View file @
8fef2381
...
...
@@ -14,6 +14,7 @@
<!-- Regular information messages -->
<string
name=
"msg_no_internet_connection"
>
Sem conexão à internet
</string>
<string
name=
"msg_invalid_server_url"
>
URL de servidor inválida
</string>
<string
name=
"msg_generic_error"
>
Desculpe, ocorreu um erro, tente novamente
</string>
<string
name=
"msg_username"
>
nome de usuário
</string>
<string
name=
"msg_username_or_email"
>
nome de usuário ou email
</string>
...
...
@@ -21,7 +22,7 @@
<string
name=
"msg_name_and_surname"
>
nome e sobrenome
</string>
<string
name=
"msg_email"
>
email
</string>
<string
name=
"msg_or_continue_using_social_accounts"
>
Ou continue através de contas sociais
</string>
<string
name=
"msg_new_
to_rocket_chat"
>
Novo no Rocket Chat
? %1$s
</string>
<string
name=
"msg_new_
user"
>
Novo usuário
? %1$s
</string>
<string
name=
"msg_new_user_agreement"
>
Ao proceder você concorda com nossos %1$s e %2$s
</string>
<string
name=
"msg_2fa_code"
>
Código 2FA
</string>
<string
name=
"msg_invalid_2fa_code"
>
Código 2FA inválido
</string>
...
...
app/src/main/res/values/strings.xml
View file @
8fef2381
...
...
@@ -15,6 +15,7 @@
<!-- Regular information messages -->
<string
name=
"msg_no_internet_connection"
>
No internet connection
</string>
<string
name=
"msg_invalid_server_url"
>
Invalid server URL
</string>
<string
name=
"msg_generic_error"
>
Sorry, an error has occurred, please try again
</string>
<string
name=
"msg_username"
>
username
</string>
<string
name=
"msg_username_or_email"
>
username or email
</string>
...
...
@@ -22,7 +23,7 @@
<string
name=
"msg_name_and_surname"
>
name and surname
</string>
<string
name=
"msg_email"
>
email
</string>
<string
name=
"msg_or_continue_using_social_accounts"
>
Or continue using social accounts
</string>
<string
name=
"msg_new_
to_rocket_chat"
>
New to Rocket Chat
? %1$s
</string>
<string
name=
"msg_new_
user"
>
New user
? %1$s
</string>
<string
name=
"msg_new_user_agreement"
>
By proceeding you are agreeing to our\n%1$s and %2$s
</string>
<string
name=
"msg_2fa_code"
>
2FA Code
</string>
<string
name=
"msg_invalid_2fa_code"
>
Invalid 2FA Code
</string>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment