Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xabber-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
xabber-android
Commits
30d1e56a
Commit
30d1e56a
authored
Jan 27, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Notifications behavior corrected due to "show text" flag.
parent
81afb227
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
24 deletions
+40
-24
MessageNotificationCreator.java
...android/data/notification/MessageNotificationCreator.java
+40
-24
No files found.
app/src/main/java/com/xabber/android/data/notification/MessageNotificationCreator.java
View file @
30d1e56a
...
...
@@ -59,15 +59,14 @@ public class MessageNotificationCreator {
notificationBuilder
.
setContentText
(
getText
(
message
,
showText
));
notificationBuilder
.
setSubText
(
message
.
getAccount
());
if
(
showText
)
{
notificationBuilder
.
setTicker
(
message
.
getText
());
}
notificationBuilder
.
setTicker
(
getText
(
message
,
showText
));
notificationBuilder
.
setSmallIcon
(
getSmallIcon
());
notificationBuilder
.
setLargeIcon
(
getLargeIcon
(
message
));
notificationBuilder
.
setWhen
(
message
.
getTimestamp
().
getTime
());
notificationBuilder
.
setColor
(
NotificationManager
.
COLOR_MATERIAL_RED_500
);
notificationBuilder
.
setStyle
(
getStyle
(
message
,
messageCount
));
notificationBuilder
.
setStyle
(
getStyle
(
message
,
messageCount
,
showText
));
notificationBuilder
.
setContentIntent
(
getIntent
(
message
));
...
...
@@ -114,14 +113,14 @@ public class MessageNotificationCreator {
}
private
CharSequence
getText
(
MessageNotification
message
,
boolean
showText
)
{
if
(!
showText
)
{
return
message
.
getAccount
();
}
if
(
isFromOneContact
())
{
return
message
.
getText
();
if
(
showText
)
{
return
message
.
getText
();
}
else
{
return
null
;
}
}
else
{
return
getContactNameAndMessage
(
message
);
return
getContactNameAndMessage
(
message
,
showText
);
}
}
...
...
@@ -144,37 +143,54 @@ public class MessageNotificationCreator {
return
messageNotifications
.
size
()
==
1
;
}
private
NotificationCompat
.
Style
getStyle
(
MessageNotification
message
,
int
messageCount
)
{
private
NotificationCompat
.
Style
getStyle
(
MessageNotification
message
,
int
messageCount
,
boolean
showText
)
{
if
(
isFromOneContact
())
{
NotificationCompat
.
BigTextStyle
bigTextStyle
=
new
NotificationCompat
.
BigTextStyle
();
bigTextStyle
.
setBigContentTitle
(
getSingleContactTitle
(
message
,
messageCount
));
bigTextStyle
.
bigText
(
message
.
getText
());
if
(
showText
)
{
bigTextStyle
.
bigText
(
message
.
getText
());
}
bigTextStyle
.
setSummaryText
(
message
.
getAccount
());
return
bigTextStyle
;
}
else
{
NotificationCompat
.
InboxStyle
inboxStyle
=
new
NotificationCompat
.
InboxStyle
();
return
getInboxStyle
(
messageCount
,
message
.
getAccount
());
}
}
inboxStyle
.
setBigContentTitle
(
getMultiContactTitle
(
messageCount
));
private
NotificationCompat
.
Style
getInboxStyle
(
int
messageCount
,
String
accountName
)
{
NotificationCompat
.
InboxStyle
inboxStyle
=
new
NotificationCompat
.
InboxStyle
();
for
(
int
i
=
1
;
i
<=
messageNotifications
.
size
();
i
++)
{
MessageNotification
messageNotification
=
messageNotifications
.
get
(
messageNotifications
.
size
()
-
i
);
inboxStyle
.
setBigContentTitle
(
getMultiContactTitle
(
messageCount
));
inboxStyle
.
addLine
(
getContactNameAndMessage
(
messageNotification
));
}
for
(
int
i
=
1
;
i
<=
messageNotifications
.
size
();
i
++)
{
MessageNotification
messageNotification
=
messageNotifications
.
get
(
messageNotifications
.
size
()
-
i
);
inboxStyle
.
setSummaryText
(
message
.
getAccount
());
boolean
showTextForThisContact
=
ChatManager
.
getInstance
().
isShowText
(
messageNotification
.
getAccount
(),
messageNotification
.
getUser
());
return
inboxStyle
;
inboxStyle
.
addLine
(
getContactNameAndMessage
(
messageNotification
,
showTextForThisContact
))
;
}
inboxStyle
.
setSummaryText
(
accountName
);
return
inboxStyle
;
}
private
Spannable
getContactNameAndMessage
(
MessageNotification
messageNotification
)
{
private
Spannable
getContactNameAndMessage
(
MessageNotification
messageNotification
,
boolean
showText
)
{
String
userName
=
getContactName
(
messageNotification
);
String
contactAndMessage
=
application
.
getString
(
R
.
string
.
chat_contact_and_message
,
userName
,
messageNotification
.
getText
());
Spannable
spannableString
=
new
SpannableString
(
contactAndMessage
);
Spannable
spannableString
;
if
(
showText
)
{
String
contactAndMessage
=
application
.
getString
(
R
.
string
.
chat_contact_and_message
,
userName
,
messageNotification
.
getText
());
spannableString
=
new
SpannableString
(
contactAndMessage
);
}
else
{
spannableString
=
new
SpannableString
(
userName
);
}
spannableString
.
setSpan
(
new
StyleSpan
(
android
.
graphics
.
Typeface
.
BOLD
),
0
,
userName
.
length
(),
Spannable
.
SPAN_EXCLUSIVE_EXCLUSIVE
);
return
spannableString
;
...
...
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