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
f646a02e
Commit
f646a02e
authored
Oct 19, 2017
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Caching Site_Name public setting and setting it as subtext on
notification.
parent
8e9506c0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
5 deletions
+55
-5
RocketChatCache.java
app/src/main/java/chat/rocket/android/RocketChatCache.java
+39
-2
AbstractAuthedActivity.java
.../chat/rocket/android/activity/AbstractAuthedActivity.java
+1
-1
MethodCallHelper.java
...c/main/java/chat/rocket/android/api/MethodCallHelper.java
+9
-2
PushManager.kt
app/src/main/java/chat/rocket/android/push/PushManager.kt
+6
-0
No files found.
app/src/main/java/chat/rocket/android/RocketChatCache.java
View file @
f646a02e
...
@@ -22,6 +22,7 @@ import io.reactivex.BackpressureStrategy;
...
@@ -22,6 +22,7 @@ import io.reactivex.BackpressureStrategy;
import
io.reactivex.Flowable
;
import
io.reactivex.Flowable
;
import
io.reactivex.annotations.NonNull
;
import
io.reactivex.annotations.NonNull
;
import
io.reactivex.annotations.Nullable
;
import
io.reactivex.annotations.Nullable
;
import
okhttp3.HttpUrl
;
/**
/**
* sharedpreference-based cache.
* sharedpreference-based cache.
...
@@ -29,6 +30,7 @@ import io.reactivex.annotations.Nullable;
...
@@ -29,6 +30,7 @@ import io.reactivex.annotations.Nullable;
public
class
RocketChatCache
{
public
class
RocketChatCache
{
private
static
final
String
KEY_SELECTED_SERVER_HOSTNAME
=
"KEY_SELECTED_SERVER_HOSTNAME"
;
private
static
final
String
KEY_SELECTED_SERVER_HOSTNAME
=
"KEY_SELECTED_SERVER_HOSTNAME"
;
private
static
final
String
KEY_SELECTED_SITE_URL
=
"KEY_SELECTED_SITE_URL"
;
private
static
final
String
KEY_SELECTED_SITE_URL
=
"KEY_SELECTED_SITE_URL"
;
private
static
final
String
KEY_SELECTED_SITE_NAME
=
"KEY_SELECTED_SITE_NAME"
;
private
static
final
String
KEY_SELECTED_ROOM_ID
=
"KEY_SELECTED_ROOM_ID"
;
private
static
final
String
KEY_SELECTED_ROOM_ID
=
"KEY_SELECTED_ROOM_ID"
;
private
static
final
String
KEY_PUSH_ID
=
"KEY_PUSH_ID"
;
private
static
final
String
KEY_PUSH_ID
=
"KEY_PUSH_ID"
;
private
static
final
String
KEY_HOSTNAME_LIST
=
"KEY_HOSTNAME_LIST"
;
private
static
final
String
KEY_HOSTNAME_LIST
=
"KEY_HOSTNAME_LIST"
;
...
@@ -51,7 +53,42 @@ public class RocketChatCache {
...
@@ -51,7 +53,42 @@ public class RocketChatCache {
setString
(
KEY_SELECTED_SERVER_HOSTNAME
,
newHostname
);
setString
(
KEY_SELECTED_SERVER_HOSTNAME
,
newHostname
);
}
}
public
void
setSelectedServerHostnameAlias
(
@Nullable
String
hostnameAlias
)
{
public
void
addHostSiteName
(
@NonNull
String
siteName
)
{
try
{
String
hostSiteNamesJson
=
getHostSiteNamesJson
();
JSONObject
jsonObject
=
(
hostSiteNamesJson
==
null
)
?
new
JSONObject
()
:
new
JSONObject
(
hostSiteNamesJson
);
jsonObject
.
put
(
getSelectedServerHostname
(),
siteName
);
setString
(
KEY_SELECTED_SITE_NAME
,
jsonObject
.
toString
());
}
catch
(
JSONException
e
)
{
RCLog
.
e
(
e
);
}
}
public
@NonNull
String
getHostSiteName
(
@NonNull
String
host
)
{
if
(
host
.
startsWith
(
"http"
))
{
HttpUrl
url
=
HttpUrl
.
parse
(
host
);
if
(
url
!=
null
)
{
host
=
url
.
host
();
}
}
try
{
String
hostSiteNamesJson
=
getHostSiteNamesJson
();
JSONObject
jsonObject
=
(
hostSiteNamesJson
==
null
)
?
new
JSONObject
()
:
new
JSONObject
(
hostSiteNamesJson
);
host
=
getSiteUrlFor
(
host
);
return
jsonObject
.
optString
(
host
);
}
catch
(
JSONException
e
)
{
RCLog
.
e
(
e
);
}
return
""
;
}
private
@Nullable
String
getHostSiteNamesJson
()
{
return
getString
(
KEY_SELECTED_SITE_NAME
,
null
);
}
public
void
addHostnameSiteUrl
(
@Nullable
String
hostnameAlias
)
{
String
alias
=
null
;
String
alias
=
null
;
if
(
hostnameAlias
!=
null
)
{
if
(
hostnameAlias
!=
null
)
{
alias
=
hostnameAlias
.
toLowerCase
();
alias
=
hostnameAlias
.
toLowerCase
();
...
@@ -68,7 +105,7 @@ public class RocketChatCache {
...
@@ -68,7 +105,7 @@ public class RocketChatCache {
}
}
}
}
public
@NonNull
String
get
LoginHostnameFrom
(
String
hostname
)
{
public
@NonNull
String
get
SiteUrlFor
(
String
hostname
)
{
try
{
try
{
String
selectedServerHostname
=
getSelectedServerHostname
();
String
selectedServerHostname
=
getSelectedServerHostname
();
return
new
JSONObject
(
getLoginHostnamesJson
())
return
new
JSONObject
(
getLoginHostnamesJson
())
...
...
app/src/main/java/chat/rocket/android/activity/AbstractAuthedActivity.java
View file @
f646a02e
...
@@ -62,7 +62,7 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
...
@@ -62,7 +62,7 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
HttpUrl
url
=
HttpUrl
.
parse
(
hostname
);
HttpUrl
url
=
HttpUrl
.
parse
(
hostname
);
if
(
url
!=
null
)
{
if
(
url
!=
null
)
{
String
hostnameFromPush
=
url
.
host
();
String
hostnameFromPush
=
url
.
host
();
String
loginHostname
=
rocketChatCache
.
get
LoginHostnameFrom
(
hostnameFromPush
);
String
loginHostname
=
rocketChatCache
.
get
SiteUrlFor
(
hostnameFromPush
);
rocketChatCache
.
setSelectedServerHostname
(
loginHostname
);
rocketChatCache
.
setSelectedServerHostname
(
loginHostname
);
if
(
intent
.
hasExtra
(
PushConstants
.
ROOM_ID
))
{
if
(
intent
.
hasExtra
(
PushConstants
.
ROOM_ID
))
{
...
...
app/src/main/java/chat/rocket/android/api/MethodCallHelper.java
View file @
f646a02e
...
@@ -423,12 +423,15 @@ public class MethodCallHelper {
...
@@ -423,12 +423,15 @@ public class MethodCallHelper {
for
(
int
i
=
0
;
i
<
settings
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
settings
.
length
();
i
++)
{
JSONObject
jsonObject
=
settings
.
getJSONObject
(
i
);
JSONObject
jsonObject
=
settings
.
getJSONObject
(
i
);
RealmPublicSetting
.
customizeJson
(
jsonObject
);
RealmPublicSetting
.
customizeJson
(
jsonObject
);
if
(
jsonObject
.
getString
(
RealmPublicSetting
.
ID
).
equalsIgnoreCase
(
PublicSettingsConstants
.
General
.
SITE_URL
))
{
if
(
isPublicSetting
(
jsonObject
,
PublicSettingsConstants
.
General
.
SITE_URL
))
{
String
siteUrl
=
jsonObject
.
getString
(
RealmPublicSetting
.
VALUE
);
String
siteUrl
=
jsonObject
.
getString
(
RealmPublicSetting
.
VALUE
);
HttpUrl
httpUrl
=
HttpUrl
.
parse
(
siteUrl
);
HttpUrl
httpUrl
=
HttpUrl
.
parse
(
siteUrl
);
if
(
httpUrl
!=
null
)
{
if
(
httpUrl
!=
null
)
{
new
RocketChatCache
(
context
).
setSelectedServerHostnameAlias
(
httpUrl
.
host
());
new
RocketChatCache
(
context
).
addHostnameSiteUrl
(
httpUrl
.
host
());
}
}
}
else
if
(
isPublicSetting
(
jsonObject
,
PublicSettingsConstants
.
General
.
SITE_NAME
))
{
String
siteName
=
jsonObject
.
getString
(
RealmPublicSetting
.
VALUE
);
new
RocketChatCache
(
context
).
addHostSiteName
(
siteName
);
}
}
}
}
...
@@ -440,6 +443,10 @@ public class MethodCallHelper {
...
@@ -440,6 +443,10 @@ public class MethodCallHelper {
});
});
}
}
private
boolean
isPublicSetting
(
JSONObject
jsonObject
,
String
id
)
{
return
jsonObject
.
optString
(
RealmPublicSetting
.
ID
).
equalsIgnoreCase
(
id
);
}
public
Task
<
Void
>
getPermissions
()
{
public
Task
<
Void
>
getPermissions
()
{
return
call
(
"permissions/get"
,
TIMEOUT_MS
)
return
call
(
"permissions/get"
,
TIMEOUT_MS
)
.
onSuccessTask
(
CONVERT_TO_JSON_ARRAY
)
.
onSuccessTask
(
CONVERT_TO_JSON_ARRAY
)
...
...
app/src/main/java/chat/rocket/android/push/PushManager.kt
View file @
f646a02e
...
@@ -17,6 +17,7 @@ import android.text.Spanned
...
@@ -17,6 +17,7 @@ import android.text.Spanned
import
android.util.Log
import
android.util.Log
import
android.util.SparseArray
import
android.util.SparseArray
import
chat.rocket.android.BuildConfig
import
chat.rocket.android.BuildConfig
import
chat.rocket.android.RocketChatCache
import
chat.rocket.android.activity.MainActivity
import
chat.rocket.android.activity.MainActivity
import
org.json.JSONObject
import
org.json.JSONObject
import
java.util.*
import
java.util.*
...
@@ -91,6 +92,11 @@ object PushManager {
...
@@ -91,6 +92,11 @@ object PushManager {
.
setDeleteIntent
(
deleteIntent
)
.
setDeleteIntent
(
deleteIntent
)
.
setContentIntent
(
contentIntent
)
.
setContentIntent
(
contentIntent
)
val
subText
=
RocketChatCache
(
context
).
getHostSiteName
(
pushMessage
.
host
)
if
(
subText
.
isNotEmpty
())
{
notificationBuilder
.
setSubText
(
subText
)
}
if
(
"inbox"
==
style
)
{
if
(
"inbox"
==
style
)
{
val
messages
=
messageStack
.
get
(
notificationId
.
toInt
())
val
messages
=
messageStack
.
get
(
notificationId
.
toInt
())
val
messageCount
=
messages
.
size
val
messageCount
=
messages
.
size
...
...
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