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
5e6bb869
Commit
5e6bb869
authored
Sep 18, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
https://github.com/RocketChat/Rocket.Chat.Android
into iss424
parents
50055574
b2c0d021
Changes
31
Show whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
551 additions
and
118 deletions
+551
-118
build.gradle
android-ddp/build.gradle
+1
-1
OkHttpHelper.kt
...src/debug/java/chat/rocket/android/helper/OkHttpHelper.kt
+2
-0
RocketChatApplication.java
.../main/java/chat/rocket/android/RocketChatApplication.java
+7
-0
RocketChatCache.java
app/src/main/java/chat/rocket/android/RocketChatCache.java
+62
-8
AbstractFragmentActivity.java
...hat/rocket/android/activity/AbstractFragmentActivity.java
+15
-2
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+119
-23
MainContract.java
.../main/java/chat/rocket/android/activity/MainContract.java
+7
-0
MainPresenter.java
...main/java/chat/rocket/android/activity/MainPresenter.java
+52
-2
MethodCallHelper.java
...c/main/java/chat/rocket/android/api/MethodCallHelper.java
+1
-1
InputHostnameFragment.java
...et/android/fragment/add_server/InputHostnameFragment.java
+1
-1
SidebarMainFragment.java
.../rocket/android/fragment/sidebar/SidebarMainFragment.java
+6
-1
FileUploadActionItem.java
...ayouthelper/extra_action/upload/FileUploadActionItem.java
+31
-0
MessageRenderer.kt
...main/java/chat/rocket/android/renderer/MessageRenderer.kt
+3
-3
UserRenderer.kt
...rc/main/java/chat/rocket/android/renderer/UserRenderer.kt
+2
-2
GcmPushRegistrationObserver.java
...android/service/observer/GcmPushRegistrationObserver.java
+7
-15
ic_insert_drive_file_white_24dp.xml
...src/main/res/drawable/ic_insert_drive_file_white_24dp.xml
+9
-0
fragment_input_hostname.xml
app/src/main/res/layout/fragment_input_hostname.xml
+1
-1
sidebar.xml
app/src/main/res/layout/sidebar.xml
+52
-22
strings.xml
app/src/main/res/values/strings.xml
+2
-0
RocketChatCacheTest.kt
...rc/test/kotlin/chat.rocket.android/RocketChatCacheTest.kt
+42
-0
build.gradle
build.gradle
+1
-0
build.gradle
rocket-chat-android-widgets/build.gradle
+1
-1
RoomToolbar.java
...src/main/java/chat/rocket/android/widget/RoomToolbar.java
+1
-1
AvatarHelper.kt
...in/java/chat/rocket/android/widget/helper/AvatarHelper.kt
+1
-1
UserViewHolder.java
...roid/widget/message/autocomplete/user/UserViewHolder.java
+4
-6
selector_text_color_multiserver.xml
...ts/src/main/res/color/selector_text_color_multiserver.xml
+6
-0
serverstatus_selected.xml
...d-widgets/src/main/res/drawable/serverstatus_selected.xml
+11
-0
server_row.xml
...t-chat-android-widgets/src/main/res/layout/server_row.xml
+75
-0
colors.xml
rocket-chat-android-widgets/src/main/res/values/colors.xml
+2
-0
AvatarHelperTest.kt
...lin/chat/rocket/android/widget/helper/AvatarHelperTest.kt
+27
-0
UserAvatarHelperTest.kt
...chat/rocket/android/widget/helper/UserAvatarHelperTest.kt
+0
-27
No files found.
android-ddp/build.gradle
View file @
5e6bb869
...
@@ -39,7 +39,7 @@ dependencies {
...
@@ -39,7 +39,7 @@ dependencies {
compile
"com.android.support:support-annotations:$rootProject.ext.supportLibraryVersion"
compile
"com.android.support:support-annotations:$rootProject.ext.supportLibraryVersion"
compile
'com.squareup.okhttp3:okhttp:3.8.0'
compile
"com.squareup.okhttp3:okhttp:$rootProject.ext.okHttpVersion"
compile
'io.reactivex.rxjava2:rxjava:2.1.0'
compile
'io.reactivex.rxjava2:rxjava:2.1.0'
...
...
app/src/debug/java/chat/rocket/android/helper/OkHttpHelper.kt
View file @
5e6bb869
...
@@ -28,6 +28,8 @@ object OkHttpHelper {
...
@@ -28,6 +28,8 @@ object OkHttpHelper {
if
(
httpClientForDownloadFile
==
null
)
{
if
(
httpClientForDownloadFile
==
null
)
{
httpClientForDownloadFile
=
OkHttpClient
.
Builder
()
httpClientForDownloadFile
=
OkHttpClient
.
Builder
()
.
addNetworkInterceptor
(
StethoInterceptor
())
.
addNetworkInterceptor
(
StethoInterceptor
())
.
followRedirects
(
true
)
.
followSslRedirects
(
true
)
.
addInterceptor
(
CookieInterceptor
(
DefaultCookieProvider
(
RocketChatCache
(
context
))))
.
addInterceptor
(
CookieInterceptor
(
DefaultCookieProvider
(
RocketChatCache
(
context
))))
.
build
()
.
build
()
}
}
...
...
app/src/main/java/chat/rocket/android/RocketChatApplication.java
View file @
5e6bb869
package
chat
.
rocket
.
android
;
package
chat
.
rocket
.
android
;
import
android.os.Build
;
import
android.support.multidex.MultiDexApplication
;
import
android.support.multidex.MultiDexApplication
;
import
android.support.v7.app.AppCompatDelegate
;
import
chat.rocket.android.helper.OkHttpHelper
;
import
chat.rocket.android.helper.OkHttpHelper
;
import
com.crashlytics.android.Crashlytics
;
import
com.crashlytics.android.Crashlytics
;
...
@@ -30,5 +33,9 @@ public class RocketChatApplication extends MultiDexApplication {
...
@@ -30,5 +33,9 @@ public class RocketChatApplication extends MultiDexApplication {
}
}
RocketChatWidgets
.
initialize
(
this
,
OkHttpHelper
.
INSTANCE
.
getClientForDownloadFile
(
this
));
RocketChatWidgets
.
initialize
(
this
,
OkHttpHelper
.
INSTANCE
.
getClientForDownloadFile
(
this
));
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
AppCompatDelegate
.
setCompatVectorFromResourcesEnabled
(
true
);
}
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/RocketChatCache.java
View file @
5e6bb869
...
@@ -5,18 +5,30 @@ import android.content.SharedPreferences;
...
@@ -5,18 +5,30 @@ import android.content.SharedPreferences;
import
com.hadisatrio.optional.Optional
;
import
com.hadisatrio.optional.Optional
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.UUID
;
import
chat.rocket.android.log.RCLog
;
import
chat.rocket.core.utils.Pair
;
import
io.reactivex.BackpressureStrategy
;
import
io.reactivex.BackpressureStrategy
;
import
io.reactivex.Flowable
;
import
io.reactivex.Flowable
;
import
io.reactivex.annotations.NonNull
;
import
io.reactivex.annotations.Nullable
;
/**
/**
* sharedpreference-based cache.
* sharedpreference-based cache.
*/
*/
public
class
RocketChatCache
{
public
class
RocketChatCache
{
private
static
final
String
KEY_SELECTED_SERVER_HOSTNAME
=
"selectedServerHostname"
;
private
static
final
String
KEY_SELECTED_SERVER_HOSTNAME
=
"KEY_SELECTED_SERVER_HOSTNAME"
;
private
static
final
String
KEY_SELECTED_ROOM_ID
=
"selectedRoomId"
;
private
static
final
String
KEY_SELECTED_ROOM_ID
=
"KEY_SELECTED_ROOM_ID"
;
private
static
final
String
KEY_PUSH_ID
=
"pushId"
;
private
static
final
String
KEY_PUSH_ID
=
"KEY_PUSH_ID"
;
private
static
final
String
KEY_HOSTNAME_LIST
=
"KEY_HOSTNAME_LIST"
;
private
Context
context
;
private
Context
context
;
...
@@ -29,15 +41,57 @@ public class RocketChatCache {
...
@@ -29,15 +41,57 @@ public class RocketChatCache {
}
}
public
void
setSelectedServerHostname
(
String
hostname
)
{
public
void
setSelectedServerHostname
(
String
hostname
)
{
setString
(
KEY_SELECTED_SERVER_HOSTNAME
,
hostname
);
setString
(
KEY_SELECTED_SERVER_HOSTNAME
,
hostname
.
toLowerCase
());
}
public
void
addHostname
(
@NonNull
String
hostname
,
@Nullable
String
hostnameAvatarUri
,
String
siteName
)
{
String
hostnameList
=
getString
(
KEY_HOSTNAME_LIST
,
null
);
try
{
JSONObject
json
;
if
(
hostnameList
==
null
)
{
json
=
new
JSONObject
();
}
else
{
json
=
new
JSONObject
(
hostnameList
);
}
JSONObject
serverInfoJson
=
new
JSONObject
();
serverInfoJson
.
put
(
"hostname"
,
hostnameAvatarUri
);
serverInfoJson
.
put
(
"sitename"
,
siteName
);
// Replace server avatar uri if exists.
json
.
put
(
hostname
,
hostnameAvatarUri
==
null
?
JSONObject
.
NULL
:
serverInfoJson
);
setString
(
KEY_HOSTNAME_LIST
,
json
.
toString
());
}
catch
(
JSONException
e
)
{
RCLog
.
e
(
e
);
}
}
public
List
<
Pair
<
String
,
Pair
<
String
,
String
>>>
getServerList
()
{
String
json
=
getString
(
KEY_HOSTNAME_LIST
,
null
);
if
(
json
==
null
)
{
return
Collections
.
emptyList
();
}
try
{
JSONObject
jsonObj
=
new
JSONObject
(
json
);
List
<
Pair
<
String
,
Pair
<
String
,
String
>>>
serverList
=
new
ArrayList
<>();
for
(
Iterator
<
String
>
iter
=
jsonObj
.
keys
();
iter
.
hasNext
();)
{
String
hostname
=
iter
.
next
();
JSONObject
serverInfoJson
=
jsonObj
.
getJSONObject
(
hostname
);
serverList
.
add
(
new
Pair
<>(
hostname
,
new
Pair
<>(
"http://"
+
hostname
+
"/"
+
serverInfoJson
.
getString
(
"hostname"
),
serverInfoJson
.
getString
(
"sitename"
))));
}
return
serverList
;
}
catch
(
JSONException
e
)
{
RCLog
.
e
(
e
);
}
return
Collections
.
emptyList
();
}
}
public
String
getSelectedRoomId
()
{
public
String
getSelectedRoomId
()
{
return
getString
(
KEY_SELECTED_ROOM_ID
,
null
);
return
getString
(
getSelectedServerHostname
()
+
KEY_SELECTED_ROOM_ID
,
null
);
}
}
public
void
setSelectedRoomId
(
String
roomId
)
{
public
void
setSelectedRoomId
(
String
roomId
)
{
setString
(
KEY_SELECTED_ROOM_ID
,
roomId
);
setString
(
getSelectedServerHostname
()
+
KEY_SELECTED_ROOM_ID
,
roomId
);
}
}
public
String
getOrCreatePushId
()
{
public
String
getOrCreatePushId
()
{
...
@@ -58,7 +112,7 @@ public class RocketChatCache {
...
@@ -58,7 +112,7 @@ public class RocketChatCache {
}
}
public
Flowable
<
Optional
<
String
>>
getSelectedRoomIdPublisher
()
{
public
Flowable
<
Optional
<
String
>>
getSelectedRoomIdPublisher
()
{
return
getValuePublisher
(
KEY_SELECTED_ROOM_ID
);
return
getValuePublisher
(
getSelectedServerHostname
()
+
KEY_SELECTED_ROOM_ID
);
}
}
private
SharedPreferences
getSharedPreferences
()
{
private
SharedPreferences
getSharedPreferences
()
{
...
@@ -69,7 +123,7 @@ public class RocketChatCache {
...
@@ -69,7 +123,7 @@ public class RocketChatCache {
return
getSharedPreferences
().
edit
();
return
getSharedPreferences
().
edit
();
}
}
p
rivate
String
getString
(
String
key
,
String
defaultValue
)
{
p
ublic
String
getString
(
String
key
,
String
defaultValue
)
{
return
getSharedPreferences
().
getString
(
key
,
defaultValue
);
return
getSharedPreferences
().
getString
(
key
,
defaultValue
);
}
}
...
...
app/src/main/java/chat/rocket/android/activity/AbstractFragmentActivity.java
View file @
5e6bb869
package
chat
.
rocket
.
android
.
activity
;
package
chat
.
rocket
.
android
.
activity
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.annotation.IdRes
;
import
android.support.annotation.IdRes
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
...
@@ -13,9 +14,16 @@ import icepick.Icepick;
...
@@ -13,9 +14,16 @@ import icepick.Icepick;
abstract
class
AbstractFragmentActivity
extends
RxAppCompatActivity
{
abstract
class
AbstractFragmentActivity
extends
RxAppCompatActivity
{
public
static
final
String
EXTRA_FINISH_ON_BACK_PRESS
=
"EXTRA_FINISH_ON_BACK_PRESS"
;
private
boolean
finishOnBackPress
;
@Override
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
Intent
intent
=
getIntent
();
if
(
intent
!=
null
)
{
finishOnBackPress
=
intent
.
getBooleanExtra
(
EXTRA_FINISH_ON_BACK_PRESS
,
false
);
}
Icepick
.
restoreInstanceState
(
this
,
savedInstanceState
);
Icepick
.
restoreInstanceState
(
this
,
savedInstanceState
);
}
}
...
@@ -30,10 +38,15 @@ abstract class AbstractFragmentActivity extends RxAppCompatActivity {
...
@@ -30,10 +38,15 @@ abstract class AbstractFragmentActivity extends RxAppCompatActivity {
@Override
@Override
public
final
void
onBackPressed
()
{
public
final
void
onBackPressed
()
{
if
(
finishOnBackPress
)
{
super
.
onBackPressed
();
finish
();
}
else
{
if
(!
onBackPress
())
{
if
(!
onBackPress
())
{
onBackPressedNotHandled
();
onBackPressedNotHandled
();
}
}
}
}
}
protected
boolean
onBackPress
()
{
protected
boolean
onBackPress
()
{
FragmentManager
fragmentManager
=
getSupportFragmentManager
();
FragmentManager
fragmentManager
=
getSupportFragmentManager
();
...
...
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
5e6bb869
package
chat
.
rocket
.
android
.
activity
;
package
chat
.
rocket
.
android
.
activity
;
import
android.content.Intent
;
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
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.content.ContextCompat
;
import
android.support.v4.widget.SlidingPaneLayout
;
import
android.support.v4.widget.SlidingPaneLayout
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
com.facebook.drawee.view.SimpleDraweeView
;
import
java.util.List
;
import
chat.rocket.android.LaunchUtil
;
import
chat.rocket.android.LaunchUtil
;
import
chat.rocket.android.R
;
import
chat.rocket.android.R
;
...
@@ -16,9 +27,13 @@ import chat.rocket.android.fragment.sidebar.SidebarMainFragment;
...
@@ -16,9 +27,13 @@ import chat.rocket.android.fragment.sidebar.SidebarMainFragment;
import
chat.rocket.android.helper.KeyboardHelper
;
import
chat.rocket.android.helper.KeyboardHelper
;
import
chat.rocket.android.service.ConnectivityManager
;
import
chat.rocket.android.service.ConnectivityManager
;
import
chat.rocket.android.widget.RoomToolbar
;
import
chat.rocket.android.widget.RoomToolbar
;
import
chat.rocket.android.widget.helper.FrescoHelper
;
import
chat.rocket.core.interactors.CanCreateRoomInteractor
;
import
chat.rocket.core.interactors.CanCreateRoomInteractor
;
import
chat.rocket.core.interactors.RoomInteractor
;
import
chat.rocket.core.interactors.RoomInteractor
;
import
chat.rocket.core.interactors.SessionInteractor
;
import
chat.rocket.core.interactors.SessionInteractor
;
import
chat.rocket.core.repositories.PublicSettingRepository
;
import
chat.rocket.core.utils.Pair
;
import
chat.rocket.persistence.realm.repositories.RealmPublicSettingRepository
;
import
chat.rocket.persistence.realm.repositories.RealmRoomRepository
;
import
chat.rocket.persistence.realm.repositories.RealmRoomRepository
;
import
chat.rocket.persistence.realm.repositories.RealmSessionRepository
;
import
chat.rocket.persistence.realm.repositories.RealmSessionRepository
;
import
chat.rocket.persistence.realm.repositories.RealmUserRepository
;
import
chat.rocket.persistence.realm.repositories.RealmUserRepository
;
...
@@ -50,8 +65,16 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -50,8 +65,16 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
@Override
@Override
protected
void
onResume
()
{
protected
void
onResume
()
{
super
.
onResume
();
super
.
onResume
();
if
(
presenter
!=
null
)
{
if
(
hostname
==
null
||
presenter
==
null
)
{
hostname
=
new
RocketChatCache
(
getApplicationContext
()).
getSelectedServerHostname
();
if
(
hostname
==
null
)
{
showAddServerScreen
();
}
else
{
onHostnameUpdated
();
}
}
else
{
presenter
.
bindViewOnly
(
this
);
presenter
.
bindViewOnly
(
this
);
presenter
.
loadSignedInServers
(
hostname
);
}
}
}
}
...
@@ -64,7 +87,14 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -64,7 +87,14 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
super
.
onPause
();
super
.
onPause
();
}
}
private
void
showAddServerActivity
()
{
Intent
intent
=
new
Intent
(
this
,
AddServerActivity
.
class
);
intent
.
putExtra
(
AddServerActivity
.
EXTRA_FINISH_ON_BACK_PRESS
,
true
);
startActivity
(
intent
);
}
private
void
setupToolbar
()
{
private
void
setupToolbar
()
{
if
(
pane
!=
null
)
{
pane
.
setPanelSlideListener
(
new
SlidingPaneLayout
.
PanelSlideListener
()
{
pane
.
setPanelSlideListener
(
new
SlidingPaneLayout
.
PanelSlideListener
()
{
@Override
@Override
public
void
onPanelSlide
(
View
view
,
float
v
)
{
public
void
onPanelSlide
(
View
view
,
float
v
)
{
...
@@ -80,15 +110,25 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -80,15 +110,25 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
@Override
@Override
public
void
onPanelClosed
(
View
view
)
{
public
void
onPanelClosed
(
View
view
)
{
toolbar
.
setNavigationIconVerticalMirror
(
false
);
toolbar
.
setNavigationIconVerticalMirror
(
false
);
Fragment
fragment
=
getSupportFragmentManager
()
.
findFragmentById
(
R
.
id
.
sidebar_fragment_container
);
if
(
fragment
!=
null
&&
fragment
instanceof
SidebarMainFragment
)
{
SidebarMainFragment
sidebarMainFragment
=
(
SidebarMainFragment
)
fragment
;
sidebarMainFragment
.
toggleUserActionContainer
(
false
);
sidebarMainFragment
.
showUserActionContainer
(
false
);
}
}
}
});
});
}
if
(
toolbar
!=
null
)
{
toolbar
.
setNavigationOnClickListener
(
view
->
{
toolbar
.
setNavigationOnClickListener
(
view
->
{
if
(
pane
.
isSlideable
()
&&
!
pane
.
isOpen
())
{
if
(
pane
.
isSlideable
()
&&
!
pane
.
isOpen
())
{
pane
.
openPane
();
pane
.
openPane
();
}
}
});
});
}
}
}
private
boolean
closeSidebarIfNeeded
()
{
private
boolean
closeSidebarIfNeeded
()
{
// REMARK: Tablet UI doesn't have SlidingPane!
// REMARK: Tablet UI doesn't have SlidingPane!
...
@@ -119,21 +159,26 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -119,21 +159,26 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
new
RealmSessionRepository
(
hostname
)
new
RealmSessionRepository
(
hostname
)
);
);
PublicSettingRepository
publicSettingRepository
=
new
RealmPublicSettingRepository
(
hostname
);
presenter
=
new
MainPresenter
(
presenter
=
new
MainPresenter
(
roomInteractor
,
roomInteractor
,
createRoomInteractor
,
createRoomInteractor
,
sessionInteractor
,
sessionInteractor
,
new
MethodCallHelper
(
this
,
hostname
),
new
MethodCallHelper
(
this
,
hostname
),
ConnectivityManager
.
getInstance
(
getApplicationContext
()),
ConnectivityManager
.
getInstance
(
getApplicationContext
()),
new
RocketChatCache
(
this
)
new
RocketChatCache
(
this
),
publicSettingRepository
);
);
updateSidebarMainFragment
();
updateSidebarMainFragment
();
presenter
.
bindView
(
this
);
presenter
.
bindView
(
this
);
presenter
.
loadSignedInServers
(
hostname
);
}
}
private
void
updateSidebarMainFragment
()
{
private
void
updateSidebarMainFragment
()
{
closeSidebarIfNeeded
();
getSupportFragmentManager
().
beginTransaction
()
getSupportFragmentManager
().
beginTransaction
()
.
replace
(
R
.
id
.
sidebar_fragment_container
,
SidebarMainFragment
.
create
(
hostname
))
.
replace
(
R
.
id
.
sidebar_fragment_container
,
SidebarMainFragment
.
create
(
hostname
))
.
commit
();
.
commit
();
...
@@ -164,7 +209,7 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -164,7 +209,7 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
@Override
@Override
public
void
showUnreadCount
(
long
roomsCount
,
int
mentionsCount
)
{
public
void
showUnreadCount
(
long
roomsCount
,
int
mentionsCount
)
{
toolbar
.
setUnreadB
u
dge
((
int
)
roomsCount
,
mentionsCount
);
toolbar
.
setUnreadB
a
dge
((
int
)
roomsCount
,
mentionsCount
);
}
}
@Override
@Override
...
@@ -199,6 +244,57 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -199,6 +244,57 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
statusTicker
.
updateStatus
(
StatusTicker
.
STATUS_DISMISS
,
null
);
statusTicker
.
updateStatus
(
StatusTicker
.
STATUS_DISMISS
,
null
);
}
}
@Override
public
void
showSignedInServers
(
List
<
Pair
<
String
,
Pair
<
String
,
String
>>>
serverList
)
{
final
SlidingPaneLayout
subPane
=
(
SlidingPaneLayout
)
findViewById
(
R
.
id
.
sub_sliding_pane
);
if
(
subPane
!=
null
)
{
LinearLayout
serverListContainer
=
subPane
.
findViewById
(
R
.
id
.
server_list_bar
);
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
;
Pair
<
String
,
String
>
serverInfoPair
=
server
.
second
;
String
logoUrl
=
serverInfoPair
.
first
;
String
siteName
=
serverInfoPair
.
second
;
if
(
serverListContainer
.
findViewWithTag
(
serverHostname
)
==
null
)
{
int
serverCount
=
serverListContainer
.
getChildCount
();
View
serverRow
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
server_row
,
serverListContainer
,
false
);
SimpleDraweeView
serverButton
=
serverRow
.
findViewById
(
R
.
id
.
drawee_server_button
);
TextView
hostnameLabel
=
serverRow
.
findViewById
(
R
.
id
.
text_view_server_label
);
TextView
siteNameLabel
=
serverRow
.
findViewById
(
R
.
id
.
text_view_site_name_label
);
ImageView
dotView
=
serverRow
.
findViewById
(
R
.
id
.
selected_server_dot
);
serverButton
.
setTag
(
serverHostname
);
hostnameLabel
.
setText
(
serverHostname
);
siteNameLabel
.
setText
(
siteName
);
// Currently selected server
if
(
serverHostname
.
equalsIgnoreCase
(
hostname
))
{
serverRow
.
setSelected
(
true
);
dotView
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
dotView
.
setVisibility
(
View
.
GONE
);
}
serverRow
.
setOnClickListener
(
view
->
changeServerIfNeeded
(
serverHostname
));
FrescoHelper
.
INSTANCE
.
loadImage
(
serverButton
,
logoUrl
,
ContextCompat
.
getDrawable
(
this
,
R
.
mipmap
.
ic_launcher
));
serverListContainer
.
addView
(
serverRow
,
serverCount
-
1
);
}
}
}
}
private
void
changeServerIfNeeded
(
String
serverHostname
)
{
if
(!
hostname
.
equalsIgnoreCase
(
serverHostname
))
{
RocketChatCache
rocketChatCache
=
new
RocketChatCache
(
getApplicationContext
());
rocketChatCache
.
setSelectedServerHostname
(
serverHostname
);
recreate
();
}
}
//TODO: consider this class to define in layouthelper for more complicated operation.
//TODO: consider this class to define in layouthelper for more complicated operation.
private
static
class
StatusTicker
{
private
static
class
StatusTicker
{
public
static
final
int
STATUS_DISMISS
=
0
;
public
static
final
int
STATUS_DISMISS
=
0
;
...
...
app/src/main/java/chat/rocket/android/activity/MainContract.java
View file @
5e6bb869
package
chat
.
rocket
.
android
.
activity
;
package
chat
.
rocket
.
android
.
activity
;
import
java.util.List
;
import
chat.rocket.android.shared.BaseContract
;
import
chat.rocket.android.shared.BaseContract
;
import
chat.rocket.core.utils.Pair
;
public
interface
MainContract
{
public
interface
MainContract
{
...
@@ -21,6 +24,8 @@ public interface MainContract {
...
@@ -21,6 +24,8 @@ public interface MainContract {
void
showConnecting
();
void
showConnecting
();
void
showConnectionOk
();
void
showConnectionOk
();
void
showSignedInServers
(
List
<
Pair
<
String
,
Pair
<
String
,
String
>>>
serverList
);
}
}
interface
Presenter
extends
BaseContract
.
Presenter
<
View
>
{
interface
Presenter
extends
BaseContract
.
Presenter
<
View
>
{
...
@@ -30,5 +35,7 @@ public interface MainContract {
...
@@ -30,5 +35,7 @@ public interface MainContract {
void
onRetryLogin
();
void
onRetryLogin
();
void
bindViewOnly
(
View
view
);
void
bindViewOnly
(
View
view
);
void
loadSignedInServers
(
String
hostname
);
}
}
}
}
app/src/main/java/chat/rocket/android/activity/MainPresenter.java
View file @
5e6bb869
package
chat
.
rocket
.
android
.
activity
;
package
chat
.
rocket
.
android
.
activity
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
android.support.v4.util.Pair
;
import
com.hadisatrio.optional.Optional
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.util.List
;
import
chat.rocket.android.BackgroundLooper
;
import
chat.rocket.android.BackgroundLooper
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.helper.LogIfError
;
import
chat.rocket.android.helper.LogIfError
;
import
chat.rocket.android.helper.Logger
;
import
chat.rocket.android.helper.Logger
;
import
chat.rocket.android.log.RCLog
;
import
chat.rocket.android.service.ConnectivityManagerApi
;
import
chat.rocket.android.service.ConnectivityManagerApi
;
import
chat.rocket.android.service.ServerConnectivity
;
import
chat.rocket.android.service.ServerConnectivity
;
import
chat.rocket.android.shared.BasePresenter
;
import
chat.rocket.android.shared.BasePresenter
;
import
chat.rocket.core.PublicSettingsConstants
;
import
chat.rocket.core.interactors.CanCreateRoomInteractor
;
import
chat.rocket.core.interactors.CanCreateRoomInteractor
;
import
chat.rocket.core.interactors.RoomInteractor
;
import
chat.rocket.core.interactors.RoomInteractor
;
import
chat.rocket.core.interactors.SessionInteractor
;
import
chat.rocket.core.interactors.SessionInteractor
;
import
chat.rocket.core.models.PublicSetting
;
import
chat.rocket.core.models.Session
;
import
chat.rocket.core.models.Session
;
import
chat.rocket.core.models.User
;
import
chat.rocket.core.models.User
;
import
chat.rocket.core.repositories.PublicSettingRepository
;
import
chat.rocket.core.utils.Pair
;
import
hu.akarnokd.rxjava.interop.RxJavaInterop
;
import
hu.akarnokd.rxjava.interop.RxJavaInterop
;
import
io.reactivex.Flowable
;
import
io.reactivex.Flowable
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
...
@@ -30,19 +41,21 @@ public class MainPresenter extends BasePresenter<MainContract.View>
...
@@ -30,19 +41,21 @@ public class MainPresenter extends BasePresenter<MainContract.View>
private
final
MethodCallHelper
methodCallHelper
;
private
final
MethodCallHelper
methodCallHelper
;
private
final
ConnectivityManagerApi
connectivityManagerApi
;
private
final
ConnectivityManagerApi
connectivityManagerApi
;
private
final
RocketChatCache
rocketChatCache
;
private
final
RocketChatCache
rocketChatCache
;
private
final
PublicSettingRepository
publicSettingRepository
;
public
MainPresenter
(
RoomInteractor
roomInteractor
,
public
MainPresenter
(
RoomInteractor
roomInteractor
,
CanCreateRoomInteractor
canCreateRoomInteractor
,
CanCreateRoomInteractor
canCreateRoomInteractor
,
SessionInteractor
sessionInteractor
,
SessionInteractor
sessionInteractor
,
MethodCallHelper
methodCallHelper
,
MethodCallHelper
methodCallHelper
,
ConnectivityManagerApi
connectivityManagerApi
,
ConnectivityManagerApi
connectivityManagerApi
,
RocketChatCache
rocketChatCache
)
{
RocketChatCache
rocketChatCache
,
PublicSettingRepository
publicSettingRepository
)
{
this
.
roomInteractor
=
roomInteractor
;
this
.
roomInteractor
=
roomInteractor
;
this
.
canCreateRoomInteractor
=
canCreateRoomInteractor
;
this
.
canCreateRoomInteractor
=
canCreateRoomInteractor
;
this
.
sessionInteractor
=
sessionInteractor
;
this
.
sessionInteractor
=
sessionInteractor
;
this
.
methodCallHelper
=
methodCallHelper
;
this
.
methodCallHelper
=
methodCallHelper
;
this
.
connectivityManagerApi
=
connectivityManagerApi
;
this
.
connectivityManagerApi
=
connectivityManagerApi
;
this
.
rocketChatCache
=
rocketChatCache
;
this
.
rocketChatCache
=
rocketChatCache
;
this
.
publicSettingRepository
=
publicSettingRepository
;
}
}
@Override
@Override
...
@@ -53,6 +66,22 @@ public class MainPresenter extends BasePresenter<MainContract.View>
...
@@ -53,6 +66,22 @@ public class MainPresenter extends BasePresenter<MainContract.View>
setUserOnline
();
setUserOnline
();
}
}
@Override
public
void
loadSignedInServers
(
@NonNull
String
hostname
)
{
final
Disposable
disposable
=
publicSettingRepository
.
getById
(
PublicSettingsConstants
.
Assets
.
LOGO
)
.
zipWith
(
publicSettingRepository
.
getById
(
PublicSettingsConstants
.
General
.
SITE_NAME
),
Pair:
:
new
)
.
map
(
this
::
getLogoAndSiteNamePair
)
.
map
(
settings
->
getServerList
(
hostname
,
settings
))
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
view:
:
showSignedInServers
,
RCLog:
:
e
);
addSubscription
(
disposable
);
}
@Override
@Override
public
void
bindView
(
@NonNull
MainContract
.
View
view
)
{
public
void
bindView
(
@NonNull
MainContract
.
View
view
)
{
super
.
bindView
(
view
);
super
.
bindView
(
view
);
...
@@ -104,6 +133,27 @@ public class MainPresenter extends BasePresenter<MainContract.View>
...
@@ -104,6 +133,27 @@ public class MainPresenter extends BasePresenter<MainContract.View>
addSubscription
(
subscription
);
addSubscription
(
subscription
);
}
}
private
Pair
<
String
,
String
>
getLogoAndSiteNamePair
(
Pair
<
Optional
<
PublicSetting
>,
Optional
<
PublicSetting
>>
settingsPair
)
{
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"
))
?
jsonObject
.
optString
(
"url"
)
:
jsonObject
.
optString
(
"defaultUrl"
);
String
siteName
=
serverInfoPair
.
second
;
rocketChatCache
.
addHostname
(
hostname
.
toLowerCase
(),
logoUrl
,
siteName
);
return
rocketChatCache
.
getServerList
();
}
private
void
openRoom
()
{
private
void
openRoom
()
{
String
hostname
=
rocketChatCache
.
getSelectedServerHostname
();
String
hostname
=
rocketChatCache
.
getSelectedServerHostname
();
String
roomId
=
rocketChatCache
.
getSelectedRoomId
();
String
roomId
=
rocketChatCache
.
getSelectedRoomId
();
...
...
app/src/main/java/chat/rocket/android/api/MethodCallHelper.java
View file @
5e6bb869
...
@@ -52,7 +52,7 @@ public class MethodCallHelper {
...
@@ -52,7 +52,7 @@ public class MethodCallHelper {
*/
*/
public
MethodCallHelper
(
Context
context
,
String
hostname
)
{
public
MethodCallHelper
(
Context
context
,
String
hostname
)
{
this
.
context
=
context
.
getApplicationContext
();
this
.
context
=
context
.
getApplicationContext
();
this
.
realmHelper
=
RealmStore
.
get
(
hostname
);
this
.
realmHelper
=
RealmStore
.
get
OrCreate
(
hostname
);
ddpClientRef
=
null
;
ddpClientRef
=
null
;
}
}
...
...
app/src/main/java/chat/rocket/android/fragment/add_server/InputHostnameFragment.java
View file @
5e6bb869
...
@@ -72,7 +72,7 @@ public class InputHostnameFragment extends AbstractFragment implements InputHost
...
@@ -72,7 +72,7 @@ public class InputHostnameFragment extends AbstractFragment implements InputHost
private
String
getHostname
()
{
private
String
getHostname
()
{
final
TextView
editor
=
(
TextView
)
rootView
.
findViewById
(
R
.
id
.
editor_hostname
);
final
TextView
editor
=
(
TextView
)
rootView
.
findViewById
(
R
.
id
.
editor_hostname
);
return
TextUtils
.
or
(
TextUtils
.
or
(
editor
.
getText
(),
editor
.
getHint
()),
""
).
toString
();
return
TextUtils
.
or
(
TextUtils
.
or
(
editor
.
getText
(),
editor
.
getHint
()),
""
).
toString
()
.
toLowerCase
()
;
}
}
private
void
showError
(
String
errString
)
{
private
void
showError
(
String
errString
)
{
...
...
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainFragment.java
View file @
5e6bb869
...
@@ -219,11 +219,16 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
...
@@ -219,11 +219,16 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
);
);
}
}
p
rivate
void
showUserActionContainer
(
boolean
show
)
{
p
ublic
void
showUserActionContainer
(
boolean
show
)
{
rootView
.
findViewById
(
R
.
id
.
user_action_outer_container
)
rootView
.
findViewById
(
R
.
id
.
user_action_outer_container
)
.
setVisibility
(
show
?
View
.
VISIBLE
:
View
.
GONE
);
.
setVisibility
(
show
?
View
.
VISIBLE
:
View
.
GONE
);
}
}
public
void
toggleUserActionContainer
(
boolean
checked
)
{
CompoundButton
toggleUserAction
=
rootView
.
findViewById
(
R
.
id
.
toggle_user_action
);
toggleUserAction
.
setChecked
(
checked
);
}
@Override
@Override
public
void
showScreen
()
{
public
void
showScreen
()
{
rootView
.
setVisibility
(
View
.
VISIBLE
);
rootView
.
setVisibility
(
View
.
VISIBLE
);
...
...
app/src/main/java/chat/rocket/android/layouthelper/extra_action/upload/FileUploadActionItem.java
0 → 100644
View file @
5e6bb869
package
chat
.
rocket
.
android
.
layouthelper
.
extra_action
.
upload
;
import
android.content.Intent
;
import
chat.rocket.android.R
;
public
class
FileUploadActionItem
extends
AbstractUploadActionItem
{
@Override
public
int
getItemId
()
{
return
13
;
}
@Override
protected
Intent
getIntentForPickFile
()
{
Intent
intent
=
new
Intent
();
intent
.
setType
(
"*/*"
);
intent
.
setAction
(
Intent
.
ACTION_GET_CONTENT
);
return
Intent
.
createChooser
(
intent
,
"Select File to Upload"
);
}
@Override
public
int
getIcon
()
{
return
R
.
drawable
.
ic_insert_drive_file_white_24dp
;
}
@Override
public
int
getTitle
()
{
return
R
.
string
.
doc_upload_message_spec_title
;
}
}
app/src/main/java/chat/rocket/android/renderer/MessageRenderer.kt
View file @
5e6bb869
...
@@ -6,7 +6,7 @@ import chat.rocket.android.R
...
@@ -6,7 +6,7 @@ import chat.rocket.android.R
import
chat.rocket.android.helper.DateTime
import
chat.rocket.android.helper.DateTime
import
chat.rocket.android.widget.AbsoluteUrl
import
chat.rocket.android.widget.AbsoluteUrl
import
chat.rocket.android.widget.RocketChatAvatar
import
chat.rocket.android.widget.RocketChatAvatar
import
chat.rocket.android.widget.helper.
User
AvatarHelper
import
chat.rocket.android.widget.helper.AvatarHelper
import
chat.rocket.android.widget.message.RocketChatMessageAttachmentsLayout
import
chat.rocket.android.widget.message.RocketChatMessageAttachmentsLayout
import
chat.rocket.android.widget.message.RocketChatMessageLayout
import
chat.rocket.android.widget.message.RocketChatMessageLayout
import
chat.rocket.android.widget.message.RocketChatMessageUrlsLayout
import
chat.rocket.android.widget.message.RocketChatMessageUrlsLayout
...
@@ -21,12 +21,12 @@ class MessageRenderer(val message: Message, val autoLoadImage: Boolean) {
...
@@ -21,12 +21,12 @@ class MessageRenderer(val message: Message, val autoLoadImage: Boolean) {
fun
showAvatar
(
rocketChatAvatarWidget
:
RocketChatAvatar
,
hostname
:
String
)
{
fun
showAvatar
(
rocketChatAvatarWidget
:
RocketChatAvatar
,
hostname
:
String
)
{
val
username
:
String
?
=
message
.
user
?.
username
val
username
:
String
?
=
message
.
user
?.
username
if
(
username
!=
null
)
{
if
(
username
!=
null
)
{
val
placeholderDrawable
=
User
AvatarHelper
.
getTextDrawable
(
username
,
rocketChatAvatarWidget
.
context
)
val
placeholderDrawable
=
AvatarHelper
.
getTextDrawable
(
username
,
rocketChatAvatarWidget
.
context
)
if
(
message
.
avatar
!=
null
)
{
if
(
message
.
avatar
!=
null
)
{
// Load user's avatar image from Oauth provider URI.
// Load user's avatar image from Oauth provider URI.
rocketChatAvatarWidget
.
loadImage
(
message
.
avatar
,
placeholderDrawable
)
rocketChatAvatarWidget
.
loadImage
(
message
.
avatar
,
placeholderDrawable
)
}
else
{
}
else
{
rocketChatAvatarWidget
.
loadImage
(
User
AvatarHelper
.
getUri
(
hostname
,
username
),
placeholderDrawable
)
rocketChatAvatarWidget
.
loadImage
(
AvatarHelper
.
getUri
(
hostname
,
username
),
placeholderDrawable
)
}
}
}
else
{
}
else
{
rocketChatAvatarWidget
.
visibility
=
View
.
GONE
rocketChatAvatarWidget
.
visibility
=
View
.
GONE
...
...
app/src/main/java/chat/rocket/android/renderer/UserRenderer.kt
View file @
5e6bb869
...
@@ -4,7 +4,7 @@ import android.view.View
...
@@ -4,7 +4,7 @@ import android.view.View
import
android.widget.ImageView
import
android.widget.ImageView
import
android.widget.TextView
import
android.widget.TextView
import
chat.rocket.android.widget.RocketChatAvatar
import
chat.rocket.android.widget.RocketChatAvatar
import
chat.rocket.android.widget.helper.
User
AvatarHelper
import
chat.rocket.android.widget.helper.AvatarHelper
import
chat.rocket.core.models.User
import
chat.rocket.core.models.User
class
UserRenderer
(
val
user
:
User
)
{
class
UserRenderer
(
val
user
:
User
)
{
...
@@ -15,7 +15,7 @@ class UserRenderer(val user: User) {
...
@@ -15,7 +15,7 @@ class UserRenderer(val user: User) {
fun
showAvatar
(
rocketChatAvatarWidget
:
RocketChatAvatar
,
hostname
:
String
)
{
fun
showAvatar
(
rocketChatAvatarWidget
:
RocketChatAvatar
,
hostname
:
String
)
{
val
username
:
String
?
=
user
.
username
val
username
:
String
?
=
user
.
username
if
(
username
!=
null
)
{
if
(
username
!=
null
)
{
rocketChatAvatarWidget
.
loadImage
(
UserAvatarHelper
.
getUri
(
hostname
,
username
),
User
AvatarHelper
.
getTextDrawable
(
username
,
rocketChatAvatarWidget
.
context
))
rocketChatAvatarWidget
.
loadImage
(
AvatarHelper
.
getUri
(
hostname
,
username
),
AvatarHelper
.
getTextDrawable
(
username
,
rocketChatAvatarWidget
.
context
))
}
else
{
}
else
{
rocketChatAvatarWidget
.
visibility
=
View
.
GONE
rocketChatAvatarWidget
.
visibility
=
View
.
GONE
}
}
...
...
app/src/main/java/chat/rocket/android/service/observer/GcmPushRegistrationObserver.java
View file @
5e6bb869
package
chat
.
rocket
.
android
.
service
.
observer
;
package
chat
.
rocket
.
android
.
service
.
observer
;
import
android.content.Context
;
import
com.google.android.gms.gcm.GoogleCloudMessaging
;
import
com.google.android.gms.gcm.GoogleCloudMessaging
;
import
com.google.android.gms.iid.InstanceID
;
import
com.google.android.gms.iid.InstanceID
;
import
android.content.Context
;
import
io.realm.Realm
;
import
io.realm.RealmResults
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.List
;
import
bolts.Task
;
import
bolts.Task
;
import
chat.rocket.android.R
;
import
chat.rocket.android.R
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.api.RaixPushHelper
;
import
chat.rocket.android.api.RaixPushHelper
;
import
chat.rocket.android.helper.LogIfError
;
import
chat.rocket.android.helper.LogIfError
;
import
chat.rocket.android.service.DDPClientRef
;
import
chat.rocket.core.SyncState
;
import
chat.rocket.core.SyncState
;
import
chat.rocket.persistence.realm.models.ddp.RealmPublicSetting
;
import
chat.rocket.persistence.realm.RealmHelper
;
import
chat.rocket.core.PublicSettingsConstants
;
import
chat.rocket.persistence.realm.models.ddp.RealmUser
;
import
chat.rocket.persistence.realm.models.ddp.RealmUser
;
import
chat.rocket.persistence.realm.models.internal.GcmPushRegistration
;
import
chat.rocket.persistence.realm.models.internal.GcmPushRegistration
;
import
chat.rocket.persistence.realm.RealmHelper
;
import
io.realm.Realm
;
import
chat.rocket.android.service.DDPClientRef
;
import
io.realm.RealmResults
;
/**
/**
* call raix:push-update if needed.
* call raix:push-update if needed.
...
@@ -83,13 +82,6 @@ public class GcmPushRegistrationObserver extends AbstractModelObserver<GcmPushRe
...
@@ -83,13 +82,6 @@ public class GcmPushRegistrationObserver extends AbstractModelObserver<GcmPushRe
}
}
private
String
getSenderId
()
{
private
String
getSenderId
()
{
final
String
senderId
=
RealmPublicSetting
.
getString
(
realmHelper
,
PublicSettingsConstants
.
Push
.
GCM_PROJECT_NUMBER
,
""
).
trim
();
if
(
senderId
.
length
()
!=
0
)
{
return
senderId
;
}
return
context
.
getString
(
R
.
string
.
gcm_sender_id
);
return
context
.
getString
(
R
.
string
.
gcm_sender_id
);
}
}
...
...
app/src/main/res/drawable/ic_insert_drive_file_white_24dp.xml
0 → 100644
View file @
5e6bb869
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"24dp"
android:height=
"24dp"
android:viewportWidth=
"24.0"
android:viewportHeight=
"24.0"
>
<path
android:fillColor=
"#FFFFFFFF"
android:pathData=
"M6,2c-1.1,0 -1.99,0.9 -1.99,2L4,20c0,1.1 0.89,2 1.99,2L18,22c1.1,0 2,-0.9 2,-2L20,8l-6,-6L6,2zM13,9L13,3.5L18.5,9L13,9z"
/>
</vector>
app/src/main/res/layout/fragment_input_hostname.xml
View file @
5e6bb869
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
android:layout_marginTop=
"@dimen/margin_8"
android:layout_marginTop=
"@dimen/margin_8"
android:hint=
"@string/fragment_input_hostname_server_hint"
android:hint=
"@string/fragment_input_hostname_server_hint"
android:imeOptions=
"actionSend"
android:imeOptions=
"actionSend"
android:inputType=
"text
WebEditText
"
android:inputType=
"text
Uri
"
android:maxLines=
"1"
android:maxLines=
"1"
app:layout_constraintTop_toBottomOf=
"@+id/hostnameTextView"
app:layout_constraintTop_toBottomOf=
"@+id/hostnameTextView"
app:layout_constraintBottom_toTopOf=
"@+id/btn_connect"
app:layout_constraintBottom_toTopOf=
"@+id/btn_connect"
...
...
app/src/main/res/layout/sidebar.xml
View file @
5e6bb869
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SlidingPaneLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<android.support.v4.widget.SlidingPaneLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/sub_sliding_pane"
android:id=
"@+id/sub_sliding_pane"
android:layout_width=
"280dp"
android:layout_width=
"280dp"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
...
@@ -7,30 +8,59 @@
...
@@ -7,30 +8,59 @@
android:theme=
"@style/AppTheme.Dark"
>
android:theme=
"@style/AppTheme.Dark"
>
<android.support.v4.widget.NestedScrollView
<android.support.v4.widget.NestedScrollView
android:layout_width=
"96dp
"
android:layout_width=
"match_parent
"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:layout_gravity=
"start"
android:layout_gravity=
"start"
android:background=
"?attr/colorPrimaryDark"
>
android:background=
"?attr/colorPrimaryDark"
>
<LinearLayout
<LinearLayout
android:id=
"@+id/server_list_bar"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
android:orientation=
"vertical"
>
<
ImageButton
<
android.support.constraint.ConstraintLayout
style=
"@style/Base.Widget.AppCompat.Button.Borderless
"
android:id=
"@+id/btn_add_server
"
android:layout_width=
"80dp
"
android:layout_width=
"match_parent
"
android:layout_height=
"80dp"
android:layout_height=
"80dp"
android:layout_margin=
"@dimen/margin_8
"
android:background=
"?selectableItemBackground
"
android:src=
"@mipmap/ic_launcher"
/
>
android:descendantFocusability=
"afterDescendants"
>
<io.github.yusukeiwaki.android.widget.FontAwesomeButton
<io.github.yusukeiwaki.android.widget.FontAwesomeTextView
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:text=
"@string/fa_plus"
/>
android:background=
"@null"
android:clickable=
"false"
android:duplicateParentState=
"true"
android:text=
"@string/fa_plus"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<TextView
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:layout_marginRight=
"16dp"
android:duplicateParentState=
"true"
android:ellipsize=
"end"
android:gravity=
"center_vertical"
android:maxLines=
"1"
android:text=
"@string/add_new_team"
android:textAppearance=
"@style/TextAppearance.AppCompat.Medium"
android:textColor=
"@android:color/white"
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toEndOf=
"@+id/fa_add_server"
app:layout_constraintTop_toTopOf=
"parent"
/>
</android.support.constraint.ConstraintLayout>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.NestedScrollView>
<FrameLayout
<FrameLayout
...
...
app/src/main/res/values/strings.xml
View file @
5e6bb869
...
@@ -84,4 +84,6 @@
...
@@ -84,4 +84,6 @@
<string
name=
"menu_favorite_messages"
>
Favorite messages
</string>
<string
name=
"menu_favorite_messages"
>
Favorite messages
</string>
<string
name=
"menu_file_list"
>
File list
</string>
<string
name=
"menu_file_list"
>
File list
</string>
<string
name=
"menu_member_list"
>
Member list
</string>
<string
name=
"menu_member_list"
>
Member list
</string>
<string
name=
"add_new_team"
>
Add new Team
</string>
</resources>
</resources>
app/src/test/kotlin/chat.rocket.android/RocketChatCacheTest.kt
0 → 100644
View file @
5e6bb869
package
chat.rocket.android;
import
android.content.Context
import
chat.rocket.core.utils.Pair
import
org.hamcrest.CoreMatchers.equalTo
import
org.json.JSONObject
import
org.junit.Assert.assertThat
import
org.junit.Before
import
org.junit.Test
import
org.junit.runner.RunWith
import
org.mockito.Mockito.*
import
org.mockito.junit.MockitoJUnitRunner
@RunWith
(
MockitoJUnitRunner
::
class
)
class
RocketChatCacheTest
{
lateinit
var
cache
:
RocketChatCache
@Before
fun
setup
()
{
val
mockedContext
=
mock
(
Context
::
class
.
java
)
val
mockAppContext
=
mock
(
Context
::
class
.
java
)
`when`
(
mockedContext
.
applicationContext
).
thenReturn
(
mockAppContext
)
cache
=
spy
(
RocketChatCache
(
mockedContext
))
}
@Test
fun
getServerList_ShouldReturnHostnameList
()
{
val
hostnameList
=
JSONObject
()
.
put
(
"http://demo.rocket.chat"
,
"images/logo/logo.png"
)
.
put
(
"http://192.168.0.6:3000"
,
"images/icon.svg"
)
.
toString
()
doReturn
(
hostnameList
).
`when`
(
cache
).
getString
(
"KEY_HOSTNAME_LIST"
,
null
)
val
expectedServerList
=
mutableListOf
(
Pair
(
"http://192.168.0.6:3000"
,
"http://192.168.0.6:3000/images/icon.svg"
),
Pair
(
"http://demo.rocket.chat"
,
"http://demo.rocket.chat/images/logo/logo.png"
))
val
serverList
=
cache
.
serverList
assertThat
(
serverList
,
equalTo
(
expectedServerList
))
}
}
\ No newline at end of file
build.gradle
View file @
5e6bb869
...
@@ -23,6 +23,7 @@ ext {
...
@@ -23,6 +23,7 @@ ext {
supportLibraryVersion
=
"25.4.0"
supportLibraryVersion
=
"25.4.0"
constraintLayoutVersion
=
"1.0.2"
constraintLayoutVersion
=
"1.0.2"
kotlinVersion
=
"1.1.4-3"
kotlinVersion
=
"1.1.4-3"
okHttpVersion
=
"3.9.0"
}
}
task
clean
(
type:
Delete
)
{
task
clean
(
type:
Delete
)
{
...
...
rocket-chat-android-widgets/build.gradle
View file @
5e6bb869
...
@@ -62,7 +62,7 @@ dependencies {
...
@@ -62,7 +62,7 @@ dependencies {
compile
'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile
'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile
'com.squareup.okhttp3:okhttp:3.8.0'
compile
"com.squareup.okhttp3:okhttp:$rootProject.ext.okHttpVersion"
compile
'com.github.yusukeiwaki.android-widget:widget-fontawesome:0.0.1'
compile
'com.github.yusukeiwaki.android-widget:widget-fontawesome:0.0.1'
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/RoomToolbar.java
View file @
5e6bb869
...
@@ -137,7 +137,7 @@ public class RoomToolbar extends Toolbar {
...
@@ -137,7 +137,7 @@ public class RoomToolbar extends Toolbar {
userStatusImage
.
setVisibility
(
VISIBLE
);
userStatusImage
.
setVisibility
(
VISIBLE
);
}
}
public
void
setUnreadB
u
dge
(
int
numUnreadChannels
,
int
numMentionsSum
)
{
public
void
setUnreadB
a
dge
(
int
numUnreadChannels
,
int
numMentionsSum
)
{
if
(
getNavigationIcon
()
==
null
)
{
if
(
getNavigationIcon
()
==
null
)
{
return
;
return
;
}
}
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/helper/
User
AvatarHelper.kt
→
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/helper/AvatarHelper.kt
View file @
5e6bb869
...
@@ -7,7 +7,7 @@ import chat.rocket.android.widget.AbsoluteUrl
...
@@ -7,7 +7,7 @@ import chat.rocket.android.widget.AbsoluteUrl
import
com.amulyakhare.textdrawable.TextDrawable
import
com.amulyakhare.textdrawable.TextDrawable
import
java.net.URLEncoder
import
java.net.URLEncoder
object
User
AvatarHelper
{
object
AvatarHelper
{
/**
/**
* Returns the user avatar URI.
* Returns the user avatar URI.
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/message/autocomplete/user/UserViewHolder.java
View file @
5e6bb869
...
@@ -4,13 +4,11 @@ import android.graphics.drawable.Drawable;
...
@@ -4,13 +4,11 @@ import android.graphics.drawable.Drawable;
import
android.view.View
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
chat.rocket.android.widget.AbsoluteUrl
;
import
chat.rocket.android.widget.R
;
import
chat.rocket.android.widget.R
;
import
chat.rocket.android.widget.RocketChatAvatar
;
import
chat.rocket.android.widget.RocketChatAvatar
;
import
chat.rocket.android.widget.helper.
User
AvatarHelper
;
import
chat.rocket.android.widget.helper.AvatarHelper
;
import
chat.rocket.android.widget.message.autocomplete.AutocompleteViewHolder
;
import
chat.rocket.android.widget.message.autocomplete.AutocompleteViewHolder
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
public
class
UserViewHolder
extends
AutocompleteViewHolder
<
UserItem
>
{
public
class
UserViewHolder
extends
AutocompleteViewHolder
<
UserItem
>
{
private
final
TextView
titleTextView
;
private
final
TextView
titleTextView
;
...
@@ -45,8 +43,8 @@ public class UserViewHolder extends AutocompleteViewHolder<UserItem> {
...
@@ -45,8 +43,8 @@ public class UserViewHolder extends AutocompleteViewHolder<UserItem> {
}
}
if
(
avatar
!=
null
)
{
if
(
avatar
!=
null
)
{
String
absoluteUri
=
User
AvatarHelper
.
INSTANCE
.
getAbsoluteUri
(
userItem
.
getAbsoluteUrl
(),
suggestion
);
String
absoluteUri
=
AvatarHelper
.
INSTANCE
.
getAbsoluteUri
(
userItem
.
getAbsoluteUrl
(),
suggestion
);
Drawable
placeholderDrawable
=
User
AvatarHelper
.
INSTANCE
.
getTextDrawable
(
suggestion
,
itemView
.
getContext
());
Drawable
placeholderDrawable
=
AvatarHelper
.
INSTANCE
.
getTextDrawable
(
suggestion
,
itemView
.
getContext
());
avatar
.
loadImage
(
absoluteUri
,
placeholderDrawable
);
avatar
.
loadImage
(
absoluteUri
,
placeholderDrawable
);
}
}
...
...
rocket-chat-android-widgets/src/main/res/color/selector_text_color_multiserver.xml
0 → 100644
View file @
5e6bb869
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:state_selected=
"true"
android:color=
"@android:color/white"
/>
<item
android:color=
"@color/color_timestamp"
/>
</selector>
\ No newline at end of file
rocket-chat-android-widgets/src/main/res/drawable/serverstatus_selected.xml
0 → 100644
View file @
5e6bb869
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"oval"
>
<solid
android:color=
"@color/serverstatus_selected"
/>
<stroke
android:width=
"1dp"
android:color=
"@color/serverstatus_outline"
/>
<size
android:width=
"16dp"
android:height=
"16dp"
/>
</shape>
rocket-chat-android-widgets/src/main/res/layout/server_row.xml
0 → 100644
View file @
5e6bb869
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:fresco=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"80dp"
tools:background=
"#044b76"
>
<com.facebook.drawee.view.SimpleDraweeView
android:id=
"@+id/drawee_server_button"
style=
"@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width=
"80dp"
android:layout_height=
"80dp"
android:layout_marginBottom=
"8dp"
android:layout_marginEnd=
"8dp"
android:layout_marginStart=
"8dp"
android:layout_marginTop=
"8dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
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
android:id=
"@+id/text_view_server_label"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"16dp"
android:layout_marginEnd=
"24dp"
android:layout_marginRight=
"24dp"
android:ellipsize=
"end"
android:gravity=
"top"
android:maxLines=
"1"
android:textAllCaps=
"false"
android:textColor=
"@color/color_embed_hostname"
android:textSize=
"16sp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toEndOf=
"@+id/drawee_server_button"
app:layout_constraintTop_toBottomOf=
"@+id/text_view_site_name_label"
tools:text=
"demo.rocket.chat"
/>
<ImageView
android:id=
"@+id/selected_server_dot"
android:layout_width=
"8dp"
android:layout_height=
"8dp"
android:layout_marginBottom=
"8dp"
android:layout_marginEnd=
"16dp"
android:layout_marginStart=
"8dp"
android:layout_marginTop=
"8dp"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toEndOf=
"@+id/text_view_site_name_label"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/serverstatus_selected"
tools:visibility=
"visible"
/>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
rocket-chat-android-widgets/src/main/res/values/colors.xml
View file @
5e6bb869
...
@@ -14,4 +14,6 @@
...
@@ -14,4 +14,6 @@
<color
name=
"color_user_status_busy"
>
#FFF44336
</color>
<!-- Red 500-->
<color
name=
"color_user_status_busy"
>
#FFF44336
</color>
<!-- Red 500-->
<color
name=
"color_user_status_away"
>
#FFFFC107
</color>
<!-- Amber 500-->
<color
name=
"color_user_status_away"
>
#FFFFC107
</color>
<!-- Amber 500-->
<color
name=
"color_user_status_offline"
>
#FF607D8B
</color>
<!-- Blue Grey 500-->
<color
name=
"color_user_status_offline"
>
#FF607D8B
</color>
<!-- Blue Grey 500-->
<color
name=
"serverstatus_selected"
>
#FFFFFFFF
</color>
<color
name=
"serverstatus_outline"
>
#c2c2c2
</color>
</resources>
</resources>
\ No newline at end of file
rocket-chat-android-widgets/src/test/kotlin/chat/rocket/android/widget/helper/AvatarHelperTest.kt
0 → 100644
View file @
5e6bb869
import
chat.rocket.android.widget.helper.AvatarHelper
import
org.junit.Test
import
kotlin.test.assertEquals
class
AvatarHelperTest
{
@Test
fun
getUsernameInitialsTest
()
{
assertEquals
(
"?"
,
AvatarHelper
.
getUsernameInitials
(
""
))
assertEquals
(
"?"
,
AvatarHelper
.
getUsernameInitials
(
"?"
))
assertEquals
(
"F"
,
AvatarHelper
.
getUsernameInitials
(
"f"
))
assertEquals
(
"B"
,
AvatarHelper
.
getUsernameInitials
(
"B"
))
assertEquals
(
"FO"
,
AvatarHelper
.
getUsernameInitials
(
"Fo"
))
assertEquals
(
"FO"
,
AvatarHelper
.
getUsernameInitials
(
"FO"
))
assertEquals
(
"FO"
,
AvatarHelper
.
getUsernameInitials
(
"fOo"
))
assertEquals
(
"FO"
,
AvatarHelper
.
getUsernameInitials
(
"FOO"
))
assertEquals
(
"FO"
,
AvatarHelper
.
getUsernameInitials
(
"F.O"
))
assertEquals
(
"FO"
,
AvatarHelper
.
getUsernameInitials
(
"F.o"
))
assertEquals
(
"FB"
,
AvatarHelper
.
getUsernameInitials
(
"Foo.bar"
))
assertEquals
(
"FB"
,
AvatarHelper
.
getUsernameInitials
(
"Foobar.bar"
))
assertEquals
(
"FZ"
,
AvatarHelper
.
getUsernameInitials
(
"Foobar.bar.zab"
))
assertEquals
(
".."
,
AvatarHelper
.
getUsernameInitials
(
".."
))
assertEquals
(
".."
,
AvatarHelper
.
getUsernameInitials
(
"..."
))
assertEquals
(
".F"
,
AvatarHelper
.
getUsernameInitials
(
".Foo."
))
assertEquals
(
"FO"
,
AvatarHelper
.
getUsernameInitials
(
"Foo.."
))
}
}
\ No newline at end of file
rocket-chat-android-widgets/src/test/kotlin/chat/rocket/android/widget/helper/UserAvatarHelperTest.kt
deleted
100644 → 0
View file @
50055574
import
chat.rocket.android.widget.helper.UserAvatarHelper
import
org.junit.Test
import
kotlin.test.assertEquals
class
UserAvatarHelperTest
{
@Test
fun
getUsernameInitialsTest
()
{
assertEquals
(
"?"
,
UserAvatarHelper
.
getUsernameInitials
(
""
))
assertEquals
(
"?"
,
UserAvatarHelper
.
getUsernameInitials
(
"?"
))
assertEquals
(
"F"
,
UserAvatarHelper
.
getUsernameInitials
(
"f"
))
assertEquals
(
"B"
,
UserAvatarHelper
.
getUsernameInitials
(
"B"
))
assertEquals
(
"FO"
,
UserAvatarHelper
.
getUsernameInitials
(
"Fo"
))
assertEquals
(
"FO"
,
UserAvatarHelper
.
getUsernameInitials
(
"FO"
))
assertEquals
(
"FO"
,
UserAvatarHelper
.
getUsernameInitials
(
"fOo"
))
assertEquals
(
"FO"
,
UserAvatarHelper
.
getUsernameInitials
(
"FOO"
))
assertEquals
(
"FO"
,
UserAvatarHelper
.
getUsernameInitials
(
"F.O"
))
assertEquals
(
"FO"
,
UserAvatarHelper
.
getUsernameInitials
(
"F.o"
))
assertEquals
(
"FB"
,
UserAvatarHelper
.
getUsernameInitials
(
"Foo.bar"
))
assertEquals
(
"FB"
,
UserAvatarHelper
.
getUsernameInitials
(
"Foobar.bar"
))
assertEquals
(
"FZ"
,
UserAvatarHelper
.
getUsernameInitials
(
"Foobar.bar.zab"
))
assertEquals
(
".."
,
UserAvatarHelper
.
getUsernameInitials
(
".."
))
assertEquals
(
".."
,
UserAvatarHelper
.
getUsernameInitials
(
"..."
))
assertEquals
(
".F"
,
UserAvatarHelper
.
getUsernameInitials
(
".Foo."
))
assertEquals
(
"FO"
,
UserAvatarHelper
.
getUsernameInitials
(
"Foo.."
))
}
}
\ 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