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
c39b5aa4
Commit
c39b5aa4
authored
Sep 11, 2017
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor UI making it closer to the iOS app
parent
0a913c38
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
78 additions
and
28 deletions
+78
-28
RocketChatCache.java
app/src/main/java/chat/rocket/android/RocketChatCache.java
+11
-5
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+13
-9
MainContract.java
.../main/java/chat/rocket/android/activity/MainContract.java
+1
-1
MainPresenter.java
...main/java/chat/rocket/android/activity/MainPresenter.java
+19
-6
sidebar.xml
app/src/main/res/layout/sidebar.xml
+9
-3
server_row.xml
...t-chat-android-widgets/src/main/res/layout/server_row.xml
+25
-4
No files found.
app/src/main/java/chat/rocket/android/RocketChatCache.java
View file @
c39b5aa4
...
@@ -44,7 +44,7 @@ public class RocketChatCache {
...
@@ -44,7 +44,7 @@ public class RocketChatCache {
setString
(
KEY_SELECTED_SERVER_HOSTNAME
,
hostname
.
toLowerCase
());
setString
(
KEY_SELECTED_SERVER_HOSTNAME
,
hostname
.
toLowerCase
());
}
}
public
void
addHostname
(
@NonNull
String
hostname
,
@Nullable
String
hostnameAvatarUri
)
{
public
void
addHostname
(
@NonNull
String
hostname
,
@Nullable
String
hostnameAvatarUri
,
String
siteName
)
{
String
hostnameList
=
getString
(
KEY_HOSTNAME_LIST
,
null
);
String
hostnameList
=
getString
(
KEY_HOSTNAME_LIST
,
null
);
try
{
try
{
JSONObject
json
;
JSONObject
json
;
...
@@ -53,25 +53,31 @@ public class RocketChatCache {
...
@@ -53,25 +53,31 @@ public class RocketChatCache {
}
else
{
}
else
{
json
=
new
JSONObject
(
hostnameList
);
json
=
new
JSONObject
(
hostnameList
);
}
}
JSONObject
serverInfoJson
=
new
JSONObject
();
serverInfoJson
.
put
(
"hostname"
,
hostnameAvatarUri
);
serverInfoJson
.
put
(
"sitename"
,
siteName
);
// Replace server avatar uri if exists.
// Replace server avatar uri if exists.
json
.
put
(
hostname
,
hostnameAvatarUri
==
null
?
JSONObject
.
NULL
:
hostnameAvatarUri
);
json
.
put
(
hostname
,
hostnameAvatarUri
==
null
?
JSONObject
.
NULL
:
serverInfoJson
);
setString
(
KEY_HOSTNAME_LIST
,
json
.
toString
());
setString
(
KEY_HOSTNAME_LIST
,
json
.
toString
());
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
RCLog
.
e
(
e
);
RCLog
.
e
(
e
);
}
}
}
}
public
List
<
Pair
<
String
,
String
>>
getServerList
()
{
public
List
<
Pair
<
String
,
Pair
<
String
,
String
>
>>
getServerList
()
{
String
json
=
getString
(
KEY_HOSTNAME_LIST
,
null
);
String
json
=
getString
(
KEY_HOSTNAME_LIST
,
null
);
if
(
json
==
null
)
{
if
(
json
==
null
)
{
return
Collections
.
emptyList
();
return
Collections
.
emptyList
();
}
}
try
{
try
{
JSONObject
jsonObj
=
new
JSONObject
(
json
);
JSONObject
jsonObj
=
new
JSONObject
(
json
);
List
<
Pair
<
String
,
String
>>
serverList
=
new
ArrayList
<>();
List
<
Pair
<
String
,
Pair
<
String
,
String
>
>>
serverList
=
new
ArrayList
<>();
for
(
Iterator
<
String
>
iter
=
jsonObj
.
keys
();
iter
.
hasNext
();)
{
for
(
Iterator
<
String
>
iter
=
jsonObj
.
keys
();
iter
.
hasNext
();)
{
String
hostname
=
iter
.
next
();
String
hostname
=
iter
.
next
();
serverList
.
add
(
new
Pair
<>(
hostname
,
"http://"
+
hostname
+
"/"
+
jsonObj
.
getString
(
hostname
)));
JSONObject
serverInfoJson
=
jsonObj
.
getJSONObject
(
hostname
);
serverList
.
add
(
new
Pair
<>(
hostname
,
new
Pair
<>(
"http://"
+
hostname
+
"/"
+
serverInfoJson
.
getString
(
"hostname"
),
serverInfoJson
.
getString
(
"sitename"
))));
}
}
return
serverList
;
return
serverList
;
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
...
...
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
c39b5aa4
package
chat
.
rocket
.
android
.
activity
;
package
chat
.
rocket
.
android
.
activity
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.graphics.Typeface
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.design.widget.Snackbar
;
import
android.support.design.widget.Snackbar
;
...
@@ -197,32 +196,37 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -197,32 +196,37 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
}
}
@Override
@Override
public
void
showSignedInServers
(
List
<
Pair
<
String
,
String
>>
serverList
)
{
public
void
showSignedInServers
(
List
<
Pair
<
String
,
Pair
<
String
,
String
>
>>
serverList
)
{
final
SlidingPaneLayout
subPane
=
(
SlidingPaneLayout
)
findViewById
(
R
.
id
.
sub_sliding_pane
);
final
SlidingPaneLayout
subPane
=
(
SlidingPaneLayout
)
findViewById
(
R
.
id
.
sub_sliding_pane
);
if
(
subPane
!=
null
)
{
if
(
subPane
!=
null
)
{
LinearLayout
serverListContainer
=
subPane
.
findViewById
(
R
.
id
.
server_list_bar
);
LinearLayout
serverListContainer
=
subPane
.
findViewById
(
R
.
id
.
server_list_bar
);
for
(
Pair
<
String
,
String
>
server
:
serverList
)
{
View
addServerButton
=
subPane
.
findViewById
(
R
.
id
.
btn_add_server
);
addServerButton
.
setOnClickListener
(
view
->
showAddServerActivity
());
for
(
Pair
<
String
,
Pair
<
String
,
String
>>
server
:
serverList
)
{
String
serverHostname
=
server
.
first
;
String
serverHostname
=
server
.
first
;
String
serverLogoUrl
=
server
.
second
;
Pair
<
String
,
String
>
serverInfoPair
=
server
.
second
;
String
logoUrl
=
serverInfoPair
.
first
;
String
siteName
=
serverInfoPair
.
second
;
if
(
serverListContainer
.
findViewWithTag
(
serverHostname
)
==
null
)
{
if
(
serverListContainer
.
findViewWithTag
(
serverHostname
)
==
null
)
{
int
serverCount
=
serverListContainer
.
getChildCount
();
int
serverCount
=
serverListContainer
.
getChildCount
();
View
serverRow
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
server_row
,
serverListContainer
,
false
);
View
serverRow
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
server_row
,
serverListContainer
,
false
);
SimpleDraweeView
serverButton
=
serverRow
.
findViewById
(
R
.
id
.
drawee_server_button
);
SimpleDraweeView
serverButton
=
serverRow
.
findViewById
(
R
.
id
.
drawee_server_button
);
TextView
serverLabel
=
serverRow
.
findViewById
(
R
.
id
.
text_view_server_label
);
TextView
hostnameLabel
=
serverRow
.
findViewById
(
R
.
id
.
text_view_server_label
);
TextView
siteNameLabel
=
serverRow
.
findViewById
(
R
.
id
.
text_view_site_name_label
);
serverButton
.
setTag
(
serverHostname
);
serverButton
.
setTag
(
serverHostname
);
serverLabel
.
setText
(
serverHostname
);
hostnameLabel
.
setText
(
serverHostname
);
siteNameLabel
.
setText
(
siteName
);
// Currently selected server
// Currently selected server
if
(
serverHostname
.
equalsIgnoreCase
(
hostname
))
{
if
(
serverHostname
.
equalsIgnoreCase
(
hostname
))
{
serverLabel
.
setSelected
(
true
);
hostnameLabel
.
setSelected
(
true
);
serverLabel
.
setTypeface
(
Typeface
.
DEFAULT_BOLD
);
}
}
serverRow
.
setOnClickListener
(
view
->
changeServerIfNeeded
(
serverHostname
));
serverRow
.
setOnClickListener
(
view
->
changeServerIfNeeded
(
serverHostname
));
FrescoHelper
.
INSTANCE
.
loadImage
(
serverButton
,
serverL
ogoUrl
,
ContextCompat
.
getDrawable
(
this
,
R
.
mipmap
.
ic_launcher
));
FrescoHelper
.
INSTANCE
.
loadImage
(
serverButton
,
l
ogoUrl
,
ContextCompat
.
getDrawable
(
this
,
R
.
mipmap
.
ic_launcher
));
serverListContainer
.
addView
(
serverRow
,
serverCount
-
1
);
serverListContainer
.
addView
(
serverRow
,
serverCount
-
1
);
}
}
...
...
app/src/main/java/chat/rocket/android/activity/MainContract.java
View file @
c39b5aa4
...
@@ -25,7 +25,7 @@ public interface MainContract {
...
@@ -25,7 +25,7 @@ public interface MainContract {
void
showConnectionOk
();
void
showConnectionOk
();
void
showSignedInServers
(
List
<
Pair
<
String
,
String
>>
serverList
);
void
showSignedInServers
(
List
<
Pair
<
String
,
Pair
<
String
,
String
>
>>
serverList
);
}
}
interface
Presenter
extends
BaseContract
.
Presenter
<
View
>
{
interface
Presenter
extends
BaseContract
.
Presenter
<
View
>
{
...
...
app/src/main/java/chat/rocket/android/activity/MainPresenter.java
View file @
c39b5aa4
...
@@ -69,9 +69,9 @@ public class MainPresenter extends BasePresenter<MainContract.View>
...
@@ -69,9 +69,9 @@ public class MainPresenter extends BasePresenter<MainContract.View>
@Override
@Override
public
void
loadSignedInServers
(
@NonNull
String
hostname
)
{
public
void
loadSignedInServers
(
@NonNull
String
hostname
)
{
final
Disposable
disposable
=
publicSettingRepository
.
getById
(
PublicSettingsConstants
.
Assets
.
LOGO
)
final
Disposable
disposable
=
publicSettingRepository
.
getById
(
PublicSettingsConstants
.
Assets
.
LOGO
)
.
filter
(
Optional:
:
isPresent
)
.
zipWith
(
publicSettingRepository
.
getById
(
PublicSettingsConstants
.
General
.
SITE_NAME
),
Pair:
:
new
)
.
map
(
Optional:
:
get
)
.
map
(
this
::
getLogoAndSiteNamePair
)
.
map
(
setting
->
getServerList
(
hostname
,
setting
))
.
map
(
setting
s
->
getServerList
(
hostname
,
settings
))
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
.
subscribe
(
...
@@ -133,11 +133,24 @@ public class MainPresenter extends BasePresenter<MainContract.View>
...
@@ -133,11 +133,24 @@ public class MainPresenter extends BasePresenter<MainContract.View>
addSubscription
(
subscription
);
addSubscription
(
subscription
);
}
}
private
List
<
Pair
<
String
,
String
>>
getServerList
(
String
hostname
,
PublicSetting
publicSetting
)
throws
JSONException
{
private
Pair
<
String
,
String
>
getLogoAndSiteNamePair
(
Pair
<
Optional
<
PublicSetting
>,
Optional
<
PublicSetting
>>
settingsPair
)
{
JSONObject
jsonObject
=
new
JSONObject
(
publicSetting
.
getValue
());
String
logoUrl
=
""
;
String
siteName
=
""
;
if
(
settingsPair
.
first
.
isPresent
())
{
logoUrl
=
settingsPair
.
first
.
get
().
getValue
();
}
if
(
settingsPair
.
second
.
isPresent
())
{
siteName
=
settingsPair
.
second
.
get
().
getValue
();
}
return
new
Pair
<>(
logoUrl
,
siteName
);
}
private
List
<
Pair
<
String
,
Pair
<
String
,
String
>>>
getServerList
(
String
hostname
,
Pair
<
String
,
String
>
serverInfoPair
)
throws
JSONException
{
JSONObject
jsonObject
=
new
JSONObject
(
serverInfoPair
.
first
);
String
logoUrl
=
(
jsonObject
.
has
(
"url"
))
?
String
logoUrl
=
(
jsonObject
.
has
(
"url"
))
?
jsonObject
.
optString
(
"url"
)
:
jsonObject
.
optString
(
"defaultUrl"
);
jsonObject
.
optString
(
"url"
)
:
jsonObject
.
optString
(
"defaultUrl"
);
rocketChatCache
.
addHostname
(
hostname
.
toLowerCase
(),
logoUrl
);
String
siteName
=
serverInfoPair
.
second
;
rocketChatCache
.
addHostname
(
hostname
.
toLowerCase
(),
logoUrl
,
siteName
);
return
rocketChatCache
.
getServerList
();
return
rocketChatCache
.
getServerList
();
}
}
...
...
app/src/main/res/layout/sidebar.xml
View file @
c39b5aa4
...
@@ -22,14 +22,19 @@
...
@@ -22,14 +22,19 @@
<android.support.constraint.ConstraintLayout
<android.support.constraint.ConstraintLayout
android:id=
"@+id/btn_add_server"
android:id=
"@+id/btn_add_server"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"80dp"
>
android:layout_height=
"80dp"
android:background=
"?selectableItemBackground"
android:descendantFocusability=
"afterDescendants"
>
<io.github.yusukeiwaki.android.widget.FontAwesome
Button
<io.github.yusukeiwaki.android.widget.FontAwesome
TextView
android:id=
"@+id/fa_add_server"
android:id=
"@+id/fa_add_server"
style=
"@style/Base.Widget.AppCompat.Button.Borderless"
style=
"@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width=
"80dp"
android:layout_width=
"80dp"
android:layout_height=
"80dp"
android:layout_height=
"80dp"
android:layout_margin=
"@dimen/margin_8"
android:layout_margin=
"@dimen/margin_8"
android:background=
"@null"
android:clickable=
"false"
android:duplicateParentState=
"true"
android:text=
"@string/fa_plus"
android:text=
"@string/fa_plus"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
@@ -40,12 +45,13 @@
...
@@ -40,12 +45,13 @@
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:layout_marginEnd=
"16dp"
android:layout_marginRight=
"16dp"
android:layout_marginRight=
"16dp"
android:duplicateParentState=
"true"
android:ellipsize=
"end"
android:ellipsize=
"end"
android:gravity=
"center_vertical"
android:gravity=
"center_vertical"
android:maxLines=
"1"
android:maxLines=
"1"
android:text=
"@string/add_new_team"
android:text=
"@string/add_new_team"
android:textAppearance=
"@style/TextAppearance.AppCompat.Medium"
android:textColor=
"@android:color/white"
android:textColor=
"@android:color/white"
android:textSize=
"16sp"
android:textStyle=
"bold"
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
...
...
rocket-chat-android-widgets/src/main/res/layout/server_row.xml
View file @
c39b5aa4
...
@@ -4,13 +4,15 @@
...
@@ -4,13 +4,15 @@
xmlns:fresco=
"http://schemas.android.com/apk/res-auto"
xmlns:fresco=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"80dp"
>
android:layout_height=
"80dp"
tools:background=
"#044b76"
>
<com.facebook.drawee.view.SimpleDraweeView
<com.facebook.drawee.view.SimpleDraweeView
android:id=
"@+id/drawee_server_button"
android:id=
"@+id/drawee_server_button"
style=
"@style/Base.Widget.AppCompat.Button.Borderless"
style=
"@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width=
"80dp"
android:layout_width=
"80dp"
android:layout_height=
"80dp"
android:layout_height=
"80dp"
android:layout_marginBottom=
"8dp"
android:layout_marginEnd=
"8dp"
android:layout_marginEnd=
"8dp"
android:layout_marginStart=
"8dp"
android:layout_marginStart=
"8dp"
android:layout_marginTop=
"8dp"
android:layout_marginTop=
"8dp"
...
@@ -19,21 +21,40 @@
...
@@ -19,21 +21,40 @@
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
fresco:actualImageScaleType=
"fitXY"
/>
fresco:actualImageScaleType=
"fitXY"
/>
<TextView
android:id=
"@+id/text_view_site_name_label"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"16dp"
android:ellipsize=
"end"
android:gravity=
"bottom"
android:maxLines=
"1"
android:textAppearance=
"@style/TextAppearance.AppCompat.Medium"
android:textColor=
"@android:color/white"
app:layout_constraintEnd_toEndOf=
"@+id/text_view_server_label"
app:layout_constraintStart_toStartOf=
"@+id/text_view_server_label"
app:layout_constraintTop_toTopOf=
"@+id/drawee_server_button"
tools:text=
"Rocket.Chat"
/>
<TextView
<TextView
android:id=
"@+id/text_view_server_label"
android:id=
"@+id/text_view_server_label"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"16dp"
android:layout_marginEnd=
"16dp"
android:layout_marginEnd=
"16dp"
android:layout_marginRight=
"16dp"
android:layout_marginRight=
"16dp"
android:ellipsize=
"end"
android:ellipsize=
"end"
android:gravity=
"
center_vertical
"
android:gravity=
"
top
"
android:maxLines=
"1"
android:maxLines=
"1"
android:textColor=
"@color/selector_text_color_multiserver"
android:textAllCaps=
"false"
android:textColor=
"@color/color_embed_hostname"
android:textSize=
"16sp"
android:textSize=
"16sp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.0"
app:layout_constraintStart_toEndOf=
"@+id/drawee_server_button"
app:layout_constraintStart_toEndOf=
"@+id/drawee_server_button"
app:layout_constraintTop_to
TopOf=
"parent
"
app:layout_constraintTop_to
BottomOf=
"@+id/text_view_site_name_label
"
tools:text=
"demo.rocket.chat"
/>
tools:text=
"demo.rocket.chat"
/>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
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