@@ -87,12 +87,14 @@ class MessagingBuilder {
8787 return null ;
8888 }
8989
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 );
9192 CharSequence text ;
9293 int count = 0 , num_lines_with_colon = 0 ;
9394 final String redundant_prefix = title .toString () + SENDER_MESSAGE_SEPARATOR ;
9495 for (final StatusBarNotification each : archive ) {
9596 final Notification notification = each .getNotification ();
97+ tickerArray .put (notification .when , notification .tickerText );
9698 final Bundle its_extras = notification .extras ;
9799 final CharSequence its_title = its_extras .getCharSequence (Notification .EXTRA_TITLE );
98100 if (! title .equals (its_title )) {
@@ -111,27 +113,28 @@ class MessagingBuilder {
111113 if (trimmed_text .toString ().startsWith (redundant_prefix )) // Remove redundant prefix
112114 trimmed_text = trimmed_text .subSequence (redundant_prefix .length (), trimmed_text .length ());
113115 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 );
115117 } else {
116118 count = 1 ;
117- lines .put (notification .when , text = its_text );
119+ textArray .put (notification .when , text = its_text );
118120 if (text .toString ().indexOf (SENDER_MESSAGE_SEPARATOR ) > 0 ) num_lines_with_colon ++;
119121 }
120122 }
121123 n .number = count ;
122- if (lines .size () == 0 ) {
124+ if (textArray .size () == 0 ) {
123125 Log .w (TAG , "No lines extracted, expected " + count );
124126 return null ;
125127 }
126128
127129 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+ }
131134 return messaging ;
132135 }
133136
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 ) {
135138 final MutableNotification n = sbn .getNotification ();
136139 final Notification .CarExtender extender = new Notification .CarExtender (n );
137140 final CarExtender .UnreadConversation convs = extender .getUnreadConversation ();
@@ -156,9 +159,8 @@ class MessagingBuilder {
156159 Log .e (TAG , "Error parsing reply intent." , e );
157160 }
158161
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 ();
162164
163165 final PendingIntent on_read = convs .getReadPendingIntent ();
164166 if (on_read != null ) mMarkReadPendingIntents .put (sbn .getKey (), on_read ); // Mapped by evolved key,
@@ -178,7 +180,7 @@ class MessagingBuilder {
178180 n .addAction (reply_action .build ());
179181
180182 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 ();
182184 if (last_sender != null && last_sender != mUserSelf ) {
183185 final String label = "@" + last_sender .getName (), prefix = "@" + Conversation .getOriginalName (last_sender ) + MENTION_SEPARATOR ;
184186 n .addAction (new Action .Builder (null , label , proxyDirectReply (sbn , on_reply , remote_input , input_history , prefix ))
0 commit comments