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
e54692a4
Commit
e54692a4
authored
Jan 16, 2017
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjust badge number
parent
b22d5da8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
8 deletions
+16
-8
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+10
-3
RoomToolbar.java
...src/main/java/chat/rocket/android/widget/RoomToolbar.java
+6
-5
No files found.
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
e54692a4
...
@@ -8,6 +8,7 @@ import android.support.v7.graphics.drawable.DrawerArrowDrawable;
...
@@ -8,6 +8,7 @@ import android.support.v7.graphics.drawable.DrawerArrowDrawable;
import
android.support.v7.widget.Toolbar
;
import
android.support.v7.widget.Toolbar
;
import
android.view.View
;
import
android.view.View
;
import
java.util.List
;
import
chat.rocket.android.LaunchUtil
;
import
chat.rocket.android.LaunchUtil
;
import
chat.rocket.android.R
;
import
chat.rocket.android.R
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.api.MethodCallHelper
;
...
@@ -233,14 +234,20 @@ public class MainActivity extends AbstractAuthedActivity {
...
@@ -233,14 +234,20 @@ public class MainActivity extends AbstractAuthedActivity {
.
equalTo
(
RoomSubscription
.
ALERT
,
true
)
.
equalTo
(
RoomSubscription
.
ALERT
,
true
)
.
equalTo
(
RoomSubscription
.
OPEN
,
true
)
.
equalTo
(
RoomSubscription
.
OPEN
,
true
)
.
findAll
())
.
findAll
())
.
setOnUpdateListener
(
results
->
updateRoomToolbarUnreadCount
(
results
.
size
())
);
.
setOnUpdateListener
(
this
::
updateRoomToolbarUnreadCount
);
unreadRoomSubscriptionObserver
.
sub
();
unreadRoomSubscriptionObserver
.
sub
();
}
}
private
void
updateRoomToolbarUnreadCount
(
int
unreadCount
)
{
private
void
updateRoomToolbarUnreadCount
(
List
<
RoomSubscription
>
unreadRooms
)
{
RoomToolbar
toolbar
=
(
RoomToolbar
)
findViewById
(
R
.
id
.
activity_main_toolbar
);
RoomToolbar
toolbar
=
(
RoomToolbar
)
findViewById
(
R
.
id
.
activity_main_toolbar
);
if
(
toolbar
!=
null
)
{
if
(
toolbar
!=
null
)
{
toolbar
.
setUnreadBudge
(
unreadCount
);
//ref: Rocket.Chat:client/startup/unread.js
final
int
numUnreadChannels
=
unreadRooms
.
size
();
int
numMentionsSum
=
0
;
for
(
RoomSubscription
room
:
unreadRooms
)
{
numMentionsSum
+=
room
.
getUnread
();
}
toolbar
.
setUnreadBudge
(
numUnreadChannels
,
numMentionsSum
);
}
}
}
}
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/RoomToolbar.java
View file @
e54692a4
...
@@ -105,7 +105,7 @@ public class RoomToolbar extends Toolbar {
...
@@ -105,7 +105,7 @@ public class RoomToolbar extends Toolbar {
titleTextView
.
setCompoundDrawablesWithIntrinsicBounds
(
drawable
,
null
,
null
,
null
);
titleTextView
.
setCompoundDrawablesWithIntrinsicBounds
(
drawable
,
null
,
null
,
null
);
}
}
public
void
setUnreadBudge
(
int
numUnread
)
{
public
void
setUnreadBudge
(
int
numUnread
Channels
,
int
numMentionsSum
)
{
if
(
getNavigationIcon
()
==
null
)
{
if
(
getNavigationIcon
()
==
null
)
{
return
;
return
;
}
}
...
@@ -118,16 +118,17 @@ public class RoomToolbar extends Toolbar {
...
@@ -118,16 +118,17 @@ public class RoomToolbar extends Toolbar {
addView
(
budgeImageView
,
generateDefaultLayoutParams
());
addView
(
budgeImageView
,
generateDefaultLayoutParams
());
}
}
if
(
numUnread
>
0
)
{
if
(
numUnread
Channels
>
0
)
{
budgeImageView
.
setImageDrawable
(
getBudgeDrawable
(
num
Unread
));
budgeImageView
.
setImageDrawable
(
getBudgeDrawable
(
num
MentionsSum
));
budgeImageView
.
setVisibility
(
View
.
VISIBLE
);
budgeImageView
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
}
else
{
budgeImageView
.
setVisibility
(
View
.
GONE
);
budgeImageView
.
setVisibility
(
View
.
GONE
);
}
}
}
}
private
Drawable
getBudgeDrawable
(
int
numUnread
)
{
private
Drawable
getBudgeDrawable
(
int
number
)
{
String
icon
=
numUnread
<
10
?
Integer
.
toString
(
numUnread
)
:
""
;
String
icon
=
number
>
99
?
"99+"
:
(
number
<=
0
?
""
:
Integer
.
toString
(
number
));
return
TextDrawable
.
builder
()
return
TextDrawable
.
builder
()
.
beginConfig
()
.
beginConfig
()
.
useFont
(
Typeface
.
SANS_SERIF
)
.
useFont
(
Typeface
.
SANS_SERIF
)
...
...
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