@@ -87,12 +87,14 @@ class MessagingBuilder {
87
87
return null ;
88
88
}
89
89
90
- final LongSparseArray <CharSequence > lines = new LongSparseArray <>(MAX_NUM_HISTORICAL_LINES );
90
+ final LongSparseArray <CharSequence > tickerArray = new LongSparseArray <>(MAX_NUM_HISTORICAL_LINES );
91
+ final LongSparseArray <CharSequence > textArray = new LongSparseArray <>(MAX_NUM_HISTORICAL_LINES );
91
92
CharSequence text ;
92
93
int count = 0 , num_lines_with_colon = 0 ;
93
94
final String redundant_prefix = title .toString () + SENDER_MESSAGE_SEPARATOR ;
94
95
for (final StatusBarNotification each : archive ) {
95
96
final Notification notification = each .getNotification ();
97
+ tickerArray .put (notification .when , notification .tickerText );
96
98
final Bundle its_extras = notification .extras ;
97
99
final CharSequence its_title = its_extras .getCharSequence (Notification .EXTRA_TITLE );
98
100
if (! title .equals (its_title )) {
@@ -111,27 +113,28 @@ class MessagingBuilder {
111
113
if (trimmed_text .toString ().startsWith (redundant_prefix )) // Remove redundant prefix
112
114
trimmed_text = trimmed_text .subSequence (redundant_prefix .length (), trimmed_text .length ());
113
115
else if (trimmed_text .toString ().indexOf (SENDER_MESSAGE_SEPARATOR ) > 0 ) num_lines_with_colon ++;
114
- lines .put (notification .when , trimmed_text );
116
+ textArray .put (notification .when , trimmed_text );
115
117
} else {
116
118
count = 1 ;
117
- lines .put (notification .when , text = its_text );
119
+ textArray .put (notification .when , text = its_text );
118
120
if (text .toString ().indexOf (SENDER_MESSAGE_SEPARATOR ) > 0 ) num_lines_with_colon ++;
119
121
}
120
122
}
121
123
n .number = count ;
122
- if (lines .size () == 0 ) {
124
+ if (textArray .size () == 0 ) {
123
125
Log .w (TAG , "No lines extracted, expected " + count );
124
126
return null ;
125
127
}
126
128
127
129
final MessagingStyle messaging = new MessagingStyle (mUserSelf );
128
- final boolean sender_inline = num_lines_with_colon == lines .size ();
129
- for (int i = 0 , size = lines .size (); i < size ; i ++) // All lines have colon in text
130
- messaging .addMessage (buildMessage (conversation , lines .keyAt (i ), n .tickerText , lines .valueAt (i ), sender_inline ? null : title .toString ()));
130
+ final boolean sender_inline = num_lines_with_colon == textArray .size ();
131
+ for (int i = 0 , size = textArray .size (); i < size ; i ++) { // All lines have colon in text
132
+ messaging .addMessage (buildMessage (conversation , textArray .keyAt (i ), tickerArray .valueAt (i ), textArray .valueAt (i ), sender_inline ? null : title .toString ()));
133
+ }
131
134
return messaging ;
132
135
}
133
136
134
- @ Nullable MessagingStyle buildFromExtender (final Conversation conversation , final MutableStatusBarNotification sbn ) {
137
+ @ Nullable MessagingStyle buildFromExtender (final Conversation conversation , final MutableStatusBarNotification sbn , final CharSequence title , final List < StatusBarNotification > archive ) {
135
138
final MutableNotification n = sbn .getNotification ();
136
139
final Notification .CarExtender extender = new Notification .CarExtender (n );
137
140
final CarExtender .UnreadConversation convs = extender .getUnreadConversation ();
@@ -156,9 +159,8 @@ class MessagingBuilder {
156
159
Log .e (TAG , "Error parsing reply intent." , e );
157
160
}
158
161
159
- final MessagingStyle messaging = new MessagingStyle (mUserSelf );
160
- final Message [] messages = WeChatMessage .buildFromCarConversation (conversation , convs );
161
- for (final Message message : messages ) messaging .addMessage (message );
162
+ final MessagingStyle messaging = buildFromArchive (conversation , n , title , archive );
163
+ final List <Message > messages = messaging .getMessages ();
162
164
163
165
final PendingIntent on_read = convs .getReadPendingIntent ();
164
166
if (on_read != null ) mMarkReadPendingIntents .put (sbn .getKey (), on_read ); // Mapped by evolved key,
@@ -178,7 +180,7 @@ class MessagingBuilder {
178
180
n .addAction (reply_action .build ());
179
181
180
182
if (conversation .isGroupChat () && mPreferences .getBoolean (mPrefKeyMentionAction , false )) {
181
- final Person last_sender = messages [ messages .length - 1 ] .getPerson ();
183
+ final Person last_sender = messages . get ( messages .size () - 1 ) .getPerson ();
182
184
if (last_sender != null && last_sender != mUserSelf ) {
183
185
final String label = "@" + last_sender .getName (), prefix = "@" + Conversation .getOriginalName (last_sender ) + MENTION_SEPARATOR ;
184
186
n .addAction (new Action .Builder (null , label , proxyDirectReply (sbn , on_reply , remote_input , input_history , prefix ))
0 commit comments