@@ -89,54 +89,63 @@ public void onMessageReceived(RemoteMessage remoteMessage) {
8989 senderName = " " ;
9090 IconCompat icon = null ;
9191 Bitmap largeIcon = null ;
92- out :
9392 if (getDefaultSharedPreferences (this ).getBoolean ("sendQQ" , false ) && this .getDatabasePath ("friends.db" ).exists ()) {
93+ boolean isfriend = senderName .equals (title );
9494 String encodeSendername = senderName .replace (" " , "%20" ).replace ("/" , "%2f" );
9595 File file = new File (this .getCacheDir ().getPath () + "/" + encodeSendername );
96+ out :
9697 try {
9798 if (!file .exists ()) {
9899 SQLiteDatabase db ;
99100 Cursor cursor ;
100- String groupNumber = null ;
101- if (senderName .equals (title )) {
101+ if (isfriend ) {
102102 db = SQLiteDatabase .openOrCreateDatabase (this .getDatabasePath ("friends.db" ), null );
103- cursor = db .query ("friends" , new String []{"uin" }, "name ='" + encodeSendername + "'" , null , null , null , null );
103+ if (getSharedPreferences ("groups" , MODE_PRIVATE ).contains ("sync_friends" ))
104+ cursor = db .query ("friends" , new String []{"uin" }, "name ='" + encodeSendername + "'" , null , null , null , null );
105+ else
106+ break out ;
104107 } else if (getSharedPreferences ("groups" , MODE_PRIVATE ).contains (title )) {
105108 db = SQLiteDatabase .openOrCreateDatabase (this .getDatabasePath ("friends.db" ), null );
106109 Cursor cursorTemp = db .query ("'" + title + "'" , new String []{"uin" }, "name ='" + encodeSendername + "'" , null , null , null , null );
107110 if (cursorTemp .getCount () == 0 ) {
108111 cursorTemp .close ();
109112 cursor = db .query ("friends" , new String []{"uin" }, "name ='" + encodeSendername + "'" , null , null , null , null );
110113 } else cursor = cursorTemp ;
111- groupNumber = getSharedPreferences ("groupsNumber" , MODE_PRIVATE ).getString (title , null );
112- } else {
113- groupNumber = getSharedPreferences ("groupsNumber" , MODE_PRIVATE ).getString (title , null );
114- largeIcon = downloadIcon ("https://p.qlogo.cn/gh/" + groupNumber + "/" + groupNumber + "/100" , title );
114+ } else
115115 break out ;
116- }
117116 if (cursor .getCount () != 0 ) {
118117 if (cursor .moveToFirst ()) {
119118 String QQnumber = cursor .getString (0 );
120119 cursor .close ();
121120 db .close ();
122- Bitmap bitmap = downloadIcon ("https://q4.qlogo.cn/g?b=qq&s=140&nk=" + QQnumber , encodeSendername );
123- if (groupNumber == null )
124- largeIcon = bitmap ;
125- else
126- largeIcon = downloadIcon ("https://p.qlogo.cn/gh/" + groupNumber + "/" + groupNumber + "/100" , title );
121+ downloadIcon ("https://q4.qlogo.cn/g?b=qq&s=140&nk=" + QQnumber , encodeSendername );
127122 }
128123 } else {
129124 cursor .close ();
130125 db .close ();
131126 break out ;
132127 }
133- } else {
134- largeIcon = BitmapFactory .decodeFile (this .getCacheDir ().getPath () + "/" + encodeSendername );
135128 }
136129 icon = IconCompat .createWithBitmap (BitmapFactory .decodeFile (this .getCacheDir ().getPath () + "/" + encodeSendername ));
137130 } catch (IOException e ) {
138131 e .printStackTrace ();
139132 }
133+ if (android .os .Build .VERSION .SDK_INT < android .os .Build .VERSION_CODES .P )
134+ if (isfriend ) {
135+ if (icon != null )
136+ largeIcon = BitmapFactory .decodeFile (this .getCacheDir ().getPath () + "/" + encodeSendername );
137+ } else if (new File (this .getCacheDir ().getPath () + "/" + title ).exists ())
138+ largeIcon = BitmapFactory .decodeFile (this .getCacheDir ().getPath () + "/" + title );
139+ else {
140+ String groupNumber = getSharedPreferences ("groupsNumber" , MODE_PRIVATE ).getString (title , null );
141+ if (groupNumber != null ) {
142+ try {
143+ largeIcon = downloadIcon ("https://p.qlogo.cn/gh/" + groupNumber + "/" + groupNumber + "/100" , title );
144+ } catch (IOException e ) {
145+ e .printStackTrace ();
146+ }
147+ }
148+ }
140149 }
141150 setSummary (packageName , AppName , intent );
142151 MessagingStyle (packageName , AppName , title , senderName , body , intent , id , icon , largeIcon );
@@ -288,7 +297,7 @@ private void MessagingStyle(String packageName, String AppName, String title, St
288297 .setColor (color )
289298 .setContentTitle (packageName )
290299 .setStyle (style );
291- if (largeIcon != null )
300+ if (largeIcon != null && android . os . Build . VERSION . SDK_INT < Build . VERSION_CODES . P )
292301 notification .setLargeIcon (largeIcon );
293302 notification .setGroup (packageName )
294303 .setContentIntent (intent )
0 commit comments